Disabled disk cache for album art and fixed the navigation drawer header image view being out of aspect ration. Scrolling in any list should be buttery smooth now. Had no time for the search rewrite today, gonna do that tomorrow.
This commit is contained in:
commit
a91804657d
18 changed files with 104 additions and 40 deletions
|
|
@ -20,6 +20,7 @@ import com.bumptech.glide.load.resource.drawable.GlideDrawable;
|
|||
import com.bumptech.glide.request.Request;
|
||||
import com.bumptech.glide.request.RequestListener;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.bumptech.glide.signature.StringSignature;
|
||||
import com.kabouzeid.gramophone.App;
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.loader.AlbumLoader;
|
||||
|
|
@ -72,6 +73,7 @@ public class AlbumAdapter extends RecyclerView.Adapter<AlbumAdapter.ViewHolder>
|
|||
Glide.with(activity)
|
||||
.loadFromMediaStore(MusicUtil.getAlbumArtUri(album.id))
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.signature(new StringSignature(album.albumArtPath))
|
||||
.error(R.drawable.default_album_art)
|
||||
.placeholder(R.drawable.default_album_art)
|
||||
.listener(new RequestListener<Uri, GlideDrawable>() {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import android.widget.TextView;
|
|||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.bumptech.glide.request.Request;
|
||||
import com.bumptech.glide.signature.StringSignature;
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.model.Album;
|
||||
import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
|
||||
|
|
@ -62,6 +63,7 @@ public class ArtistAlbumAdapter extends RecyclerView.Adapter<ArtistAlbumAdapter.
|
|||
holder.albumArt.setTag(Glide.with(activity)
|
||||
.loadFromMediaStore(MusicUtil.getAlbumArtUri(album.id))
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.signature(new StringSignature(album.albumArtPath))
|
||||
.error(R.drawable.default_album_art)
|
||||
.placeholder(R.drawable.default_album_art)
|
||||
.into(holder.albumArt)
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import android.widget.TextView;
|
|||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.bumptech.glide.signature.StringSignature;
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.helper.MenuItemClickHelper;
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
|
|
@ -51,6 +52,7 @@ public class ArtistSongAdapter extends ArrayAdapter<Song> {
|
|||
Glide.with(activity)
|
||||
.loadFromMediaStore(MusicUtil.getAlbumArtUri(song.albumId))
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.signature(new StringSignature(String.valueOf(song.dateModified)))
|
||||
.error(R.drawable.default_album_art)
|
||||
.placeholder(R.drawable.default_album_art)
|
||||
.into(albumArt);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import android.widget.TextView;
|
|||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.bumptech.glide.request.Request;
|
||||
import com.bumptech.glide.signature.StringSignature;
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.helper.MenuItemClickHelper;
|
||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||
|
|
@ -66,6 +67,7 @@ public class PlaylistSongAdapter extends RecyclerView.Adapter<PlaylistSongAdapte
|
|||
Glide.with(activity)
|
||||
.loadFromMediaStore(MusicUtil.getAlbumArtUri(song.albumId))
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.signature(new StringSignature(String.valueOf(song.dateModified)))
|
||||
.error(R.drawable.default_album_art)
|
||||
.placeholder(R.drawable.default_album_art)
|
||||
.into(holder.albumArt)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import com.afollestad.materialdialogs.ThemeSingleton;
|
|||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.bumptech.glide.request.Request;
|
||||
import com.bumptech.glide.signature.StringSignature;
|
||||
import com.kabouzeid.gramophone.App;
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.helper.MenuItemClickHelper;
|
||||
|
|
@ -82,6 +83,7 @@ public class SongAdapter extends RecyclerView.Adapter<SongAdapter.ViewHolder> {
|
|||
Glide.with(activity)
|
||||
.loadFromMediaStore(MusicUtil.getAlbumArtUri(song.albumId))
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.signature(new StringSignature(String.valueOf(song.dateModified)))
|
||||
.error(R.drawable.default_album_art)
|
||||
.placeholder(R.drawable.default_album_art)
|
||||
.into(holder.albumArt)
|
||||
|
|
|
|||
|
|
@ -27,8 +27,9 @@ public class AlbumLoader {
|
|||
final int artistId = cursor.getInt(3);
|
||||
final int songCount = cursor.getInt(4);
|
||||
final int year = cursor.getInt(5);
|
||||
final String albumArtPath = cursor.getString(6);
|
||||
|
||||
final Album album = new Album(id, albumName, artist, artistId, songCount, year);
|
||||
final Album album = new Album(id, albumName, artist, artistId, songCount, year, albumArtPath);
|
||||
albums.add(album);
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
|
|
@ -56,7 +57,9 @@ public class AlbumLoader {
|
|||
/* 4 */
|
||||
MediaStore.Audio.AlbumColumns.NUMBER_OF_SONGS,
|
||||
/* 5 */
|
||||
MediaStore.Audio.AlbumColumns.FIRST_YEAR
|
||||
MediaStore.Audio.AlbumColumns.FIRST_YEAR,
|
||||
/* 6 */
|
||||
MediaStore.Audio.AlbumColumns.ALBUM_ART
|
||||
}, selection, values, PreferenceUtils.getInstance(context).getAlbumSortOrder());
|
||||
}
|
||||
|
||||
|
|
@ -70,8 +73,9 @@ public class AlbumLoader {
|
|||
final int artistId = cursor.getInt(3);
|
||||
final int songCount = cursor.getInt(4);
|
||||
final int year = cursor.getInt(5);
|
||||
final String albumArtPath = cursor.getString(6);
|
||||
|
||||
album = new Album(id, albumName, artist, artistId, songCount, year);
|
||||
album = new Album(id, albumName, artist, artistId, songCount, year, albumArtPath);
|
||||
}
|
||||
|
||||
if (cursor != null) {
|
||||
|
|
@ -91,8 +95,9 @@ public class AlbumLoader {
|
|||
final int artistId = cursor.getInt(3);
|
||||
final int songCount = cursor.getInt(4);
|
||||
final int year = cursor.getInt(5);
|
||||
final String albumArtPath = cursor.getString(6);
|
||||
|
||||
final Album album = new Album(id, albumName, artist, artistId, songCount, year);
|
||||
final Album album = new Album(id, albumName, artist, artistId, songCount, year, albumArtPath);
|
||||
albums.add(album);
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,9 @@ public class AlbumSongLoader {
|
|||
final long duration = cursor.getLong(4);
|
||||
final int trackNumber = cursor.getInt(5);
|
||||
final int artistId = cursor.getInt(6);
|
||||
final long dateModified = cursor.getInt(7);
|
||||
|
||||
final Song song = new Song(id, albumId, artistId, songName, artist, album, duration, trackNumber);
|
||||
final Song song = new Song(id, albumId, artistId, songName, artist, album, duration, trackNumber, dateModified);
|
||||
songs.add(song);
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
|
|
@ -53,7 +54,9 @@ public class AlbumSongLoader {
|
|||
/* 5 */
|
||||
MediaStore.Audio.AudioColumns.TRACK,
|
||||
/* 6 */
|
||||
MediaStore.Audio.AudioColumns.ARTIST_ID
|
||||
MediaStore.Audio.AudioColumns.ARTIST_ID,
|
||||
/* 7 */
|
||||
MediaStore.Audio.AudioColumns.DATE_MODIFIED
|
||||
}, (MediaStore.Audio.AudioColumns.IS_MUSIC + "=1") + " AND " +
|
||||
MediaStore.Audio.AudioColumns.TITLE + " != ''" + " AND " +
|
||||
MediaStore.Audio.AudioColumns.ALBUM_ID + "=" + albumId, null,
|
||||
|
|
|
|||
|
|
@ -26,8 +26,9 @@ public class ArtistAlbumLoader {
|
|||
final String artist = cursor.getString(2);
|
||||
final int songCount = cursor.getInt(3);
|
||||
final int year = cursor.getInt(4);
|
||||
final String albumArtPath = cursor.getString(5);
|
||||
|
||||
final Album album = new Album(id, albumName, artist, artistId, songCount, year);
|
||||
final Album album = new Album(id, albumName, artist, artistId, songCount, year, albumArtPath);
|
||||
albums.add(album);
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
|
|
@ -49,7 +50,9 @@ public class ArtistAlbumLoader {
|
|||
/* 3 */
|
||||
MediaStore.Audio.AlbumColumns.NUMBER_OF_SONGS,
|
||||
/* 4 */
|
||||
MediaStore.Audio.AlbumColumns.FIRST_YEAR
|
||||
MediaStore.Audio.AlbumColumns.FIRST_YEAR,
|
||||
/* 5 */
|
||||
MediaStore.Audio.AlbumColumns.ALBUM_ART
|
||||
}, null, null, PreferenceUtils.getInstance(context).getArtistAlbumSortOrder());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,9 @@ public class ArtistSongLoader {
|
|||
final long duration = cursor.getLong(4);
|
||||
final int trackNumber = cursor.getInt(5);
|
||||
final int albumId = cursor.getInt(6);
|
||||
final long dateModified = cursor.getInt(7);
|
||||
|
||||
final Song song = new Song(id, albumId, artistId, songName, artist, album, duration, trackNumber);
|
||||
final Song song = new Song(id, albumId, artistId, songName, artist, album, duration, trackNumber, dateModified);
|
||||
songs.add(song);
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
|
|
@ -53,7 +54,9 @@ public class ArtistSongLoader {
|
|||
/* 5 */
|
||||
MediaStore.Audio.AudioColumns.TRACK,
|
||||
/* 6 */
|
||||
MediaStore.Audio.AudioColumns.ALBUM_ID
|
||||
MediaStore.Audio.AudioColumns.ALBUM_ID,
|
||||
/* 7 */
|
||||
MediaStore.Audio.AudioColumns.DATE_MODIFIED
|
||||
}, (MediaStore.Audio.AudioColumns.IS_MUSIC + "=1") + " AND " +
|
||||
MediaStore.Audio.AudioColumns.TITLE + " != ''" + " AND " +
|
||||
MediaStore.Audio.AudioColumns.ARTIST_ID + "=" + artistId, null,
|
||||
|
|
|
|||
|
|
@ -26,8 +26,9 @@ public class PlaylistSongLoader {
|
|||
final int albumId = cursor.getInt(6);
|
||||
final int artistId = cursor.getInt(7);
|
||||
final int idInPlaylist = cursor.getInt(8);
|
||||
final long dateModified = cursor.getInt(9);
|
||||
|
||||
final PlaylistSong song = new PlaylistSong(id, albumId, artistId, songName, artist, album, duration, trackNumber, playlistID, idInPlaylist);
|
||||
final PlaylistSong song = new PlaylistSong(id, albumId, artistId, songName, artist, album, duration, trackNumber, playlistID, idInPlaylist, dateModified);
|
||||
|
||||
songs.add(song);
|
||||
} while (cursor.moveToNext());
|
||||
|
|
@ -59,7 +60,9 @@ public class PlaylistSongLoader {
|
|||
/* 7 */
|
||||
AudioColumns.ARTIST_ID,
|
||||
/* 8 */
|
||||
MediaStore.Audio.Playlists.Members._ID
|
||||
MediaStore.Audio.Playlists.Members._ID,
|
||||
/* 9 */
|
||||
MediaStore.Audio.AudioColumns.DATE_MODIFIED
|
||||
}, (AudioColumns.IS_MUSIC + "=1") + " AND " + AudioColumns.TITLE + " != ''", null,
|
||||
MediaStore.Audio.Playlists.Members.DEFAULT_SORT_ORDER);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,8 +30,9 @@ public class SongLoader {
|
|||
final int trackNumber = cursor.getInt(5);
|
||||
final int artistId = cursor.getInt(6);
|
||||
final int albumId = cursor.getInt(7);
|
||||
final long dateModified = cursor.getInt(8);
|
||||
|
||||
final Song song = new Song(id, albumId, artistId, songName, artist, album, duration, trackNumber);
|
||||
final Song song = new Song(id, albumId, artistId, songName, artist, album, duration, trackNumber, dateModified);
|
||||
songs.add(song);
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
|
|
@ -67,7 +68,9 @@ public class SongLoader {
|
|||
/* 6 */
|
||||
MediaStore.Audio.AudioColumns.ARTIST_ID,
|
||||
/* 7 */
|
||||
MediaStore.Audio.AudioColumns.ALBUM_ID
|
||||
MediaStore.Audio.AudioColumns.ALBUM_ID,
|
||||
/* 8 */
|
||||
MediaStore.Audio.AudioColumns.DATE_MODIFIED
|
||||
}, finalSelection, values, PreferenceUtils.getInstance(context).getSongSortOrder());
|
||||
}
|
||||
|
||||
|
|
@ -84,8 +87,9 @@ public class SongLoader {
|
|||
final int trackNumber = cursor.getInt(5);
|
||||
final int artistId = cursor.getInt(6);
|
||||
final int albumId = cursor.getInt(7);
|
||||
final long dateModified = cursor.getInt(8);
|
||||
|
||||
final Song song = new Song(id, albumId, artistId, songName, artist, album, duration, trackNumber);
|
||||
final Song song = new Song(id, albumId, artistId, songName, artist, album, duration, trackNumber, dateModified);
|
||||
songs.add(song);
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
|
|
@ -107,7 +111,8 @@ public class SongLoader {
|
|||
final int trackNumber = cursor.getInt(5);
|
||||
final int artistId = cursor.getInt(6);
|
||||
final int albumId = cursor.getInt(7);
|
||||
song = new Song(id, albumId, artistId, songName, artist, album, duration, trackNumber);
|
||||
final long dateModified = cursor.getInt(8);
|
||||
song = new Song(id, albumId, artistId, songName, artist, album, duration, trackNumber, dateModified);
|
||||
}
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
|
|
|
|||
|
|
@ -6,27 +6,31 @@ package com.kabouzeid.gramophone.model;
|
|||
public class Album {
|
||||
|
||||
public final int id;
|
||||
public int artistId;
|
||||
public final int artistId;
|
||||
public final String title;
|
||||
public final String artistName;
|
||||
public final int songCount;
|
||||
public final int year;
|
||||
public final String albumArtPath; //used as cache key
|
||||
|
||||
public Album(final int id, final String title, final String artistName, final int artistId,
|
||||
final int songNumber, final int albumYear) {
|
||||
final int songNumber, final int albumYear, final String albumArtPath) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.artistName = artistName;
|
||||
this.artistId = artistId;
|
||||
songCount = songNumber;
|
||||
year = albumYear;
|
||||
this.albumArtPath = albumArtPath != null ? albumArtPath : "";
|
||||
}
|
||||
|
||||
public Album() {
|
||||
this.id = -1;
|
||||
this.title = "";
|
||||
this.artistName = "";
|
||||
this.artistId = -1;
|
||||
songCount = -1;
|
||||
year = -1;
|
||||
this.albumArtPath = "";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ public class PlaylistSong extends Song {
|
|||
private static final long serialVersionUID = 1098600801627571043L;
|
||||
|
||||
public final int playlistId;
|
||||
public int idInPlayList;
|
||||
public final int idInPlayList;
|
||||
|
||||
public PlaylistSong(final int id, final int albumId, final int artistId, final String title, final String artistName,
|
||||
final String albumName, final long duration, final int trackNumber, final int playlistId, final int idInPlayList) {
|
||||
super(id, albumId, artistId, title, artistName, albumName, duration, trackNumber);
|
||||
final String albumName, final long duration, final int trackNumber, final int playlistId, final int idInPlayList, final long dateModified) {
|
||||
super(id, albumId, artistId, title, artistName, albumName, duration, trackNumber, dateModified);
|
||||
this.playlistId = playlistId;
|
||||
this.idInPlayList = idInPlayList;
|
||||
}
|
||||
|
|
@ -17,6 +17,6 @@ public class PlaylistSong extends Song {
|
|||
public PlaylistSong() {
|
||||
super();
|
||||
playlistId = -1;
|
||||
id = -1;
|
||||
idInPlayList = -1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ import java.io.Serializable;
|
|||
public class Song implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 3720703366054566981L;
|
||||
|
||||
public int id;
|
||||
|
||||
public final int id;
|
||||
public final int albumId;
|
||||
public final int artistId;
|
||||
public final String title;
|
||||
|
|
@ -17,9 +17,10 @@ public class Song implements Serializable {
|
|||
public final String albumName;
|
||||
public final long duration;
|
||||
public final int trackNumber;
|
||||
public final long dateModified; //used as cache key
|
||||
|
||||
public Song(final int id, final int albumId, final int artistId, final String title, final String artistName,
|
||||
final String albumName, final long duration, final int trackNumber) {
|
||||
final String albumName, final long duration, final int trackNumber, final long dateModified) {
|
||||
this.id = id;
|
||||
this.albumId = albumId;
|
||||
this.artistId = artistId;
|
||||
|
|
@ -28,6 +29,7 @@ public class Song implements Serializable {
|
|||
this.albumName = albumName;
|
||||
this.duration = duration;
|
||||
this.trackNumber = trackNumber;
|
||||
this.dateModified = dateModified;
|
||||
}
|
||||
|
||||
public Song() {
|
||||
|
|
@ -39,5 +41,6 @@ public class Song implements Serializable {
|
|||
this.albumName = "";
|
||||
this.duration = -1;
|
||||
this.trackNumber = -1;
|
||||
this.dateModified = -1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable;
|
|||
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
|
||||
import com.bumptech.glide.request.RequestListener;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.bumptech.glide.signature.StringSignature;
|
||||
import com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView;
|
||||
import com.kabouzeid.gramophone.App;
|
||||
import com.kabouzeid.gramophone.R;
|
||||
|
|
@ -178,6 +179,7 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
Glide.with(AlbumDetailActivity.this)
|
||||
.loadFromMediaStore(MusicUtil.getAlbumArtUri(album.id))
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.signature(new StringSignature(album.albumArtPath))
|
||||
.error(R.drawable.default_album_art)
|
||||
.listener(new RequestListener<Uri, GlideDrawable>() {
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
|
|
|
|||
|
|
@ -29,6 +29,10 @@ import com.afollestad.materialdialogs.ThemeSingleton;
|
|||
import com.astuetz.PagerSlidingTabStrip;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
|
||||
import com.bumptech.glide.request.RequestListener;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.bumptech.glide.signature.StringSignature;
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.adapter.PagerAdapter;
|
||||
import com.kabouzeid.gramophone.dialogs.AboutDialog;
|
||||
|
|
@ -69,6 +73,8 @@ public class MainActivity extends AbsFabActivity
|
|||
private ViewPager viewPager;
|
||||
private PagerSlidingTabStrip slidingTabLayout;
|
||||
private int currentPage = -1;
|
||||
private int navigationDrawerImageWidth = -1;
|
||||
private int navigationDrawerImageHeight = -1;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
|
@ -78,9 +84,9 @@ public class MainActivity extends AbsFabActivity
|
|||
|
||||
initViews();
|
||||
navigationDrawerFragment.setUp(
|
||||
R.id.navigation_drawer,
|
||||
drawerLayout
|
||||
);
|
||||
setUpDrawerLayout();
|
||||
setUpToolBar();
|
||||
setUpViewPager();
|
||||
|
||||
|
|
@ -165,9 +171,19 @@ public class MainActivity extends AbsFabActivity
|
|||
R.string.navigation_drawer_open,
|
||||
R.string.navigation_drawer_close
|
||||
);
|
||||
drawerLayout.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
drawerToggle.syncState();
|
||||
}
|
||||
});
|
||||
drawerLayout.setDrawerListener(drawerToggle);
|
||||
}
|
||||
|
||||
private void setUpDrawerLayout() {
|
||||
drawerLayout.setStatusBarBackgroundColor(PreferenceUtils
|
||||
.getInstance(this).getThemeColorPrimaryDarker());
|
||||
|
||||
FrameLayout navDrawerFrame = (FrameLayout) findViewById(R.id.nav_drawer_frame);
|
||||
int navDrawerMargin = getResources().getDimensionPixelSize(R.dimen.nav_drawer_margin);
|
||||
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
|
||||
|
|
@ -179,13 +195,8 @@ public class MainActivity extends AbsFabActivity
|
|||
navDrawerFrame.setLayoutParams(new DrawerLayout.LayoutParams(navDrawerWidth,
|
||||
DrawerLayout.LayoutParams.MATCH_PARENT, Gravity.START));
|
||||
|
||||
drawerLayout.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
drawerToggle.syncState();
|
||||
}
|
||||
});
|
||||
drawerLayout.setDrawerListener(drawerToggle);
|
||||
navigationDrawerImageWidth = navDrawerWidth;
|
||||
navigationDrawerImageHeight = getResources().getDimensionPixelSize(R.dimen.navigation_drawer_image_height);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -207,10 +218,23 @@ public class MainActivity extends AbsFabActivity
|
|||
navigationDrawerFragment.getSongArtist().setText(song.artistName);
|
||||
Glide.with(this)
|
||||
.loadFromMediaStore(MusicUtil.getAlbumArtUri(song.albumId))
|
||||
.centerCrop()
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.error(R.drawable.default_album_art)
|
||||
.placeholder(R.drawable.default_album_art)
|
||||
.into(navigationDrawerFragment.getAlbumArtImageView());
|
||||
.signature(new StringSignature(String.valueOf(song.dateModified)))
|
||||
.listener(new RequestListener<Uri, GlideDrawable>() {
|
||||
@Override
|
||||
public boolean onException(Exception e, Uri model, Target<GlideDrawable> target, boolean isFirstResource) {
|
||||
navigationDrawerFragment.getAlbumArtImageView().setImageResource(R.drawable.default_album_art);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResourceReady(GlideDrawable resource, Uri model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
|
||||
navigationDrawerFragment.getAlbumArtImageView().setImageDrawable(resource);
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.into(navigationDrawerImageWidth, navigationDrawerImageHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable;
|
|||
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
|
||||
import com.bumptech.glide.request.RequestListener;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.bumptech.glide.signature.StringSignature;
|
||||
import com.kabouzeid.gramophone.App;
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.dialogs.AddToPlaylistDialog;
|
||||
|
|
@ -302,6 +303,7 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
Glide.with(this)
|
||||
.loadFromMediaStore(MusicUtil.getAlbumArtUri(song.albumId))
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.signature(new StringSignature(String.valueOf(song.dateModified)))
|
||||
.error(R.drawable.default_album_art)
|
||||
.placeholder(R.drawable.default_album_art)
|
||||
.listener(new RequestListener<Uri, GlideDrawable>() {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ public class NavigationDrawerFragment extends Fragment {
|
|||
private NavigationDrawerItemAdapter drawerAdapter;
|
||||
private DrawerLayout drawerLayout;
|
||||
private RecyclerView drawerRecyclerView;
|
||||
private View fragmentContainerView;
|
||||
|
||||
private Button headerButton;
|
||||
private ImageView albumArt;
|
||||
|
|
@ -54,12 +53,10 @@ public class NavigationDrawerFragment extends Fragment {
|
|||
return drawerLayout != null && drawerLayout.isDrawerOpen(Gravity.START);
|
||||
}
|
||||
|
||||
public void setUp(int fragmentId, final DrawerLayout drawerLayout) {
|
||||
fragmentContainerView = getActivity().findViewById(fragmentId);
|
||||
public void setUp(final DrawerLayout drawerLayout) {
|
||||
this.drawerLayout = drawerLayout;
|
||||
this.drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
|
||||
|
||||
|
||||
if (!userLearnedDrawer && !fromSavedInstanceState) {
|
||||
this.drawerLayout.openDrawer(Gravity.START);
|
||||
userLearnedDrawer = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue