@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_worker_availability);

    settings = PreferenceManager.getDefaultSharedPreferences(this);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    result =
        new DrawerBuilder()
            .withActivity(this)
            .withToolbar(toolbar)
            .withSavedInstance(savedInstanceState)
            .build();
    result.getActionBarDrawerToggle().setDrawerIndicatorEnabled(false);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    toolbar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            finish();
          }
        });
    data = (HashMap<Integer, String>) getIntent().getSerializableExtra("data");
    days = new ArrayList<>();
    mon = (CheckBox) findViewById(R.id.chkMon);
    tues = (CheckBox) findViewById(R.id.chkTues);
    wed = (CheckBox) findViewById(R.id.chkWed);
    thurs = (CheckBox) findViewById(R.id.chkThurs);
    fri = (CheckBox) findViewById(R.id.chkFri);
    sat = (CheckBox) findViewById(R.id.chkSat);
    sun = (CheckBox) findViewById(R.id.chkSun);
    days.add(mon);
    days.add(tues);
    days.add(wed);
    days.add(thurs);
    days.add(fri);
    days.add(sat);
    days.add(sun);

    availability = "\"availability\":[";

    try {
      action = getIntent().getAction();
      profileData = getIntent().getStringExtra("availability");
      jsonArray = new JSONArray(profileData);
      for (int i = 0; i < jsonArray.length(); i++) {
        days.get(jsonArray.getInt(i) - 1).setChecked(true);
      }
    } catch (Exception e) {
      action = "";
      profileData = "";
    }

    progress = new ProgressDialog(this);
    progress.setMessage("Updating profile");
  }
  protected void initDrawer(Toolbar toolbar, final String className) {
    setSupportActionBar(toolbar);

    drawer =
        new DrawerBuilder()
            .withActivity(this)
            .withToolbar(toolbar)
            .addDrawerItems(
                new PrimaryDrawerItem().withName(R.string.main_drawer_item),
                new PrimaryDrawerItem().withName(R.string.map_drawer_item))
            .withSelectedItem(-1)
            .build();
    drawer.setOnDrawerItemClickListener(
        new Drawer.OnDrawerItemClickListener() {
          @Override
          public boolean onItemClick(View view, int i, IDrawerItem iDrawerItem) {
            Intent intent;

            switch (i) {
              case 0:
                if (!className.equals("MainActivity")) {
                  intent = new Intent(DrawerBaseActivity.this, MainActivity.class);
                  startActivity(intent);

                  new Handler()
                      .postDelayed(
                          new Runnable() {
                            @Override
                            public void run() {
                              finish();
                            }
                          },
                          300);
                } else {
                  drawer.closeDrawer();
                  drawer.setSelection(-1);
                }
                break;
              case 1:
                if (!className.equals("MapActivity")) {
                  intent = new Intent(DrawerBaseActivity.this, MapActivity.class);
                  startActivity(intent);

                  new Handler()
                      .postDelayed(
                          new Runnable() {
                            @Override
                            public void run() {
                              finish();
                            }
                          },
                          300);
                } else {
                  drawer.closeDrawer();
                  drawer.setSelection(-1);
                }
                break;
              default:
            }
            return true;
          }
        });

    getSupportActionBar().setDisplayHomeAsUpEnabled(false);
    drawer.getActionBarDrawerToggle().setDrawerIndicatorEnabled(true);
  }
Exemple #3
0
  private void initDrawer() {
    drawer =
        new DrawerBuilder()
            .withActivity(this)
            .withToolbar(toolbar)
            .withActionBarDrawerToggleAnimated(true)
            .withTranslucentStatusBar(false)
            .withHeader(R.layout.drawer_header)
            .withShowDrawerOnFirstLaunch(true)
            .addDrawerItems(
                new PrimaryDrawerItem()
                    .withName(R.string.drawer_main_sec1_text)
                    .withIcon(FontAwesome.Icon.faw_graduation_cap),
                new PrimaryDrawerItem()
                    .withName(R.string.drawer_main_sec2_text)
                    .withIcon(FontAwesome.Icon.faw_university),
                new PrimaryDrawerItem()
                    .withName(R.string.drawer_main_sec3_text)
                    .withIcon(FontAwesome.Icon.faw_pencil),
                new DividerDrawerItem(),
                new PrimaryDrawerItem()
                    .withName(R.string.drawer_extra_sec1_text)
                    .withIcon(FontAwesome.Icon.faw_star)
                    .withSelectable(false))
            .addStickyDrawerItems(
                new SecondaryDrawerItem()
                    .withName(R.string.drawer_footer_sec1_text)
                    .withSelectable(false),
                new SecondaryDrawerItem()
                    .withName(R.string.drawer_footer_sec2_text)
                    .withSelectable(false))
            .withOnDrawerItemClickListener(
                new Drawer.OnDrawerItemClickListener() {
                  @Override
                  public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {

                    switch (position) {
                      case 1:
                        curFrag = new SearchFragment();
                        renderScreen();
                        break;
                      case 2:
                        curFrag = new CollegesFragment();
                        renderScreen();
                        break;
                      case 3:
                        curFrag = new OlympsFragment();
                        renderScreen();
                        break;
                      case 5:
                        curFrag = new SearchFragment(true);
                        renderScreen();
                        break;
                      default:
                        Toast.makeText(ctx, "Coming soon", Toast.LENGTH_SHORT).show();
                        return true;
                    }
                    drawer.closeDrawer();
                    return true;
                  }
                })
            .withOnDrawerListener(
                new Drawer.OnDrawerListener() {
                  @Override
                  public void onDrawerClosed(View view) {}

                  @Override
                  public void onDrawerOpened(View view) {}

                  @Override
                  public void onDrawerSlide(View view, float v) {}
                })
            .build();

    ActionBarDrawerToggle toggle = drawer.getActionBarDrawerToggle();

    ImageView headerImg = (ImageView) drawer.getHeader().findViewById(R.id.drawer_header_img);
    Picasso.with(this).load(R.drawable.face).into(headerImg);
  }