Refactor MainDrawerBuilder / start with gempurchases

This commit is contained in:
Negue 2015-10-19 20:25:57 +02:00
parent 15327e4530
commit 9c1d903752
15 changed files with 262 additions and 72 deletions

View file

@ -0,0 +1,70 @@
package com.habitrpg.android.habitica.ui.helpers;
// https://gist.github.com/lodlock/e3cd12130bad70a098db
import android.content.Context;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPropertyAnimatorListener;
import android.util.AttributeSet;
import android.view.View;
import com.github.clans.fab.FloatingActionMenu;
import java.util.List;
public class FloatingActionMenuBehavior extends CoordinatorLayout.Behavior {
private float mTranslationY;
public FloatingActionMenuBehavior(Context context, AttributeSet attrs) {
super();
}
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
return dependency instanceof Snackbar.SnackbarLayout;
}
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
if (child instanceof FloatingActionMenu && dependency instanceof Snackbar.SnackbarLayout) {
this.updateTranslation(parent, child, dependency);
}
return false;
}
private void updateTranslation(CoordinatorLayout parent, View child, View dependency) {
float translationY = this.getTranslationY(parent, child);
if (translationY != this.mTranslationY) {
ViewCompat.animate(child)
.cancel();
if (Math.abs(translationY - this.mTranslationY) == (float) dependency.getHeight()) {
ViewCompat.animate(child)
.translationY(translationY)
.setListener((ViewPropertyAnimatorListener) null);
} else {
ViewCompat.setTranslationY(child, translationY);
}
this.mTranslationY = translationY;
}
}
private float getTranslationY(CoordinatorLayout parent, View child) {
float minOffset = 0.0F;
List dependencies = parent.getDependencies(child);
int i = 0;
for (int z = dependencies.size(); i < z; ++i) {
View view = (View) dependencies.get(i);
if (view instanceof Snackbar.SnackbarLayout && parent.doViewsOverlap(child, view)) {
minOffset = Math.min(minOffset, ViewCompat.getTranslationY(view) - (float) view.getHeight());
}
}
return minOffset;
}
}

View file

@ -2,7 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.habitrpg.android.habitica"
android:versionCode="4"
android:versionName="0.0.4">
android:versionName="0.0.4"
android:screenOrientation="portrait" >
<uses-sdk
android:minSdkVersion="14"
@ -11,23 +12,20 @@
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="com.android.vending.BILLING" />
<application
android:name=".HabiticaApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:windowSoftInputMode="stateHidden|adjustResize">
android:windowSoftInputMode="stateHidden|adjustResize" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@ -37,7 +35,7 @@
<activity
android:name=".prefs.PrefsActivity"
android:label="@string/PS_param_title"
android:theme="@style/AppThemeWithActionBar">
android:theme="@style/AppThemeWithActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
@ -46,7 +44,7 @@
android:name=".LoginActivity"
android:label="@string/LoginActivityName"
android:theme="@style/AppThemeWithActionBarBlackText"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
@ -55,7 +53,7 @@
<receiver
android:name=".widget.SimpleWidget"
android:icon="@mipmap/ic_launcher"
android:label="Habitica Simple Widget">
android:label="Habitica Simple Widget" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
@ -78,7 +76,7 @@
android:name=".TaskFormActivity"
android:label="@string/title_activity_task_form"
android:parentActivityName=".MainActivity"
android:theme="@style/AppThemeWithActionBarBlackText">
android:theme="@style/AppThemeWithActionBarBlackText" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.habitrpg.android.habitica.MainActivity" />
@ -87,7 +85,7 @@
android:name=".TavernActivity"
android:label="@string/title_activity_tavern"
android:parentActivityName=".MainActivity"
android:theme="@style/AppThemeWithOwnActionBar">
android:theme="@style/AppThemeWithOwnActionBar" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.habitrpg.android.habitica.MainActivity" />
@ -95,7 +93,16 @@
<activity
android:name=".PartyActivity"
android:label="@string/title_activity_party"
android:parentActivityName=".MainActivity">
android:parentActivityName=".MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.habitrpg.android.habitica.MainActivity" />
</activity>
<activity
android:name=".GemPurchaseActivity"
android:label="@string/title_activity_gem_purchase"
android:parentActivityName=".MainActivity"
android:theme="@style/AppThemeWithOwnActionBar" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.habitrpg.android.habitica.MainActivity" />

View file

