Fixed missing fragment on tablets after rotation

This commit is contained in:
Sylvain Berfini 2016-07-20 14:30:03 +02:00
parent 0a1f2370a1
commit 7a539b6496
3 changed files with 15 additions and 2 deletions

View file

@ -77,7 +77,6 @@
<LinearLayout
android:id="@+id/fragmentContainer2"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"

View file

@ -77,7 +77,6 @@
<LinearLayout
android:id="@+id/fragmentContainer2"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"

View file

@ -200,6 +200,8 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
currentFragment = nextFragment = FragmentsAvailable.EMPTY;
if (savedInstanceState == null) {
changeCurrentFragment(FragmentsAvailable.DIALER, getIntent().getExtras());
} else {
currentFragment = (FragmentsAvailable) savedInstanceState.getSerializable("currentFragment");
}
mListener = new LinphoneCoreListenerBase(){
@ -1284,6 +1286,12 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
checkAndRequestReadContactsPermission();
}
}
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putSerializable("currentFragment", currentFragment);
super.onSaveInstanceState(outState);
}
@Override
protected void onResume() {
@ -1297,6 +1305,13 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
if (lc != null) {
lc.addListener(mListener);
}
if (isTablet()) {
LinearLayout ll = (LinearLayout) findViewById(R.id.fragmentContainer2);
if (currentFragment == FragmentsAvailable.DIALER) {
ll.setVisibility(View.GONE);
}
}
refreshAccounts();