Fix error message when adding the first list

This commit is contained in:
Thomas 2022-11-23 15:49:31 +01:00
parent 4f8377d9d9
commit 9c728f24c3

View file

@ -279,8 +279,15 @@ public class MastodonListActivity extends BaseActivity implements MastodonListAd
if (mastodonListList == null) { if (mastodonListList == null) {
mastodonListList = new ArrayList<>(); mastodonListList = new ArrayList<>();
} }
if (newMastodonList != null && mastodonListAdapter != null) { if (newMastodonList != null) {
mastodonListList.add(0, newMastodonList); mastodonListList.add(0, newMastodonList);
if (mastodonListAdapter == null) {
mastodonListAdapter = new MastodonListAdapter(mastodonListList);
mastodonListAdapter.actionOnList = MastodonListActivity.this;
binding.notContent.setVisibility(View.GONE);
binding.recyclerView.setAdapter(mastodonListAdapter);
binding.recyclerView.setLayoutManager(new LinearLayoutManager(MastodonListActivity.this));
}
mastodonListAdapter.notifyItemInserted(0); mastodonListAdapter.notifyItemInserted(0);
} else { } else {
Toasty.error(MastodonListActivity.this, getString(R.string.toast_error), Toasty.LENGTH_LONG).show(); Toasty.error(MastodonListActivity.this, getString(R.string.toast_error), Toasty.LENGTH_LONG).show();