@ -69,11 +69,11 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.databinding/library/1.0-rc1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/cardview-v7/22.2.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/22.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/gridlayout-v7/22.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/22.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/gridlayout-v7/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.crashlytics.sdk.android/answers/1.2.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.crashlytics.sdk.android/beta/1.1.2/jars" />
@ -90,6 +90,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.raizlabs.android/DBFlow/2.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.rengwuxian.materialedittext/library/2.1.4/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/io.fabric.sdk.android/fabric/1.3.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/org.solovyev.android/checkout/0.7.4/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
@ -106,7 +107,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="gson-2.3.1" level="project" />
<orderEntry type="library" exported="" name="library-1.0.19" level="project" />
@ -123,41 +124,42 @@
<orderEntry type="library" exported="" name="org.abego.treelayout.core-1.0.1" level="project" />
<orderEntry type="library" exported="" name="DBFlow-2.2.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.0.1" level="project" />
<orderEntry type="library" exported="" name="checkout-0.7.4" level="project" />
<orderEntry type="library" exported="" name="compilerCommon-1.0-rc1" level="project" />
<orderEntry type="library" exported="" name="compiler-1.0-rc1" level="project" />
<orderEntry type="library" exported="" name="mimecraft-1.1.1" level="project" />
<orderEntry type="library" exported="" name="library-2.4.0" level="project" />
<orderEntry type="library" exported="" name="mimecraft-1.1.1" level="project" />
<orderEntry type="library" exported="" name="guava-18.0" level="project" />
<orderEntry type="library" exported="" name="iconics-1.1.0" level="project" />
<orderEntry type="library" exported="" name="gridlayout-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="auto-service-1.0-rc2" level="project" />
<orderEntry type="library" exported="" name="baseLibrary-1.0-rc1" level="project" />
<orderEntry type="library" exported="" name="design-23.0.1" level="project" />
<orderEntry type="library" exported="" name="fabric-1.3.1" level="project" />
<orderEntry type="library" exported="" name="beta-1.1.2" level="project" />
<orderEntry type="library" exported="" name="gridlayout-v7-22.2.1" level="project" />
<orderEntry type="library" exported="" name="commons-codec-1.10" level="project" />
<orderEntry type="library" exported="" name="javawriter-2.5.0" level="project" />
<orderEntry type="library" exported="" name="commons-lang3-3.3.2" level="project" />
<orderEntry type="library" exported="" name="commons-codec-1.10" level="project" />
<orderEntry type="library" exported="" name="kotlin-stdlib-0.12.613" level="project" />
<orderEntry type="library" exported="" name="design-22.2.1" level="project" />
<orderEntry type="library" exported="" name="commons-lang3-3.3.2" level="project" />
<orderEntry type="library" exported="" name="fab-1.6.1" level="project" />
<orderEntry type="library" exported="" name="instabugcore-1.8-SNAPSHOT" level="project" />
<orderEntry type="library" exported="" name="cardview-v7-22.2.0" level="project" />
<orderEntry type="library" exported="" name="DBFlow-Compiler-2.2.1" level="project" />
<orderEntry type="library" exported="" name="kotlin-runtime-0.12.613" level="project" />
<orderEntry type="library" exported="" name="DBFlow-Compiler-2.2.1" level="project" />
<orderEntry type="library" exported="" name="answers-1.2.0" level="project" />
<orderEntry type="library" exported="" name="picasso-2.5.2" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-22.2.1" level="project" />
<orderEntry type="library" exported="" name="retrofit-1.9.0" level="project" />
<orderEntry type="library" exported="" name="DBFlow-Core-2.2.1" level="project" />
<orderEntry type="library" exported="" name="materialdrawer-3.0.8" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.2.1" level="project" />
<orderEntry type="library" exported="" name="auto-common-0.3" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="antlr-runtime-3.5.2" level="project" />
<orderEntry type="library" exported="" name="butterknife-6.1.0" level="project" />
<orderEntry type="library" exported="" name="instabugsupport-1.8-SNAPSHOT" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="okio-1.3.0" level="project" />
<orderEntry type="library" exported="" name="adapters-1.0-rc1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.0.1" level="project" />
<orderEntry type="library" exported="" name="adapters-1.0-rc1" level="project" />
<orderEntry type="library" exported="" name="okhttp-urlconnection-2.3.0" level="project" />
<orderEntry type="library" exported="" name="eventbus-2.4.0" level="project" />
<orderEntry type="library" exported="" name="library-2.1.4" level="project" />

View file

