Fix huge fragment leak when switching between tabs
This commit is contained in:
parent
a90fa14b7f
commit
35a233462d
1 changed files with 11 additions and 5 deletions
|
@ -437,7 +437,8 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeFragment(Fragment newFragment, FragmentsAvailable newFragmentType, boolean withoutAnimation) {
|
private void changeFragment(Fragment newFragment, FragmentsAvailable newFragmentType, boolean withoutAnimation) {
|
||||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
FragmentManager fm = getFragmentManager();
|
||||||
|
FragmentTransaction transaction = fm.beginTransaction();
|
||||||
|
|
||||||
/*if (!withoutAnimation && !isAnimationDisabled && currentFragment.shouldAnimate()) {
|
/*if (!withoutAnimation && !isAnimationDisabled && currentFragment.shouldAnimate()) {
|
||||||
if (newFragmentType.isRightOf(currentFragment)) {
|
if (newFragmentType.isRightOf(currentFragment)) {
|
||||||
|
@ -454,14 +455,19 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if (newFragmentType != FragmentsAvailable.DIALER
|
if (newFragmentType != FragmentsAvailable.DIALER
|
||||||
|| newFragmentType != FragmentsAvailable.CONTACTS_LIST
|
&& newFragmentType != FragmentsAvailable.CONTACTS_LIST
|
||||||
|| newFragmentType != FragmentsAvailable.CHAT_LIST
|
&& newFragmentType != FragmentsAvailable.CHAT_LIST
|
||||||
|| newFragmentType != FragmentsAvailable.HISTORY_LIST) {
|
&& newFragmentType != FragmentsAvailable.HISTORY_LIST) {
|
||||||
transaction.addToBackStack(newFragmentType.toString());
|
transaction.addToBackStack(newFragmentType.toString());
|
||||||
|
} else {
|
||||||
|
while (fm.getBackStackEntryCount() > 0) {
|
||||||
|
fm.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction.replace(R.id.fragmentContainer, newFragment, newFragmentType.toString());
|
transaction.replace(R.id.fragmentContainer, newFragment, newFragmentType.toString());
|
||||||
transaction.commitAllowingStateLoss();
|
transaction.commitAllowingStateLoss();
|
||||||
getFragmentManager().executePendingTransactions();
|
fm.executePendingTransactions();
|
||||||
|
|
||||||
currentFragment = newFragmentType;
|
currentFragment = newFragmentType;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue