diff options
author | orionlee <orionlee@yahoo.com> | 2019-09-21 14:08:48 -0700 |
---|---|---|
committer | orionlee <orionlee@yahoo.com> | 2019-09-21 14:08:48 -0700 |
commit | 0be47a8d19a304cfb3f1158ab695dd21ddf4b844 (patch) | |
tree | 2663f02a4759d8f826fd10b316a5054b072b0847 /app/src | |
parent | fcb1a180adf6fd893929b1b041628fd5368d9a08 (diff) | |
download | AntennaPod-0be47a8d19a304cfb3f1158ab695dd21ddf4b844.zip |
#2929 - refactor common "Open Podcast" intent construction
Diffstat (limited to 'app/src')
3 files changed, 18 insertions, 12 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java index a0a3c85c2..08686bd02 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -2,6 +2,7 @@ package de.danoeh.antennapod.activity; import android.annotation.TargetApi; import android.app.ProgressDialog; +import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; @@ -10,6 +11,7 @@ import android.database.DataSetObserver; import android.os.Build; import android.os.Bundle; import android.os.Handler; +import android.support.annotation.NonNull; import android.support.annotation.VisibleForTesting; import android.support.design.widget.Snackbar; import android.support.v4.app.Fragment; @@ -32,9 +34,11 @@ import android.widget.Toast; import com.bumptech.glide.Glide; -import de.danoeh.antennapod.preferences.PreferenceUpgrader; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.Validate; +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; import java.util.List; @@ -67,13 +71,11 @@ import de.danoeh.antennapod.fragment.PlaybackHistoryFragment; import de.danoeh.antennapod.fragment.QueueFragment; import de.danoeh.antennapod.fragment.SubscriptionFragment; import de.danoeh.antennapod.menuhandler.NavDrawerActivity; +import de.danoeh.antennapod.preferences.PreferenceUpgrader; import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; -import org.greenrobot.eventbus.EventBus; -import org.greenrobot.eventbus.Subscribe; -import org.greenrobot.eventbus.ThreadMode; /** * The activity that is shown when the user launches the app. @@ -93,7 +95,7 @@ public class MainActivity extends CastEnabledActivity implements NavDrawerActivi public static final String EXTRA_NAV_INDEX = "nav_index"; public static final String EXTRA_FRAGMENT_TAG = "fragment_tag"; public static final String EXTRA_FRAGMENT_ARGS = "fragment_args"; - public static final String EXTRA_FEED_ID = "fragment_feed_id"; + private static final String EXTRA_FEED_ID = "fragment_feed_id"; private static final String SAVE_BACKSTACK_COUNT = "backstackCount"; private static final String SAVE_TITLE = "title"; @@ -127,6 +129,14 @@ public class MainActivity extends CastEnabledActivity implements NavDrawerActivi private long lastBackButtonPressTime = 0; + @NonNull + public static Intent getIntentToOpenFeed(@NonNull Context context, long feedId) { + Intent intent = new Intent(context.getApplicationContext(), MainActivity.class); + intent.putExtra(MainActivity.EXTRA_FEED_ID, feedId); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + return intent; + } + @Override public void onCreate(Bundle savedInstanceState) { setTheme(UserPreferences.getNoTitleTheme()); diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java index 6ac693f5c..5a12664c9 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java @@ -454,9 +454,7 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements if(media instanceof FeedMedia) { FeedItem feedItem = ((FeedMedia)media).getItem(); if (feedItem != null) { - Intent intent = new Intent(getApplicationContext(), MainActivity.class); - intent.putExtra(MainActivity.EXTRA_FEED_ID, feedItem.getFeedId()); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + Intent intent = MainActivity.getIntentToOpenFeed(this, feedItem.getFeedId()); startActivity(intent); } } diff --git a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java index ea7687bc9..c38eb7d47 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java @@ -32,7 +32,6 @@ import android.widget.TextView; import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; -import de.danoeh.antennapod.core.glide.FastBlurTransformation; import org.apache.commons.lang3.StringUtils; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -55,6 +54,7 @@ import de.danoeh.antennapod.core.feed.Feed; import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedPreferences; 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.DownloadRequest; import de.danoeh.antennapod.core.service.download.DownloadStatus; @@ -442,11 +442,9 @@ public class OnlineFeedViewActivity extends AppCompatActivity { subscribeButton.setOnClickListener(v -> { if(feedInFeedlist(feed)) { - Intent intent = new Intent(OnlineFeedViewActivity.this, MainActivity.class); // feed.getId() is always 0, we have to retrieve the id from the feed list from // the database - intent.putExtra(MainActivity.EXTRA_FEED_ID, getFeedId(feed)); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + Intent intent = MainActivity.getIntentToOpenFeed(this, getFeedId(feed)); startActivity(intent); } else { Feed f = new Feed(selectedDownloadUrl, null, feed.getTitle()); |