use of com.nutomic.syncthingandroid.fragments.DrawerFragment in project syncthing-android by syncthing.
the class MainActivity method onCreate.
/**
* Initializes tab navigation.
*/
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((SyncthingApp) getApplication()).component().inject(this);
setContentView(R.layout.activity_main);
mDrawerLayout = findViewById(R.id.drawer_layout);
FragmentManager fm = getSupportFragmentManager();
if (savedInstanceState != null) {
mFolderListFragment = (FolderListFragment) fm.getFragment(savedInstanceState, FolderListFragment.class.getName());
mDeviceListFragment = (DeviceListFragment) fm.getFragment(savedInstanceState, DeviceListFragment.class.getName());
mDrawerFragment = (DrawerFragment) fm.getFragment(savedInstanceState, DrawerFragment.class.getName());
} else {
mFolderListFragment = new FolderListFragment();
mDeviceListFragment = new DeviceListFragment();
mDrawerFragment = new DrawerFragment();
}
mViewPager = findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
TabLayout tabLayout = findViewById(R.id.tabContainer);
tabLayout.setupWithViewPager(mViewPager);
if (savedInstanceState != null) {
mViewPager.setCurrentItem(savedInstanceState.getInt("currentTab"));
if (savedInstanceState.getBoolean(IS_SHOWING_RESTART_DIALOG)) {
showRestartDialog();
}
mBatteryOptimizationDialogDismissed = savedInstanceState.getBoolean(BATTERY_DIALOG_DISMISSED);
if (savedInstanceState.getBoolean(IS_QRCODE_DIALOG_DISPLAYED)) {
showQrCodeDialog(savedInstanceState.getString(DEVICEID_KEY), savedInstanceState.getParcelable(QRCODE_BITMAP_KEY));
}
}
fm.beginTransaction().replace(R.id.drawer, mDrawerFragment).commit();
mDrawerToggle = new Toggle(this, mDrawerLayout);
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
mDrawerLayout.addDrawerListener(mDrawerToggle);
setOptimalDrawerWidth(findViewById(R.id.drawer));
// SyncthingService needs to be started from this activity as the user
// can directly launch this activity from the recent activity switcher.
Intent serviceIntent = new Intent(this, SyncthingService.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(serviceIntent);
} else {
startService(serviceIntent);
}
onNewIntent(getIntent());
}
Aggregations