Esempio n. 1
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   AppController.getController().getBus().register(this);
   manager = new GridLayoutManager(this, getResources().getInteger(R.integer.num_row));
   recycler.setItemAnimator(new DefaultItemAnimator());
   recycler.setHasFixedSize(true);
   recycler.setLayoutManager(manager);
   mDrawerLayout.setStatusBarBackgroundColor(
       AppHelper.getPrimaryDarkColor(AppHelper.getPrimaryColor(this)));
   navigationView.setItemIconTintList(ColorStateList.valueOf(AppHelper.getAccentColor(this)));
   if (AppHelper.isDarkTheme(this)) {
     navigationView.setItemTextColor(ColorStateList.valueOf(AppHelper.getAccentColor(this)));
   }
   adapter = new AppsAdapter(this, new ArrayList<AppsModel>());
   recycler.setAdapter(adapter);
   mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
   if (navigationView != null) {
     setupDrawerContent(navigationView);
   }
   getLoaderManager().restartLoader(0, null, this);
   productsList.addAll(Arrays.asList(getResources().getStringArray(R.array.in_app_billing)));
   mHelper = new IabHelper(this, getString(R.string.base64));
   mHelper.startSetup(mPurchaseFinishedListener);
   showWhatsNew();
   countBackup();
 }
Esempio n. 2
0
  private void setupNavigationView() {

    NavigationView navigationView = (NavigationView) findViewById(R.id.navigation_view);
    navigationView.setNavigationItemSelectedListener(
        new NavigationView.OnNavigationItemSelectedListener() {

          @Override
          public boolean onNavigationItemSelected(MenuItem item) {
            switch (item.getItemId()) {
              case R.id.nav_profile:
                fragmentManager.beginTransaction().replace(R.id.frame_layout, fragment1).commit();
                break;
              case R.id.nav_settings:
                fragmentManager.beginTransaction().replace(R.id.frame_layout, fragment2).commit();
                break;
              case R.id.nav_social:
                fragmentManager.beginTransaction().replace(R.id.frame_layout, fragment3).commit();
                break;
              default:
                break;
            }

            drawerLayout.closeDrawers();
            return true;
          }
        });

    navigationView.setItemIconTintList(ContextCompat.getColorStateList(this, R.color.my_icon_tint));
    navigationView.setItemTextColor(ContextCompat.getColorStateList(this, R.color.my_icon_tint));
    navigationView.setItemTextAppearance(R.style.myNavigationText);
  }
Esempio n. 3
0
  private void updateDrawer(boolean updateFavorites) {
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    assert navigationView != null : "Navigation view is null";

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
      navigationView.setItemIconTintList(null);

    MenuItem stats = navigationView.getMenu().findItem(R.id.nav_stats);
    if (ProSettings.checkEnabled(ProSettings.STATISTICS_KEY)) stats.setVisible(true);
    else stats.setVisible(false);

    MenuItem notes = navigationView.getMenu().findItem(R.id.nav_notes);
    if (ProSettings.checkEnabled(ProSettings.NOTES_KEY)) notes.setVisible(true);
    else notes.setVisible(false);

    if (updateFavorites) {
      SubMenu fab_menu = navigationView.getMenu().findItem(R.id.nav_header_favorites).getSubMenu();
      fab_menu.clear();

      Sites favorites = dataManager.getFavoriteSites();
      for (Site site : favorites) {
        MenuItem mi = fab_menu.add(2, site.code, Menu.NONE, site.name);
        configureMenuItem(mi, site);
      }
    }
    navigationView.invalidate();
  }
Esempio n. 4
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mCoordinator = (CoordinatorLayout) findViewById(R.id.root_coordinator);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mToolbar = (Toolbar) findViewById(R.id.app_bar);
    setSupportActionBar(mToolbar);

    navigationView = (NavigationView) findViewById(R.id.navigation_drawer);
    navigationView.setItemIconTintList(null);
    navigationView.setNavigationItemSelectedListener(this);

    mDrawerToggle =
        new ActionBarDrawerToggle(
            this, mDrawerLayout, mToolbar, R.string.drawer_open, R.string.drawer_close);
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mDrawerToggle.syncState();

    mTabLayout = (TabLayout) findViewById(R.id.tab_layout);
    mAdapter = new TabPagerAdapter(this, getSupportFragmentManager());
    mPager = (ViewPager) findViewById(R.id.view_pager);
    mPager.setAdapter(mAdapter);
    // Notice how the Tab Layout links with the Pager Adapter
    mTabLayout.setTabsFromPagerAdapter(mAdapter);

    // Notice how The Tab Layout adn View Pager object are linked
    mTabLayout.setupWithViewPager(mPager);
    mPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabLayout));
    if (getIntent() != null) {
      mPager.setCurrentItem(getIntent().getIntExtra("tab", 0));
    }
    fragmentManager = getSupportFragmentManager();
  }
Esempio n. 5
0
 public static void updateNavigationItemTint(NavigationView navigationView, int primaryColorRes) {
   Context context = navigationView.getContext();
   int primaryColor = ContextCompat.getColor(context, primaryColorRes);
   navigationView.setItemIconTintList(
       createNavigationItemTintList(android.R.attr.textColorSecondary, primaryColor, context));
   navigationView.setItemTextColor(
       createNavigationItemTintList(android.R.attr.textColorPrimary, primaryColor, context));
 }