@ -1,4 +1,25 @@
[
{
"name": "Version 0.0.5",
"items":[
{
"type": "F",
"title": "New Floating-Action-Button with sub buttons"
},
{
"type": "B",
"title": "Tag-Filter now fully working"
},
{
"type": "B",
"title": "Speed up loading+saving of data"
},
{
"type": "B",
"title": "Tasks were saved/added without a title"
}
]
},
{
"name": "Version 0.0.4",
"items":[

View file

@ -86,6 +86,9 @@ dependencies {
compile "com.raizlabs.android:DBFlow:2.2.1"
compile 'de.greenrobot:eventbus:2.4.0'
// IAP Handling / Verification
compile 'org.solovyev.android:checkout:0.7.4@aar'
}
android {

View file

@ -0,0 +1,30 @@
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:gravity="center"
tools:context=".GemPurchaseActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:theme="@style/Toolbar"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</LinearLayout>
</android.support.v4.widget.DrawerLayout>

View file

@ -129,7 +129,7 @@
fab:fab_shadowColor="#000"
fab:fab_elevationCompat="6dp"
android:src="@drawable/ic_menu_edit"
android:src="@drawable/fab_add"
fab:fab_size="mini"
fab:fab_label="New Daily" />
@ -145,7 +145,7 @@
fab:fab_shadowColor="#000"
fab:fab_elevationCompat="6dp"
android:src="@drawable/ic_menu_edit"
android:src="@drawable/fab_add"
fab:fab_size="mini"
fab:fab_label="New Todo" />
@ -161,7 +161,7 @@
fab:fab_shadowColor="#000"
fab:fab_elevationCompat="6dp"
android:src="@drawable/ic_menu_edit"
android:src="@drawable/fab_add"
fab:fab_size="mini"
fab:fab_label="New Reward" />

View file

@ -4,6 +4,7 @@
<string name="sidebar.section.social">Social</string>
<string name="sidebar.tavern">Tavern</string>
<string name="sidebar.party">Party</string>
<string name="sidebar.purchaseGems">Purchase Gems</string>
<string name="sidebar.guilds">Guilds</string>
<string name="sidebar.challenges">Challenges</string>
<string name="sidebar.section.inventory">Inventory</string>

View file

@ -148,4 +148,7 @@
<string name="sunday">Sunday</string>
<string name="title_activity_tavern">Tavern</string>
<string name="title_activity_party">Party</string>
<string name="title_activity_gem_purchase">Purchase Gems</string>
<string name="hello_world">Hello world!</string>
</resources>

View file

@ -2,16 +2,11 @@ package com.habitrpg.android.habitica;
import com.magicmicky.habitrpgwrapper.lib.api.ApiService;
import com.magicmicky.habitrpgwrapper.lib.models.ContentResult;
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
import com.magicmicky.habitrpgwrapper.lib.models.QuestBoss;
import com.magicmicky.habitrpgwrapper.lib.models.QuestContent;
import com.raizlabs.android.dbflow.sql.SqlUtils;
import com.raizlabs.android.dbflow.sql.builder.Condition;
import com.raizlabs.android.dbflow.sql.language.Insert;
import com.raizlabs.android.dbflow.sql.language.Select;
import java.util.HashMap;
import retrofit.Callback;
import retrofit.RetrofitError;
import retrofit.client.Response;

View file

@ -0,0 +1,53 @@
package com.habitrpg.android.habitica;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import com.habitrpg.android.habitica.ui.MainDrawerBuilder;
import com.mikepenz.materialdrawer.Drawer;
import butterknife.ButterKnife;
import butterknife.InjectView;
public class GemPurchaseActivity extends AppCompatActivity {
@InjectView(R.id.toolbar)
Toolbar toolbar;
Drawer drawer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gem_purchase);
// Inject Controls
ButterKnife.inject(this);
if (toolbar != null) {
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setHomeButtonEnabled(false);
}
toolbar.setPadding(0, getResources().getDimensionPixelSize(R.dimen.tool_bar_top_padding), 0, 0);
toolbar.setTitle("Purchase Gems");
actionBar.setTitle("Purchase Gems 2");
}
drawer = MainDrawerBuilder.CreateDefaultBuilderSettings(this, toolbar)
.build();
}
}

View file

@ -100,7 +100,6 @@ public class MainActivity extends AvatarActivityBase implements HabitRPGUserCall
}
drawer = MainDrawerBuilder.CreateDefaultBuilderSettings(this, toolbar)
.withSelectedItem(0)
.build();
filterDrawer = new DrawerBuilder()

View file

@ -43,7 +43,6 @@ public class PartyActivity extends AvatarActivityBase implements AppBarLayout.On
super.onCreate(savedInstanceState);
drawer = MainDrawerBuilder.CreateDefaultBuilderSettings(this, toolbar)
.withSelectedItem(0)
.build();
setViewPagerAdapter();

View file

