Skip to content

Commit

Permalink
Improve Navigation Drawer with number of installed apps
Browse files Browse the repository at this point in the history
  • Loading branch information
javiersantos committed Jun 4, 2015
1 parent 95741fa commit 4b5e1fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ protected void onCreate(Bundle savedInstanceState) {
AppAdapter appAdapter = new AppAdapter(createList(appListName, appListApk, appListVersion, appListSource, appListData, appListIcon), this);
recyclerView.setAdapter(appAdapter);

setNavigationDrawer(appAdapter);
setFAB();

}
Expand All @@ -82,9 +83,10 @@ private void setInitialConfiguration() {
getWindow().setNavigationBarColor(appPreferences.getPrimaryColorPref());
}
}
}

UtilsUI.setNavigationDrawer(this, getApplicationContext(), toolbar);

private void setNavigationDrawer(AppAdapter appAdapter) {
UtilsUI.setNavigationDrawer(this, getApplicationContext(), toolbar, appAdapter);
}

private void setFAB() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.AdapterView;

import com.javiersantos.mlmanager.AboutActivity;
import com.javiersantos.mlmanager.R;
import com.javiersantos.mlmanager.SettingsActivity;
import com.javiersantos.mlmanager.adapters.AppAdapter;
import com.mikepenz.iconics.typeface.FontAwesome;
import com.mikepenz.materialdrawer.Drawer;
import com.mikepenz.materialdrawer.DrawerBuilder;
Expand All @@ -37,7 +37,7 @@ public static int darker (int color, double factor) {
return Color.argb(a, Math.max( (int)(r * factor), 0 ), Math.max( (int)(g * factor), 0 ), Math.max( (int)(b * factor), 0 ) );
}

public static Drawer setNavigationDrawer (Activity activity, final Context context, Toolbar toolbar) {
public static Drawer setNavigationDrawer (Activity activity, final Context context, Toolbar toolbar, AppAdapter appAdapter) {
int header;
appPreferences = new AppPreferences(context);

Expand All @@ -58,7 +58,7 @@ public static Drawer setNavigationDrawer (Activity activity, final Context conte
.withAccountHeader(headerResult)
.withStatusBarColor(UtilsUI.darker(appPreferences.getPrimaryColorPref(), 0.8))
.addDrawerItems(
new PrimaryDrawerItem().withName(context.getResources().getString(R.string.app_name)).withIcon(ContextCompat.getDrawable(context, R.mipmap.ic_launcher)),
new PrimaryDrawerItem().withName(context.getResources().getString(R.string.action_apps)).withIcon(FontAwesome.Icon.faw_mobile).withBadge(Integer.toString(appAdapter.getItemCount())),
new DividerDrawerItem(),
new SecondaryDrawerItem().withName(context.getResources().getString(R.string.action_settings)).withIcon(FontAwesome.Icon.faw_cog),
new SecondaryDrawerItem().withName(context.getResources().getString(R.string.action_about)).withIcon(FontAwesome.Icon.faw_info)
Expand Down

0 comments on commit 4b5e1fb

Please sign in to comment.