mirror of
https://github.com/Xcreen/RestSMS.git
synced 2026-05-19 06:09:22 -04:00
Bug-Fix: Dont switch fragment on orientation change
This commit is contained in:
@@ -42,13 +42,16 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||
navigationView = findViewById(R.id.nav_view);
|
||||
navigationView.setNavigationItemSelectedListener(this);
|
||||
|
||||
//Set Home Fragment
|
||||
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
|
||||
try {
|
||||
Fragment homeFragment = HomeFragment.class.newInstance();
|
||||
fragmentTransaction.replace(R.id.main_framelayout, homeFragment).commit();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
//Dont replace Fragment, on orientation-change
|
||||
if(savedInstanceState == null) {
|
||||
//Set Home Fragment
|
||||
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
|
||||
try {
|
||||
Fragment homeFragment = HomeFragment.class.newInstance();
|
||||
fragmentTransaction.replace(R.id.main_framelayout, homeFragment).commit();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user