Fix an issue

This commit is contained in:
tom79 2020-03-10 19:36:56 +01:00
parent f716688a8d
commit 381bab2028
3 changed files with 24 additions and 13 deletions

View File

@ -2545,7 +2545,7 @@ public abstract class BaseMainActivity extends BaseActivity
TextView actionView = item.getActionView().findViewById(R.id.counter);
if(actionView != null) {
if (unread > 0) {
actionView.setText(unread);
actionView.setText(String.valueOf(unread));
actionView.setVisibility(View.VISIBLE);
}else{
actionView.setVisibility(View.GONE);

View File

@ -620,22 +620,13 @@ public class API {
if( resobj.getString("ends_at").compareTo("null") != 0) {
announcement.setEndAt(Helper.mstStringToDate(context, resobj.getString("ends_at")));
}
announcement.setRead(resobj.getBoolean("read"));
announcement.setReactions(parseReaction(resobj.getJSONArray("reactions")));
List<Mention> mentions = new ArrayList<>();
JSONArray arrayMention = resobj.getJSONArray("mentions");
for (int j = 0; j < arrayMention.length(); j++) {
JSONObject menObj = arrayMention.getJSONObject(j);
Mention mention = new Mention();
mention.setId(menObj.get("id").toString());
mention.setUrl(menObj.get("url").toString());
mention.setAcct(menObj.get("acct").toString());
mention.setUsername(menObj.get("username").toString());
mentions.add(mention);
}
announcement.setMentions(mentions);
List<Tag> tags = new ArrayList<>();
JSONArray arrayTag = resobj.getJSONArray("tags");
@ -661,6 +652,23 @@ public class API {
announcement.setEmojis(new ArrayList<>());
}
List<Mention> mentions = new ArrayList<>();
try {
JSONArray arrayMention = resobj.getJSONArray("mentions");
for (int j = 0; j < arrayMention.length(); j++) {
JSONObject menObj = arrayMention.getJSONObject(j);
Mention mention = new Mention();
mention.setId(menObj.get("id").toString());
mention.setUrl(menObj.get("url").toString());
mention.setAcct(menObj.get("acct").toString());
mention.setUsername(menObj.get("username").toString());
mentions.add(mention);
}
announcement.setMentions(mentions);
} catch (Exception e) {
announcement.setMentions(new ArrayList<>());
}
} catch (JSONException | ParseException e) {
e.printStackTrace();
}

View File

@ -1692,6 +1692,9 @@ public class Helper {
MenuItem nav_trends = menu.findItem(R.id.nav_trends);
if (nav_trends != null)
nav_trends.setVisible(false);
MenuItem nav_announcements = menu.findItem(R.id.nav_announcements);
if (nav_announcements != null)
nav_announcements.setVisible(false);
MenuItem nav_peertube = menu.findItem(R.id.nav_peertube);
if (nav_peertube != null)
nav_peertube.setVisible(false);