(Hopefully) fixed crash when user moved on after loading the labels took too long
This commit is contained in:
parent
8057980f6c
commit
ccfeb5b479
@ -104,6 +104,8 @@ public class MainActivity extends AppCompatActivity
|
|||||||
|
|
||||||
private static WeakReference<MainActivity> instance;
|
private static WeakReference<MainActivity> instance;
|
||||||
|
|
||||||
|
private boolean active;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not the activity is in two-pane mode, i.e. running on a tablet
|
* Whether or not the activity is in two-pane mode, i.e. running on a tablet
|
||||||
* device.
|
* device.
|
||||||
@ -196,20 +198,21 @@ public class MainActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
private <F extends Fragment & ListHolder> void changeList(F listFragment) {
|
private <F extends Fragment & ListHolder> void changeList(F listFragment) {
|
||||||
|
if (active) {
|
||||||
|
FragmentTransaction transaction = getSupportFragmentManager()
|
||||||
|
.beginTransaction();
|
||||||
|
transaction.replace(R.id.item_list, listFragment);
|
||||||
|
Fragment detailFragment = getSupportFragmentManager().findFragmentById(R.id.message_detail_container);
|
||||||
|
if (detailFragment != null) {
|
||||||
|
transaction.remove(detailFragment);
|
||||||
|
}
|
||||||
|
transaction.addToBackStack(null).commit();
|
||||||
|
|
||||||
FragmentTransaction transaction = getSupportFragmentManager()
|
if (twoPane) {
|
||||||
.beginTransaction();
|
// In two-pane mode, list items should be given the
|
||||||
transaction.replace(R.id.item_list, listFragment);
|
// 'activated' state when touched.
|
||||||
Fragment detailFragment = getSupportFragmentManager().findFragmentById(R.id.message_detail_container);
|
listFragment.setActivateOnItemClick(true);
|
||||||
if (detailFragment != null) {
|
}
|
||||||
transaction.remove(detailFragment);
|
|
||||||
}
|
|
||||||
transaction.addToBackStack(null).commit();
|
|
||||||
|
|
||||||
if (twoPane) {
|
|
||||||
// In two-pane mode, list items should be given the
|
|
||||||
// 'activated' state when touched.
|
|
||||||
listFragment.setActivateOnItemClick(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,7 +340,7 @@ public class MainActivity extends AppCompatActivity
|
|||||||
ListHolder listHolder = (ListHolder) listFragment;
|
ListHolder listHolder = (ListHolder) listFragment;
|
||||||
if (listHolder.showPreviousList()) {
|
if (listHolder.showPreviousList()) {
|
||||||
IDrawerItem drawerItem = drawer.getDrawerItem(listHolder.getCurrentLabel());
|
IDrawerItem drawerItem = drawer.getDrawerItem(listHolder.getCurrentLabel());
|
||||||
if (drawerItem != null){
|
if (drawerItem != null) {
|
||||||
drawer.setSelection(drawerItem);
|
drawer.setSelection(drawerItem);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -414,9 +417,16 @@ public class MainActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
updateNodeSwitch();
|
updateNodeSwitch();
|
||||||
Singleton.getMessageListener(this).resetNotification();
|
Singleton.getMessageListener(this).resetNotification();
|
||||||
|
active = true;
|
||||||
super.onResume();
|
super.onResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
active = false;
|
||||||
|
}
|
||||||
|
|
||||||
public void addIdentityEntry(BitmessageAddress identity) {
|
public void addIdentityEntry(BitmessageAddress identity) {
|
||||||
IProfile newProfile = new ProfileDrawerItem()
|
IProfile newProfile = new ProfileDrawerItem()
|
||||||
.withIcon(new Identicon(identity))
|
.withIcon(new Identicon(identity))
|
||||||
|
Loading…
Reference in New Issue
Block a user