Exemplo n.º 1
0
  public static void goTo(String code) {

    replaceFragment(sf);
    currentFragment = sf;

    assert (actionBar != null);

    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setTitle(R.string.title_activity_main);

    ScheduleFragment.user = Framework.MY_SCHEDULE;
    UpdateSchedule.dayOfWeek = DayPicker.toDayNumber(cal.get(Calendar.DAY_OF_WEEK));
    ScheduleFragment.setWeekUnix((int) (System.currentTimeMillis() / 1000));
    UpdateSchedule.scroll = true;
    ScheduleFragment.createList();
    datePickerButton.setVisibility(View.VISIBLE);
    menu.findItem(R.id.menu_search).setVisible(true);

    navigationView.getMenu().getItem(0).setChecked(true);
    if (ScheduleFragment.classArrayList.size() == 0) {
      progressBar.setVisibility(View.VISIBLE);
    }

    ScheduleFragment.user = code;
    goToday();

    actionBar.invalidateOptionsMenu();
  }
Exemplo n.º 2
0
 public static void goToday() {
   cal.setTime(new Date(System.currentTimeMillis()));
   UpdateSchedule.dayOfWeek = DayPicker.toDayNumber(cal.get(Calendar.DAY_OF_WEEK));
   ScheduleFragment.setWeekUnix((int) (System.currentTimeMillis() / 1000));
   UpdateSchedule.scroll = true;
   ScheduleFragment.createList();
   dialog =
       DatePickerDialog.newInstance(
           new DayPicker(),
           cal.get(Calendar.YEAR),
           cal.get(Calendar.MONTH),
           cal.get(Calendar.DAY_OF_MONTH));
 }
Exemplo n.º 3
0
  // TODO: Move some off this stuff into seperate functions
  @SuppressWarnings("StatementWithEmptyBody")
  @Override
  public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    assert (actionBar != null);

    progressBar.setVisibility(View.GONE);

    if (id == R.id.nav_schedule) {
      actionBar.setDisplayShowTitleEnabled(false);
      actionBar.setTitle(R.string.title_activity_main);

      ScheduleFragment.user = Framework.MY_SCHEDULE;
      UpdateSchedule.dayOfWeek = DayPicker.toDayNumber(cal.get(Calendar.DAY_OF_WEEK));
      ScheduleFragment.setWeekUnix((int) (System.currentTimeMillis() / 1000));
      UpdateSchedule.scroll = true;
      ScheduleFragment.createList();
      datePickerButton.setVisibility(View.VISIBLE);
      menu.findItem(R.id.menu_search).setVisible(true);

      navigationView.getMenu().getItem(0).setChecked(true);
      if (ScheduleFragment.classArrayList.size() == 0) {
        progressBar.setVisibility(View.VISIBLE);
      }

      replaceFragment(sf);
      currentFragment = sf;
      //        } else if (id == R.id.nav_announcements) {
      //            ab.setDisplayShowTitleEnabled(true);
      //            ab.setTitle(R.string.title_fragment_announcements);
      //
      //            datePickerButton.setVisibility(View.GONE);
      //            menu.findItem(R.id.menu_search).setVisible(false);
      //
      //            replaceFragment(af);
    } else if (id == R.id.nav_friends) {
      actionBar.setDisplayShowTitleEnabled(true);
      actionBar.setTitle(R.string.title_fragment_friends);

      datePickerButton.setVisibility(View.GONE);
      menu.findItem(R.id.menu_search).setVisible(false);

      replaceFragment(ff);
      currentFragment = ff;
    } else if (id == R.id.nav_info) {

      MaterialDialog.Builder about =
          new MaterialDialog.Builder(this)
              .title(R.string.about)
              .content(R.string.about_text)
              .positiveText(R.string.ok)
              .negativeText(R.string.contact)
              .onNegative(
                  new MaterialDialog.SingleButtonCallback() {
                    @Override
                    public void onClick(
                        @NonNull MaterialDialog materialDialog,
                        @NonNull DialogAction dialogAction) {

                      Uri uri =
                          Uri.parse("mailto:[email protected]")
                              .buildUpon()
                              .build();

                      Intent intent = new Intent(Intent.ACTION_SENDTO, uri);

                      startActivity(Intent.createChooser(intent, getString(R.string.send)));
                    }
                  });
      about.show();
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);

    invalidateOptionsMenu();

    return true;
  }