Fix error-prone errors

This commit is contained in:
Andrew Gaul 2018-10-12 21:14:50 -07:00
parent 2d4739bd84
commit d88e1202b1
30 changed files with 28 additions and 108 deletions

View File

@ -20,7 +20,7 @@ public class PodcastApp extends Application {
try {
Class.forName("de.danoeh.antennapod.config.ClientConfigurator");
} catch (Exception e) {
throw new RuntimeException("ClientConfigurator not found");
throw new RuntimeException("ClientConfigurator not found", e);
}
}

View File

@ -69,22 +69,6 @@ public class FeedSettingsActivity extends AppCompatActivity {
private Subscription subscription;
private final View.OnClickListener copyUrlToClipboard = new View.OnClickListener() {
@Override
public void onClick(View v) {
if(feed != null && feed.getDownload_url() != null) {
String url = feed.getDownload_url();
ClipData clipData = ClipData.newPlainText(url, url);
android.content.ClipboardManager cm = (android.content.ClipboardManager) FeedSettingsActivity.this
.getSystemService(Context.CLIPBOARD_SERVICE);
cm.setPrimaryClip(clipData);
Toast t = Toast.makeText(FeedSettingsActivity.this, R.string.copied_url_msg, Toast.LENGTH_SHORT);
t.show();
}
}
};
private boolean authInfoChanged = false;
private final TextWatcher authTextWatcher = new TextWatcher() {

View File

@ -231,7 +231,6 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
Log.d(TAG, "onCreate()");
StorageUtils.checkStorageAvailability(this);
orientation = getResources().getConfiguration().orientation;
getWindow().setFormat(PixelFormat.TRANSPARENT);
}
@ -265,15 +264,10 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
private void onBufferUpdate(float progress) {
if (sbPosition != null) {
sbPosition.setSecondaryProgress((int) progress * sbPosition.getMax());
sbPosition.setSecondaryProgress((int) (progress * sbPosition.getMax()));
}
}
/**
* Current screen orientation.
*/
private int orientation;
@Override
protected void onStart() {
super.onStart();
@ -992,7 +986,7 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
}
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (requestCode == REQUEST_CODE_STORAGE) {
if (grantResults.length <= 0 || grantResults[0] != PackageManager.PERMISSION_GRANTED) {
Toast.makeText(this, R.string.needs_storage_permission, Toast.LENGTH_LONG).show();

View File

@ -357,7 +357,7 @@ public abstract class MediaplayerInfoActivity extends MediaplayerActivity implem
@Override
public boolean onOptionsItemSelected(MenuItem item) {
return drawerToggle != null && drawerToggle.onOptionsItemSelected(item) || super.onOptionsItemSelected(item);
return (drawerToggle != null && drawerToggle.onOptionsItemSelected(item)) || super.onOptionsItemSelected(item);
}
@Override

View File

@ -144,7 +144,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
feedUrl = getIntent().getStringExtra(ARG_FEEDURL);
} else if (TextUtils.equals(getIntent().getAction(), Intent.ACTION_SEND)
|| TextUtils.equals(getIntent().getAction(), Intent.ACTION_VIEW)) {
feedUrl = (TextUtils.equals(getIntent().getAction(), Intent.ACTION_SEND))
feedUrl = TextUtils.equals(getIntent().getAction(), Intent.ACTION_SEND)
? getIntent().getStringExtra(Intent.EXTRA_TEXT) : getIntent().getDataString();
if (actionBar != null) {
actionBar.setTitle(R.string.add_feed_label);
@ -306,7 +306,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
}
private void parseFeed() {
if (feed == null || feed.getFile_url() == null && feed.isDownloaded()) {
if (feed == null || (feed.getFile_url() == null && feed.isDownloaded())) {
throw new IllegalStateException("feed must be non-null and downloaded when parseFeed is called");
}
Log.d(TAG, "Parsing feed");

View File

@ -45,8 +45,6 @@ import de.danoeh.antennapod.core.service.GpodnetSyncService;
public class GpodnetAuthenticationActivity extends AppCompatActivity {
private static final String TAG = "GpodnetAuthActivity";
private static final String CURRENT_STEP = "current_step";
private ViewFlipper viewFlipper;
private static final int STEP_DEFAULT = -1;

View File

@ -22,7 +22,6 @@ import de.danoeh.antennapod.core.util.playback.Playable;
public class CoverFragment extends Fragment implements MediaplayerInfoContentFragment {
private static final String TAG = "CoverFragment";
private static final String ARG_PLAYABLE = "arg.playable";
private Playable media;

View File

@ -210,11 +210,6 @@ public class ExternalPlayerFragment extends Fragment {
}
}
private String getPositionString(int position, int duration) {
return Converter.getDurationStringLong(position) + " / "
+ Converter.getDurationStringLong(duration);
}
public PlaybackController getPlaybackControllerTestingOnly() {
return controller;
}

View File

@ -417,13 +417,10 @@ public class ItemlistFragment extends ListFragment {
}
private boolean insideOnFragmentLoaded = false;
private void onFragmentLoaded() {
if(!isVisible()) {
return;
}
insideOnFragmentLoaded = true;
if (adapter == null) {
setListAdapter(null);
setupHeaderView();
@ -440,9 +437,6 @@ public class ItemlistFragment extends ListFragment {
if (feed != null && feed.getNextPageLink() == null && listFooter != null) {
getListView().removeFooterView(listFooter.getRoot());
}
insideOnFragmentLoaded = false;
}
private void refreshHeaderView() {

View File

@ -487,8 +487,8 @@ public class QueueFragment extends Fragment {
private void reallyMoved(int from, int to) {
// Write drag operation to database
Log.d(TAG, "Write to database move(" + dragFrom + ", " + dragTo + ")");
DBWriter.moveQueueItem(dragFrom, dragTo, true);
Log.d(TAG, "Write to database move(" + from + ", " + to + ")");
DBWriter.moveQueueItem(from, to, true);
}
}
);
@ -537,8 +537,8 @@ public class QueueFragment extends Fragment {
for(FeedItem item : queue) {
if(item.getMedia() != null) {
timeLeft +=
(item.getMedia().getDuration() - item.getMedia().getPosition())
/ playbackSpeed;
(long) ((item.getMedia().getDuration() - item.getMedia().getPosition())
/ playbackSpeed);
}
}
info += " \u2022 ";

View File

@ -19,11 +19,9 @@ import de.danoeh.antennapod.core.util.flattr.FlattrUtils;
public class FlattrStatusFetcher extends Thread {
private static final String TAG = "FlattrStatusFetcher";
private final Context context;
public FlattrStatusFetcher(Context context) {
super();
this.context = context;
}
@Override

View File

@ -50,7 +50,7 @@ public abstract class FeedComponent {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (o == null || !(o instanceof FeedComponent)) return false;
FeedComponent that = (FeedComponent) o;
@ -62,4 +62,4 @@ public abstract class FeedComponent {
public int hashCode() {
return (int) (id ^ (id >>> 32));
}
}
}

View File

@ -194,7 +194,7 @@ public class FeedItem extends FeedComponent implements ShownotesProvider, Flattr
if (other.link != null) {
link = other.link;
}
if (other.pubDate != null && other.pubDate != pubDate) {
if (other.pubDate != null && other.pubDate.equals(pubDate)) {
pubDate = other.pubDate;
}
if (other.media != null) {

View File

@ -532,8 +532,8 @@ public class FeedMedia extends FeedFile implements Playable {
UserPreferences.isAutoFlattr() &&
item.getPaymentLink() != null &&
item.getFlattrStatus().getUnflattred() &&
(completed && autoFlattrThreshold <= 1.0f ||
played_duration >= autoFlattrThreshold * duration)) {
((completed && autoFlattrThreshold <= 1.0f) ||
(played_duration >= autoFlattrThreshold * duration))) {
DBTasks.flattrItemIfLoggedIn(context, item);
}
}
@ -626,6 +626,9 @@ public class FeedMedia extends FeedFile implements Playable {
@Override
public boolean equals(Object o) {
if (o == null) {
return false;
}
if (FeedMediaFlavorHelper.instanceOfRemoteMedia(o)) {
return o.equals(this);
}

View File

@ -169,7 +169,7 @@ public class GpodnetEpisodeAction {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (o == null || !(o instanceof GpodnetEpisodeAction)) return false;
GpodnetEpisodeAction that = (GpodnetEpisodeAction) o;

View File

@ -23,7 +23,6 @@ public class SleepTimerPreferences {
private static final String DEFAULT_VALUE = "15";
private static final int DEFAULT_TIME_UNIT = 1;
private static Context context;
private static SharedPreferences prefs;
/**

View File

@ -124,7 +124,7 @@ public class DownloadRequest implements Parcelable {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (o == null || !(o instanceof DownloadRequest)) return false;
DownloadRequest that = (DownloadRequest) o;

View File

@ -117,11 +117,6 @@ public class DownloadService extends Service {
private CompletionService<Downloader> downloadExecutor;
private FeedSyncThread feedSyncThread;
/**
* Number of threads of downloadExecutor.
*/
private static final int NUM_PARALLEL_DOWNLOADS = 6;
private DownloadRequester requester;
@ -862,22 +857,6 @@ public class DownloadService extends Service {
return true;
}
/**
* Delete files that aren't needed anymore
*/
private void cleanup(Feed feed) {
if (feed.getFile_url() != null) {
if (new File(feed.getFile_url()).delete()) {
Log.d(TAG, "Successfully deleted cache file.");
} else {
Log.e(TAG, "Failed to delete cache file.");
}
feed.setFile_url(null);
} else {
Log.d(TAG, "Didn't delete cache file: File url is not set.");
}
}
public void shutdown() {
isActive = false;
if (isCollectingRequests) {

View File

@ -304,7 +304,7 @@ public class HttpDownloader extends Downloader {
String encoded = ByteString.of(bytes).base64();
return "Basic " + encoded;
} catch (UnsupportedEncodingException e) {
throw new AssertionError();
throw new AssertionError(e);
}
}

View File

@ -602,14 +602,6 @@ public class PlaybackService extends MediaBrowserServiceCompat {
mediaPlayer.setVideoSurface(sh);
}
/**
* Called when the surface holder of the mediaplayer has to be changed.
*/
private void resetVideoSurface() {
taskManager.cancelPositionSaver();
mediaPlayer.resetVideoSurface();
}
public void notifyVideoSurfaceAbandoned() {
mediaPlayer.pause(true, false);
mediaPlayer.resetVideoSurface();

View File

@ -12,7 +12,7 @@ public enum PlayerStatus {
INITIALIZING(9), // playback service is loading the Playable's metadata
INITIALIZED(10); // playback service was started, data source of media player was set.
private int statusValue;
private final int statusValue;
private static final PlayerStatus[] fromOrdinalLookup;
static {

View File

@ -75,7 +75,7 @@ public final class DBReader {
cursor = adapter.getAllFeedsCursor();
List<Feed> feeds = new ArrayList<>(cursor.getCount());
while (cursor.moveToNext()) {
Feed feed = extractFeedFromCursorRow(adapter, cursor);
Feed feed = extractFeedFromCursorRow(cursor);
feeds.add(feed);
}
return feeds;
@ -243,7 +243,7 @@ public final class DBReader {
return result;
}
private static Feed extractFeedFromCursorRow(PodDBAdapter adapter, Cursor cursor) {
private static Feed extractFeedFromCursorRow(Cursor cursor) {
Feed feed = Feed.fromCursor(cursor);
FeedPreferences preferences = FeedPreferences.fromCursor(cursor);
feed.setPreferences(preferences);
@ -580,7 +580,7 @@ public final class DBReader {
try {
cursor = adapter.getFeedCursor(feedId);
if (cursor.moveToNext()) {
feed = extractFeedFromCursorRow(adapter, cursor);
feed = extractFeedFromCursorRow(cursor);
feed.setItems(getFeedItemList(feed));
} else {
Log.e(TAG, "getFeed could not find feed with id " + feedId);
@ -1007,7 +1007,7 @@ public final class DBReader {
Cursor feedCursor = adapter.getFeedsInFlattrQueueCursor();
if (feedCursor.moveToFirst()) {
do {
result.add(extractFeedFromCursorRow(adapter, feedCursor));
result.add(extractFeedFromCursorRow(feedCursor));
} while (feedCursor.moveToNext());
}
feedCursor.close();

View File

@ -777,10 +777,8 @@ public final class DBTasks {
*/
abstract static class QueryTask<T> implements Callable<T> {
private T result;
private final Context context;
public QueryTask(Context context) {
this.context = context;
}
@Override

View File

@ -22,9 +22,6 @@ public class NSRSS20 extends Namespace {
private static final String TAG = "NSRSS20";
private static final String NSTAG = "rss";
private static final String NSURI = "";
public static final String CHANNEL = "channel";
public static final String ITEM = "item";
private static final String GUID = "guid";

View File

@ -15,7 +15,6 @@ public abstract class Namespace {
public abstract SyndElement handleElementStart(String localName, HandlerState state, Attributes attributes);
/** Called by a Feedhandler when in endElement and it detects a namespace element
* @return true if namespace handled the element, false if it ignored it
* */
public abstract void handleElementEnd(String localName, HandlerState state);

View File

@ -47,8 +47,6 @@ public class NSAtom extends Namespace {
private static final String LINK_REL_ARCHIVES = "archives";
private static final String LINK_REL_ENCLOSURE = "enclosure";
private static final String LINK_REL_PAYMENT = "payment";
private static final String LINK_REL_RELATED = "related";
private static final String LINK_REL_SELF = "self";
private static final String LINK_REL_NEXT = "next";
// type-values
private static final String LINK_TYPE_ATOM = "application/atom+xml";

View File

@ -28,7 +28,6 @@ public final class Converter {
/** Determines the length of the number for best readability.*/
private static final int NUM_LENGTH = 1024;
private static final int DAYS_MIL = 86400000;
private static final int HOURS_MIL = 3600000;
private static final int MINUTES_MIL = 60000;
private static final int SECONDS_MIL = 1000;

View File

@ -135,7 +135,7 @@ public class DateUtils {
if (parts.length >= 2) {
result += Integer.parseInt(parts[idx]) * 60000L;
idx++;
result += (Float.parseFloat(parts[idx])) * 1000L;
result += (long) (Float.parseFloat(parts[idx]) * 1000L);
}
return result;
}

View File

@ -702,7 +702,7 @@ public abstract class PlaybackController {
return org.antennapod.audio.MediaPlayer.isPrestoLibraryInstalled(activity.getApplicationContext())
|| UserPreferences.useSonic()
|| Build.VERSION.SDK_INT >= 23
|| playbackService != null && playbackService.canSetSpeed();
|| (playbackService != null && playbackService.canSetSpeed());
}
public void setPlaybackSpeed(float speed) {

View File

@ -1440,12 +1440,6 @@ public class CastManager extends BaseCastManager implements OnFailedListener {
return idleReason;
}
private void onMessageSendFailed(int errorCode) {
for (CastConsumer consumer : castConsumers) {
consumer.onDataMessageSendFailed(errorCode);
}
}
/*
* This is called by onStatusUpdated() of the RemoteMediaPlayer
*/