From dc3b124e0b8c8998636bb2c49676d118e45fee9f Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Sun, 4 Oct 2020 21:53:03 +0200 Subject: [PATCH] Allow to go back to search results list --- .../java/de/danoeh/antennapod/activity/MainActivity.java | 7 ++++++- .../danoeh/antennapod/activity/OnlineFeedViewActivity.java | 2 ++ .../danoeh/antennapod/fragment/OnlineSearchFragment.java | 2 ++ .../antennapod/fragment/gpodnet/PodcastListFragment.java | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) 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 f772cb084..371f15de7 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -71,6 +71,7 @@ public class MainActivity extends CastEnabledActivity { public static final String EXTRA_FEED_ID = "fragment_feed_id"; public static final String EXTRA_OPEN_PLAYER = "open_player"; public static final String EXTRA_REFRESH_ON_START = "refresh_on_start"; + public static final String EXTRA_STARTED_FROM_SEARCH = "started_from_search"; private @Nullable DrawerLayout drawerLayout; private @Nullable ActionBarDrawerToggle drawerToggle; @@ -477,7 +478,11 @@ public class MainActivity extends CastEnabledActivity { if (tag != null) { loadFragment(tag, args); } else if (feedId > 0) { - loadFeedFragmentById(feedId, args); + if (intent.getBooleanExtra(EXTRA_STARTED_FROM_SEARCH, false)) { + loadChildFragment(FeedItemlistFragment.newInstance(feedId)); + } else { + loadFeedFragmentById(feedId, args); + } } sheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); } else if (intent.getBooleanExtra(EXTRA_OPEN_PLAYER, false)) { 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 f6623d5dc..3bacdc75f 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java @@ -508,6 +508,8 @@ public class OnlineFeedViewActivity extends AppCompatActivity { // feed.getId() is always 0, we have to retrieve the id from the feed list from // the database Intent intent = MainActivity.getIntentToOpenFeed(this, getFeedId(feed)); + intent.putExtra(MainActivity.EXTRA_STARTED_FROM_SEARCH, + getIntent().getBooleanExtra(MainActivity.EXTRA_STARTED_FROM_SEARCH, false)); finish(); startActivity(intent); } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/OnlineSearchFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/OnlineSearchFragment.java index e8bd5a1e1..037c687a1 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/OnlineSearchFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/OnlineSearchFragment.java @@ -18,6 +18,7 @@ import android.widget.GridView; import android.widget.ProgressBar; import android.widget.TextView; import de.danoeh.antennapod.R; +import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.activity.OnlineFeedViewActivity; import de.danoeh.antennapod.adapter.itunes.ItunesAdapter; import de.danoeh.antennapod.discovery.PodcastSearchResult; @@ -101,6 +102,7 @@ public class OnlineSearchFragment extends Fragment { PodcastSearchResult podcast = searchResults.get(position); Intent intent = new Intent(getActivity(), OnlineFeedViewActivity.class); intent.putExtra(OnlineFeedViewActivity.ARG_FEEDURL, podcast.feedUrl); + intent.putExtra(MainActivity.EXTRA_STARTED_FROM_SEARCH, true); startActivity(intent); }); progressBar = root.findViewById(R.id.progressBar); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/PodcastListFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/PodcastListFragment.java index d5cac07f1..4cb50e2f4 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/PodcastListFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/PodcastListFragment.java @@ -104,6 +104,7 @@ public abstract class PodcastListFragment extends Fragment { Log.d(TAG, "Selected podcast: " + selection.toString()); Intent intent = new Intent(getActivity(), OnlineFeedViewActivity.class); intent.putExtra(OnlineFeedViewActivity.ARG_FEEDURL, selection.getUrl()); + intent.putExtra(MainActivity.EXTRA_STARTED_FROM_SEARCH, true); startActivity(intent); }