Beispiel #1
0
  @Override
  public boolean onBackClick() {
    if (AppSettings.isAppResident()) {
      if (lastSelectedMenu != null && !"1".equals(lastSelectedMenu.getType())) {
        onMenuSelected(MenuGenerator.generateMenu("1"), true, null);
        return true;
      } else {
        if (isDrawerOpened()) {
          closeDrawer();

          return true;
        }
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addCategory(Intent.CATEGORY_HOME);
        startActivity(intent);
      }
      return true;
    } else {
      if (!canFinish) {
        canFinish = true;

        showMessage(R.string.comm_hint_exit);

        new Handler()
            .postDelayed(
                new Runnable() {

                  @Override
                  public void run() {
                    canFinish = false;
                  }
                },
                1500);

        return true;
      }

      setMDestory(true);
      return super.onBackClick();
    }
  }
Beispiel #2
0
  @Override
  public boolean onBackClick() {
    if (AppSettings.isAppResident()) {
      //            if (menuFragment.backToMain()) {
      //                return true;
      //            } else {
      if (isDrawerOpened()) {
        closeDrawer();

        return true;
      }
      Intent intent = new Intent(Intent.ACTION_MAIN);
      intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      intent.addCategory(Intent.CATEGORY_HOME);
      startActivity(intent);
      //            }
      return true;
    } else {
      if (!canFinish) {
        canFinish = true;

        showMessage(R.string.hint_exit);

        new Handler()
            .postDelayed(
                new Runnable() {

                  @Override
                  public void run() {
                    canFinish = false;
                  }
                },
                1500);

        return true;
      }

      return super.onBackClick();
    }
  }