Upgrade MaterialDrawer to 3.0.9
This commit is contained in:
@@ -33,6 +33,7 @@ import com.mikepenz.community_material_typeface_library.CommunityMaterial;
|
||||
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
|
||||
import com.mikepenz.iconics.typeface.FontAwesome;
|
||||
import com.mikepenz.materialdrawer.Drawer;
|
||||
import com.mikepenz.materialdrawer.DrawerBuilder;
|
||||
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem;
|
||||
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
|
||||
|
||||
@@ -56,7 +57,7 @@ public class MainActivity extends BaseNfcActivity implements FabContainer, OnBac
|
||||
public static final String EXTRA_SKIP_FIRST_TIME = "skip_first_time";
|
||||
public static final String EXTRA_INIT_FRAG = "init_frag";
|
||||
|
||||
public Drawer.Result mDrawerResult;
|
||||
public Drawer mDrawer;
|
||||
private Toolbar mToolbar;
|
||||
|
||||
@Override
|
||||
@@ -68,7 +69,7 @@ public class MainActivity extends BaseNfcActivity implements FabContainer, OnBac
|
||||
mToolbar.setTitle(R.string.app_name);
|
||||
setSupportActionBar(mToolbar);
|
||||
|
||||
mDrawerResult = new Drawer()
|
||||
mDrawer = new DrawerBuilder()
|
||||
.withActivity(this)
|
||||
.withHeader(R.layout.main_drawer_header)
|
||||
.withToolbar(mToolbar)
|
||||
@@ -89,7 +90,7 @@ public class MainActivity extends BaseNfcActivity implements FabContainer, OnBac
|
||||
)
|
||||
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id, IDrawerItem drawerItem) {
|
||||
public boolean onItemClick(AdapterView<?> parent, View view, int position, long id, IDrawerItem drawerItem) {
|
||||
if (drawerItem != null) {
|
||||
Intent intent = null;
|
||||
switch(drawerItem.getIdentifier()) {
|
||||
@@ -116,6 +117,8 @@ public class MainActivity extends BaseNfcActivity implements FabContainer, OnBac
|
||||
MainActivity.this.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.withSelectedItem(-1)
|
||||
@@ -179,28 +182,28 @@ public class MainActivity extends BaseNfcActivity implements FabContainer, OnBac
|
||||
|
||||
private void onKeysSelected() {
|
||||
mToolbar.setTitle(R.string.app_name);
|
||||
mDrawerResult.setSelectionByIdentifier(ID_KEYS, false);
|
||||
mDrawer.setSelectionByIdentifier(ID_KEYS, false);
|
||||
Fragment frag = new KeyListFragment();
|
||||
setFragment(frag, false);
|
||||
}
|
||||
|
||||
private void onEnDecryptSelected() {
|
||||
mToolbar.setTitle(R.string.nav_encrypt_decrypt);
|
||||
mDrawerResult.setSelectionByIdentifier(ID_ENCRYPT_DECRYPT, false);
|
||||
mDrawer.setSelectionByIdentifier(ID_ENCRYPT_DECRYPT, false);
|
||||
Fragment frag = new EncryptDecryptOverviewFragment();
|
||||
setFragment(frag, true);
|
||||
}
|
||||
|
||||
private void onAppsSelected() {
|
||||
mToolbar.setTitle(R.string.nav_apps);
|
||||
mDrawerResult.setSelectionByIdentifier(ID_APPS, false);
|
||||
mDrawer.setSelectionByIdentifier(ID_APPS, false);
|
||||
Fragment frag = new AppsListFragment();
|
||||
setFragment(frag, true);
|
||||
}
|
||||
|
||||
private void onBackupSelected() {
|
||||
mToolbar.setTitle(R.string.nav_backup);
|
||||
mDrawerResult.setSelectionByIdentifier(ID_APPS, false);
|
||||
mDrawer.setSelectionByIdentifier(ID_APPS, false);
|
||||
Fragment frag = new BackupFragment();
|
||||
setFragment(frag, true);
|
||||
}
|
||||
@@ -208,15 +211,15 @@ public class MainActivity extends BaseNfcActivity implements FabContainer, OnBac
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
// add the values which need to be saved from the drawer to the bundle
|
||||
outState = mDrawerResult.saveInstanceState(outState);
|
||||
outState = mDrawer.saveInstanceState(outState);
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
// close the drawer first and if the drawer is closed do regular backstack handling
|
||||
if (mDrawerResult != null && mDrawerResult.isDrawerOpen()) {
|
||||
mDrawerResult.closeDrawer();
|
||||
if (mDrawer != null && mDrawer.isDrawerOpen()) {
|
||||
mDrawer.closeDrawer();
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
}
|
||||
@@ -255,16 +258,16 @@ public class MainActivity extends BaseNfcActivity implements FabContainer, OnBac
|
||||
// make sure the selected icon is the one shown at this point
|
||||
if (frag instanceof KeyListFragment) {
|
||||
mToolbar.setTitle(R.string.app_name);
|
||||
mDrawerResult.setSelection(mDrawerResult.getPositionFromIdentifier(ID_KEYS), false);
|
||||
mDrawer.setSelection(mDrawer.getPositionFromIdentifier(ID_KEYS), false);
|
||||
} else if (frag instanceof EncryptDecryptOverviewFragment) {
|
||||
mToolbar.setTitle(R.string.nav_encrypt_decrypt);
|
||||
mDrawerResult.setSelection(mDrawerResult.getPositionFromIdentifier(ID_ENCRYPT_DECRYPT), false);
|
||||
mDrawer.setSelection(mDrawer.getPositionFromIdentifier(ID_ENCRYPT_DECRYPT), false);
|
||||
} else if (frag instanceof AppsListFragment) {
|
||||
mToolbar.setTitle(R.string.nav_apps);
|
||||
mDrawerResult.setSelection(mDrawerResult.getPositionFromIdentifier(ID_APPS), false);
|
||||
mDrawer.setSelection(mDrawer.getPositionFromIdentifier(ID_APPS), false);
|
||||
} else if (frag instanceof BackupFragment) {
|
||||
mToolbar.setTitle(R.string.nav_backup);
|
||||
mDrawerResult.setSelection(mDrawerResult.getPositionFromIdentifier(ID_BACKUP), false);
|
||||
mDrawer.setSelection(mDrawer.getPositionFromIdentifier(ID_BACKUP), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user