(Hopefully) fixed crash when user moved on after loading the labels took too long

This commit is contained in:
Christian Basler 2017-07-22 08:16:06 +02:00
parent 8057980f6c
commit ccfeb5b479

View File

@ -104,6 +104,8 @@ public class MainActivity extends AppCompatActivity
private static WeakReference<MainActivity> instance;
private boolean active;
/**
* Whether or not the activity is in two-pane mode, i.e. running on a tablet
* device.
@ -196,7 +198,7 @@ public class MainActivity extends AppCompatActivity
}
private <F extends Fragment & ListHolder> void changeList(F listFragment) {
if (active) {
FragmentTransaction transaction = getSupportFragmentManager()
.beginTransaction();
transaction.replace(R.id.item_list, listFragment);
@ -212,6 +214,7 @@ public class MainActivity extends AppCompatActivity
listFragment.setActivateOnItemClick(true);
}
}
}
private void createDrawer(Toolbar toolbar) {
final ArrayList<IProfile> profiles = new ArrayList<>();
@ -337,7 +340,7 @@ public class MainActivity extends AppCompatActivity
ListHolder listHolder = (ListHolder) listFragment;
if (listHolder.showPreviousList()) {
IDrawerItem drawerItem = drawer.getDrawerItem(listHolder.getCurrentLabel());
if (drawerItem != null){
if (drawerItem != null) {
drawer.setSelection(drawerItem);
}
return;
@ -414,9 +417,16 @@ public class MainActivity extends AppCompatActivity
}
updateNodeSwitch();
Singleton.getMessageListener(this).resetNotification();
active = true;
super.onResume();
}
@Override
protected void onPause() {
super.onPause();
active = false;
}
public void addIdentityEntry(BitmessageAddress identity) {
IProfile newProfile = new ProfileDrawerItem()
.withIcon(new Identicon(identity))