From c40f6c3330ceade83ecd9277ded527d414631157 Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 15 Jan 2024 09:06:30 +0100 Subject: [PATCH] Fix a crash when searching tags --- .../mastodon/activities/HashTagActivity.java | 4 +++- .../android/mastodon/ui/drawer/TagAdapter.java | 15 +++++++++++---- .../timeline/FragmentMastodonTimeline.java | 1 - 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/HashTagActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/HashTagActivity.java index 4dd56586..db07020a 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/HashTagActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/HashTagActivity.java @@ -91,8 +91,10 @@ public class HashTagActivity extends BaseActivity { if( bundle != null) { tag = bundle.getString(Helper.ARG_SEARCH_KEYWORD, null); } - if (tag == null) + if (tag == null) { finish(); + return; + } pinnedTag = null; followedTag = null; mutedTag = null; diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/TagAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/TagAdapter.java index 81e1b67c..8ee8508d 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/TagAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/TagAdapter.java @@ -14,6 +14,8 @@ package app.fedilab.android.mastodon.ui.drawer; * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see . */ +import static app.fedilab.android.BaseMainActivity.currentAccount; + import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; @@ -41,6 +43,7 @@ import app.fedilab.android.databinding.DrawerTagBinding; import app.fedilab.android.mastodon.activities.HashTagActivity; import app.fedilab.android.mastodon.client.entities.api.History; import app.fedilab.android.mastodon.client.entities.api.Tag; +import app.fedilab.android.mastodon.client.entities.app.CachedBundle; import app.fedilab.android.mastodon.helper.Helper; public class TagAdapter extends RecyclerView.Adapter { @@ -100,10 +103,14 @@ public class TagAdapter extends RecyclerView.Adapter { tagViewHolder.binding.getRoot().setOnClickListener(v1 -> { Intent intent = new Intent(context, HashTagActivity.class); - Bundle b = new Bundle(); - b.putString(Helper.ARG_SEARCH_KEYWORD, tag.name.trim()); - intent.putExtras(b); - context.startActivity(intent); + Bundle args = new Bundle(); + args.putString(Helper.ARG_SEARCH_KEYWORD, tag.name.trim()); + new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> { + Bundle bundle = new Bundle(); + bundle.putLong(Helper.ARG_INTENT_ID, bundleId); + intent.putExtras(bundle); + context.startActivity(intent); + }); }); } diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java index 20232c4e..6a64147c 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java @@ -27,7 +27,6 @@ import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; import android.os.Looper; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup;