diff options
author | Andrew Gaul <andrew@gaul.org> | 2016-03-13 22:15:59 -0700 |
---|---|---|
committer | Andrew Gaul <andrew@gaul.org> | 2016-03-13 22:34:50 -0700 |
commit | 6b449c18ee6bd56fed7df0bcc556e26794d4aa73 (patch) | |
tree | 13e3bab6e9c5976b4c60b625b52e38efc37fc2ea /core | |
parent | a7ef24606962385a5b20d1c6df2dec623cc3aa69 (diff) | |
download | AntennaPod-6b449c18ee6bd56fed7df0bcc556e26794d4aa73.zip |
Address error-prone warnings
Diffstat (limited to 'core')
4 files changed, 17 insertions, 13 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/asynctask/FlattrClickWorker.java b/core/src/main/java/de/danoeh/antennapod/core/asynctask/FlattrClickWorker.java index ac032fcc0..c0ec8d08a 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/asynctask/FlattrClickWorker.java +++ b/core/src/main/java/de/danoeh/antennapod/core/asynctask/FlattrClickWorker.java @@ -17,6 +17,7 @@ import java.util.LinkedList; import java.util.List; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; +import java.util.concurrent.atomic.AtomicInteger; import de.danoeh.antennapod.core.BuildConfig; import de.danoeh.antennapod.core.ClientConfig; @@ -46,8 +47,8 @@ public class FlattrClickWorker extends AsyncTask<Void, Integer, FlattrClickWorke public static enum ExitCode {EXIT_NORMAL, NO_TOKEN, NO_NETWORK, NO_THINGS} - private volatile int countFailed = 0; - private volatile int countSuccess = 0; + private final AtomicInteger countFailed = new AtomicInteger(); + private final AtomicInteger countSuccess = new AtomicInteger(); private volatile FlattrThing extraFlattrThing; @@ -114,12 +115,12 @@ public class FlattrClickWorker extends AsyncTask<Void, Integer, FlattrClickWorke FlattrUtils.clickUrl(context, thing.getPaymentLink()); thing.getFlattrStatus().setFlattred(); publishProgress(R.string.flattr_click_success); - countSuccess++; + countSuccess.incrementAndGet(); } catch (FlattrException e) { e.printStackTrace(); - countFailed++; - if (countFailed == 1) { + int failed = countFailed.incrementAndGet(); + if (failed == 1) { exception = e; } } @@ -148,7 +149,7 @@ public class FlattrClickWorker extends AsyncTask<Void, Integer, FlattrClickWorke super.onPostExecute(exitCode); switch (exitCode) { case EXIT_NORMAL: - if (countFailed > 0) { + if (countFailed.get() > 0) { postFlattrFailedNotification(); } break; @@ -190,7 +191,8 @@ public class FlattrClickWorker extends AsyncTask<Void, Integer, FlattrClickWorke } private void postFlattrFailedNotification() { - if (countFailed == 0) { + int failed = countFailed.get(); + if (failed == 0) { return; } @@ -198,15 +200,15 @@ public class FlattrClickWorker extends AsyncTask<Void, Integer, FlattrClickWorke String title; String subtext; - if (countFailed == 1) { + if (failed == 1) { title = context.getString(R.string.flattrd_failed_label); String exceptionMsg = (exception.getMessage() != null) ? exception.getMessage() : ""; subtext = context.getString(R.string.flattr_click_failure, extraFlattrThing.getTitle()) + "\n" + exceptionMsg; } else { title = context.getString(R.string.flattrd_label); - subtext = context.getString(R.string.flattr_click_success_count, countSuccess) + "\n" - + context.getString(R.string.flattr_click_failure_count, countFailed); + subtext = context.getString(R.string.flattr_click_success_count, countSuccess.get()) + "\n" + + context.getString(R.string.flattr_click_failure_count, failed); } Notification notification = new NotificationCompat.Builder(context) diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequest.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequest.java index 7f40ea6e2..de91916a9 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequest.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequest.java @@ -128,7 +128,8 @@ public class DownloadRequest implements Parcelable { DownloadRequest that = (DownloadRequest) o; - if (lastModified != that.lastModified) return false; + if (lastModified != null ? !lastModified.equals(that.lastModified) : that.lastModified != null) + return false; if (deleteOnFailure != that.deleteOnFailure) return false; if (feedfileId != that.feedfileId) return false; if (feedfileType != that.feedfileType) return false; diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java index 68187306d..4f2400e1d 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java @@ -4,6 +4,7 @@ import android.database.Cursor; import android.support.v4.util.ArrayMap; import android.util.Log; +import java.util.Arrays; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -676,7 +677,7 @@ public final class DBReader { * as well as chapter marks of the FeedItems will also be loaded from the database. */ public static List<FeedItem> getFeedItems(final long... itemIds) { - Log.d(TAG, "getFeedItems() called with: " + "itemIds = [" + itemIds + "]"); + Log.d(TAG, "getFeedItems() called with: " + "itemIds = [" + Arrays.toString(itemIds) + "]"); PodDBAdapter adapter = PodDBAdapter.getInstance(); adapter.open(); List<FeedItem> items = getFeedItems(adapter, itemIds); diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/IntList.java b/core/src/main/java/de/danoeh/antennapod/core/util/IntList.java index 673c81235..1cbe7fade 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/IntList.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/IntList.java @@ -35,7 +35,7 @@ public final class IntList { int hashCode = 1; for (int i = 0; i < size; i++) { int value = values[i]; - hashCode = 31 * hashCode + (int)(value ^ (value >>> 32)); + hashCode = 31 * hashCode + value; } return hashCode; } |