Merge branch 'develop' into exoplayer-main-thread

This commit is contained in:
ByteHamster 2019-04-07 11:52:24 +02:00
commit 2c9cb25eda
16 changed files with 94 additions and 65 deletions

View File

@ -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;
@ -58,9 +58,11 @@ import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DownloadRequestException; import de.danoeh.antennapod.core.storage.DownloadRequestException;
import de.danoeh.antennapod.core.storage.DownloadRequester; import de.danoeh.antennapod.core.storage.DownloadRequester;
import de.danoeh.antennapod.core.syndication.handler.FeedHandler; import de.danoeh.antennapod.core.syndication.handler.FeedHandler;
import de.danoeh.antennapod.core.syndication.handler.FeedHandlerResult;
import de.danoeh.antennapod.core.syndication.handler.UnsupportedFeedtypeException; import de.danoeh.antennapod.core.syndication.handler.UnsupportedFeedtypeException;
import de.danoeh.antennapod.core.util.DownloadError; import de.danoeh.antennapod.core.util.DownloadError;
import de.danoeh.antennapod.core.util.FileNameGenerator; import de.danoeh.antennapod.core.util.FileNameGenerator;
import de.danoeh.antennapod.core.util.Optional;
import de.danoeh.antennapod.core.util.StorageUtils; import de.danoeh.antennapod.core.util.StorageUtils;
import de.danoeh.antennapod.core.util.URLChecker; import de.danoeh.antennapod.core.util.URLChecker;
import de.danoeh.antennapod.core.util.syndication.FeedDiscoverer; import de.danoeh.antennapod.core.util.syndication.FeedDiscoverer;
@ -288,12 +290,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;
} }
@ -320,15 +317,33 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
} }
Log.d(TAG, "Parsing feed"); Log.d(TAG, "Parsing feed");
parser = Observable.fromCallable(() -> { parser = Observable.fromCallable(this::doParseFeed)
.subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(optionalResult -> {
if(optionalResult.isPresent()) {
FeedHandlerResult result = optionalResult.get();
beforeShowFeedInformation(result.feed);
showFeedInformation(result.feed, result.alternateFeedUrls);
}
}, error -> {
String errorMsg = DownloadError.ERROR_PARSER_EXCEPTION.getErrorString(
OnlineFeedViewActivity.this) + " (" + error.getMessage() + ")";
showErrorDialog(errorMsg);
Log.d(TAG, "Feed parser exception: " + Log.getStackTraceString(error));
});
}
@NonNull
private Optional<FeedHandlerResult> doParseFeed() throws Exception {
FeedHandler handler = new FeedHandler(); FeedHandler handler = new FeedHandler();
try { try {
return handler.parseFeed(feed); return Optional.of(handler.parseFeed(feed));
} catch (UnsupportedFeedtypeException e) { } catch (UnsupportedFeedtypeException e) {
Log.d(TAG, "Unsupported feed type detected"); Log.d(TAG, "Unsupported feed type detected");
if ("html".equalsIgnoreCase(e.getRootElement())) { if ("html".equalsIgnoreCase(e.getRootElement())) {
showFeedDiscoveryDialog(new File(feed.getFile_url()), feed.getDownload_url()); showFeedDiscoveryDialog(new File(feed.getFile_url()), feed.getDownload_url());
return null; return Optional.empty();
} else { } else {
throw e; throw e;
} }
@ -339,20 +354,6 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
boolean rc = new File(feed.getFile_url()).delete(); boolean rc = new File(feed.getFile_url()).delete();
Log.d(TAG, "Deleted feed source file. Result: " + rc); Log.d(TAG, "Deleted feed source file. Result: " + rc);
} }
})
.subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(result -> {
if(result != null) {
beforeShowFeedInformation(result.feed);
showFeedInformation(result.feed, result.alternateFeedUrls);
}
}, error -> {
String errorMsg = DownloadError.ERROR_PARSER_EXCEPTION.getErrorString(
OnlineFeedViewActivity.this) + " (" + error.getMessage() + ")";
showErrorDialog(errorMsg);
Log.d(TAG, "Feed parser exception: " + Log.getStackTraceString(error));
});
} }
/** /**

View File

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

View File

@ -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);
} }

View File

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

View File

@ -588,6 +588,7 @@ public class ItemFragment extends Fragment implements OnSwipeGesture {
}, error -> Log.e(TAG, Log.getStackTraceString(error))); }, error -> Log.e(TAG, Log.getStackTraceString(error)));
} }
@Nullable
private FeedItem loadInBackground() { private FeedItem loadInBackground() {
FeedItem feedItem = DBReader.getFeedItem(feedItems[feedItemPos]); FeedItem feedItem = DBReader.getFeedItem(feedItems[feedItemPos]);
if (feedItem != null) { if (feedItem != null) {

View File

@ -6,6 +6,7 @@ import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.graphics.LightingColorFilter; import android.graphics.LightingColorFilter;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable;
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.widget.SearchView; import android.support.v7.widget.SearchView;
@ -25,7 +26,6 @@ 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 com.joanzapata.iconify.IconDrawable;
import com.joanzapata.iconify.Iconify; import com.joanzapata.iconify.Iconify;
import com.joanzapata.iconify.widget.IconTextView; import com.joanzapata.iconify.widget.IconTextView;
@ -618,16 +618,15 @@ public class ItemlistFragment extends ListFragment {
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(result -> { .subscribe(result -> {
if (result != null) {
feed = result; feed = result;
itemsLoaded = true; itemsLoaded = true;
if (viewsCreated) { if (viewsCreated) {
onFragmentLoaded(); onFragmentLoaded();
} }
}
}, error -> Log.e(TAG, Log.getStackTraceString(error))); }, error -> Log.e(TAG, Log.getStackTraceString(error)));
} }
@Nullable
private Feed loadData() { private Feed loadData() {
Feed feed = DBReader.getFeed(feedID); Feed feed = DBReader.getFeed(feedID);
DBReader.loadAdditionalFeedItemListData(feed.getItems()); DBReader.loadAdditionalFeedItemListData(feed.getItems());

View File

@ -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);

View File

@ -639,14 +639,12 @@ 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)));
} }

View File

@ -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);

View File

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

View File

@ -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;
} }

View File

@ -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);
} }

View File

@ -1,6 +1,7 @@
package de.danoeh.antennapod.core.storage; package de.danoeh.antennapod.core.storage;
import android.database.Cursor; import android.database.Cursor;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.util.ArrayMap; import android.support.v4.util.ArrayMap;
import android.text.TextUtils; 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 * of the returned list does NOT have its list of FeedItems yet. The FeedItem-list
* can be loaded separately with {@link #getFeedItemList(Feed)}. * can be loaded separately with {@link #getFeedItemList(Feed)}.
*/ */
@NonNull
public static List<Feed> getFeedList() { public static List<Feed> getFeedList() {
Log.d(TAG, "Extracting Feedlist"); Log.d(TAG, "Extracting Feedlist");
@ -70,6 +72,7 @@ public final class DBReader {
} }
} }
@NonNull
private static List<Feed> getFeedList(PodDBAdapter adapter) { private static List<Feed> getFeedList(PodDBAdapter adapter) {
Cursor cursor = null; Cursor cursor = null;
try { try {
@ -199,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());
@ -251,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;
@ -307,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");
@ -324,6 +330,7 @@ public final class DBReader {
* *
* @return A list of FeedItems whose episdoe has been downloaded. * @return A list of FeedItems whose episdoe has been downloaded.
*/ */
@NonNull
public static List<FeedItem> getDownloadedItems() { public static List<FeedItem> getDownloadedItems() {
Log.d(TAG, "getDownloadedItems() called"); Log.d(TAG, "getDownloadedItems() called");
@ -414,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 + "]");
@ -440,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");
@ -595,6 +604,7 @@ public final class DBReader {
} }
} }
@Nullable
private static FeedItem getFeedItem(final long itemId, PodDBAdapter adapter) { private static FeedItem getFeedItem(final long itemId, PodDBAdapter adapter) {
Log.d(TAG, "Loading feeditem with id " + itemId); Log.d(TAG, "Loading feeditem with id " + itemId);
@ -628,6 +638,7 @@ public final class DBReader {
* @return The FeedItem or null if the FeedItem could not be found. All FeedComponent-attributes * @return The FeedItem or null if the FeedItem could not be found. All FeedComponent-attributes
* as well as chapter marks of the FeedItem will also be loaded from the database. * as well as chapter marks of the FeedItem will also be loaded from the database.
*/ */
@Nullable
public static FeedItem getFeedItem(final long itemId) { public static FeedItem getFeedItem(final long itemId) {
Log.d(TAG, "getFeedItem() called with: " + "itemId = [" + itemId + "]"); Log.d(TAG, "getFeedItem() called with: " + "itemId = [" + itemId + "]");
@ -640,6 +651,7 @@ public final class DBReader {
} }
} }
@Nullable
private static FeedItem getFeedItem(final String podcastUrl, final String episodeUrl, PodDBAdapter adapter) { private static FeedItem getFeedItem(final String podcastUrl, final String episodeUrl, PodDBAdapter adapter) {
Log.d(TAG, "Loading feeditem with podcast url " + podcastUrl + " and episode url " + episodeUrl); Log.d(TAG, "Loading feeditem with podcast url " + podcastUrl + " and episode url " + episodeUrl);
Cursor cursor = null; Cursor cursor = null;
@ -859,6 +871,7 @@ public final class DBReader {
* countAll calculation time * countAll calculation time
* @return The StatisticsInfo object * @return The StatisticsInfo object
*/ */
@NonNull
public static StatisticsData getStatistics(boolean sortByCountAll) { public static StatisticsData getStatistics(boolean sortByCountAll) {
PodDBAdapter adapter = PodDBAdapter.getInstance(); PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open(); adapter.open();
@ -1025,6 +1038,7 @@ public final class DBReader {
* the list of subscriptions, the number of items in the queue and the number of unread * the list of subscriptions, the number of items in the queue and the number of unread
* items. * items.
*/ */
@NonNull
public static NavDrawerData getNavDrawerData() { public static NavDrawerData getNavDrawerData() {
Log.d(TAG, "getNavDrawerData() called with: " + ""); Log.d(TAG, "getNavDrawerData() called with: " + "");
PodDBAdapter adapter = PodDBAdapter.getInstance(); PodDBAdapter adapter = PodDBAdapter.getInstance();

View File

@ -5,6 +5,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.util.Log; import android.util.Log;
import org.shredzone.flattr4j.model.Flattr; import org.shredzone.flattr4j.model.Flattr;
@ -48,7 +49,6 @@ import de.danoeh.antennapod.core.util.flattr.FlattrStatus;
import de.danoeh.antennapod.core.util.flattr.FlattrThing; import de.danoeh.antennapod.core.util.flattr.FlattrThing;
import de.danoeh.antennapod.core.util.flattr.SimpleFlattrThing; import de.danoeh.antennapod.core.util.flattr.SimpleFlattrThing;
import de.greenrobot.event.EventBus; import de.greenrobot.event.EventBus;
import io.reactivex.annotations.NonNull;
/** /**
* Provides methods for writing data to AntennaPod's database. * Provides methods for writing data to AntennaPod's database.
@ -633,11 +633,13 @@ public class DBWriter {
* FeedItem.NEW, FeedItem.UNPLAYED * FeedItem.NEW, FeedItem.UNPLAYED
* @param resetMediaPosition true if this method should also reset the position of the FeedItem's FeedMedia object. * @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) { public static Future<?> markItemPlayed(FeedItem item, int played, boolean resetMediaPosition) {
long mediaId = (item.hasMedia()) ? item.getMedia().getId() : 0; long mediaId = (item.hasMedia()) ? item.getMedia().getId() : 0;
return markItemPlayed(item.getId(), played, mediaId, resetMediaPosition); return markItemPlayed(item.getId(), played, mediaId, resetMediaPosition);
} }
@NonNull
private static Future<?> markItemPlayed(final long itemId, private static Future<?> markItemPlayed(final long itemId,
final int played, final int played,
final long mediaId, final long mediaId,

View File

@ -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));

View File

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