Commit ebb83f61 authored by Alexander Martinz's avatar Alexander Martinz Committed by Michael Bestas

Correct some lint warnings

Correcting lint issues such as:
 - if -> switch
 - unnecessary (un)boxing
 - for / while -> foreach where appropriate
 - remove unused imports
 - remove obsolete SDK_INT checks

Change-Id: Icb7170b0564b9c1cf191a0a102d1babab61e2ec2
Signed-off-by: default avatarAlexander Martinz <amartinz@shiftphones.com>
parent 5b70dfcd
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 Andrew Neal
Copyright (C) 2014 The CyanogenMod Project
Copyright (C) 2019 The LineageOS Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
......@@ -15,9 +16,11 @@
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.lineageos.eleven"
android:versionCode="3"
android:versionName="3.0">
android:versionName="3.0"
tools:ignore="GradleOverrides">
<uses-sdk
android:minSdkVersion="26"
......@@ -87,7 +90,7 @@
<category android:name="android.intent.category.APP_MUSIC" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<intent-filter tools:ignore="AppLinkUrlError">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
......
......@@ -17,7 +17,6 @@
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res/org.lineageos.eleven"
android:id="@+id/bottom_action_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_action_bar_height"
......
......@@ -205,7 +205,7 @@
partial scaled up values for different resolutions -->
<dimen name="divider_height">1px</dimen>
<item name="letter_to_tile_ratio" type="dimen">53%</item>
<item name="letter_to_tile_ratio" type="fraction">53%</item>
<!-- Audio preview -->
<dimen name="preview_layout_height">125dp</dimen>
......
......@@ -496,7 +496,7 @@ public class MusicPlaybackService extends Service {
private String mLyrics;
private ArrayList<MusicPlaybackTrack> mPlaylist = new ArrayList<MusicPlaybackTrack>(100);
private ArrayList<MusicPlaybackTrack> mPlaylist = new ArrayList<>(100);
private long[] mAutoShuffleList = null;
......@@ -914,7 +914,7 @@ public class MusicPlaybackService extends Service {
// Make sure we don't indefinitely hold the wake lock under any circumstances
mHeadsetHookWakeLock.acquire(10000);
Message msg = mPlayerHandler.obtainMessage(HEADSET_HOOK_EVENT, Long.valueOf(timestamp));
Message msg = mPlayerHandler.obtainMessage(HEADSET_HOOK_EVENT, timestamp);
msg.sendToTarget();
}
......@@ -1153,7 +1153,7 @@ public class MusicPlaybackService extends Service {
position = mPlaylist.size();
}
final ArrayList<MusicPlaybackTrack> arrayList = new ArrayList<MusicPlaybackTrack>(addlen);
final ArrayList<MusicPlaybackTrack> arrayList = new ArrayList<>(addlen);
for (int i = 0; i < list.length; i++) {
arrayList.add(new MusicPlaybackTrack(list[i], sourceId, sourceType, i));
}
......@@ -1330,7 +1330,7 @@ public class MusicPlaybackService extends Service {
// has been played
final int numHistory = mHistory.size();
for (int i = 0; i < numHistory; i++) {
final int idx = mHistory.get(i).intValue();
final int idx = mHistory.get(i);
if (idx >= 0 && idx < numTracks) {
trackNumPlays[idx]++;
}
......@@ -1345,12 +1345,12 @@ public class MusicPlaybackService extends Service {
// how many tracks share that count
int minNumPlays = Integer.MAX_VALUE;
int numTracksWithMinNumPlays = 0;
for (int i = 0; i < trackNumPlays.length; i++) {
for (final int trackNumPlay : trackNumPlays) {
// if we found a new track that has less number of plays, reset the counters
if (trackNumPlays[i] < minNumPlays) {
minNumPlays = trackNumPlays[i];
if (trackNumPlay < minNumPlays) {
minNumPlays = trackNumPlay;
numTracksWithMinNumPlays = 1;
} else if (trackNumPlays[i] == minNumPlays) {
} else if (trackNumPlay == minNumPlays) {
// increment this track shares the # of tracks
numTracksWithMinNumPlays++;
}
......@@ -1530,26 +1530,30 @@ public class MusicPlaybackService extends Service {
musicIntent.setAction(what.replace(ELEVEN_PACKAGE_NAME, MUSIC_PACKAGE_NAME));
sendStickyBroadcast(musicIntent);
if (what.equals(META_CHANGED)) {
// Add the track to the recently played list.
mRecentsCache.addSongId(getAudioId());
mSongPlayCountCache.bumpSongCount(getAudioId());
} else if (what.equals(QUEUE_CHANGED)) {
saveQueue(true);
if (isPlaying()) {
// if we are in shuffle mode and our next track is still valid,
// try to re-use the track
// We need to reimplement the queue to prevent hacky solutions like this
if (mNextPlayPos >= 0 && mNextPlayPos < mPlaylist.size()
&& getShuffleMode() != SHUFFLE_NONE) {
setNextTrack(mNextPlayPos);
} else {
setNextTrack();
switch (what) {
case META_CHANGED:
// Add the track to the recently played list.
mRecentsCache.addSongId(getAudioId());
mSongPlayCountCache.bumpSongCount(getAudioId());
break;
case QUEUE_CHANGED:
saveQueue(true);
if (isPlaying()) {
// if we are in shuffle mode and our next track is still valid,
// try to re-use the track
// We need to reimplement the queue to prevent hacky solutions like this
if (mNextPlayPos >= 0 && mNextPlayPos < mPlaylist.size()
&& getShuffleMode() != SHUFFLE_NONE) {
setNextTrack(mNextPlayPos);
} else {
setNextTrack();
}
}
}
} else {
saveQueue(false);
break;
default:
saveQueue(false);
break;
}
if (what.equals(PLAYSTATE_CHANGED)) {
......@@ -1928,20 +1932,13 @@ public class MusicPlaybackService extends Service {
*/
private String getValueForDownloadedFile(Context context, Uri uri, String column) {
Cursor cursor = null;
final String[] projection = {
column
};
try {
cursor = context.getContentResolver().query(uri, projection, null, null, null);
try (Cursor cursor = context.getContentResolver().query(uri, projection, null, null, null)) {
if (cursor != null && cursor.moveToFirst()) {
return cursor.getString(0);
}
} finally {
if (cursor != null) {
cursor.close();
}
}
return null;
}
......@@ -2652,7 +2649,7 @@ public class MusicPlaybackService extends Service {
if (removeFromHistory) {
mHistory.remove(histsize - 1);
}
return pos.intValue();
return pos;
} else {
if (mPlayPos > 0) {
return mPlayPos - 1;
......@@ -3009,7 +3006,7 @@ public class MusicPlaybackService extends Service {
*/
public MusicPlayerHandler(final MusicPlaybackService service, final Looper looper) {
super(looper);
mService = new WeakReference<MusicPlaybackService>(service);
mService = new WeakReference<>(service);
}
/**
......@@ -3141,9 +3138,9 @@ public class MusicPlaybackService extends Service {
private static final class Shuffler {
private final LinkedList<Integer> mHistoryOfNumbers = new LinkedList<Integer>();
private final LinkedList<Integer> mHistoryOfNumbers = new LinkedList<>();
private final TreeSet<Integer> mPreviousNumbers = new TreeSet<Integer>();
private final TreeSet<Integer> mPreviousNumbers = new TreeSet<>();
private final Random mRandom = new Random();
......@@ -3164,8 +3161,7 @@ public class MusicPlaybackService extends Service {
int next;
do {
next = mRandom.nextInt(interval);
} while (next == mPrevious && interval > 1
&& !mPreviousNumbers.contains(Integer.valueOf(next)));
} while (next == mPrevious && interval > 1 && !mPreviousNumbers.contains(next));
mPrevious = next;
mHistoryOfNumbers.add(mPrevious);
mPreviousNumbers.add(mPrevious);
......@@ -3217,7 +3213,7 @@ public class MusicPlaybackService extends Service {
* Constructor of <code>MultiPlayer</code>
*/
public MultiPlayer(final MusicPlaybackService service) {
mService = new WeakReference<MusicPlaybackService>(service);
mService = new WeakReference<>(service);
mSrtManager = new SrtManager() {
@Override
public void onTimedText(String text) {
......@@ -3499,7 +3495,7 @@ public class MusicPlaybackService extends Service {
private final WeakReference<MusicPlaybackService> mService;
private ServiceStub(final MusicPlaybackService service) {
mService = new WeakReference<MusicPlaybackService>(service);
mService = new WeakReference<>(service);
}
/**
......
......@@ -50,7 +50,7 @@ public class AlbumArtPagerAdapter extends FragmentStatePagerAdapter {
private static final int MAX_ALBUM_ARTIST_SIZE = 10;
// This helps with flickering and jumping and reloading the same tracks
private final static LinkedList<AlbumArtistDetails> sCacheAlbumArtistDetails = new LinkedList<AlbumArtistDetails>();
private final static LinkedList<AlbumArtistDetails> sCacheAlbumArtistDetails = new LinkedList<>();
/**
* Adds the album artist details to the cache
......
......@@ -38,7 +38,7 @@ import java.util.Locale;
*/
public class PagerAdapter extends FragmentPagerAdapter {
private final SparseArray<WeakReference<Fragment>> mFragmentArray = new SparseArray<WeakReference<Fragment>>();
private final SparseArray<WeakReference<Fragment>> mFragmentArray = new SparseArray<>();
private final List<Holder> mHolderList = Lists.newArrayList();
......@@ -99,7 +99,7 @@ public class PagerAdapter extends FragmentPagerAdapter {
if (mWeakFragment != null) {
mWeakFragment.clear();
}
mFragmentArray.put(position, new WeakReference<Fragment>(mFragment));
mFragmentArray.put(position, new WeakReference<>(mFragment));
return mFragment;
}
......
......@@ -19,8 +19,6 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import org.lineageos.eleven.MusicPlaybackService;
public abstract class AppWidgetBase extends AppWidgetProvider {
protected PendingIntent buildPendingIntent(Context context, final String action,
......
......@@ -25,7 +25,6 @@ import android.widget.RemoteViews;
import org.lineageos.eleven.MusicPlaybackService;
import org.lineageos.eleven.R;
import org.lineageos.eleven.ui.activities.HomeActivity;
import org.lineageos.eleven.utils.ElevenUtils;
/**
* 4x2 App-Widget
......
......@@ -25,7 +25,6 @@ import android.widget.RemoteViews;
import org.lineageos.eleven.MusicPlaybackService;
import org.lineageos.eleven.R;
import org.lineageos.eleven.ui.activities.HomeActivity;
import org.lineageos.eleven.utils.ElevenUtils;
import org.lineageos.eleven.widgets.RepeatButton;
import org.lineageos.eleven.widgets.ShuffleButton;
......
......@@ -27,7 +27,6 @@ import android.widget.RemoteViews;
import org.lineageos.eleven.MusicPlaybackService;
import org.lineageos.eleven.R;
import org.lineageos.eleven.ui.activities.HomeActivity;
import org.lineageos.eleven.utils.ElevenUtils;
/**
* 4x1 App-Widget
......
......@@ -88,7 +88,7 @@ public abstract class BitmapWorkerTask<Params, Progress, Result>
mImageCache = ImageCache.getInstance(mContext);
mResources = mContext.getResources();
mImageReference = new WeakReference<ImageView>(imageView);
mImageReference = new WeakReference<>(imageView);
mImageType = imageType;
// A transparent image (layer 0) and the new result (layer 1)
......
......@@ -74,7 +74,7 @@ public class BlurBitmapWorkerTask extends BitmapWorkerTask<String, Void, BlurBit
final ImageType imageType, final Drawable fromDrawable,
final Context context, final RenderScript renderScript) {
super(key, blurScrimImage.getImageView(), imageType, fromDrawable, context);
mBlurScrimImage = new WeakReference<BlurScrimImage>(blurScrimImage);
mBlurScrimImage = new WeakReference<>(blurScrimImage);
mRenderScript = renderScript;
// use the existing image as the drawable and if it doesn't exist fallback to transparent
......@@ -186,4 +186,4 @@ public class BlurBitmapWorkerTask extends BitmapWorkerTask<String, Void, BlurBit
}
return null;
}
}
\ No newline at end of file
}
......@@ -155,7 +155,7 @@ public final class DiskLruCache implements Closeable {
private Writer journalWriter;
private final LinkedHashMap<String, Entry> lruEntries = new LinkedHashMap<String, Entry>(0,
private final LinkedHashMap<String, Entry> lruEntries = new LinkedHashMap<>(0,
0.75f, true);
private int redundantOpCount;
......@@ -690,7 +690,7 @@ public final class DiskLruCache implements Closeable {
if (journalWriter == null) {
return; // already closed
}
for (final Entry entry : new ArrayList<Entry>(lruEntries.values())) {
for (final Entry entry : new ArrayList<>(lruEntries.values())) {
if (entry.currentEditor != null) {
entry.currentEditor.abort();
}
......
......@@ -95,7 +95,7 @@ public final class ImageCache {
/**
* listeners to the cache state
*/
private HashSet<ICacheListener> mListeners = new HashSet<ICacheListener>();
private HashSet<ICacheListener> mListeners = new HashSet<>();
private static ImageCache sInstance;
......
......@@ -22,11 +22,9 @@ import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.TransitionDrawable;
import android.support.v8.renderscript.RenderScript;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import org.lineageos.eleven.R;
import org.lineageos.eleven.provider.PlaylistArtworkStore;
import org.lineageos.eleven.utils.ElevenUtils;
import org.lineageos.eleven.utils.ImageUtils;
......@@ -369,7 +367,7 @@ public abstract class ImageWorker {
* Constructor of <code>AsyncDrawable</code>
*/
public AsyncTaskContainer(final BitmapWorkerTask bitmapWorkerTask) {
mBitmapWorkerTaskReference = new WeakReference<BitmapWorkerTask>(bitmapWorkerTask);
mBitmapWorkerTaskReference = new WeakReference<>(bitmapWorkerTask);
mKey = bitmapWorkerTask.mKey;
}
......
......@@ -56,7 +56,7 @@ public class LruCache<K, V> {
throw new IllegalArgumentException("maxSize <= 0");
}
this.maxSize = maxSize;
this.map = new LinkedHashMap<K, V>(0, 0.75f, true);
this.map = new LinkedHashMap<>(0, 0.75f, true);
}
/**
......@@ -319,7 +319,7 @@ public class LruCache<K, V> {
* recently accessed to most recently accessed.
*/
public synchronized final Map<K, V> snapshot() {
return new LinkedHashMap<K, V>(this.map);
return new LinkedHashMap<>(this.map);
}
@SuppressLint("DefaultLocale")
......
......@@ -25,7 +25,6 @@ import android.graphics.drawable.TransitionDrawable;
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;
......@@ -125,11 +124,8 @@ public class PlaylistWorkerTask extends BitmapWorkerTask<Void, Void, TransitionD
}
// 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;
......@@ -158,10 +154,6 @@ public class PlaylistWorkerTask extends BitmapWorkerTask<Void, Void, TransitionD
} else {
bitmap = loadTopSongs(sortedCursor);
}
} finally {
if (sortedCursor != null) {
sortedCursor.close();
}
}
// if we have a bitmap create a transition drawable
......@@ -276,7 +268,7 @@ public class PlaylistWorkerTask extends BitmapWorkerTask<Void, Void, TransitionD
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);
......@@ -288,7 +280,7 @@ public class PlaylistWorkerTask extends BitmapWorkerTask<Void, Void, TransitionD
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()) {
......
......@@ -266,7 +266,6 @@ public class NowPlayingCursor extends AbstractCursor {
mSize = mNowPlaying.length;
if (mSize == 0) {
mCursorIndexes = null;
return;
}
}
}
......
......@@ -176,7 +176,7 @@ public class PlaylistSongLoader extends WrappedAsyncTaskLoader<List<Song>> {
final int idCol = cursor.getColumnIndexOrThrow(MediaStore.Audio.Playlists.Members.AUDIO_ID);
final Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId);
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
ArrayList<ContentProviderOperation> ops = new ArrayList<>();
// Delete all results in the playlist
ops.add(ContentProviderOperation.newDelete(uri).build());
......
......@@ -134,13 +134,14 @@ public class SongLoader extends SectionCreator.SimpleListLoader<Song> {
* @param sortOrder the song ordering preference selected by the user
*/
private static LocalizedStore.SortParameter getSortParameter(String sortOrder) {
if (sortOrder.equals(SortOrder.SongSortOrder.SONG_A_Z) ||
sortOrder.equals(SortOrder.SongSortOrder.SONG_Z_A)) {
return LocalizedStore.SortParameter.Song;
} else if (sortOrder.equals(SortOrder.SongSortOrder.SONG_ALBUM)) {
return LocalizedStore.SortParameter.Album;
} else if (sortOrder.equals(SortOrder.SongSortOrder.SONG_ARTIST)) {
return LocalizedStore.SortParameter.Artist;
switch (sortOrder) {
case SortOrder.SongSortOrder.SONG_A_Z:
case SortOrder.SongSortOrder.SONG_Z_A:
return SortParameter.Song;
case SortOrder.SongSortOrder.SONG_ALBUM:
return SortParameter.Album;
case SortOrder.SongSortOrder.SONG_ARTIST:
return SortParameter.Artist;
}
return null;
......
......@@ -64,12 +64,12 @@ public class SortedCursor extends AbstractCursor {
*/
private ArrayList<Long> buildCursorPositionMapping(final long[] order,
final String columnName, final List<? extends Object> extraData) {
ArrayList<Long> missingIds = new ArrayList<Long>();
ArrayList<Long> missingIds = new ArrayList<>();
mOrderedPositions = new ArrayList<Integer>(mCursor.getCount());
mExtraData = new ArrayList<Object>();
mOrderedPositions = new ArrayList<>(mCursor.getCount());
mExtraData = new ArrayList<>();
mMapCursorPositions = new HashMap<Long, Integer>(mCursor.getCount());
mMapCursorPositions = new HashMap<>(mCursor.getCount());
final int idPosition = mCursor.getColumnIndex(columnName);
if (mCursor.moveToFirst()) {
......
......@@ -178,7 +178,7 @@ public class LocaleUtils {
public ArrayList<String> getLabels() {
final int bucketCount = getBucketCount();
final ArrayList<String> labels = new ArrayList<String>(bucketCount);
final ArrayList<String> labels = new ArrayList<>(bucketCount);
for(int i = 0; i < bucketCount; ++i) {
labels.add(getBucketLabel(i));
}
......
......@@ -24,7 +24,6 @@ import android.widget.ListAdapter;
import org.lineageos.eleven.Config;
import org.lineageos.eleven.R;
import org.lineageos.eleven.ui.activities.HomeActivity;
import org.lineageos.eleven.utils.ElevenUtils;
import org.lineageos.eleven.utils.Lists;
import org.lineageos.eleven.utils.MusicUtils;
......@@ -93,7 +92,7 @@ public class PhotoSelectionDialog extends DialogFragment {
}
// Dialog item Adapter
final HomeActivity activity = (HomeActivity) getActivity();
final ListAdapter adapter = new ArrayAdapter<String>(activity,
final ListAdapter adapter = new ArrayAdapter<>(activity,
android.R.layout.select_dialog_item, mChoices);
return new AlertDialog.Builder(activity).setTitle(title)
.setAdapter(adapter, new DialogInterface.OnClickListener() {
......
......@@ -394,22 +394,15 @@ public class LocalizedStore {
Log.d(TAG, "Running selection: " + selection);
}
Cursor c = null;
try {
c = mMusicDatabase.getReadableDatabase().rawQuery(selection, null);
try (Cursor c = mMusicDatabase.getReadableDatabase().rawQuery(selection, null)) {
if (c != null && c.moveToFirst()) {
sortData.ids = new long[c.getCount()];
sortData.bucketLabels = new ArrayList<String>(c.getCount());
sortData.bucketLabels = new ArrayList<>(c.getCount());
do {
sortData.ids[c.getPosition()] = c.getLong(0);
sortData.bucketLabels.add(c.getString(1));
} while (c.moveToNext());
}
} finally {
if (c != null) {
c.close();
}
}
return sortData;
......
......@@ -139,7 +139,7 @@ public class SearchHistory {
public ArrayList<String> getRecentSearches() {
Cursor searches = queryRecentSearches(String.valueOf(MAX_ITEMS_IN_DB));
ArrayList<String> results = new ArrayList<String>(MAX_ITEMS_IN_DB);
ArrayList<String> results = new ArrayList<>(MAX_ITEMS_IN_DB);
try {
if (searches != null && searches.moveToFirst()) {
......
......@@ -285,7 +285,7 @@ public class SongPlayCount {
return null;
}
HashSet<Long> uniqueIds = new HashSet<Long>(ids.length);
HashSet<Long> uniqueIds = new HashSet<>(ids.length);
// create the list of ids to select against
StringBuilder selection = new StringBuilder();
......@@ -344,9 +344,8 @@ public class SongPlayCount {
}
// append the remaining items - these are songs that haven't been played recently
Iterator<Long> iter = uniqueIds.iterator();
while (iter.hasNext()) {
sortedList[idx++] = iter.next();
for (final Long uniqueId : uniqueIds) {
sortedList[idx++] = uniqueId;
}
return sortedList;
......
......@@ -87,7 +87,7 @@ public class SectionAdapter<TItem,
mContext = context;
mUnderlyingAdapter = underlyingAdapter;
mUnderlyingAdapter.setPopupMenuClickedListener(this);
mSections = new TreeMap<Integer, Section>();
mSections = new TreeMap<>();
setupHeaderParameters(R.layout.list_header, false);
// since we have no good default footer, just re-use the header layout
setupFooterParameters(R.layout.list_header, false);
......
......@@ -73,6 +73,6 @@ public class SectionCreator<T> extends WrappedAsyncTaskLoader<SectionListContain
sections = SectionCreatorUtils.createSections(results, mComparator);
}
return new SectionListContainer<T>(sections, results);
return new SectionListContainer<>(sections, results);
}
}
......@@ -100,34 +100,34 @@ public class MusicHolder {
public MusicHolder(final View view) {
super();
// Initialize mImage
mImage = new WeakReference<ImageView>((ImageView)view.findViewById(R.id.image));
mImage = new WeakReference<>((ImageView) view.findViewById(R.id.image));
// Initialize mLineOne
mLineOne = new WeakReference<TextView>((TextView)view.findViewById(R.id.line_one));
mLineOne = new WeakReference<>((TextView) view.findViewById(R.id.line_one));
// Initialize mLineOneRight
mLineOneRight = new WeakReference<TextView>(
(TextView)view.findViewById(R.id.line_one_right));
mLineOneRight = new WeakReference<>(
(TextView) view.findViewById(R.id.line_one_right));
// Initialize mLineTwo
mLineTwo = new WeakReference<TextView>((TextView)view.findViewById(R.id.line_two));
mLineTwo = new WeakReference<>((TextView) view.findViewById(R.id.line_two));
// Initialize Circular progress bar container
mPlayPauseProgressButton = new WeakReference<PlayPauseProgressButton>(
(PlayPauseProgressButton)view.findViewById(R.id.playPauseProgressButton));
mPlayPauseProgressButton = new WeakReference<>(
(PlayPauseProgressButton) view.findViewById(R.id.playPauseProgressButton));
// Get the padding container for the progress bar
mPlayPauseProgressContainer = new WeakReference<View>(
mPlayPauseProgressContainer = new WeakReference<>(
view.findViewById(R.id.play_pause_container));
mNowPlayingIndicator = new WeakReference<View>(view.findViewById(R.id.now_playing));
mNowPlayingIndicator = new WeakReference<>(view.findViewById(R.id.now_playing));
// Get the divider for the list item
mDivider = new WeakReference<View>(view.findViewById(R.id.divider));
mDivider = new WeakReference<>(view.findViewById(R.id.divider));
// Get the pop up menu button
mPopupMenuButton = new WeakReference<PopupMenuButton>(
(PopupMenuButton)view.findViewById(R.id.popup_menu_button));
mPopupMenuButton = new WeakReference<>(
(PopupMenuButton) view.findViewById(R.id.popup_menu_button));
}
/**
......
......@@ -379,7 +379,7 @@ public abstract class BaseActivity extends FragmentActivity implements ServiceCo
* Constructor of <code>PlaybackStatus</code>
*/
public PlaybackStatus(final BaseActivity activity) {
mReference = new WeakReference<BaseActivity>(activity);
mReference = new WeakReference<>(activity);
}
/**
......@@ -388,21 +388,31 @@ public abstract class BaseActivity extends FragmentActivity implements ServiceCo
@Override
public void onReceive(final Context context, final Intent intent) {
final String action = intent.getAction();
BaseActivity baseActivity = mReference.get();
if (action == null || action.isEmpty()) {
return;
}
final BaseActivity baseActivity = mReference.get();
if (baseActivity != null) {
if (action.equals(MusicPlaybackService.META_CHANGED)) {
baseActivity.onMetaChanged();