mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2024-12-22 14:24:27 +01:00
Migrate rxjava to version 2
This commit is contained in:
parent
c105a63165
commit
3de661d953
@ -161,10 +161,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") {
|
||||
@ -179,7 +178,7 @@ dependencies {
|
||||
|
||||
implementation "com.github.AntennaPod:AntennaPod-AudioPlayer:$audioPlayerVersion"
|
||||
|
||||
implementation 'com.github.mfietz:fyydlin:v0.3'
|
||||
implementation 'com.github.mfietz:fyydlin:v0.4'
|
||||
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();
|
||||
|
@ -16,8 +16,14 @@ import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.joanzapata.iconify.Iconify;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.core.dialog.DownloadRequestErrorDialogCreator;
|
||||
import de.danoeh.antennapod.core.feed.Feed;
|
||||
@ -30,13 +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 org.apache.commons.lang3.StringUtils;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
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.
|
||||
@ -56,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() {
|
||||
@ -101,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());
|
||||
@ -164,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,8 +23,9 @@ 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;
|
||||
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.core.dialog.ConfirmationDialog;
|
||||
import de.danoeh.antennapod.core.dialog.DownloadRequestErrorDialogCreator;
|
||||
@ -40,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.
|
||||
@ -67,23 +68,7 @@ public class FeedSettingsActivity extends AppCompatActivity {
|
||||
private Spinner spnAutoDelete;
|
||||
private boolean filterInclude = true;
|
||||
|
||||
private Subscription subscription;
|
||||
|
||||
|
||||
private final View.OnClickListener copyUrlToClipboard = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(feed != null && feed.getDownload_url() != null) {
|
||||
String url = feed.getDownload_url();
|
||||
ClipData clipData = ClipData.newPlainText(url, url);
|
||||
android.content.ClipboardManager cm = (android.content.ClipboardManager) FeedSettingsActivity.this
|
||||
.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
cm.setPrimaryClip(clipData);
|
||||
Toast t = Toast.makeText(FeedSettingsActivity.this, R.string.copied_url_msg, Toast.LENGTH_SHORT);
|
||||
t.show();
|
||||
}
|
||||
}
|
||||
};
|
||||
private Disposable disposable;
|
||||
|
||||
private boolean authInfoChanged = false;
|
||||
|
||||
@ -153,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)
|
||||
@ -259,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();
|
||||
});
|
||||
}
|
||||
|
||||
@ -296,8 +287,8 @@ public class FeedSettingsActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if(disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,9 +30,6 @@ import android.widget.ListView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
|
||||
import de.danoeh.antennapod.core.event.ServiceEvent;
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
import de.danoeh.antennapod.core.util.gui.NotificationUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
@ -45,6 +42,7 @@ import de.danoeh.antennapod.core.dialog.ConfirmationDialog;
|
||||
import de.danoeh.antennapod.core.event.MessageEvent;
|
||||
import de.danoeh.antennapod.core.event.ProgressEvent;
|
||||
import de.danoeh.antennapod.core.event.QueueEvent;
|
||||
import de.danoeh.antennapod.core.event.ServiceEvent;
|
||||
import de.danoeh.antennapod.core.feed.EventDistributor;
|
||||
import de.danoeh.antennapod.core.feed.Feed;
|
||||
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
|
||||
@ -55,7 +53,9 @@ import de.danoeh.antennapod.core.storage.DBTasks;
|
||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import de.danoeh.antennapod.core.util.FeedItemUtil;
|
||||
import de.danoeh.antennapod.core.util.Flavors;
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
import de.danoeh.antennapod.core.util.StorageUtils;
|
||||
import de.danoeh.antennapod.core.util.gui.NotificationUtils;
|
||||
import de.danoeh.antennapod.dialog.RatingDialog;
|
||||
import de.danoeh.antennapod.dialog.RenameFeedDialog;
|
||||
import de.danoeh.antennapod.fragment.AddFeedFragment;
|
||||
@ -68,10 +68,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.
|
||||
@ -121,7 +121,7 @@ public class MainActivity extends CastEnabledActivity implements NavDrawerActivi
|
||||
|
||||
private ProgressDialog pd;
|
||||
|
||||
private Subscription subscription;
|
||||
private Disposable disposable;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@ -488,8 +488,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();
|
||||
@ -717,8 +717,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) {
|
||||
|
||||
@ -293,6 +296,9 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
|
||||
controller.release();
|
||||
controller = null; // prevent leak
|
||||
}
|
||||
if(disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@ -644,7 +650,6 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
|
||||
if (controller != null) {
|
||||
controller.init();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -730,8 +735,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;
|
||||
|
||||
/**
|
||||
@ -743,7 +748,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;
|
||||
@ -762,10 +767,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));
|
||||
}
|
||||
}
|
||||
@ -946,22 +951,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) {
|
||||
|
@ -9,11 +9,12 @@ import android.support.annotation.Nullable;
|
||||
import android.support.v4.graphics.drawable.DrawableCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
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
|
||||
@ -37,14 +38,14 @@ 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);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
startActivity(intent);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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)));
|
||||
}
|
||||
|
||||
|
@ -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,15 +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.Subscriber;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
|
||||
public class ProxyDialog {
|
||||
|
||||
@ -55,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;
|
||||
@ -229,8 +229,8 @@ public class ProxyDialog {
|
||||
}
|
||||
|
||||
private void test() {
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if(disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
if(!checkValidity()) {
|
||||
setTestRequired(true);
|
||||
@ -243,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();
|
||||
@ -275,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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -466,15 +466,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);
|
||||
@ -499,8 +499,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
|
||||
|
@ -1,8 +1,6 @@
|
||||
package de.danoeh.antennapod.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.ListFragment;
|
||||
import android.util.Log;
|
||||
@ -12,9 +10,6 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.joanzapata.iconify.IconDrawable;
|
||||
import com.joanzapata.iconify.fonts.FontAwesomeIcons;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.danoeh.antennapod.R;
|
||||
@ -22,15 +17,14 @@ import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.adapter.DownloadedEpisodesListAdapter;
|
||||
import de.danoeh.antennapod.core.feed.EventDistributor;
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
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
|
||||
@ -48,7 +42,7 @@ public class CompletedDownloadsFragment extends ListFragment {
|
||||
|
||||
private boolean viewCreated = false;
|
||||
|
||||
private Subscription subscription;
|
||||
private Disposable disposable;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@ -67,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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,8 +79,8 @@ public class CompletedDownloadsFragment extends ListFragment {
|
||||
super.onDestroyView();
|
||||
listAdapter = null;
|
||||
viewCreated = false;
|
||||
if(subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
if(disposable != null) {
|
||||
disposable.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,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)));
|
||||
}
|
||||
|
@ -12,10 +12,10 @@ import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.widget.TextView;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.adapter.DownloadLogAdapter;
|
||||
import de.danoeh.antennapod.core.feed.EventDistributor;
|
||||
@ -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) {
|
||||
|
@ -23,9 +23,10 @@ import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
import de.danoeh.antennapod.core.util.Converter;
|
||||
import de.danoeh.antennapod.core.util.playback.Playable;
|
||||
import de.danoeh.antennapod.core.util.playback.PlaybackController;
|
||||
import rx.Single;
|
||||
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,6 +42,7 @@ public class ExternalPlayerFragment extends Fragment {
|
||||
private TextView mFeedName;
|
||||
private ProgressBar mProgressBar;
|
||||
private PlaybackController controller;
|
||||
private Disposable disposable;
|
||||
|
||||
public ExternalPlayerFragment() {
|
||||
super();
|
||||
@ -177,10 +179,18 @@ public class ExternalPlayerFragment extends Fragment {
|
||||
return false;
|
||||
}
|
||||
|
||||
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",
|
||||
|
@ -34,8 +34,6 @@ import com.bumptech.glide.Glide;
|
||||
import com.joanzapata.iconify.Iconify;
|
||||
import com.joanzapata.iconify.widget.IconButton;
|
||||
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import java.util.List;
|
||||
@ -53,26 +51,27 @@ import de.danoeh.antennapod.core.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.glide.ApGlideSettings;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.download.Downloader;
|
||||
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.storage.DownloadRequestException;
|
||||
import de.danoeh.antennapod.core.storage.DownloadRequester;
|
||||
import de.danoeh.antennapod.core.util.Converter;
|
||||
import de.danoeh.antennapod.core.util.DateUtils;
|
||||
import de.danoeh.antennapod.core.util.Flavors;
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
import de.danoeh.antennapod.core.util.LongList;
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
import de.danoeh.antennapod.core.util.ShareUtils;
|
||||
import de.danoeh.antennapod.core.util.playback.Timeline;
|
||||
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.
|
||||
@ -135,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.
|
||||
@ -286,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);
|
||||
@ -572,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);
|
||||
|
@ -4,8 +4,6 @@ import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.LightingColorFilter;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.ListFragment;
|
||||
@ -26,18 +24,16 @@ import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.joanzapata.iconify.IconDrawable;
|
||||
import com.joanzapata.iconify.Iconify;
|
||||
import com.joanzapata.iconify.fonts.FontAwesomeIcons;
|
||||
import com.joanzapata.iconify.widget.IconTextView;
|
||||
|
||||
import de.danoeh.antennapod.activity.FeedSettingsActivity;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.FeedInfoActivity;
|
||||
import de.danoeh.antennapod.activity.FeedSettingsActivity;
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.adapter.DefaultActionButtonCallback;
|
||||
import de.danoeh.antennapod.adapter.FeedItemlistAdapter;
|
||||
@ -55,7 +51,6 @@ import de.danoeh.antennapod.core.feed.FeedItemFilter;
|
||||
import de.danoeh.antennapod.core.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.glide.ApGlideSettings;
|
||||
import de.danoeh.antennapod.core.glide.FastBlurTransformation;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadService;
|
||||
import de.danoeh.antennapod.core.service.download.Downloader;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
@ -71,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.
|
||||
@ -114,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
|
||||
@ -165,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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -618,11 +613,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) {
|
||||
|
@ -21,7 +21,6 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration;
|
||||
|
||||
@ -46,7 +45,6 @@ import de.danoeh.antennapod.core.service.download.Downloader;
|
||||
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.storage.DownloadRequestException;
|
||||
import de.danoeh.antennapod.core.storage.DownloadRequester;
|
||||
import de.danoeh.antennapod.core.util.Converter;
|
||||
import de.danoeh.antennapod.core.util.FeedItemUtil;
|
||||
@ -55,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
|
||||
@ -86,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;
|
||||
|
||||
@ -120,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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -425,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 + ")");
|
||||
@ -622,16 +620,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) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package de.danoeh.antennapod.fragment;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
@ -16,7 +15,6 @@ import android.widget.GridView;
|
||||
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.activity.MediaplayerInfoActivity;
|
||||
import de.danoeh.antennapod.adapter.SubscriptionsAdapter;
|
||||
import de.danoeh.antennapod.core.asynctask.FeedRemover;
|
||||
import de.danoeh.antennapod.core.dialog.ConfirmationDialog;
|
||||
@ -29,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
|
||||
@ -50,7 +48,7 @@ public class SubscriptionFragment extends Fragment {
|
||||
|
||||
private int mPosition = -1;
|
||||
|
||||
private Subscription subscription;
|
||||
private Disposable disposable;
|
||||
|
||||
public SubscriptionFragment() {
|
||||
}
|
||||
@ -96,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;
|
||||
@ -163,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)));
|
||||
@ -180,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)));
|
||||
|
@ -36,24 +36,9 @@ import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
|
||||
import com.bytehamster.lib.preferencesearch.SearchConfiguration;
|
||||
import com.bytehamster.lib.preferencesearch.SearchPreference;
|
||||
import de.danoeh.antennapod.activity.AboutActivity;
|
||||
import de.danoeh.antennapod.activity.ImportExportActivity;
|
||||
import de.danoeh.antennapod.activity.MediaplayerActivity;
|
||||
import de.danoeh.antennapod.activity.OpmlImportFromPathActivity;
|
||||
import de.danoeh.antennapod.activity.PreferenceActivity;
|
||||
import de.danoeh.antennapod.activity.StatisticsActivity;
|
||||
import de.danoeh.antennapod.core.export.html.HtmlWriter;
|
||||
import de.danoeh.antennapod.core.export.opml.OpmlWriter;
|
||||
import de.danoeh.antennapod.core.service.GpodnetSyncService;
|
||||
import de.danoeh.antennapod.dialog.AuthenticationDialog;
|
||||
import de.danoeh.antennapod.dialog.AutoFlattrPreferenceDialog;
|
||||
import de.danoeh.antennapod.dialog.GpodnetSetHostnameDialog;
|
||||
import de.danoeh.antennapod.dialog.ProxyDialog;
|
||||
import de.danoeh.antennapod.dialog.VariableSpeedDialog;
|
||||
import de.danoeh.antennapod.core.util.gui.PictureInPictureUtil;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import java.io.File;
|
||||
@ -67,18 +52,33 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import de.danoeh.antennapod.CrashReportWriter;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.AboutActivity;
|
||||
import de.danoeh.antennapod.activity.DirectoryChooserActivity;
|
||||
import de.danoeh.antennapod.activity.ImportExportActivity;
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.activity.MediaplayerActivity;
|
||||
import de.danoeh.antennapod.activity.OpmlImportFromPathActivity;
|
||||
import de.danoeh.antennapod.activity.PreferenceActivity;
|
||||
import de.danoeh.antennapod.activity.StatisticsActivity;
|
||||
import de.danoeh.antennapod.asynctask.ExportWorker;
|
||||
import de.danoeh.antennapod.core.export.ExportWriter;
|
||||
import de.danoeh.antennapod.core.export.html.HtmlWriter;
|
||||
import de.danoeh.antennapod.core.export.opml.OpmlWriter;
|
||||
import de.danoeh.antennapod.core.preferences.GpodnetPreferences;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.GpodnetSyncService;
|
||||
import de.danoeh.antennapod.core.util.flattr.FlattrUtils;
|
||||
import de.danoeh.antennapod.core.util.gui.PictureInPictureUtil;
|
||||
import de.danoeh.antennapod.dialog.AuthenticationDialog;
|
||||
import de.danoeh.antennapod.dialog.AutoFlattrPreferenceDialog;
|
||||
import de.danoeh.antennapod.dialog.ChooseDataFolderDialog;
|
||||
import rx.Observable;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import de.danoeh.antennapod.dialog.GpodnetSetHostnameDialog;
|
||||
import de.danoeh.antennapod.dialog.ProxyDialog;
|
||||
import de.danoeh.antennapod.dialog.VariableSpeedDialog;
|
||||
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;
|
||||
@ -624,7 +624,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);
|
||||
@ -702,8 +702,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;
|
||||
|
@ -57,8 +57,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 "com.google.android.exoplayer:exoplayer:$exoPlayerVersion"
|
||||
implementation "com.github.AntennaPod:AntennaPod-AudioPlayer:$audioPlayerVersion"
|
||||
|
@ -8,14 +8,7 @@ import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import de.danoeh.antennapod.core.R;
|
||||
import de.danoeh.antennapod.core.service.download.ProxyConfig;
|
||||
import de.danoeh.antennapod.core.storage.APCleanupAlgorithm;
|
||||
import de.danoeh.antennapod.core.storage.APNullCleanupAlgorithm;
|
||||
import de.danoeh.antennapod.core.storage.APQueueCleanupAlgorithm;
|
||||
import de.danoeh.antennapod.core.storage.EpisodeCleanupAlgorithm;
|
||||
import de.danoeh.antennapod.core.util.Converter;
|
||||
import de.danoeh.antennapod.core.util.download.AutoUpdateManager;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
||||
@ -27,6 +20,15 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import de.danoeh.antennapod.core.R;
|
||||
import de.danoeh.antennapod.core.service.download.ProxyConfig;
|
||||
import de.danoeh.antennapod.core.storage.APCleanupAlgorithm;
|
||||
import de.danoeh.antennapod.core.storage.APNullCleanupAlgorithm;
|
||||
import de.danoeh.antennapod.core.storage.APQueueCleanupAlgorithm;
|
||||
import de.danoeh.antennapod.core.storage.EpisodeCleanupAlgorithm;
|
||||
import de.danoeh.antennapod.core.util.Converter;
|
||||
import de.danoeh.antennapod.core.util.download.AutoUpdateManager;
|
||||
|
||||
/**
|
||||
* Provides access to preferences set by the user in the settings screen. A
|
||||
* private instance of this class must first be instantiated via
|
||||
@ -108,6 +110,7 @@ public class UserPreferences {
|
||||
private static final String PREF_RIGHT_VOLUME = "prefRightVolume";
|
||||
|
||||
// Experimental
|
||||
public static final String PREF_SONIC = "prefSonic";
|
||||
private static final String PREF_STEREO_TO_MONO = "PrefStereoToMono";
|
||||
public static final String PREF_CAST_ENABLED = "prefCast"; //Used for enabling Chromecast support
|
||||
public static final int EPISODE_CLEANUP_QUEUE = -1;
|
||||
|
@ -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,13 +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.Subscriber;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
|
||||
public class NetworkUtils {
|
||||
|
||||
@ -111,11 +111,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 +128,7 @@ public class NetworkUtils {
|
||||
|
||||
String url = media.getDownload_url();
|
||||
if(TextUtils.isEmpty(url)) {
|
||||
subscriber.onNext(0L);
|
||||
subscriber.onCompleted();
|
||||
emitter.onSuccess(0L);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -150,8 +148,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 +160,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());
|
||||
}
|
||||
|
||||
|
@ -7,12 +7,10 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.ServiceConnection;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.TypedArray;
|
||||
import android.media.MediaPlayer;
|
||||
import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
@ -24,10 +22,8 @@ import android.widget.ImageButton;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.concurrent.RejectedExecutionHandler;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import de.danoeh.antennapod.core.R;
|
||||
@ -42,13 +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.Completable;
|
||||
import rx.Observable;
|
||||
import rx.Single;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.observers.Subscribers;
|
||||
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
|
||||
@ -76,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
|
||||
@ -151,7 +147,7 @@ public abstract class PlaybackController {
|
||||
}
|
||||
|
||||
if(serviceBinder != null) {
|
||||
serviceBinder.unsubscribe();
|
||||
serviceBinder.dispose();
|
||||
}
|
||||
try {
|
||||
activity.unbindService(mConnection);
|
||||
@ -186,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;
|
||||
@ -783,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(
|
||||
@ -800,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)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -808,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
Block a user