#2966 RxJava2 null - explicit mark underlying Rx sources as NonNull

to be on the safe side, for cases that the consuming observers
already assumes the result is not null.

Rx observer : underlying sources marked as NonNull
OnlineFeedViewActivity.listener member : DBReader.getFeedList
StatisticsActivity.loadStatistics : DBReader.getStatistics
CustomMRControllerDialog.updateViews : CustomMRControllerDialog.fetchArt
CompletedDownloadsFragment.loadItems : DBReader.getDownloadedItems
DownloadLogFragment.loadItems : DBReader.getDownloadedItems
ItemDescriptionFragment.onViewCreated : .loadData, Timeline.processShownotes
SubscriptionFragment.loadSubscriptions : DBReader.getNavDrawerData
SubscriptionFragment.onContextItemSelected (x2) : DBWriter.markFeedSeen, DBWriter.markFeedRead
PreferenceController.export : ExportWorker.output member
This commit is contained in:
orionlee 2019-01-09 14:27:59 -08:00
parent 5f86af88b1
commit 670fc124eb
6 changed files with 19 additions and 6 deletions

View File

@ -23,15 +23,15 @@ public class ExportWorker {
private static final String TAG = "ExportWorker";
private static final String DEFAULT_OUTPUT_NAME = "antennapod-feeds";
private final ExportWriter exportWriter;
private final File output;
private final @NonNull ExportWriter exportWriter;
private final @NonNull File output;
public ExportWorker(ExportWriter exportWriter) {
public ExportWorker(@NonNull ExportWriter exportWriter) {
this(exportWriter, new File(UserPreferences.getDataFolder(EXPORT_DIR),
DEFAULT_OUTPUT_NAME + "." + exportWriter.fileExtension()));
}
private ExportWorker(ExportWriter exportWriter, @NonNull File output) {
private ExportWorker(@NonNull ExportWriter exportWriter, @NonNull File output) {
this.exportWriter = exportWriter;
this.output = output;
}

View File

@ -11,6 +11,7 @@ import android.content.res.TypedArray;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.ContextMenu;
@ -313,6 +314,7 @@ public class ItemDescriptionFragment extends Fragment implements MediaplayerInfo
}, error -> Log.e(TAG, Log.getStackTraceString(error)));
}
@NonNull
private String loadData() {
Timeline timeline = new Timeline(getActivity(), shownotesProvider);
return timeline.processShownotes(highlightTimecodes);

View File

@ -455,6 +455,7 @@ public class CustomMRControllerDialog extends MediaRouteControllerDialog {
return context.getTheme().resolveAttribute(attr, value, true) ? value.resourceId : 0;
}
@NonNull
private Pair<Bitmap, Integer> fetchArt(@NonNull MediaDescriptionCompat description) {
Bitmap iconBitmap = description.getIconBitmap();
Uri iconUri = description.getIconUri();

View File

@ -1,6 +1,7 @@
package de.danoeh.antennapod.core.storage;
import android.database.Cursor;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.util.ArrayMap;
import android.text.TextUtils;
@ -58,6 +59,7 @@ public final class DBReader {
* of the returned list does NOT have its list of FeedItems yet. The FeedItem-list
* can be loaded separately with {@link #getFeedItemList(Feed)}.
*/
@NonNull
public static List<Feed> getFeedList() {
Log.d(TAG, "Extracting Feedlist");
@ -70,6 +72,7 @@ public final class DBReader {
}
}
@NonNull
private static List<Feed> getFeedList(PodDBAdapter adapter) {
Cursor cursor = null;
try {
@ -324,6 +327,7 @@ public final class DBReader {
*
* @return A list of FeedItems whose episdoe has been downloaded.
*/
@NonNull
public static List<FeedItem> getDownloadedItems() {
Log.d(TAG, "getDownloadedItems() called");
@ -859,6 +863,7 @@ public final class DBReader {
* countAll calculation time
* @return The StatisticsInfo object
*/
@NonNull
public static StatisticsData getStatistics(boolean sortByCountAll) {
PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open();
@ -1025,6 +1030,7 @@ public final class DBReader {
* the list of subscriptions, the number of items in the queue and the number of unread
* items.
*/
@NonNull
public static NavDrawerData getNavDrawerData() {
Log.d(TAG, "getNavDrawerData() called with: " + "");
PodDBAdapter adapter = PodDBAdapter.getInstance();

View File

@ -5,6 +5,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.util.Log;
import org.shredzone.flattr4j.model.Flattr;
@ -633,11 +634,13 @@ public class DBWriter {
* FeedItem.NEW, FeedItem.UNPLAYED
* @param resetMediaPosition true if this method should also reset the position of the FeedItem's FeedMedia object.
*/
@NonNull
public static Future<?> markItemPlayed(FeedItem item, int played, boolean resetMediaPosition) {
long mediaId = (item.hasMedia()) ? item.getMedia().getId() : 0;
return markItemPlayed(item.getId(), played, mediaId, resetMediaPosition);
}
@NonNull
private static Future<?> markItemPlayed(final long itemId,
final int played,
final long mediaId,

View File

@ -83,6 +83,7 @@ public class Timeline {
* @param addTimecodes True if this method should add timecode links
* @return The processed HTML string.
*/
@NonNull
public String processShownotes(final boolean addTimecodes) {
final Playable playable = (shownotesProvider instanceof Playable) ? (Playable) shownotesProvider : null;
@ -92,8 +93,8 @@ public class Timeline {
try {
shownotes = shownotesProvider.loadShownotes().call();
} catch (Exception e) {
e.printStackTrace();
return null;
Log.e(TAG, "processShownotes() - encounters exceptions unexpectedly in load, treat as if no shownotes.", e);
shownotes = "";
}
if (TextUtils.isEmpty(shownotes)) {