From 99c03d59b31e19afd53bb51e7d6e111cf44afb4b Mon Sep 17 00:00:00 2001 From: Andrew Rabert Date: Tue, 24 Apr 2018 20:08:00 -0400 Subject: [PATCH] Remove unreachable statements --- .../audinaut/activity/SubsonicActivity.java | 5 ----- .../activity/SubsonicFragmentActivity.java | 4 ++-- .../adapter/ExpandableSectionAdapter.java | 4 +--- .../nullsum/audinaut/adapter/MainAdapter.java | 4 +--- .../fragments/NowPlayingFragment.java | 2 +- .../fragments/PreferenceCompatFragment.java | 3 --- .../audinaut/fragments/SubsonicFragment.java | 20 +++++------------ .../provider/AudinautSearchProvider.java | 3 --- .../audinaut/service/DownloadService.java | 2 +- .../audinaut/service/parser/GenreParser.java | 10 ++++----- .../net/nullsum/audinaut/util/FileUtil.java | 9 -------- .../net/nullsum/audinaut/util/MenuUtil.java | 2 +- .../net/nullsum/audinaut/view/SongView.java | 22 +++++-------------- 13 files changed, 21 insertions(+), 69 deletions(-) diff --git a/app/src/main/java/net/nullsum/audinaut/activity/SubsonicActivity.java b/app/src/main/java/net/nullsum/audinaut/activity/SubsonicActivity.java index b6c6622..4280175 100644 --- a/app/src/main/java/net/nullsum/audinaut/activity/SubsonicActivity.java +++ b/app/src/main/java/net/nullsum/audinaut/activity/SubsonicActivity.java @@ -768,11 +768,6 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte } public DownloadService getDownloadService() { - boolean finished = false; - if (finished) { - return null; - } - // If service is not available, request it to start and wait for it. for (int i = 0; i < 5; i++) { DownloadService downloadService = DownloadService.getInstance(); diff --git a/app/src/main/java/net/nullsum/audinaut/activity/SubsonicFragmentActivity.java b/app/src/main/java/net/nullsum/audinaut/activity/SubsonicFragmentActivity.java index 520a09e..f43f316 100644 --- a/app/src/main/java/net/nullsum/audinaut/activity/SubsonicFragmentActivity.java +++ b/app/src/main/java/net/nullsum/audinaut/activity/SubsonicFragmentActivity.java @@ -97,7 +97,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity implements Downlo firstRun = true; } - if ("".equals(fragmentType) || fragmentType == null || firstRun) { + if ("".equals(fragmentType) || firstRun) { // Initial startup stuff if (!sessionInitialized) { loadSession(); @@ -590,7 +590,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity implements Downlo private boolean resetCacheLocation(SharedPreferences prefs) { String newDirectory = FileUtil.getDefaultMusicDirectory(this).getPath(); String oldDirectory = prefs.getString(Constants.PREFERENCES_KEY_CACHE_LOCATION, null); - if (newDirectory == null || (oldDirectory != null && newDirectory.equals(oldDirectory))) { + if (oldDirectory != null && newDirectory.equals(oldDirectory)) { return false; } else { SharedPreferences.Editor editor = prefs.edit(); diff --git a/app/src/main/java/net/nullsum/audinaut/adapter/ExpandableSectionAdapter.java b/app/src/main/java/net/nullsum/audinaut/adapter/ExpandableSectionAdapter.java index 0a8985c..c38ab87 100644 --- a/app/src/main/java/net/nullsum/audinaut/adapter/ExpandableSectionAdapter.java +++ b/app/src/main/java/net/nullsum/audinaut/adapter/ExpandableSectionAdapter.java @@ -120,8 +120,6 @@ abstract class ExpandableSectionAdapter extends SectionAdapter { toggleSelectionView.setVisibility(View.GONE); } - if (view != null) { - view.setObject(header); - } + view.setObject(header); } } diff --git a/app/src/main/java/net/nullsum/audinaut/adapter/MainAdapter.java b/app/src/main/java/net/nullsum/audinaut/adapter/MainAdapter.java index 00182ff..48db710 100644 --- a/app/src/main/java/net/nullsum/audinaut/adapter/MainAdapter.java +++ b/app/src/main/java/net/nullsum/audinaut/adapter/MainAdapter.java @@ -76,8 +76,6 @@ public class MainAdapter extends SectionAdapter { checkBox.setVisibility(View.GONE); } - if (view != null) { - view.setObject(display); - } + view.setObject(display); } } diff --git a/app/src/main/java/net/nullsum/audinaut/fragments/NowPlayingFragment.java b/app/src/main/java/net/nullsum/audinaut/fragments/NowPlayingFragment.java index 01a9533..98e6e63 100644 --- a/app/src/main/java/net/nullsum/audinaut/fragments/NowPlayingFragment.java +++ b/app/src/main/java/net/nullsum/audinaut/fragments/NowPlayingFragment.java @@ -653,7 +653,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis PlayerState state = service.getPlayerState(); if (state == PAUSED || state == COMPLETED || state == STOPPED) { service.start(); - } else if (state == STOPPED || state == IDLE) { + } else if (state == IDLE) { warnIfStorageUnavailable(); int current = service.getCurrentPlayingIndex(); // TODO: Use play() method. diff --git a/app/src/main/java/net/nullsum/audinaut/fragments/PreferenceCompatFragment.java b/app/src/main/java/net/nullsum/audinaut/fragments/PreferenceCompatFragment.java index 2343c74..14bfd6d 100644 --- a/app/src/main/java/net/nullsum/audinaut/fragments/PreferenceCompatFragment.java +++ b/app/src/main/java/net/nullsum/audinaut/fragments/PreferenceCompatFragment.java @@ -85,9 +85,6 @@ public abstract class PreferenceCompatFragment extends SubsonicFragment { } mList = (ListView) listView; - if (mList == null) { - throw new RuntimeException("Your content must have a ListView whose id attribute is 'android.R.id.list'"); - } mHandler.post(mRequestFocus); } diff --git a/app/src/main/java/net/nullsum/audinaut/fragments/SubsonicFragment.java b/app/src/main/java/net/nullsum/audinaut/fragments/SubsonicFragment.java index 21a1880..da9710d 100644 --- a/app/src/main/java/net/nullsum/audinaut/fragments/SubsonicFragment.java +++ b/app/src/main/java/net/nullsum/audinaut/fragments/SubsonicFragment.java @@ -661,8 +661,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR }.execute(); } }); - _useCombo = true; - final boolean useCombo = _useCombo; + final boolean useCombo = true; startYearBox.setText(oldStartYear); endYearBox.setText(oldEndYear); @@ -674,11 +673,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR .setView(dialogView) .setPositiveButton(R.string.common_ok, (dialog, id) -> { String genre; - if (useCombo) { - genre = genreCombo.getText().toString(); - } else { - genre = genreBox.getText().toString(); - } + genre = genreCombo.getText().toString(); String startYear = startYearBox.getText().toString(); String endYear = endYearBox.getText().toString(); @@ -1051,14 +1046,9 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR size = file.length(); // If no duration try to read bitrate tag - if (duration == null) { - tmp = metadata.extractMetadata(MediaMetadataRetriever.METADATA_KEY_BITRATE); - bitrate = Integer.parseInt((tmp != null) ? tmp : "0") / 1000; - } else { - // Otherwise do a calculation for it - // Divide by 1000 so in kbps - bitrate = (int) (size / duration) / 1000 * 8; - } + // Otherwise do a calculation for it + // Divide by 1000 so in kbps + bitrate = (int) (size / duration) / 1000 * 8; if (Util.isOffline(context)) { song.setGenre(metadata.extractMetadata(MediaMetadataRetriever.METADATA_KEY_GENRE)); diff --git a/app/src/main/java/net/nullsum/audinaut/provider/AudinautSearchProvider.java b/app/src/main/java/net/nullsum/audinaut/provider/AudinautSearchProvider.java index a088207..b68115c 100644 --- a/app/src/main/java/net/nullsum/audinaut/provider/AudinautSearchProvider.java +++ b/app/src/main/java/net/nullsum/audinaut/provider/AudinautSearchProvider.java @@ -66,9 +66,6 @@ public class AudinautSearchProvider extends ContentProvider { private SearchResult search(String query) { MusicService musicService = MusicServiceFactory.getMusicService(getContext()); - if (musicService == null) { - return null; - } try { return musicService.search(new SearchCritera(query, 5, 10, 10), getContext(), null); diff --git a/app/src/main/java/net/nullsum/audinaut/service/DownloadService.java b/app/src/main/java/net/nullsum/audinaut/service/DownloadService.java index 0aa5b84..9a40bec 100644 --- a/app/src/main/java/net/nullsum/audinaut/service/DownloadService.java +++ b/app/src/main/java/net/nullsum/audinaut/service/DownloadService.java @@ -935,7 +935,7 @@ public class DownloadService extends Service { private int seekToWrapper(int difference) { int msPlayed = Math.max(0, getPlayerPosition()); Integer duration = getPlayerDuration(); - int msTotal = duration == null ? 0 : duration; + int msTotal = duration; int seekTo; if (msPlayed + difference > msTotal) { diff --git a/app/src/main/java/net/nullsum/audinaut/service/parser/GenreParser.java b/app/src/main/java/net/nullsum/audinaut/service/parser/GenreParser.java index 3f587c1..669a1b1 100644 --- a/app/src/main/java/net/nullsum/audinaut/service/parser/GenreParser.java +++ b/app/src/main/java/net/nullsum/audinaut/service/parser/GenreParser.java @@ -67,12 +67,10 @@ public class GenreParser extends AbstractParser { } else if (eventType == XmlPullParser.TEXT) { if (genre != null) { String value = getText(); - if (genre != null) { - genre.setName(Html.fromHtml(value).toString()); - genre.setIndex(value.substring(0, 1)); - result.add(genre); - genre = null; - } + genre.setName(Html.fromHtml(value).toString()); + genre.setIndex(value.substring(0, 1)); + result.add(genre); + genre = null; } } } while (eventType != XmlPullParser.END_DOCUMENT); diff --git a/app/src/main/java/net/nullsum/audinaut/util/FileUtil.java b/app/src/main/java/net/nullsum/audinaut/util/FileUtil.java index 4cc9f96..18c2c1e 100644 --- a/app/src/main/java/net/nullsum/audinaut/util/FileUtil.java +++ b/app/src/main/java/net/nullsum/audinaut/util/FileUtil.java @@ -637,15 +637,6 @@ public class FileUtil { return null; } - if (0 != 0) { - Date fileDate = new Date(file.lastModified()); - // Convert into hours - long age = (new Date().getTime() - fileDate.getTime()) / 1000 / 3600; - if (age > 0) { - return null; - } - } - RandomAccessFile randomFile = new RandomAccessFile(file, "r"); in = new Input(new FileInputStream(randomFile.getFD())); diff --git a/app/src/main/java/net/nullsum/audinaut/util/MenuUtil.java b/app/src/main/java/net/nullsum/audinaut/util/MenuUtil.java index ed5cf85..a6c3078 100644 --- a/app/src/main/java/net/nullsum/audinaut/util/MenuUtil.java +++ b/app/src/main/java/net/nullsum/audinaut/util/MenuUtil.java @@ -65,7 +65,7 @@ public final class MenuUtil { folder = ((AlbumView) updateView).getFile(); } else if (updateView instanceof ArtistView) { folder = ((ArtistView) updateView).getFile(); - } else if (updateView instanceof ArtistEntryView) { + } else { folder = ((ArtistEntryView) updateView).getFile(); } diff --git a/app/src/main/java/net/nullsum/audinaut/view/SongView.java b/app/src/main/java/net/nullsum/audinaut/view/SongView.java index 70b69ce..72a27f3 100644 --- a/app/src/main/java/net/nullsum/audinaut/view/SongView.java +++ b/app/src/main/java/net/nullsum/audinaut/view/SongView.java @@ -199,31 +199,19 @@ public class SongView extends UpdateView2 { boolean playing = Util.equals(downloadService.getCurrentPlaying(), downloadFile); if (playing) { if (!this.playing) { - this.playing = playing; + this.playing = true; playingTextView.setCompoundDrawablesWithIntrinsicBounds(DrawableTint.getDrawableRes(context, R.attr.playing), 0, 0, 0); } } else { if (this.playing) { - this.playing = playing; + this.playing = false; playingTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); } } - boolean isPlayed = false; - if (isPlayed) { - if (!isPlayedShown) { - if (playedButton.getDrawable() == null) { - playedButton.setImageDrawable(DrawableTint.getTintedDrawable(context)); - } - - playedButton.setVisibility(View.VISIBLE); - isPlayedShown = true; - } - } else { - if (isPlayedShown) { - playedButton.setVisibility(View.GONE); - isPlayedShown = false; - } + if (isPlayedShown) { + playedButton.setVisibility(View.GONE); + isPlayedShown = false; } }