Example #1
0
  @AfterViews
  void bindDrawer() {

    getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    getActionBar().setHomeButtonEnabled(true);
    getActionBar().setDisplayHomeAsUpEnabled(true);

    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (drawerLayout == null) {
      return;
    }
    drawer = findViewById(R.id.drawer);

    View headerView = inflater.inflate(R.layout.drawer_listview_header, null);
    headerView.findViewById(R.id.create_payment_group).setOnClickListener(this);

    ListView drawerListView = (ListView) drawer.findViewById(R.id.drawer_listview);
    drawerListView.addHeaderView(headerView);

    List<PaymentGroup> paymentGroups = paymentGroupDao.queryForAllSorted();

    adapter = new PaymentGroupAdapter(this);
    adapter.setData(paymentGroups);

    drawerListView.setAdapter(adapter);

    drawerToggle =
        new ActionBarDrawerToggle(
            this, drawerLayout, R.drawable.ic_drawer, R.string.app_name, R.string.app_name) {

          public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            adapter.notifyDataSetChanged();
            invalidateOptionsMenu();
          }

          public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            adapter.notifyDataSetChanged();
            invalidateOptionsMenu();
          }

          @Override
          public void onDrawerSlide(View drawerView, float slideOffset) {
            super.onDrawerSlide(drawerView, slideOffset);
          }

          @Override
          public void onDrawerStateChanged(int newState) {
            super.onDrawerStateChanged(newState);
          }
        };

    drawerLayout.setDrawerListener(drawerToggle);
  }
Example #2
0
 @UiThread
 void setUpListview(List<PaymentGroup> paymentGroups) {
   adapter.setData(paymentGroups);
 }