Fix a crash when searching tags

This commit is contained in:
Thomas 2024-01-15 09:06:30 +01:00
parent 6b03aef11b
commit c40f6c3330
3 changed files with 14 additions and 6 deletions

View file

@ -91,8 +91,10 @@ public class HashTagActivity extends BaseActivity {
if( bundle != null) { if( bundle != null) {
tag = bundle.getString(Helper.ARG_SEARCH_KEYWORD, null); tag = bundle.getString(Helper.ARG_SEARCH_KEYWORD, null);
} }
if (tag == null) if (tag == null) {
finish(); finish();
return;
}
pinnedTag = null; pinnedTag = null;
followedTag = null; followedTag = null;
mutedTag = null; mutedTag = null;

View file

@ -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, * You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */ * see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; 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.activities.HashTagActivity;
import app.fedilab.android.mastodon.client.entities.api.History; 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.api.Tag;
import app.fedilab.android.mastodon.client.entities.app.CachedBundle;
import app.fedilab.android.mastodon.helper.Helper; import app.fedilab.android.mastodon.helper.Helper;
public class TagAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class TagAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@ -100,11 +103,15 @@ public class TagAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
tagViewHolder.binding.getRoot().setOnClickListener(v1 -> { tagViewHolder.binding.getRoot().setOnClickListener(v1 -> {
Intent intent = new Intent(context, HashTagActivity.class); Intent intent = new Intent(context, HashTagActivity.class);
Bundle b = new Bundle(); Bundle args = new Bundle();
b.putString(Helper.ARG_SEARCH_KEYWORD, tag.name.trim()); args.putString(Helper.ARG_SEARCH_KEYWORD, tag.name.trim());
intent.putExtras(b); new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
context.startActivity(intent); context.startActivity(intent);
}); });
});
} }
public int getCount() { public int getCount() {

View file

@ -27,7 +27,6 @@ import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;