Merge pull request #2842 from AntennaPod/rxjava2
Migrate rxjava to version 2
This commit is contained in:
commit
7a92f8a2ba
|
@ -166,10 +166,9 @@ dependencies {
|
|||
implementation "com.squareup.okhttp3:okhttp-urlconnection:$okhttpVersion"
|
||||
implementation "com.squareup.okio:okio:$okioVersion"
|
||||
implementation "de.greenrobot:eventbus:$eventbusVersion"
|
||||
implementation "io.reactivex:rxandroid:$rxAndroidVersion"
|
||||
implementation "io.reactivex:rxjava:$rxJavaVersion"
|
||||
// And ProGuard rules for RxJava!
|
||||
implementation "com.artemzin.rxjava:proguard-rules:$rxJavaRulesVersion"
|
||||
implementation "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion"
|
||||
implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
|
||||
|
||||
implementation "com.joanzapata.iconify:android-iconify-fontawesome:$iconifyVersion"
|
||||
implementation "com.joanzapata.iconify:android-iconify-material:$iconifyVersion"
|
||||
implementation("com.afollestad.material-dialogs:commons:$materialDialogsVersion") {
|
||||
|
@ -184,7 +183,7 @@ dependencies {
|
|||
|
||||
implementation "com.github.AntennaPod:AntennaPod-AudioPlayer:$audioPlayerVersion"
|
||||
|
||||
implementation 'com.github.mfietz:fyydlin:v0.3'
|
||||
implementation 'com.github.mfietz:fyydlin:v0.4.1'
|
||||
implementation 'com.github.ByteHamster:SearchPreference:v1.0.8'
|
||||
|
||||
androidTestImplementation "com.jayway.android.robotium:robotium-solo:$robotiumSoloVersion"
|
||||
|
|
|
@ -21,10 +21,10 @@ import java.nio.charset.Charset;
|
|||
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import rx.Single;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Displays the 'about' screen
|
||||
|
@ -35,7 +35,7 @@ public class AboutActivity extends AppCompatActivity {
|
|||
|
||||
private WebView webView;
|
||||
private LinearLayout webViewContainer;
|
||||
private Subscription subscription;
|
||||
private Disposable disposable;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -69,7 +69,7 @@ public class AboutActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
private void loadAsset(String filename) {
|
||||
subscription = Single.create(subscriber -> {
|
||||
disposable = Single.create(subscriber -> {
|
||||
InputStream input = null;
|
||||
try {
|
||||
TypedArray res = AboutActivity.this.getTheme().obtainStyledAttributes(
|
||||
|
@ -115,7 +115,7 @@ public class AboutActivity extends AppCompatActivity {
|
|||
IOUtils.closeQuietly(input);
|
||||
}
|
||||
})
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
webViewData ->
|
||||
|
@ -146,8 +146,8 @@ public class AboutActivity extends AppCompatActivity {
|
|||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
if (webViewContainer != null && webView != null) {
|
||||
webViewContainer.removeAllViews();
|
||||
|
|
|
@ -36,10 +36,11 @@ import de.danoeh.antennapod.core.util.IntentUtils;
|
|||
import de.danoeh.antennapod.core.util.LangUtils;
|
||||
import de.danoeh.antennapod.core.util.syndication.HtmlToPlainText;
|
||||
import de.danoeh.antennapod.menuhandler.FeedMenuHandler;
|
||||
import rx.Observable;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import io.reactivex.Maybe;
|
||||
import io.reactivex.MaybeOnSubscribe;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Displays information about a feed.
|
||||
|
@ -59,7 +60,7 @@ public class FeedInfoActivity extends AppCompatActivity {
|
|||
private TextView txtvAuthor;
|
||||
private TextView txtvUrl;
|
||||
|
||||
private Subscription subscription;
|
||||
private Disposable disposable;
|
||||
|
||||
|
||||
private final View.OnClickListener copyUrlToClipboard = new View.OnClickListener() {
|
||||
|
@ -104,14 +105,17 @@ public class FeedInfoActivity extends AppCompatActivity {
|
|||
|
||||
txtvUrl.setOnClickListener(copyUrlToClipboard);
|
||||
|
||||
subscription = Observable.fromCallable(()-> DBReader.getFeed(feedId))
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
disposable = Maybe.create((MaybeOnSubscribe<Feed>) emitter -> {
|
||||
Feed feed = DBReader.getFeed(feedId);
|
||||
if (feed != null) {
|
||||
emitter.onSuccess(feed);
|
||||
} else {
|
||||
emitter.onComplete();
|
||||
}
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(result -> {
|
||||
if (result == null) {
|
||||
Log.e(TAG, "Activity was started with invalid arguments");
|
||||
finish();
|
||||
}
|
||||
feed = result;
|
||||
Log.d(TAG, "Language is " + feed.getLanguage());
|
||||
Log.d(TAG, "Author is " + feed.getAuthor());
|
||||
|
@ -167,14 +171,17 @@ public class FeedInfoActivity extends AppCompatActivity {
|
|||
}, error -> {
|
||||
Log.d(TAG, Log.getStackTraceString(error));
|
||||
finish();
|
||||
}, () -> {
|
||||
Log.e(TAG, "Activity was started with invalid arguments");
|
||||
finish();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package de.danoeh.antennapod.activity;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
|
@ -24,7 +23,6 @@ import android.widget.ImageView;
|
|||
import android.widget.RadioButton;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
|
||||
|
@ -42,10 +40,11 @@ import de.danoeh.antennapod.core.storage.DBWriter;
|
|||
import de.danoeh.antennapod.core.storage.DownloadRequestException;
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
import de.danoeh.antennapod.menuhandler.FeedMenuHandler;
|
||||
import rx.Observable;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import io.reactivex.Maybe;
|
||||
import io.reactivex.MaybeOnSubscribe;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Displays information about a feed.
|
||||
|
@ -69,7 +68,7 @@ public class FeedSettingsActivity extends AppCompatActivity {
|
|||
private Spinner spnAutoDelete;
|
||||
private boolean filterInclude = true;
|
||||
|
||||
private Subscription subscription;
|
||||
private Disposable disposable;
|
||||
|
||||
private boolean authInfoChanged = false;
|
||||
|
||||
|
@ -139,14 +138,17 @@ public class FeedSettingsActivity extends AppCompatActivity {
|
|||
filterTextChanged = true;
|
||||
});
|
||||
|
||||
subscription = Observable.fromCallable(()-> DBReader.getFeed(feedId))
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
disposable = Maybe.create((MaybeOnSubscribe<Feed>) emitter -> {
|
||||
Feed feed = DBReader.getFeed(feedId);
|
||||
if (feed != null) {
|
||||
emitter.onSuccess(feed);
|
||||
} else {
|
||||
emitter.onComplete();
|
||||
}
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(result -> {
|
||||
if (result == null) {
|
||||
Log.e(TAG, "Activity was started with invalid arguments");
|
||||
finish();
|
||||
}
|
||||
feed = result;
|
||||
FeedPreferences prefs = feed.getPreferences();
|
||||
Glide.with(FeedSettingsActivity.this)
|
||||
|
@ -245,6 +247,9 @@ public class FeedSettingsActivity extends AppCompatActivity {
|
|||
}, error -> {
|
||||
Log.d(TAG, Log.getStackTraceString(error));
|
||||
finish();
|
||||
}, () -> {
|
||||
Log.e(TAG, "Activity was started with invalid arguments");
|
||||
finish();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -282,8 +287,8 @@ public class FeedSettingsActivity extends AppCompatActivity {
|
|||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,10 +69,10 @@ import de.danoeh.antennapod.fragment.QueueFragment;
|
|||
import de.danoeh.antennapod.fragment.SubscriptionFragment;
|
||||
import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
|
||||
import de.greenrobot.event.EventBus;
|
||||
import rx.Observable;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* The activity that is shown when the user launches the app.
|
||||
|
@ -122,7 +122,7 @@ public class MainActivity extends CastEnabledActivity implements NavDrawerActivi
|
|||
|
||||
private ProgressDialog pd;
|
||||
|
||||
private Subscription subscription;
|
||||
private Disposable disposable;
|
||||
|
||||
private long lastBackButtonPressTime = 0;
|
||||
|
||||
|
@ -491,8 +491,8 @@ public class MainActivity extends CastEnabledActivity implements NavDrawerActivi
|
|||
super.onStop();
|
||||
EventDistributor.getInstance().unregister(contentUpdate);
|
||||
EventBus.getDefault().unregister(this);
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
if(pd != null) {
|
||||
pd.dismiss();
|
||||
|
@ -750,8 +750,8 @@ public class MainActivity extends CastEnabledActivity implements NavDrawerActivi
|
|||
};
|
||||
|
||||
private void loadData() {
|
||||
subscription = Observable.fromCallable(DBReader::getNavDrawerData)
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
disposable = Observable.fromCallable(DBReader::getNavDrawerData)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(result -> {
|
||||
boolean handleIntent = (navDrawerData == null);
|
||||
|
|
|
@ -47,9 +47,11 @@ import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
|||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.storage.DBTasks;
|
||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import de.danoeh.antennapod.core.util.Consumer;
|
||||
import de.danoeh.antennapod.core.util.Converter;
|
||||
import de.danoeh.antennapod.core.util.FeedItemUtil;
|
||||
import de.danoeh.antennapod.core.util.Flavors;
|
||||
import de.danoeh.antennapod.core.util.Function;
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
import de.danoeh.antennapod.core.util.ShareUtils;
|
||||
import de.danoeh.antennapod.core.util.StorageUtils;
|
||||
|
@ -62,11 +64,10 @@ import de.danoeh.antennapod.core.util.playback.PlaybackController;
|
|||
import de.danoeh.antennapod.core.util.playback.PlaybackServiceStarter;
|
||||
import de.danoeh.antennapod.dialog.SleepTimerDialog;
|
||||
import de.danoeh.antennapod.dialog.VariableSpeedDialog;
|
||||
import rx.Observable;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.functions.Action1;
|
||||
import rx.functions.Func1;
|
||||
import rx.schedulers.Schedulers;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -95,6 +96,8 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
|
|||
|
||||
private boolean isFavorite = false;
|
||||
|
||||
private Disposable disposable;
|
||||
|
||||
private PlaybackController newPlaybackController() {
|
||||
return new PlaybackController(this, false) {
|
||||
|
||||
|
@ -287,6 +290,9 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
|
|||
controller.release();
|
||||
controller = null; // prevent leak
|
||||
}
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
|
@ -638,7 +644,6 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
|
|||
if (controller != null) {
|
||||
controller.init();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -724,8 +729,8 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
|
|||
R.string.pref_rewind);
|
||||
|
||||
private final Supplier<Integer> getPrefSecsFn;
|
||||
private final Func1<MediaplayerActivity, TextView> getTextViewFn;
|
||||
private final Action1<Integer> setPrefSecsFn;
|
||||
private final Function<MediaplayerActivity, TextView> getTextViewFn;
|
||||
private final Consumer<Integer> setPrefSecsFn;
|
||||
private final int titleResourceID;
|
||||
|
||||
/**
|
||||
|
@ -737,7 +742,7 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
|
|||
* @param setPrefSecsFn Handle to function that sets the preference (setting) for the skip delta value (and optionally updates the button label with the current values)
|
||||
* @param titleResourceID ID of the resource string with the title for a view
|
||||
*/
|
||||
SkipDirection(Supplier<Integer> getPrefSecsFn, Func1<MediaplayerActivity, TextView> getTextViewFn, Action1<Integer> setPrefSecsFn, int titleResourceID) {
|
||||
SkipDirection(Supplier<Integer> getPrefSecsFn, Function<MediaplayerActivity, TextView> getTextViewFn, Consumer<Integer> setPrefSecsFn, int titleResourceID) {
|
||||
this.getPrefSecsFn = getPrefSecsFn;
|
||||
this.getTextViewFn = getTextViewFn;
|
||||
this.setPrefSecsFn = setPrefSecsFn;
|
||||
|
@ -756,10 +761,10 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
|
|||
* @param activity MediaplyerActivity that contains textview to update the display of the skip delta setting (or null if nothing to update)
|
||||
*/
|
||||
public void setPrefSkipSeconds(int seconds, @Nullable Activity activity) {
|
||||
setPrefSecsFn.call(seconds);
|
||||
setPrefSecsFn.accept(seconds);
|
||||
|
||||
if (activity != null && activity instanceof MediaplayerActivity) {
|
||||
TextView tv = getTextViewFn.call((MediaplayerActivity)activity);
|
||||
TextView tv = getTextViewFn.apply((MediaplayerActivity)activity);
|
||||
if (tv != null) tv.setText(String.valueOf(seconds));
|
||||
}
|
||||
}
|
||||
|
@ -940,22 +945,27 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
|
|||
|
||||
private void checkFavorite() {
|
||||
Playable playable = controller.getMedia();
|
||||
if (playable != null && playable instanceof FeedMedia) {
|
||||
FeedItem feedItem = ((FeedMedia) playable).getItem();
|
||||
if (feedItem != null) {
|
||||
Observable.fromCallable(() -> DBReader.getFeedItem(feedItem.getId()))
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
item -> {
|
||||
boolean isFav = item.isTagged(FeedItem.TAG_FAVORITE);
|
||||
if (isFavorite != isFav) {
|
||||
isFavorite = isFav;
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
}, error -> Log.e(TAG, Log.getStackTraceString(error)));
|
||||
}
|
||||
if (!(playable instanceof FeedMedia)) {
|
||||
return;
|
||||
}
|
||||
FeedItem feedItem = ((FeedMedia) playable).getItem();
|
||||
if (feedItem == null) {
|
||||
return;
|
||||
}
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
disposable = Observable.fromCallable(() -> DBReader.getFeedItem(feedItem.getId()))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
item -> {
|
||||
boolean isFav = item.isTagged(FeedItem.TAG_FAVORITE);
|
||||
if (isFavorite != isFav) {
|
||||
isFavorite = isFav;
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
}, error -> Log.e(TAG, Log.getStackTraceString(error)));
|
||||
}
|
||||
|
||||
void playExternalMedia(Intent intent, MediaType type) {
|
||||
|
|
|
@ -63,10 +63,10 @@ import de.danoeh.antennapod.fragment.QueueFragment;
|
|||
import de.danoeh.antennapod.fragment.SubscriptionFragment;
|
||||
import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
|
||||
import de.greenrobot.event.EventBus;
|
||||
import rx.Observable;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Activity for playing files that do not require a video surface.
|
||||
|
@ -106,7 +106,7 @@ public abstract class MediaplayerInfoActivity extends MediaplayerActivity implem
|
|||
private ViewPager pager;
|
||||
private MediaplayerInfoPagerAdapter pagerAdapter;
|
||||
|
||||
private Subscription subscription;
|
||||
private Disposable disposable;
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
|
@ -127,8 +127,8 @@ public abstract class MediaplayerInfoActivity extends MediaplayerActivity implem
|
|||
if(pagerAdapter != null) {
|
||||
pagerAdapter.setController(null);
|
||||
}
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
EventDistributor.getInstance().unregister(contentUpdate);
|
||||
saveCurrentFragment();
|
||||
|
@ -472,8 +472,8 @@ public abstract class MediaplayerInfoActivity extends MediaplayerActivity implem
|
|||
private DBReader.NavDrawerData navDrawerData;
|
||||
|
||||
private void loadData() {
|
||||
subscription = Observable.fromCallable(DBReader::getNavDrawerData)
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
disposable = Observable.fromCallable(DBReader::getNavDrawerData)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(result -> {
|
||||
navDrawerData = result;
|
||||
|
|
|
@ -65,10 +65,10 @@ import de.danoeh.antennapod.core.util.syndication.FeedDiscoverer;
|
|||
import de.danoeh.antennapod.core.util.syndication.HtmlToPlainText;
|
||||
import de.danoeh.antennapod.dialog.AuthenticationDialog;
|
||||
import de.greenrobot.event.EventBus;
|
||||
import rx.Observable;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Downloads a feed from a feed URL and parses it. Subclasses can display the
|
||||
|
@ -97,15 +97,15 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
|||
|
||||
private Button subscribeButton;
|
||||
|
||||
private Subscription download;
|
||||
private Subscription parser;
|
||||
private Subscription updater;
|
||||
private Disposable download;
|
||||
private Disposable parser;
|
||||
private Disposable updater;
|
||||
private final EventDistributor.EventListener listener = new EventDistributor.EventListener() {
|
||||
@Override
|
||||
public void update(EventDistributor eventDistributor, Integer arg) {
|
||||
if ((arg & EventDistributor.FEED_LIST_UPDATE) != 0) {
|
||||
updater = Observable.fromCallable(DBReader::getFeedList)
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
feeds -> {
|
||||
|
@ -212,13 +212,13 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
|||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if(updater != null) {
|
||||
updater.unsubscribe();
|
||||
updater.dispose();
|
||||
}
|
||||
if(download != null) {
|
||||
download.unsubscribe();
|
||||
download.dispose();
|
||||
}
|
||||
if(parser != null) {
|
||||
parser.unsubscribe();
|
||||
parser.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -273,7 +273,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
|||
downloader.call();
|
||||
return downloader.getResult();
|
||||
})
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(this::checkDownloadResult,
|
||||
error -> Log.e(TAG, Log.getStackTraceString(error)));
|
||||
|
@ -331,7 +331,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
|||
Log.d(TAG, "Deleted feed source file. Result: " + rc);
|
||||
}
|
||||
})
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.subscribeOn(Schedulers.computation())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(result -> {
|
||||
if(result != null) {
|
||||
|
|
|
@ -12,9 +12,9 @@ import android.widget.ProgressBar;
|
|||
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import rx.Completable;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import io.reactivex.Completable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Shows the AntennaPod logo while waiting for the main activity to start
|
||||
|
@ -38,9 +38,9 @@ public class SplashActivity extends AppCompatActivity {
|
|||
// Trigger schema updates
|
||||
PodDBAdapter.getInstance().open();
|
||||
PodDBAdapter.getInstance().close();
|
||||
subscriber.onCompleted();
|
||||
subscriber.onComplete();
|
||||
})
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(() -> {
|
||||
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
|
||||
|
|
|
@ -20,10 +20,10 @@ import de.danoeh.antennapod.adapter.StatisticsListAdapter;
|
|||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.util.Converter;
|
||||
import rx.Observable;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Displays the 'statistics' screen
|
||||
|
@ -35,7 +35,7 @@ public class StatisticsActivity extends AppCompatActivity
|
|||
private static final String PREF_NAME = "StatisticsActivityPrefs";
|
||||
private static final String PREF_COUNT_ALL = "countAll";
|
||||
|
||||
private Subscription subscription;
|
||||
private Disposable disposable;
|
||||
private TextView totalTimeTextView;
|
||||
private ListView feedStatisticsList;
|
||||
private ProgressBar progressBar;
|
||||
|
@ -119,21 +119,19 @@ public class StatisticsActivity extends AppCompatActivity
|
|||
}
|
||||
|
||||
private void loadStatistics() {
|
||||
if (subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
subscription = Observable.fromCallable(() -> DBReader.getStatistics(countAll))
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
disposable = Observable.fromCallable(() -> DBReader.getStatistics(countAll))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(result -> {
|
||||
if (result != null) {
|
||||
totalTimeTextView.setText(Converter
|
||||
.shortLocalizedDuration(this, countAll ? result.totalTimeCountAll : result.totalTime));
|
||||
listAdapter.update(result.feedTime);
|
||||
progressBar.setVisibility(View.GONE);
|
||||
totalTimeTextView.setVisibility(View.VISIBLE);
|
||||
feedStatisticsList.setVisibility(View.VISIBLE);
|
||||
}
|
||||
totalTimeTextView.setText(Converter
|
||||
.shortLocalizedDuration(this, countAll ? result.totalTimeCountAll : result.totalTime));
|
||||
listAdapter.update(result.feedTime);
|
||||
progressBar.setVisibility(View.GONE);
|
||||
totalTimeTextView.setVisibility(View.VISIBLE);
|
||||
feedStatisticsList.setVisibility(View.VISIBLE);
|
||||
}, error -> Log.e(TAG, Log.getStackTraceString(error)));
|
||||
}
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ public class ItunesAdapter extends ArrayAdapter<ItunesAdapter.Podcast> {
|
|||
}
|
||||
|
||||
public static Podcast fromSearch(SearchHit searchHit) {
|
||||
return new Podcast(searchHit.getTitle(), searchHit.getImageUrl(), searchHit.getXmlUrl());
|
||||
return new Podcast(searchHit.getTitle(), searchHit.getThumbImageURL(), searchHit.getXmlUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,7 +12,7 @@ import de.danoeh.antennapod.core.export.ExportWriter;
|
|||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.util.LangUtils;
|
||||
import rx.Observable;
|
||||
import io.reactivex.Observable;
|
||||
|
||||
/**
|
||||
* Writes an OPML file into the export directory in the background.
|
||||
|
@ -57,7 +57,7 @@ public class ExportWorker {
|
|||
subscriber.onError(e);
|
||||
}
|
||||
}
|
||||
subscriber.onCompleted();
|
||||
subscriber.onComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -29,14 +29,15 @@ import de.danoeh.antennapod.R;
|
|||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.core.service.download.ProxyConfig;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.SingleOnSubscribe;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.Credentials;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import rx.Observable;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
|
||||
public class ProxyDialog {
|
||||
|
||||
|
@ -54,7 +55,7 @@ public class ProxyDialog {
|
|||
|
||||
private boolean testSuccessful = false;
|
||||
private TextView txtvMessage;
|
||||
private Subscription subscription;
|
||||
private Disposable disposable;
|
||||
|
||||
public ProxyDialog(Context context) {
|
||||
this.context = context;
|
||||
|
@ -228,8 +229,8 @@ public class ProxyDialog {
|
|||
}
|
||||
|
||||
private void test() {
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
if(!checkValidity()) {
|
||||
setTestRequired(true);
|
||||
|
@ -242,7 +243,7 @@ public class ProxyDialog {
|
|||
txtvMessage.setTextColor(textColorPrimary);
|
||||
txtvMessage.setText("{fa-circle-o-notch spin} " + checking);
|
||||
txtvMessage.setVisibility(View.VISIBLE);
|
||||
subscription = Observable.create((Observable.OnSubscribe<Response>) subscriber -> {
|
||||
disposable = Single.create((SingleOnSubscribe<Response>) emitter -> {
|
||||
String type = (String) spType.getSelectedItem();
|
||||
String host = etHost.getText().toString();
|
||||
String port = etPort.getText().toString();
|
||||
|
@ -274,13 +275,12 @@ public class ProxyDialog {
|
|||
.build();
|
||||
try {
|
||||
Response response = client.newCall(request).execute();
|
||||
subscriber.onNext(response);
|
||||
emitter.onSuccess(response);
|
||||
} catch(IOException e) {
|
||||
subscriber.onError(e);
|
||||
emitter.onError(e);
|
||||
}
|
||||
subscriber.onCompleted();
|
||||
})
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
response -> {
|
||||
|
|
|
@ -50,10 +50,10 @@ import de.danoeh.antennapod.core.util.LongList;
|
|||
import de.danoeh.antennapod.menuhandler.FeedItemMenuHandler;
|
||||
import de.danoeh.antennapod.menuhandler.MenuItemUtils;
|
||||
import de.greenrobot.event.EventBus;
|
||||
import rx.Observable;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Shows unread or recently published episodes
|
||||
|
@ -84,7 +84,7 @@ public class AllEpisodesFragment extends Fragment {
|
|||
private boolean isUpdatingFeeds;
|
||||
boolean isMenuInvalidationAllowed = false;
|
||||
|
||||
Subscription subscription;
|
||||
Disposable disposable;
|
||||
private LinearLayoutManager layoutManager;
|
||||
|
||||
boolean showOnlyNewEpisodes() { return false; }
|
||||
|
@ -125,8 +125,8 @@ public class AllEpisodesFragment extends Fragment {
|
|||
public void onStop() {
|
||||
super.onStop();
|
||||
EventDistributor.getInstance().unregister(contentUpdate);
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -462,15 +462,15 @@ public class AllEpisodesFragment extends Fragment {
|
|||
}
|
||||
|
||||
void loadItems() {
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
if (viewsCreated && !itemsLoaded) {
|
||||
recyclerView.setVisibility(View.GONE);
|
||||
progLoading.setVisibility(View.VISIBLE);
|
||||
}
|
||||
subscription = Observable.fromCallable(this::loadData)
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
disposable = Observable.fromCallable(this::loadData)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(data -> {
|
||||
recyclerView.setVisibility(View.VISIBLE);
|
||||
|
@ -495,8 +495,8 @@ public class AllEpisodesFragment extends Fragment {
|
|||
}
|
||||
|
||||
Log.d(TAG, "markItemAsSeenWithUndo(" + item.getId() + ")");
|
||||
if (subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
// we're marking it as unplayed since the user didn't actually play it
|
||||
// but they don't want it considered 'NEW' anymore
|
||||
|
|
|
@ -21,10 +21,10 @@ import de.danoeh.antennapod.core.storage.DBReader;
|
|||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import de.danoeh.antennapod.core.util.FeedItemUtil;
|
||||
import de.danoeh.antennapod.dialog.EpisodesApplyActionFragment;
|
||||
import rx.Observable;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Displays all running downloads and provides a button to delete them
|
||||
|
@ -42,7 +42,7 @@ public class CompletedDownloadsFragment extends ListFragment {
|
|||
|
||||
private boolean viewCreated = false;
|
||||
|
||||
private Subscription subscription;
|
||||
private Disposable disposable;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -61,16 +61,16 @@ public class CompletedDownloadsFragment extends ListFragment {
|
|||
public void onStop() {
|
||||
super.onStop();
|
||||
EventDistributor.getInstance().unregister(contentUpdate);
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,8 +79,8 @@ public class CompletedDownloadsFragment extends ListFragment {
|
|||
super.onDestroyView();
|
||||
listAdapter = null;
|
||||
viewCreated = false;
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -182,21 +182,19 @@ public class CompletedDownloadsFragment extends ListFragment {
|
|||
};
|
||||
|
||||
private void loadItems() {
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
if (items == null && viewCreated) {
|
||||
setListShown(false);
|
||||
}
|
||||
subscription = Observable.fromCallable(DBReader::getDownloadedItems)
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
disposable = Observable.fromCallable(DBReader::getDownloadedItems)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(result -> {
|
||||
if (result != null) {
|
||||
items = result;
|
||||
if (viewCreated && getActivity() != null) {
|
||||
onFragmentLoaded();
|
||||
}
|
||||
items = result;
|
||||
if (viewCreated && getActivity() != null) {
|
||||
onFragmentLoaded();
|
||||
}
|
||||
}, error -> Log.e(TAG, Log.getStackTraceString(error)));
|
||||
}
|
||||
|
|
|
@ -23,10 +23,10 @@ import de.danoeh.antennapod.core.feed.FeedMedia;
|
|||
import de.danoeh.antennapod.core.service.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import rx.Observable;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Shows the download log
|
||||
|
@ -41,7 +41,7 @@ public class DownloadLogFragment extends ListFragment {
|
|||
private boolean viewsCreated = false;
|
||||
private boolean itemsLoaded = false;
|
||||
|
||||
private Subscription subscription;
|
||||
private Disposable disposable;
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
@ -55,8 +55,8 @@ public class DownloadLogFragment extends ListFragment {
|
|||
public void onStop() {
|
||||
super.onStop();
|
||||
EventDistributor.getInstance().unregister(contentUpdate);
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if(disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,11 +178,11 @@ public class DownloadLogFragment extends ListFragment {
|
|||
}
|
||||
|
||||
private void loadItems() {
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if(disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
subscription = Observable.fromCallable(DBReader::getDownloadLog)
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
disposable = Observable.fromCallable(DBReader::getDownloadLog)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(result -> {
|
||||
if (result != null) {
|
||||
|
|
|
@ -22,10 +22,10 @@ import de.danoeh.antennapod.core.glide.ApGlideSettings;
|
|||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
import de.danoeh.antennapod.core.util.playback.Playable;
|
||||
import de.danoeh.antennapod.core.util.playback.PlaybackController;
|
||||
import rx.Single;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import io.reactivex.Maybe;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Fragment which is supposed to be displayed outside of the MediaplayerActivity
|
||||
|
@ -41,7 +41,7 @@ public class ExternalPlayerFragment extends Fragment {
|
|||
private TextView mFeedName;
|
||||
private ProgressBar mProgressBar;
|
||||
private PlaybackController controller;
|
||||
private Subscription subscription;
|
||||
private Disposable disposable;
|
||||
|
||||
public ExternalPlayerFragment() {
|
||||
super();
|
||||
|
@ -143,8 +143,8 @@ public class ExternalPlayerFragment extends Fragment {
|
|||
if (controller != null) {
|
||||
controller.release();
|
||||
}
|
||||
if (subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,13 +181,21 @@ public class ExternalPlayerFragment extends Fragment {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
subscription = Single.create(subscriber -> subscriber.onSuccess(controller.getMedia()))
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
disposable = Maybe.create(emitter -> {
|
||||
Playable media = controller.getMedia();
|
||||
if (media != null) {
|
||||
emitter.onSuccess(media);
|
||||
} else {
|
||||
emitter.onComplete();
|
||||
}
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(media -> updateUi((Playable) media));
|
||||
.subscribe(media -> updateUi((Playable) media),
|
||||
error -> Log.e(TAG, Log.getStackTraceString(error)));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,8 +62,8 @@ public class FavoriteEpisodesFragment extends AllEpisodesFragment {
|
|||
AllEpisodesRecycleAdapter.Holder holder = (AllEpisodesRecycleAdapter.Holder)viewHolder;
|
||||
Log.d(TAG, "remove(" + holder.getItemId() + ")");
|
||||
|
||||
if (subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
FeedItem item = holder.getFeedItem();
|
||||
if (item != null) {
|
||||
|
|
|
@ -28,9 +28,9 @@ import de.danoeh.antennapod.menuhandler.MenuItemUtils;
|
|||
import de.mfietz.fyydlin.FyydClient;
|
||||
import de.mfietz.fyydlin.FyydResponse;
|
||||
import de.mfietz.fyydlin.SearchHit;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
import static de.danoeh.antennapod.adapter.itunes.ItunesAdapter.Podcast;
|
||||
import static java.util.Collections.emptyList;
|
||||
|
@ -55,7 +55,7 @@ public class FyydSearchFragment extends Fragment {
|
|||
* List of podcasts retreived from the search
|
||||
*/
|
||||
private List<Podcast> searchResults;
|
||||
private Subscription subscription;
|
||||
private Disposable disposable;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -98,8 +98,8 @@ public class FyydSearchFragment extends Fragment {
|
|||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
adapter = null;
|
||||
}
|
||||
|
@ -141,12 +141,12 @@ public class FyydSearchFragment extends Fragment {
|
|||
}
|
||||
|
||||
private void search(String query) {
|
||||
if (subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
showOnlyProgressBar();
|
||||
subscription = client.searchPodcasts(query)
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
disposable = client.searchPodcasts(query, 10)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(result -> {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
|
@ -174,7 +174,7 @@ public class FyydSearchFragment extends Fragment {
|
|||
if (!response.getData().isEmpty()) {
|
||||
adapter.clear();
|
||||
searchResults = new ArrayList<>();
|
||||
for (SearchHit searchHit : response.getData().values()) {
|
||||
for (SearchHit searchHit : response.getData()) {
|
||||
Podcast podcast = Podcast.fromSearch(searchHit);
|
||||
searchResults.add(podcast);
|
||||
}
|
||||
|
|
|
@ -39,10 +39,10 @@ import de.danoeh.antennapod.core.util.ShownotesProvider;
|
|||
import de.danoeh.antennapod.core.util.playback.Playable;
|
||||
import de.danoeh.antennapod.core.util.playback.PlaybackController;
|
||||
import de.danoeh.antennapod.core.util.playback.Timeline;
|
||||
import rx.Observable;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Displays the description of a Playable object in a Webview.
|
||||
|
@ -66,7 +66,7 @@ public class ItemDescriptionFragment extends Fragment implements MediaplayerInfo
|
|||
private ShownotesProvider shownotesProvider;
|
||||
private Playable media;
|
||||
|
||||
private Subscription webViewLoader;
|
||||
private Disposable webViewLoader;
|
||||
|
||||
/**
|
||||
* URL that was selected via long-press.
|
||||
|
@ -167,7 +167,7 @@ public class ItemDescriptionFragment extends Fragment implements MediaplayerInfo
|
|||
super.onDestroy();
|
||||
Log.d(TAG, "Fragment destroyed");
|
||||
if (webViewLoader != null) {
|
||||
webViewLoader.unsubscribe();
|
||||
webViewLoader.dispose();
|
||||
}
|
||||
if (webvDescription != null) {
|
||||
webvDescription.removeAllViews();
|
||||
|
@ -198,7 +198,7 @@ public class ItemDescriptionFragment extends Fragment implements MediaplayerInfo
|
|||
} else if (args.containsKey(ARG_FEEDITEM_ID)) {
|
||||
long id = getArguments().getLong(ARG_FEEDITEM_ID);
|
||||
Observable.defer(() -> Observable.just(DBReader.getFeedItem(id)))
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(feedItem -> {
|
||||
shownotesProvider = feedItem;
|
||||
|
@ -298,13 +298,13 @@ public class ItemDescriptionFragment extends Fragment implements MediaplayerInfo
|
|||
private void load() {
|
||||
Log.d(TAG, "load()");
|
||||
if(webViewLoader != null) {
|
||||
webViewLoader.unsubscribe();
|
||||
webViewLoader.dispose();
|
||||
}
|
||||
if(shownotesProvider == null) {
|
||||
return;
|
||||
}
|
||||
webViewLoader = Observable.defer(() -> Observable.just(loadData()))
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
webViewLoader = Observable.fromCallable(this::loadData)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(data -> {
|
||||
webvDescription.loadDataWithBaseURL(null, data, "text/html",
|
||||
|
|
|
@ -68,10 +68,10 @@ import de.danoeh.antennapod.menuhandler.FeedItemMenuHandler;
|
|||
import de.danoeh.antennapod.view.OnSwipeGesture;
|
||||
import de.danoeh.antennapod.view.SwipeGestureDetector;
|
||||
import de.greenrobot.event.EventBus;
|
||||
import rx.Observable;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Displays information about a FeedItem and actions.
|
||||
|
@ -134,7 +134,7 @@ public class ItemFragment extends Fragment implements OnSwipeGesture {
|
|||
private IconButton butAction2;
|
||||
private Menu popupMenu;
|
||||
|
||||
private Subscription subscription;
|
||||
private Disposable disposable;
|
||||
|
||||
/**
|
||||
* URL that was selected via long-press.
|
||||
|
@ -285,8 +285,8 @@ public class ItemFragment extends Fragment implements OnSwipeGesture {
|
|||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if(disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
if (webvDescription != null && root != null) {
|
||||
root.removeView(webvDescription);
|
||||
|
@ -571,12 +571,12 @@ public class ItemFragment extends Fragment implements OnSwipeGesture {
|
|||
};
|
||||
|
||||
private void load() {
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if(disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
progbarLoading.setVisibility(View.VISIBLE);
|
||||
subscription = Observable.fromCallable(this::loadInBackground)
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
disposable = Observable.fromCallable(this::loadInBackground)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(result -> {
|
||||
progbarLoading.setVisibility(View.GONE);
|
||||
|
|
|
@ -66,10 +66,10 @@ import de.danoeh.antennapod.menuhandler.FeedItemMenuHandler;
|
|||
import de.danoeh.antennapod.menuhandler.FeedMenuHandler;
|
||||
import de.danoeh.antennapod.menuhandler.MenuItemUtils;
|
||||
import de.greenrobot.event.EventBus;
|
||||
import rx.Observable;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Displays a list of FeedItems.
|
||||
|
@ -109,7 +109,7 @@ public class ItemlistFragment extends ListFragment {
|
|||
|
||||
private TextView txtvInformation;
|
||||
|
||||
private Subscription subscription;
|
||||
private Disposable disposable;
|
||||
|
||||
/**
|
||||
* Creates new ItemlistFragment which shows the Feeditems of a specific
|
||||
|
@ -160,8 +160,8 @@ public class ItemlistFragment extends ListFragment {
|
|||
super.onPause();
|
||||
EventDistributor.getInstance().unregister(contentUpdate);
|
||||
EventBus.getDefault().unregister(this);
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if(disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -607,11 +607,11 @@ public class ItemlistFragment extends ListFragment {
|
|||
|
||||
|
||||
private void loadItems() {
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if(disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
subscription = Observable.fromCallable(this::loadData)
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
disposable = Observable.fromCallable(this::loadData)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(result -> {
|
||||
if (result != null) {
|
||||
|
|
|
@ -36,13 +36,14 @@ import de.danoeh.antennapod.adapter.itunes.ItunesAdapter;
|
|||
import de.danoeh.antennapod.core.ClientConfig;
|
||||
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.menuhandler.MenuItemUtils;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.SingleOnSubscribe;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import rx.Observable;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
|
||||
import static de.danoeh.antennapod.adapter.itunes.ItunesAdapter.Podcast;
|
||||
|
||||
|
@ -69,7 +70,7 @@ public class ItunesSearchFragment extends Fragment {
|
|||
*/
|
||||
private List<Podcast> searchResults;
|
||||
private List<Podcast> topList;
|
||||
private Subscription subscription;
|
||||
private Disposable disposable;
|
||||
|
||||
/**
|
||||
* Replace adapter data with provided search results from SearchTask.
|
||||
|
@ -127,7 +128,7 @@ public class ItunesSearchFragment extends Fragment {
|
|||
} else {
|
||||
gridView.setVisibility(View.GONE);
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
subscription = Observable.create((Observable.OnSubscribe<String>) subscriber -> {
|
||||
disposable = Single.create((SingleOnSubscribe<String>) emitter -> {
|
||||
OkHttpClient client = AntennapodHttpClient.getHttpClient();
|
||||
Request.Builder httpReq = new Request.Builder()
|
||||
.url(podcast.feedUrl)
|
||||
|
@ -139,17 +140,16 @@ public class ItunesSearchFragment extends Fragment {
|
|||
JSONObject result = new JSONObject(resultString);
|
||||
JSONObject results = result.getJSONArray("results").getJSONObject(0);
|
||||
String feedUrl = results.getString("feedUrl");
|
||||
subscriber.onNext(feedUrl);
|
||||
emitter.onSuccess(feedUrl);
|
||||
} else {
|
||||
String prefix = getString(R.string.error_msg_prefix);
|
||||
subscriber.onError(new IOException(prefix + response));
|
||||
emitter.onError(new IOException(prefix + response));
|
||||
}
|
||||
} catch (IOException | JSONException e) {
|
||||
subscriber.onError(e);
|
||||
emitter.onError(e);
|
||||
}
|
||||
subscriber.onCompleted();
|
||||
})
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(feedUrl -> {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
|
@ -183,8 +183,8 @@ public class ItunesSearchFragment extends Fragment {
|
|||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
adapter = null;
|
||||
}
|
||||
|
@ -228,15 +228,15 @@ public class ItunesSearchFragment extends Fragment {
|
|||
}
|
||||
|
||||
private void loadToplist() {
|
||||
if (subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
gridView.setVisibility(View.GONE);
|
||||
txtvError.setVisibility(View.GONE);
|
||||
butRetry.setVisibility(View.GONE);
|
||||
txtvEmpty.setVisibility(View.GONE);
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
subscription = Observable.create((Observable.OnSubscribe<List<Podcast>>) subscriber -> {
|
||||
disposable = Single.create((SingleOnSubscribe<List<Podcast>>) emitter -> {
|
||||
String lang = Locale.getDefault().getLanguage();
|
||||
String url = "https://itunes.apple.com/" + lang + "/rss/toppodcasts/limit=25/explicit=true/json";
|
||||
OkHttpClient client = AntennapodHttpClient.getHttpClient();
|
||||
|
@ -268,15 +268,14 @@ public class ItunesSearchFragment extends Fragment {
|
|||
}
|
||||
else {
|
||||
String prefix = getString(R.string.error_msg_prefix);
|
||||
subscriber.onError(new IOException(prefix + response));
|
||||
emitter.onError(new IOException(prefix + response));
|
||||
}
|
||||
} catch (IOException | JSONException e) {
|
||||
subscriber.onError(e);
|
||||
emitter.onError(e);
|
||||
}
|
||||
subscriber.onNext(results);
|
||||
subscriber.onCompleted();
|
||||
emitter.onSuccess(results);
|
||||
})
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(podcasts -> {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
|
@ -293,15 +292,15 @@ public class ItunesSearchFragment extends Fragment {
|
|||
}
|
||||
|
||||
private void search(String query) {
|
||||
if (subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
gridView.setVisibility(View.GONE);
|
||||
txtvError.setVisibility(View.GONE);
|
||||
butRetry.setVisibility(View.GONE);
|
||||
txtvEmpty.setVisibility(View.GONE);
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
subscription = rx.Observable.create((Observable.OnSubscribe<List<Podcast>>) subscriber -> {
|
||||
disposable = Single.create((SingleOnSubscribe<List<Podcast>>) subscriber -> {
|
||||
String encodedQuery = null;
|
||||
try {
|
||||
encodedQuery = URLEncoder.encode(query, "UTF-8");
|
||||
|
@ -341,10 +340,9 @@ public class ItunesSearchFragment extends Fragment {
|
|||
} catch (IOException | JSONException e) {
|
||||
subscriber.onError(e);
|
||||
}
|
||||
subscriber.onNext(podcasts);
|
||||
subscriber.onCompleted();
|
||||
subscriber.onSuccess(podcasts);
|
||||
})
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(podcasts -> {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
|
|
|
@ -30,10 +30,10 @@ import de.danoeh.antennapod.core.storage.DBWriter;
|
|||
import de.danoeh.antennapod.core.util.FeedItemUtil;
|
||||
import de.danoeh.antennapod.core.util.LongList;
|
||||
import de.greenrobot.event.EventBus;
|
||||
import rx.Observable;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
public class PlaybackHistoryFragment extends ListFragment {
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class PlaybackHistoryFragment extends ListFragment {
|
|||
|
||||
private List<Downloader> downloaderList;
|
||||
|
||||
private Subscription subscription;
|
||||
private Disposable disposable;
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
|
@ -107,16 +107,16 @@ public class PlaybackHistoryFragment extends ListFragment {
|
|||
public void onStop() {
|
||||
super.onStop();
|
||||
EventDistributor.getInstance().unregister(contentUpdate);
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if(disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if(disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -269,11 +269,11 @@ public class PlaybackHistoryFragment extends ListFragment {
|
|||
};
|
||||
|
||||
private void loadItems() {
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if(disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
subscription = Observable.fromCallable(this::loadData)
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
disposable = Observable.fromCallable(this::loadData)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(result -> {
|
||||
if (result != null) {
|
||||
|
|
|
@ -53,10 +53,10 @@ import de.danoeh.antennapod.core.util.QueueSorter;
|
|||
import de.danoeh.antennapod.menuhandler.FeedItemMenuHandler;
|
||||
import de.danoeh.antennapod.menuhandler.MenuItemUtils;
|
||||
import de.greenrobot.event.EventBus;
|
||||
import rx.Observable;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Shows all items in the queue
|
||||
|
@ -84,7 +84,7 @@ public class QueueFragment extends Fragment {
|
|||
private static final String PREF_SCROLL_POSITION = "scroll_position";
|
||||
private static final String PREF_SCROLL_OFFSET = "scroll_offset";
|
||||
|
||||
private Subscription subscription;
|
||||
private Disposable disposable;
|
||||
private LinearLayoutManager layoutManager;
|
||||
private ItemTouchHelper itemTouchHelper;
|
||||
|
||||
|
@ -118,8 +118,8 @@ public class QueueFragment extends Fragment {
|
|||
saveScrollPosition();
|
||||
EventDistributor.getInstance().unregister(contentUpdate);
|
||||
EventBus.getDefault().unregister(this);
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if(disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -423,8 +423,8 @@ public class QueueFragment extends Fragment {
|
|||
|
||||
@Override
|
||||
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if(disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
final int position = viewHolder.getAdapterPosition();
|
||||
Log.d(TAG, "remove(" + position + ")");
|
||||
|
@ -623,16 +623,16 @@ public class QueueFragment extends Fragment {
|
|||
|
||||
private void loadItems(final boolean restoreScrollPosition) {
|
||||
Log.d(TAG, "loadItems()");
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if(disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
if (queue == null) {
|
||||
recyclerView.setVisibility(View.GONE);
|
||||
txtvEmpty.setVisibility(View.GONE);
|
||||
progLoading.setVisibility(View.VISIBLE);
|
||||
}
|
||||
subscription = Observable.fromCallable(DBReader::getQueue)
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
disposable = Observable.fromCallable(DBReader::getQueue)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(items -> {
|
||||
if(items != null) {
|
||||
|
|
|
@ -24,10 +24,10 @@ import de.danoeh.antennapod.core.feed.FeedComponent;
|
|||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
import de.danoeh.antennapod.core.feed.SearchResult;
|
||||
import de.danoeh.antennapod.core.storage.FeedSearcher;
|
||||
import rx.Observable;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Performs a search operation on all feeds or one specific feed and displays the search result.
|
||||
|
@ -44,7 +44,7 @@ public class SearchFragment extends ListFragment {
|
|||
private boolean viewCreated = false;
|
||||
private boolean itemsLoaded = false;
|
||||
|
||||
private Subscription subscription;
|
||||
private Disposable disposable;
|
||||
|
||||
/**
|
||||
* Create a new SearchFragment that searches all feeds.
|
||||
|
@ -85,8 +85,8 @@ public class SearchFragment extends ListFragment {
|
|||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if(disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
EventDistributor.getInstance().unregister(contentUpdate);
|
||||
}
|
||||
|
@ -94,8 +94,8 @@ public class SearchFragment extends ListFragment {
|
|||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if(disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -205,14 +205,14 @@ public class SearchFragment extends ListFragment {
|
|||
|
||||
|
||||
private void search() {
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if(disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
if (viewCreated && !itemsLoaded) {
|
||||
setListShown(false);
|
||||
}
|
||||
subscription = Observable.fromCallable(this::performSearch)
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
disposable = Observable.fromCallable(this::performSearch)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(result -> {
|
||||
if (result != null) {
|
||||
|
|
|
@ -27,10 +27,10 @@ import de.danoeh.antennapod.core.storage.DBWriter;
|
|||
import de.danoeh.antennapod.core.util.FeedItemUtil;
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
import de.danoeh.antennapod.dialog.RenameFeedDialog;
|
||||
import rx.Observable;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Fragment for displaying feed subscriptions
|
||||
|
@ -48,7 +48,7 @@ public class SubscriptionFragment extends Fragment {
|
|||
|
||||
private int mPosition = -1;
|
||||
|
||||
private Subscription subscription;
|
||||
private Disposable disposable;
|
||||
|
||||
public SubscriptionFragment() {
|
||||
}
|
||||
|
@ -94,17 +94,17 @@ public class SubscriptionFragment extends Fragment {
|
|||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if(disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadSubscriptions() {
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if(disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
subscription = Observable.fromCallable(DBReader::getNavDrawerData)
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
disposable = Observable.fromCallable(DBReader::getNavDrawerData)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(result -> {
|
||||
navDrawerData = result;
|
||||
|
@ -161,7 +161,7 @@ public class SubscriptionFragment extends Fragment {
|
|||
dialog.dismiss();
|
||||
|
||||
Observable.fromCallable(() -> DBWriter.markFeedSeen(feed.getId()))
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(result -> loadSubscriptions(),
|
||||
error -> Log.e(TAG, Log.getStackTraceString(error)));
|
||||
|
@ -178,7 +178,7 @@ public class SubscriptionFragment extends Fragment {
|
|||
public void onConfirmButtonPressed(DialogInterface dialog) {
|
||||
dialog.dismiss();
|
||||
Observable.fromCallable(() -> DBWriter.markFeedRead(feed.getId()))
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(result -> loadSubscriptions(),
|
||||
error -> Log.e(TAG, Log.getStackTraceString(error)));
|
||||
|
|
|
@ -75,10 +75,10 @@ import de.danoeh.antennapod.dialog.ChooseDataFolderDialog;
|
|||
import de.danoeh.antennapod.dialog.GpodnetSetHostnameDialog;
|
||||
import de.danoeh.antennapod.dialog.ProxyDialog;
|
||||
import de.danoeh.antennapod.dialog.VariableSpeedDialog;
|
||||
import rx.Observable;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
import static de.danoeh.antennapod.activity.PreferenceActivity.PARAM_RESOURCE;
|
||||
|
||||
|
@ -137,7 +137,7 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
|
|||
}
|
||||
};
|
||||
private CheckBoxPreference[] selectedNetworks;
|
||||
private Subscription subscription;
|
||||
private Disposable disposable;
|
||||
|
||||
public PreferenceController(PreferenceUI ui) {
|
||||
this.ui = ui;
|
||||
|
@ -651,7 +651,7 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
|
|||
final AlertDialog.Builder alert = new AlertDialog.Builder(context)
|
||||
.setNeutralButton(android.R.string.ok, (dialog, which) -> dialog.dismiss());
|
||||
Observable<File> observable = new ExportWorker(exportWriter).exportObservable();
|
||||
subscription = observable.subscribeOn(Schedulers.newThread())
|
||||
disposable = observable.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(output -> {
|
||||
alert.setTitle(R.string.export_success_title);
|
||||
|
@ -729,8 +729,8 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
|
|||
}
|
||||
|
||||
public void unsubscribeExportSubscription() {
|
||||
if (subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if (disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,10 +41,10 @@ import java.util.concurrent.ExecutionException;
|
|||
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.core.glide.ApGlideSettings;
|
||||
import rx.Observable;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
public class CustomMRControllerDialog extends MediaRouteControllerDialog {
|
||||
public static final String TAG = "CustomMRContrDialog";
|
||||
|
@ -60,7 +60,7 @@ public class CustomMRControllerDialog extends MediaRouteControllerDialog {
|
|||
|
||||
private boolean viewsCreated = false;
|
||||
|
||||
private Subscription fetchArtSubscription;
|
||||
private Disposable fetchArtSubscription;
|
||||
|
||||
private MediaControllerCompat mediaController;
|
||||
private MediaControllerCompat.Callback mediaControllerCallback;
|
||||
|
@ -327,7 +327,7 @@ public class CustomMRControllerDialog extends MediaRouteControllerDialog {
|
|||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
if (fetchArtSubscription != null) {
|
||||
fetchArtSubscription.unsubscribe();
|
||||
fetchArtSubscription.dispose();
|
||||
fetchArtSubscription = null;
|
||||
}
|
||||
super.onDetachedFromWindow();
|
||||
|
@ -396,11 +396,11 @@ public class CustomMRControllerDialog extends MediaRouteControllerDialog {
|
|||
}
|
||||
|
||||
if (fetchArtSubscription != null) {
|
||||
fetchArtSubscription.unsubscribe();
|
||||
fetchArtSubscription.dispose();
|
||||
}
|
||||
|
||||
fetchArtSubscription = Observable.fromCallable(() -> fetchArt(description))
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(result -> {
|
||||
fetchArtSubscription = null;
|
||||
|
|
|
@ -58,8 +58,8 @@ project.ext {
|
|||
okioVersion = "1.14.0"
|
||||
recyclerviewFlexibledividerVersion = "1.4.0"
|
||||
robotiumSoloVersion = "5.6.3"
|
||||
rxAndroidVersion = "1.2.1"
|
||||
rxJavaVersion = "1.3.8"
|
||||
rxAndroidVersion = "2.1.0"
|
||||
rxJavaVersion = "2.2.2"
|
||||
rxJavaRulesVersion = "1.3.3.0"
|
||||
triangleLabelViewVersion = "1.1.2"
|
||||
|
||||
|
|
|
@ -65,7 +65,8 @@ dependencies {
|
|||
implementation "com.squareup.okhttp3:okhttp-urlconnection:$okhttpVersion"
|
||||
implementation "com.squareup.okio:okio:$okioVersion"
|
||||
implementation "de.greenrobot:eventbus:$eventbusVersion"
|
||||
implementation "io.reactivex:rxandroid:$rxAndroidVersion"
|
||||
implementation "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion"
|
||||
implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
|
||||
implementation "org.awaitility:awaitility:$awaitilityVersion"
|
||||
|
||||
implementation "com.google.android.exoplayer:exoplayer:$exoPlayerVersion"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
@ -574,6 +575,7 @@ public final class DBReader {
|
|||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static Feed getFeed(final long feedId, PodDBAdapter adapter) {
|
||||
Feed feed = null;
|
||||
Cursor cursor = null;
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package de.danoeh.antennapod.core.util;
|
||||
|
||||
public interface Consumer<T> {
|
||||
void accept(T t);
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package de.danoeh.antennapod.core.util;
|
||||
|
||||
import io.reactivex.annotations.NonNull;
|
||||
|
||||
public interface Function<T, R> {
|
||||
R apply(@NonNull T t);
|
||||
}
|
|
@ -18,12 +18,13 @@ import de.danoeh.antennapod.core.feed.FeedMedia;
|
|||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.SingleOnSubscribe;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import rx.Observable;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
|
||||
public class NetworkUtils {
|
||||
private NetworkUtils(){}
|
||||
|
@ -111,11 +112,10 @@ public class NetworkUtils {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static Observable<Long> getFeedMediaSizeObservable(FeedMedia media) {
|
||||
return Observable.create((Observable.OnSubscribe<Long>) subscriber -> {
|
||||
public static Single<Long> getFeedMediaSizeObservable(FeedMedia media) {
|
||||
return Single.create((SingleOnSubscribe<Long>) emitter -> {
|
||||
if (!NetworkUtils.isDownloadAllowed()) {
|
||||
subscriber.onNext(0L);
|
||||
subscriber.onCompleted();
|
||||
emitter.onSuccess(0L);
|
||||
return;
|
||||
}
|
||||
long size = Integer.MIN_VALUE;
|
||||
|
@ -129,8 +129,7 @@ public class NetworkUtils {
|
|||
|
||||
String url = media.getDownload_url();
|
||||
if(TextUtils.isEmpty(url)) {
|
||||
subscriber.onNext(0L);
|
||||
subscriber.onCompleted();
|
||||
emitter.onSuccess(0L);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -150,8 +149,7 @@ public class NetworkUtils {
|
|||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
subscriber.onNext(0L);
|
||||
subscriber.onCompleted();
|
||||
emitter.onSuccess(0L);
|
||||
Log.e(TAG, Log.getStackTraceString(e));
|
||||
return; // better luck next time
|
||||
}
|
||||
|
@ -163,11 +161,10 @@ public class NetworkUtils {
|
|||
} else {
|
||||
media.setSize(size);
|
||||
}
|
||||
subscriber.onNext(size);
|
||||
subscriber.onCompleted();
|
||||
emitter.onSuccess(size);
|
||||
DBWriter.setFeedMedia(media);
|
||||
})
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
|
|
|
@ -38,11 +38,12 @@ import de.danoeh.antennapod.core.service.playback.PlayerStatus;
|
|||
import de.danoeh.antennapod.core.storage.DBTasks;
|
||||
import de.danoeh.antennapod.core.util.Converter;
|
||||
import de.danoeh.antennapod.core.util.playback.Playable.PlayableUtils;
|
||||
import rx.Observable;
|
||||
import rx.Single;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import io.reactivex.Maybe;
|
||||
import io.reactivex.MaybeOnSubscribe;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Communicates with the playback service. GUI classes should use this class to
|
||||
|
@ -70,7 +71,8 @@ public abstract class PlaybackController {
|
|||
private boolean released = false;
|
||||
private boolean initialized = false;
|
||||
|
||||
private Subscription serviceBinder;
|
||||
private Disposable serviceBinder;
|
||||
private Disposable mediaLoader;
|
||||
|
||||
/**
|
||||
* True if controller should reinit playback service if 'pause' button is
|
||||
|
@ -145,7 +147,7 @@ public abstract class PlaybackController {
|
|||
}
|
||||
|
||||
if(serviceBinder != null) {
|
||||
serviceBinder.unsubscribe();
|
||||
serviceBinder.dispose();
|
||||
}
|
||||
try {
|
||||
activity.unbindService(mConnection);
|
||||
|
@ -180,10 +182,10 @@ public abstract class PlaybackController {
|
|||
private void bindToService() {
|
||||
Log.d(TAG, "Trying to connect to service");
|
||||
if (serviceBinder != null) {
|
||||
serviceBinder.unsubscribe();
|
||||
serviceBinder.dispose();
|
||||
}
|
||||
serviceBinder = Observable.fromCallable(this::getPlayLastPlayedMediaIntent)
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(intent -> {
|
||||
boolean bound = false;
|
||||
|
@ -777,15 +779,18 @@ public abstract class PlaybackController {
|
|||
}
|
||||
|
||||
private void initServiceNotRunning() {
|
||||
Single.create(subscriber -> subscriber.onSuccess(getMedia()))
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
mediaLoader = Maybe.create((MaybeOnSubscribe<Playable>) emitter -> {
|
||||
Playable media = getMedia();
|
||||
if (media != null) {
|
||||
emitter.onSuccess(media);
|
||||
} else {
|
||||
emitter.onComplete();
|
||||
}
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe((Object media) -> {
|
||||
if (media == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (((Playable) media).getMediaType() == MediaType.AUDIO) {
|
||||
.subscribe(media -> {
|
||||
if (media.getMediaType() == MediaType.AUDIO) {
|
||||
TypedArray res = activity.obtainStyledAttributes(new int[]{
|
||||
de.danoeh.antennapod.core.R.attr.av_play_big});
|
||||
getPlayButton().setImageResource(
|
||||
|
@ -794,7 +799,7 @@ public abstract class PlaybackController {
|
|||
} else {
|
||||
getPlayButton().setImageResource(R.drawable.ic_av_play_circle_outline_80dp);
|
||||
}
|
||||
});
|
||||
}, error -> Log.e(TAG, Log.getStackTraceString(error)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -802,7 +807,7 @@ public abstract class PlaybackController {
|
|||
*/
|
||||
public class MediaPositionObserver implements Runnable {
|
||||
|
||||
public static final int WAITING_INTERVALL = 1000;
|
||||
static final int WAITING_INTERVALL = 1000;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
Loading…
Reference in New Issue