@ -203,8 +203,12 @@ public class TaskFormActivity extends AppCompatActivity implements AdapterView.O
}
private void saveTask(Task task) {
private boolean saveTask(Task task) {
task.text = taskText.getText().toString();
if(task.text.isEmpty())
return false;
task.notes = taskNotes.getText().toString();
if (this.taskDifficultySpinner.getSelectedItemPosition() == 0) {
@ -237,6 +241,8 @@ public class TaskFormActivity extends AppCompatActivity implements AdapterView.O
task.setEveryX(this.frequencyPicker.getValue());
}
}
return true;
}
public void onItemSelected(AdapterView<?> parent, View view,
@ -255,11 +261,10 @@ public class TaskFormActivity extends AppCompatActivity implements AdapterView.O
this.task = new Task();
this.task.setType(taskType);
}
this.saveTask(this.task);
event.task = this.task;
EventBus.getDefault().post(event);
if(this.saveTask(this.task)) {
event.task = this.task;
EventBus.getDefault().post(event);
}
}
@Override

View file

@ -7,6 +7,7 @@ import android.view.View;
import android.widget.AdapterView;
import com.habitrpg.android.habitica.AboutActivity;
import com.habitrpg.android.habitica.GemPurchaseActivity;
import com.habitrpg.android.habitica.MainActivity;
import com.habitrpg.android.habitica.PartyActivity;
import com.habitrpg.android.habitica.R;
@ -20,17 +21,32 @@ import com.mikepenz.materialdrawer.model.SecondaryDrawerItem;
import com.mikepenz.materialdrawer.model.SectionDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
import java.util.HashMap;
/**
* Created by Negue on 18.08.2015.
*/
public class MainDrawerBuilder {
static final int SIDEBAR_TASKS = 1;
// Change the identificationIDs to the position IDs so that its easier to set the selected entry
static final int SIDEBAR_TASKS = 0;
static final int SIDEBAR_TAVERN = 2;
static final int SIDEBAR_PARTY = 3;
static final int SIDEBAR_SETTINGS = 11;
static final int SIDEBAR_ABOUT = 12;
static final int SIDEBAR_PURCHASE = 4;
static final int SIDEBAR_SETTINGS = 6;
static final int SIDEBAR_ABOUT = 7;
private static HashMap<Integer, Class> ClassMap = new HashMap<>();
static {
ClassMap.put(SIDEBAR_TASKS, MainActivity.class);
ClassMap.put(SIDEBAR_TAVERN, TavernActivity.class);
ClassMap.put(SIDEBAR_PARTY, PartyActivity.class);
ClassMap.put(SIDEBAR_PURCHASE, GemPurchaseActivity.class);
ClassMap.put(SIDEBAR_SETTINGS, PrefsActivity.class);
ClassMap.put(SIDEBAR_ABOUT, AboutActivity.class);
}
public static DrawerBuilder CreateDefaultBuilderSettings(final Activity activity, Toolbar toolbar) {
DrawerBuilder builder = new DrawerBuilder()
@ -48,6 +64,7 @@ public class MainDrawerBuilder {
new SectionDrawerItem().withName(activity.getString(R.string.sidebar_section_social)),
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_tavern)).withIdentifier(SIDEBAR_TAVERN),
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_party)).withIdentifier(SIDEBAR_PARTY),
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_purchaseGems)).withIdentifier(SIDEBAR_PURCHASE),
/*new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_guilds)),
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_challenges)),
@ -68,30 +85,7 @@ public class MainDrawerBuilder {
public boolean onItemClick(AdapterView<?> parent, View view, int position, long id, IDrawerItem drawerItem) {
// do something with the clicked item :D
Class selectedClass = null;
switch (drawerItem.getIdentifier()) {
case SIDEBAR_TASKS: {
selectedClass = MainActivity.class;
break;
}
case SIDEBAR_TAVERN: {
selectedClass = TavernActivity.class;
break;
}
case SIDEBAR_PARTY: {
selectedClass = PartyActivity.class;
break;
}
case SIDEBAR_SETTINGS: {
selectedClass = PrefsActivity.class;
break;
}
case SIDEBAR_ABOUT: {
selectedClass = AboutActivity.class;
break;
}
}
Class selectedClass = ClassMap.get(drawerItem.getIdentifier());
if (selectedClass != null && activity.getClass() != selectedClass) {
activity.startActivity(new Intent(activity, selectedClass));
@ -106,6 +100,14 @@ public class MainDrawerBuilder {
}
});
Class activityClass = activity.getClass();
for (java.util.Map.Entry<Integer,Class> entry: ClassMap.entrySet()) {
if(entry.getValue() == activityClass){
builder.withSelectedItem(entry.getKey());
}
}
return builder;
}
}