Make instance catalog work if joinmastodon.org is unavailable
This commit is contained in:
parent
19d0af01fd
commit
34ebd35fc0
|
@ -142,7 +142,8 @@ public class InstanceCatalogFragment extends BaseRecyclerFragment<CatalogInstanc
|
|||
|
||||
@Override
|
||||
public void onError(ErrorResponse error){
|
||||
InstanceCatalogFragment.this.onError(error);
|
||||
error.showToast(getActivity());
|
||||
onDataLoaded(Collections.emptyList(), false);
|
||||
}
|
||||
})
|
||||
.execNoAuth("");
|
||||
|
@ -155,6 +156,24 @@ public class InstanceCatalogFragment extends BaseRecyclerFragment<CatalogInstanc
|
|||
all.category="all";
|
||||
categories.add(all);
|
||||
result.stream().sorted(Comparator.comparingInt((CatalogCategory cc)->cc.serversCount).reversed()).forEach(categories::add);
|
||||
updateCategories();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorResponse error){
|
||||
getCategoriesRequest=null;
|
||||
error.showToast(getActivity());
|
||||
CatalogCategory all=new CatalogCategory();
|
||||
all.category="all";
|
||||
categories.add(all);
|
||||
updateCategories();
|
||||
}
|
||||
})
|
||||
.execNoAuth("");
|
||||
}
|
||||
|
||||
private void updateCategories(){
|
||||
categoriesList.removeAllTabs();
|
||||
for(CatalogCategory cat:categories){
|
||||
int titleRes=getTitleForCategory(cat.category);
|
||||
TabLayout.Tab tab=categoriesList.newTab().setText(titleRes!=0 ? getString(titleRes) : cat.category).setCustomView(R.layout.item_instance_category);
|
||||
|
@ -164,15 +183,6 @@ public class InstanceCatalogFragment extends BaseRecyclerFragment<CatalogInstanc
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorResponse error){
|
||||
getCategoriesRequest=null;
|
||||
error.showToast(getActivity());
|
||||
}
|
||||
})
|
||||
.execNoAuth("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy(){
|
||||
super.onDestroy();
|
||||
|
|
Loading…
Reference in New Issue