import android.provider.MediaStore;
import android.widget.ImageView;
-import org.lineageos.eleven.R;
import org.lineageos.eleven.cache.ImageWorker.ImageType;
import org.lineageos.eleven.loaders.PlaylistSongLoader;
import org.lineageos.eleven.loaders.SortedCursor;
}
// otherwise re-run the logic to get the bitmap
- Cursor sortedCursor = null;
-
- try {
+ try (Cursor sortedCursor = getTopSongsForPlaylist()) {
// get the top songs for our playlist
- sortedCursor = getTopSongsForPlaylist();
if (isCancelled()) {
return null;
} else {
bitmap = loadTopSongs(sortedCursor);
}
- } finally {
- if (sortedCursor != null) {
- sortedCursor.close();
- }
}
// if we have a bitmap create a transition drawable
return null;
}
- ArrayList<Bitmap> loadedBitmaps = new ArrayList<Bitmap>(MAX_NUM_BITMAPS_TO_LOAD);
+ ArrayList<Bitmap> loadedBitmaps = new ArrayList<>(MAX_NUM_BITMAPS_TO_LOAD);
final int artistIdx = sortedCursor.getColumnIndex(MediaStore.Audio.AudioColumns.ARTIST);
final int albumIdIdx = sortedCursor.getColumnIndex(MediaStore.Audio.AudioColumns.ALBUM_ID);
long albumId = -1;
// create a hashset of the keys so we don't load images from the same album multiple times
- HashSet<String> keys = new HashSet<String>(sortedCursor.getCount());
+ HashSet<String> keys = new HashSet<>(sortedCursor.getCount());
do {
if (isCancelled()) {