String[] cols = new String[] {
MediaStore.Audio.Albums._ID,
- MediaStore.Audio.Albums.ALBUM,
- MediaStore.Audio.Albums.ALBUM_KEY,
MediaStore.Audio.Albums.ARTIST,
- MediaStore.Audio.Albums.NUMBER_OF_SONGS,
+ MediaStore.Audio.Albums.ALBUM,
MediaStore.Audio.Albums.ALBUM_ART
};
Cursor ret = null;
private final BitmapDrawable mDefaultAlbumIcon;
private int mAlbumIdx;
private int mArtistIdx;
- private int mNumSongsIdx;
private int mAlbumArtIndex;
private final Resources mResources;
private final StringBuilder mStringBuilder = new StringBuilder();
private String mConstraint = null;
private boolean mConstraintIsValid = false;
- class ViewHolder {
+ static class ViewHolder {
TextView line1;
TextView line2;
- TextView duration;
ImageView play_indicator;
ImageView icon;
}
if (cursor != null) {
mAlbumIdx = cursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM);
mArtistIdx = cursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.ARTIST);
- mNumSongsIdx = cursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.NUMBER_OF_SONGS);
mAlbumArtIndex = cursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM_ART);
if (mIndexer != null) {
ViewHolder vh = new ViewHolder();
vh.line1 = (TextView) v.findViewById(R.id.line1);
vh.line2 = (TextView) v.findViewById(R.id.line2);
- vh.duration = (TextView) v.findViewById(R.id.duration);
vh.play_indicator = (ImageView) v.findViewById(R.id.play_indicator);
vh.icon = (ImageView) v.findViewById(R.id.icon);
vh.icon.setBackgroundDrawable(mDefaultAlbumIcon);
private String mConstraint = null;
private boolean mConstraintIsValid = false;
- class ViewHolder {
+ static class ViewHolder {
TextView line1;
TextView line2;
ImageView play_indicator;
int numsongs = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.NUMBER_OF_SONGS));
int numartistsongs = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.NUMBER_OF_SONGS_FOR_ARTIST));
- int first = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.FIRST_YEAR));
- int last = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.LAST_YEAR));
-
- if (first == 0) {
- first = last;
- }
final StringBuilder builder = mBuffer;
builder.delete(0, builder.length());
MediaStore.Audio.Albums.ALBUM,
MediaStore.Audio.Albums.NUMBER_OF_SONGS,
MediaStore.Audio.Albums.NUMBER_OF_SONGS_FOR_ARTIST,
- MediaStore.Audio.Albums.FIRST_YEAR,
- MediaStore.Audio.Albums.LAST_YEAR,
MediaStore.Audio.Albums.ALBUM_ART
};
Cursor c = MusicUtils.query(mActivity,
final Resources res = service.getResources();
final RemoteViews views = new RemoteViews(service.getPackageName(), R.layout.album_appwidget);
- final int track = service.getQueuePosition() + 1;
CharSequence titleName = service.getTrackName();
CharSequence artistName = service.getArtistName();
CharSequence errorState = null;
LONG_PRESS_DELAY);
}
- SharedPreferences pref = context.getSharedPreferences("Music",
- Context.MODE_WORLD_READABLE | Context.MODE_WORLD_WRITEABLE);
- String q = pref.getString("queue", "");
// The service may or may not be running, but we need to send it
// a command.
Intent i = new Intent(context, MediaPlaybackService.class);
private String mLastYear;
private String mWhereClause;
- class PickListAdapter extends SimpleCursorAdapter {
+ static class PickListAdapter extends SimpleCursorAdapter {
int mTitleIdx;
int mArtistIdx;
int mAlbumIdx;
if (knownartist && view.equals(mArtistName.getParent())) {
title = artist;
- query = artist.toString();
+ query = artist;
mime = MediaStore.Audio.Artists.ENTRY_CONTENT_TYPE;
} else if (knownalbum && view.equals(mAlbumName.getParent())) {
title = album;
}
}
- private class Worker implements Runnable {
+ private static class Worker implements Runnable {
private final Object mLock = new Object();
private Looper mLooper;
// A simple variation of Random that makes sure that the
// value it returns is not equal to the value it returned
// previously, unless the interval is 1.
- private class Shuffler {
+ private static class Shuffler {
private int mPrevious;
private Random mRandom = new Random();
public int nextInt(int interval) {
static final String SORT_MODE_KEY = "sortMode";
/** Arbitrary number, doesn't matter since we only do one query type. */
- final int MY_QUERY_TOKEN = 42;
+ static final int MY_QUERY_TOKEN = 42;
/** Menu item to sort the music list by track title. */
static final int TRACK_MENU = Menu.FIRST;
private int mArtistIdx;
private int mAlbumIdx;
private int mDurationIdx;
- private int mAudioIdIdx;
- private int mTrackIdx;
private boolean mLoading = true;
private int mIndexerSortMode;
mArtistIdx = cursor.getColumnIndex(MediaStore.Audio.Media.ARTIST);
mAlbumIdx = cursor.getColumnIndex(MediaStore.Audio.Media.ALBUM);
mDurationIdx = cursor.getColumnIndex(MediaStore.Audio.Media.DURATION);
- int audioIdIdx = cursor.getColumnIndex(MediaStore.Audio.Playlists.Members.AUDIO_ID);
- if (audioIdIdx < 0) {
- audioIdIdx = cursor.getColumnIndex(MediaStore.Audio.Media._ID);
- }
- mAudioIdIdx = audioIdIdx;
- mTrackIdx = cursor.getColumnIndex(MediaStore.Audio.Media.TRACK);
}
// The next time the indexer is needed, we will need to rebind it
// maybe it never existed to begin with.
Bitmap bm = getArtworkFromFile(context, null, album_id);
if (bm != null) {
+ if (bm.getConfig() == null) {
+ bm = bm.copy(Bitmap.Config.RGB_565, false);
+ if (bm == null) {
+ if (allowDefault) {
+ return getDefaultArtwork(context);
+ } else {
+ return null;
+ }
+ }
+ }
// Put the newly found artwork in the database.
// Note that this shouldn't be done for the "unknown" album,
// but if this method is called correctly, that won't happen.
if (ensureFileExists(file)) {
try {
OutputStream outstream = new FileOutputStream(file);
- if (bm.getConfig() == null) {
- bm = bm.copy(Bitmap.Config.RGB_565, false);
- if (bm == null) {
- if (allowDefault) {
- return getDefaultArtwork(context);
- } else {
- return null;
- }
- }
- }
boolean success = bm.compress(Bitmap.CompressFormat.JPEG, 75, outstream);
outstream.close();
if (success) {
public class TrackBrowserActivity extends ListActivity
implements View.OnCreateContextMenuListener, MusicUtils.Defs, ServiceConnection
{
- private final int Q_SELECTED = CHILD_MENU_BASE;
- private final int Q_ALL = CHILD_MENU_BASE + 1;
- private final int SAVE_AS_PLAYLIST = CHILD_MENU_BASE + 2;
- private final int PLAY_ALL = CHILD_MENU_BASE + 3;
- private final int CLEAR_PLAYLIST = CHILD_MENU_BASE + 4;
- private final int REMOVE = CHILD_MENU_BASE + 5;
- private final int SEARCH = CHILD_MENU_BASE + 6;
+ private static final int Q_SELECTED = CHILD_MENU_BASE;
+ private static final int Q_ALL = CHILD_MENU_BASE + 1;
+ private static final int SAVE_AS_PLAYLIST = CHILD_MENU_BASE + 2;
+ private static final int PLAY_ALL = CHILD_MENU_BASE + 3;
+ private static final int CLEAR_PLAYLIST = CHILD_MENU_BASE + 4;
+ private static final int REMOVE = CHILD_MENU_BASE + 5;
+ private static final int SEARCH = CHILD_MENU_BASE + 6;
private static final String LOGTAG = "TrackBrowser";
mTrackList = getListView();
mTrackList.setOnCreateContextMenuListener(this);
if (mEditMode) {
- //((TouchInterceptor) mTrackList).setDragListener(mDragListener);
((TouchInterceptor) mTrackList).setDropListener(mDropListener);
((TouchInterceptor) mTrackList).setRemoveListener(mRemoveListener);
mTrackList.setCacheColorHint(0);
}
}
- private TouchInterceptor.DragListener mDragListener =
- new TouchInterceptor.DragListener() {
- public void drag(int from, int to) {
- if (mTrackCursor instanceof NowPlayingCursor) {
- NowPlayingCursor c = (NowPlayingCursor) mTrackCursor;
- c.moveItem(from, to);
- ((TrackListAdapter)getListAdapter()).notifyDataSetChanged();
- getListView().invalidateViews();
- mDeletedOneRow = true;
- }
- }
- };
private TouchInterceptor.DropListener mDropListener =
new TouchInterceptor.DropListener() {
public void drop(int from, int to) {
int mTitleIdx;
int mArtistIdx;
- int mAlbumIdx;
int mDurationIdx;
int mAudioIdIdx;
private String mConstraint = null;
private boolean mConstraintIsValid = false;
- class ViewHolder {
+ static class ViewHolder {
TextView line1;
TextView line2;
TextView duration;
if (cursor != null) {
mTitleIdx = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE);
mArtistIdx = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ARTIST);
- mAlbumIdx = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM);
mDurationIdx = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DURATION);
try {
mAudioIdIdx = cursor.getColumnIndexOrThrow(