#2966 RxJava2 null - explicit mark underlying Rx sources as NonNull
to be on the safe side, for cases that the consuming observers checks null unnecessarily. Rx observer : underlying sources marked as NonNull OnlineFeedViewActivity.startFeedDownload : Downloader.getResult AllEpisodesFragment.loadItems : AllEpisodesFragment.loadData PlaybackHistoryFragment.loadItems : DBReader.getPlaybackHistory QueueFragment.loadItems : DBReader.getQueue SearchFragment.search : .performSearch
This commit is contained in:
parent
670fc124eb
commit
0472bb9237
@ -5,6 +5,7 @@ import android.content.Context;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.UiThread;
|
import android.support.annotation.UiThread;
|
||||||
import android.support.v4.app.NavUtils;
|
import android.support.v4.app.NavUtils;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
@ -27,7 +28,6 @@ import android.widget.Spinner;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
|
|
||||||
import com.bumptech.glide.request.RequestOptions;
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@ -288,12 +288,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
|||||||
error -> Log.e(TAG, Log.getStackTraceString(error)));
|
error -> Log.e(TAG, Log.getStackTraceString(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkDownloadResult(DownloadStatus status) {
|
private void checkDownloadResult(@NonNull DownloadStatus status) {
|
||||||
if (status == null) {
|
|
||||||
Log.wtf(TAG, "DownloadStatus returned by Downloader was null");
|
|
||||||
finish();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (status.isCancelled()) {
|
if (status.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import android.content.DialogInterface;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.view.MenuItemCompat;
|
import android.support.v4.view.MenuItemCompat;
|
||||||
@ -498,16 +499,15 @@ public class AllEpisodesFragment extends Fragment {
|
|||||||
.subscribe(data -> {
|
.subscribe(data -> {
|
||||||
recyclerView.setVisibility(View.VISIBLE);
|
recyclerView.setVisibility(View.VISIBLE);
|
||||||
progLoading.setVisibility(View.GONE);
|
progLoading.setVisibility(View.GONE);
|
||||||
if (data != null) {
|
episodes = data;
|
||||||
episodes = data;
|
itemsLoaded = true;
|
||||||
itemsLoaded = true;
|
if (viewsCreated) {
|
||||||
if (viewsCreated) {
|
onFragmentLoaded();
|
||||||
onFragmentLoaded();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, error -> Log.e(TAG, Log.getStackTraceString(error)));
|
}, error -> Log.e(TAG, Log.getStackTraceString(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
List<FeedItem> loadData() {
|
List<FeedItem> loadData() {
|
||||||
return DBReader.getRecentlyPublishedEpisodes(RECENT_EPISODES_LIMIT);
|
return DBReader.getRecentlyPublishedEpisodes(RECENT_EPISODES_LIMIT);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package de.danoeh.antennapod.fragment;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.app.ListFragment;
|
import android.support.v4.app.ListFragment;
|
||||||
import android.support.v4.view.MenuItemCompat;
|
import android.support.v4.view.MenuItemCompat;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -293,6 +294,7 @@ public class PlaybackHistoryFragment extends ListFragment {
|
|||||||
}, error -> Log.e(TAG, Log.getStackTraceString(error)));
|
}, error -> Log.e(TAG, Log.getStackTraceString(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
private List<FeedItem> loadData() {
|
private List<FeedItem> loadData() {
|
||||||
List<FeedItem> history = DBReader.getPlaybackHistory();
|
List<FeedItem> history = DBReader.getPlaybackHistory();
|
||||||
DBReader.loadAdditionalFeedItemListData(history);
|
DBReader.loadAdditionalFeedItemListData(history);
|
||||||
|
@ -639,13 +639,11 @@ public class QueueFragment extends Fragment {
|
|||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(items -> {
|
.subscribe(items -> {
|
||||||
if(items != null) {
|
progLoading.setVisibility(View.GONE);
|
||||||
progLoading.setVisibility(View.GONE);
|
queue = items;
|
||||||
queue = items;
|
onFragmentLoaded(restoreScrollPosition);
|
||||||
onFragmentLoaded(restoreScrollPosition);
|
if(recyclerAdapter != null) {
|
||||||
if(recyclerAdapter != null) {
|
recyclerAdapter.notifyDataSetChanged();
|
||||||
recyclerAdapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, error -> Log.e(TAG, Log.getStackTraceString(error)));
|
}, error -> Log.e(TAG, Log.getStackTraceString(error)));
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package de.danoeh.antennapod.fragment;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.app.ListFragment;
|
import android.support.v4.app.ListFragment;
|
||||||
import android.support.v4.view.MenuItemCompat;
|
import android.support.v4.view.MenuItemCompat;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
@ -215,16 +216,15 @@ public class SearchFragment extends ListFragment {
|
|||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(result -> {
|
.subscribe(result -> {
|
||||||
if (result != null) {
|
itemsLoaded = true;
|
||||||
itemsLoaded = true;
|
searchResults = result;
|
||||||
searchResults = result;
|
if (viewCreated) {
|
||||||
if (viewCreated) {
|
onFragmentLoaded();
|
||||||
onFragmentLoaded();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, error -> Log.e(TAG, Log.getStackTraceString(error)));
|
}, error -> Log.e(TAG, Log.getStackTraceString(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
private List<SearchResult> performSearch() {
|
private List<SearchResult> performSearch() {
|
||||||
Bundle args = getArguments();
|
Bundle args = getArguments();
|
||||||
String query = args.getString(ARG_QUERY);
|
String query = args.getString(ARG_QUERY);
|
||||||
|
@ -2,6 +2,7 @@ package de.danoeh.antennapod.core.service.download;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
@ -18,10 +19,12 @@ public abstract class Downloader implements Callable<Downloader> {
|
|||||||
|
|
||||||
volatile boolean cancelled;
|
volatile boolean cancelled;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
final DownloadRequest request;
|
final DownloadRequest request;
|
||||||
|
@NonNull
|
||||||
final DownloadStatus result;
|
final DownloadStatus result;
|
||||||
|
|
||||||
Downloader(DownloadRequest request) {
|
Downloader(@NonNull DownloadRequest request) {
|
||||||
super();
|
super();
|
||||||
this.request = request;
|
this.request = request;
|
||||||
this.request.setStatusMsg(R.string.download_pending);
|
this.request.setStatusMsg(R.string.download_pending);
|
||||||
@ -54,10 +57,12 @@ public abstract class Downloader implements Callable<Downloader> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public DownloadRequest getDownloadRequest() {
|
public DownloadRequest getDownloadRequest() {
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public DownloadStatus getResult() {
|
public DownloadStatus getResult() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package de.danoeh.antennapod.core.service.download;
|
package de.danoeh.antennapod.core.service.download;
|
||||||
|
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ public class HttpDownloader extends Downloader {
|
|||||||
|
|
||||||
private static final int BUFFER_SIZE = 8 * 1024;
|
private static final int BUFFER_SIZE = 8 * 1024;
|
||||||
|
|
||||||
public HttpDownloader(DownloadRequest request) {
|
public HttpDownloader(@NonNull DownloadRequest request) {
|
||||||
super(request);
|
super(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,6 +202,7 @@ public final class DBReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
private static List<FeedItem> extractItemlistFromCursor(PodDBAdapter adapter, Cursor cursor) {
|
private static List<FeedItem> extractItemlistFromCursor(PodDBAdapter adapter, Cursor cursor) {
|
||||||
List<FeedItem> result = new ArrayList<>(cursor.getCount());
|
List<FeedItem> result = new ArrayList<>(cursor.getCount());
|
||||||
|
|
||||||
@ -254,6 +255,7 @@ public final class DBReader {
|
|||||||
return feed;
|
return feed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
static List<FeedItem> getQueue(PodDBAdapter adapter) {
|
static List<FeedItem> getQueue(PodDBAdapter adapter) {
|
||||||
Log.d(TAG, "getQueue()");
|
Log.d(TAG, "getQueue()");
|
||||||
Cursor cursor = null;
|
Cursor cursor = null;
|
||||||
@ -310,6 +312,7 @@ public final class DBReader {
|
|||||||
* @return A list of FeedItems sorted by the same order as the queue. The caller can wrap the returned
|
* @return A list of FeedItems sorted by the same order as the queue. The caller can wrap the returned
|
||||||
* list in a {@link de.danoeh.antennapod.core.util.QueueAccess} object for easier access to the queue's properties.
|
* list in a {@link de.danoeh.antennapod.core.util.QueueAccess} object for easier access to the queue's properties.
|
||||||
*/
|
*/
|
||||||
|
@NonNull
|
||||||
public static List<FeedItem> getQueue() {
|
public static List<FeedItem> getQueue() {
|
||||||
Log.d(TAG, "getQueue() called");
|
Log.d(TAG, "getQueue() called");
|
||||||
|
|
||||||
@ -418,6 +421,7 @@ public final class DBReader {
|
|||||||
*
|
*
|
||||||
* @param limit The maximum number of episodes that should be loaded.
|
* @param limit The maximum number of episodes that should be loaded.
|
||||||
*/
|
*/
|
||||||
|
@NonNull
|
||||||
public static List<FeedItem> getRecentlyPublishedEpisodes(int limit) {
|
public static List<FeedItem> getRecentlyPublishedEpisodes(int limit) {
|
||||||
Log.d(TAG, "getRecentlyPublishedEpisodes() called with: " + "limit = [" + limit + "]");
|
Log.d(TAG, "getRecentlyPublishedEpisodes() called with: " + "limit = [" + limit + "]");
|
||||||
|
|
||||||
@ -444,6 +448,7 @@ public final class DBReader {
|
|||||||
* @return The playback history. The FeedItems are sorted by their media's playbackCompletionDate in descending order.
|
* @return The playback history. The FeedItems are sorted by their media's playbackCompletionDate in descending order.
|
||||||
* The size of the returned list is limited by {@link #PLAYBACK_HISTORY_SIZE}.
|
* The size of the returned list is limited by {@link #PLAYBACK_HISTORY_SIZE}.
|
||||||
*/
|
*/
|
||||||
|
@NonNull
|
||||||
public static List<FeedItem> getPlaybackHistory() {
|
public static List<FeedItem> getPlaybackHistory() {
|
||||||
Log.d(TAG, "getPlaybackHistory() called");
|
Log.d(TAG, "getPlaybackHistory() called");
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package de.danoeh.antennapod.core.storage;
|
package de.danoeh.antennapod.core.storage;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -35,6 +36,7 @@ public class FeedSearcher {
|
|||||||
* @param selectedFeed feed to search, 0 to search through all feeds
|
* @param selectedFeed feed to search, 0 to search through all feeds
|
||||||
* @return list of episodes containing the query
|
* @return list of episodes containing the query
|
||||||
*/
|
*/
|
||||||
|
@NonNull
|
||||||
public static List<SearchResult> performSearch(final Context context,
|
public static List<SearchResult> performSearch(final Context context,
|
||||||
final String query, final long selectedFeed) {
|
final String query, final long selectedFeed) {
|
||||||
final int values[] = {2, 1, 0, 0, 0, 0};
|
final int values[] = {2, 1, 0, 0, 0, 0};
|
||||||
@ -45,7 +47,7 @@ public class FeedSearcher {
|
|||||||
context.getString(R.string.found_in_authors_label),
|
context.getString(R.string.found_in_authors_label),
|
||||||
context.getString(R.string.found_in_feeds_label)};
|
context.getString(R.string.found_in_feeds_label)};
|
||||||
|
|
||||||
List<SearchResult> result = new ArrayList<>();
|
final List<SearchResult> result = new ArrayList<>();
|
||||||
|
|
||||||
List<FutureTask<List<FeedItem>>> tasks = new ArrayList<>();
|
List<FutureTask<List<FeedItem>>> tasks = new ArrayList<>();
|
||||||
tasks.add(DBTasks.searchFeedItemTitle(context, selectedFeed, query));
|
tasks.add(DBTasks.searchFeedItemTitle(context, selectedFeed, query));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user