From 8053e8bb055397b2c053639be2047cf1f14f7b33 Mon Sep 17 00:00:00 2001 From: sk Date: Sun, 28 May 2023 19:51:29 +0200 Subject: [PATCH] fix hashtag search crash on akkoma servers closes mastodon#468 closes sk22#523 --- .../fragments/discover/TrendingHashtagsFragment.java | 6 ++++++ .../android/ui/displayitems/HashtagStatusDisplayItem.java | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/TrendingHashtagsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/TrendingHashtagsFragment.java index bcb3d7442..9ded86b9f 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/TrendingHashtagsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/TrendingHashtagsFragment.java @@ -98,6 +98,12 @@ public class TrendingHashtagsFragment extends BaseRecyclerFragment impl @Override public void onBind(Hashtag item){ title.setText('#'+item.name); + if (item.history == null || item.history.isEmpty()) { + subtitle.setText(null); + chart.setVisibility(View.GONE); + return; + } + chart.setVisibility(View.VISIBLE); int numPeople=item.history.get(0).accounts; if(item.history.size()>1) numPeople+=item.history.get(1).accounts; diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HashtagStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HashtagStatusDisplayItem.java index cc2f3d2b8..586fb45a9 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HashtagStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HashtagStatusDisplayItem.java @@ -1,6 +1,7 @@ package org.joinmastodon.android.ui.displayitems; import android.content.Context; +import android.view.View; import android.view.ViewGroup; import android.widget.TextView; @@ -37,6 +38,12 @@ public class HashtagStatusDisplayItem extends StatusDisplayItem{ public void onBind(HashtagStatusDisplayItem _item){ Hashtag item=_item.tag; title.setText('#'+item.name); + if (item.history == null || item.history.isEmpty()) { + subtitle.setText(null); + chart.setVisibility(View.GONE); + return; + } + chart.setVisibility(View.VISIBLE); int numPeople=item.history.get(0).accounts; if(item.history.size()>1) numPeople+=item.history.get(1).accounts;