Fix some crashes

This commit is contained in:
tom79 2019-05-24 15:37:56 +02:00
parent 67ab25a60a
commit 764078d446
2 changed files with 24 additions and 18 deletions

View File

@ -2153,20 +2153,28 @@ public abstract class BaseMainActivity extends BaseActivity
public void updateHomeCounter(){ public void updateHomeCounter(){
if( tabLayout.getTabAt(0) == null ) int i = 0;
return; if( timelines != null && timelines.size() > 0){
//noinspection ConstantConditions for(ManageTimelines tl: timelines){
View tabHome = tabLayout.getTabAt(0).getCustomView(); if( tl.getType() == ManageTimelines.Type.HOME){
if( tabHome == null) if( tabLayout.getTabCount() > i) {
return; View tabHome = tabLayout.getTabAt(i).getCustomView();
TextView tabCounterHome = tabHome.findViewById(R.id.tab_counter); if( tabHome != null){
tabCounterHome.setText(String.valueOf(countNewStatus)); TextView tabCounterHome = tabHome.findViewById(R.id.tab_counter);
if( countNewStatus> 0){ tabCounterHome.setText(String.valueOf(countNewStatus));
//New data are available if( countNewStatus> 0){
//The fragment is not displayed, so the counter is displayed //New data are available
tabCounterHome.setVisibility(View.VISIBLE); //The fragment is not displayed, so the counter is displayed
}else { tabCounterHome.setVisibility(View.VISIBLE);
tabCounterHome.setVisibility(View.GONE); }else {
tabCounterHome.setVisibility(View.GONE);
}
}
}
}
i++;
}
} }
} }

View File

@ -1471,13 +1471,13 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
if ((getItemViewType(viewHolder.getAdapterPosition()) != COMPACT_STATUS) && getItemViewType(viewHolder.getAdapterPosition()) != CONSOLE_STATUS && (trans_forced || (translator != Helper.TRANS_NONE && currentLocale != null && differentLanguage))) { if ((getItemViewType(viewHolder.getAdapterPosition()) != COMPACT_STATUS) && getItemViewType(viewHolder.getAdapterPosition()) != CONSOLE_STATUS && (trans_forced || (translator != Helper.TRANS_NONE && currentLocale != null && differentLanguage))) {
if (status.getSpoiler_text() != null && status.getSpoiler_text().length() > 0) { if (status.getSpoiler_text() != null && status.getSpoiler_text().length() > 0) {
if (status.isSpoilerShown() || getItemViewType(viewHolder.getAdapterPosition()) == FOCUSED_STATUS) { if (status.isSpoilerShown() || expand_cw || getItemViewType(viewHolder.getAdapterPosition()) == FOCUSED_STATUS) {
holder.status_translate.setVisibility(View.VISIBLE); holder.status_translate.setVisibility(View.VISIBLE);
} else { } else {
holder.status_translate.setVisibility(View.GONE); holder.status_translate.setVisibility(View.GONE);
} }
} else if (status.getReblog() != null && status.getReblog().getSpoiler_text() != null && status.getReblog().getSpoiler_text().length() > 0) { } else if (status.getReblog() != null && status.getReblog().getSpoiler_text() != null && status.getReblog().getSpoiler_text().length() > 0) {
if (status.isSpoilerShown() || getItemViewType(viewHolder.getAdapterPosition()) == FOCUSED_STATUS) { if (status.isSpoilerShown() || expand_cw || getItemViewType(viewHolder.getAdapterPosition()) == FOCUSED_STATUS) {
holder.status_translate.setVisibility(View.VISIBLE); holder.status_translate.setVisibility(View.VISIBLE);
} else { } else {
holder.status_translate.setVisibility(View.GONE); holder.status_translate.setVisibility(View.GONE);
@ -1711,10 +1711,8 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
if (status.isTranslationShown() && status.getContentSpanTranslated() != null) { if (status.isTranslationShown() && status.getContentSpanTranslated() != null) {
holder.status_content_translated.setText(status.getContentSpanTranslated(), TextView.BufferType.SPANNABLE); holder.status_content_translated.setText(status.getContentSpanTranslated(), TextView.BufferType.SPANNABLE);
holder.status_content.setVisibility(View.GONE);
holder.status_content_translated_container.setVisibility(View.VISIBLE); holder.status_content_translated_container.setVisibility(View.VISIBLE);
} else { //Toot is not translated } else { //Toot is not translated
holder.status_content.setVisibility(View.VISIBLE);
holder.status_content_translated_container.setVisibility(View.GONE); holder.status_content_translated_container.setVisibility(View.GONE);
} }