@Override
  public void onBackPressed() {
    int count = getSupportFragmentManager().getBackStackEntryCount();
    if (count <= 1) {
      if (doubleBackToExitPressedOnce) {
        super.onBackPressed();
        System.exit(1);
      }

      this.doubleBackToExitPressedOnce = true;
      Toast.makeText(this, "Please click BACK again to exit", Toast.LENGTH_SHORT).show();
      new Handler()
          .postDelayed(
              new Runnable() {

                @Override
                public void run() {
                  doubleBackToExitPressedOnce = false;
                }
              },
              2000);
    } else {
      super.onBackPressed();
    }
  }
Ejemplo n.º 2
0
 @Override
 public void onBackPressed() {
   if (itemEditFragment != null) {
     if (itemEditFragment.onBackPressed()) {
       super.onBackPressed();
     }
   } else {
     super.onBackPressed();
   }
 }
  @Override
  public void onBackPressed() {

    if (getSupportFragmentManager().getBackStackEntryCount() == 1) {

      if (!closeRealTimeLocation()) {
        super.onBackPressed();
        this.finish();
      }
    } else {
      super.onBackPressed();
    }
  }
Ejemplo n.º 4
0
 /**
  * Return to Physician activity or Nurse Activity depending on the type of user operating the
  * activity.
  */
 public void onBackPressed() {
   String id = user.split(" ")[0];
   if (id.equals("Nurse")) {
     Intent intent = new Intent(this, MainActivity.class);
     intent.putExtra("user", user);
     startActivity(intent);
     super.onBackPressed();
   } else {
     Intent intent = new Intent(this, PhysicianMain.class);
     intent.putExtra("user", user);
     startActivity(intent);
     super.onBackPressed();
   }
 }
Ejemplo n.º 5
0
  @Override
  public void onBackPressed() {
    FragmentManager manager = getSupportFragmentManager();
    long currentTimeMillis = System.currentTimeMillis();
    if (manager.getBackStackEntryCount() == 0) {
      boolean shouldExit = ((currentTimeMillis - lastBackPressTime) / 1000) < 3000;
      if (shouldExit) {
        super.onBackPressed();
      } else {
        Toast.makeText(this, "Press back again to exit", Toast.LENGTH_LONG).show();
      }
    } else {
      // If there are back-stack entries, leave the FragmentActivity
      // implementation take care of them.
      // super.onBackPressed();
      manager.popBackStack();

      if (preTitle1 != null) {
        tv_thu_menu.setText(preTitle1);
        preTitle1 = null;
      } else if (preTitle != null) {
        tv_thu_menu.setText(preTitle);
        if (preTitle.equalsIgnoreCase(weekDay)) {
          tv_ngay_menu.setVisibility(View.VISIBLE);
        } else {
          tv_ngay_menu.setVisibility(View.GONE);
        }
        preTitle = null;
      }
    }
    lastBackPressTime = currentTimeMillis;
  }
Ejemplo n.º 6
0
  @Override
  public void onBackPressed() {
    String name = tv_name.getText().toString();
    if (TextUtils.isEmpty(name) && task.getRepeat() == 0) {
      return;
    }
    task.setName(name);
    Calendar mCalendar = Calendar.getInstance();
    mCalendar.setTimeInMillis(task.getTime());

    String timeStr = tv_time.getText().toString().trim();
    int hour = Integer.parseInt(timeStr.substring(0, 2));
    int min = Integer.parseInt(timeStr.substring(3, 5));
    mCalendar.set(Calendar.HOUR_OF_DAY, hour);
    mCalendar.set(Calendar.MINUTE, min);
    task.setTime(mCalendar.getTimeInMillis());

    if (task.getTime() < System.currentTimeMillis() && task.getRepeat() == 0) {
      T.show(context, "时间已经过去了╮(-_-)╭");
      return;
    }

    new TaskDao(context).update(task);

    BusProvider.getInstance().post(new RefreshEvent());

    super.onBackPressed();
  }
Ejemplo n.º 7
0
  @Override
  public void onBackPressed() {

    // if drawer is open first close drawer
    if (drawerLayout.isDrawerOpen(Gravity.LEFT)) {
      drawerLayout.closeDrawer(Gravity.LEFT);
    } else {

      int backStackCount = getSupportFragmentManager().getBackStackEntryCount();

      if (backStackCount == 0) {
        // nothing exist in backStack OS handle it
        super.onBackPressed();
      } else {

        getSupportFragmentManager().popBackStack();

        if (!titleStack.isEmpty()) {
          toolbarTitle.setText(titleStack.pop());
        }

        if (backStackCount == 1) {
          previousMenuItem = navigationView.getMenu().findItem(R.id.nav_category);
          previousMenuItem.setChecked(true);
          previousMenuItem.setCheckable(true);
        }
      }
    }
  }
 @Override
 public void onBackPressed() {
   if (!mAnimator.isLeaving()) {
     mAnimator.exit(true);
   } else {
     super.onBackPressed();
   }
 }
Ejemplo n.º 9
0
 @Override
 public void onBackPressed() {
   if (getFragmentManager().getBackStackEntryCount() == 0) {
     super.onBackPressed();
   } else {
     getFragmentManager().popBackStack();
   }
 }
Ejemplo n.º 10
0
 @Override
 public void onBackPressed() {
   if (showAlert) {
     showAlertSmsLimit(false);
     return;
   }
   super.onBackPressed();
 }
Ejemplo n.º 11
0
 @Override
 public void onBackPressed() {
   if (drawerLayout.isDrawerOpen(Gravity.LEFT)) {
     drawerLayout.closeDrawer(Gravity.LEFT);
   } else {
     super.onBackPressed();
   }
 }
Ejemplo n.º 12
0
 @Override
 public void onBackPressed() {
   if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
     mDrawerLayout.closeDrawers();
   } else {
     super.onBackPressed();
   }
 }
Ejemplo n.º 13
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   if (item.getItemId() == android.R.id.home) {
     super.onBackPressed();
     return true;
   }
   return false;
 }
Ejemplo n.º 14
0
 @Override
 public void onBackPressed() {
   if (mWebView.canGoBack()) {
     mWebView.goBack();
   } else {
     super.onBackPressed();
   }
 }
Ejemplo n.º 15
0
 @Override
 public void onBackPressed() {
   // app icon in action bar clicked; go home
   Intent intent = new Intent(this, MainActivity.class);
   intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
   startActivity(intent);
   super.onBackPressed();
 }
 /** 连续按两次返回键就退出 */
 @Override
 public void onBackPressed() {
   if (firstTime + 2000 > System.currentTimeMillis()) {
     super.onBackPressed();
   } else {
     ShowToast("再按一次退出程序");
   }
   firstTime = System.currentTimeMillis();
 }
Ejemplo n.º 17
0
 @Override
 public void onBackPressed() {
   FragmentManager fragmentManager = getSupportFragmentManager();
   if (fragmentManager.getBackStackEntryCount() > 0) {
     fragmentManager.popBackStack();
   } else {
     super.onBackPressed();
   }
 }
Ejemplo n.º 18
0
 @Override
 public void onBackPressed() {
   DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
   if (drawer.isDrawerOpen(GravityCompat.START)) {
     drawer.closeDrawer(GravityCompat.START);
   } else {
     super.onBackPressed();
   }
 }
Ejemplo n.º 19
0
  /*
   * (non-Javadoc)
   * @see android.support.v7.app.ActionBarActivity#onBackPressed()
   *
   * Overrides the onBackPressed behavior for the attached fragments
   */
  public void onBackPressed() {

    Fragment f;

    // SketchFragment
    f = checkFragmentInstance(R.id.fragment_container, SketchFragment.class);
    if (f != null) {
      ((SketchFragment) f).save();

      // Removes forced portrait orientation for this fragment
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);

      mFragmentManager.popBackStack();
      return;
    }

    // DetailFragment
    f = checkFragmentInstance(R.id.fragment_container, DetailFragment.class);
    if (f != null) {
      ((DetailFragment) f).goBack = true;
      ((DetailFragment) f).saveAndExit((DetailFragment) f);
      return;
    }

    // ListFragment
    f = checkFragmentInstance(R.id.fragment_container, ListFragment.class);
    if (f != null) {
      // Before exiting from app the navigation drawer is opened
      if (prefs.getBoolean("settings_navdrawer_on_exit", false)
          && getDrawerLayout() != null
          && !getDrawerLayout().isDrawerOpen(GravityCompat.START)) {
        getDrawerLayout().openDrawer(GravityCompat.START);
      } else if (!prefs.getBoolean("settings_navdrawer_on_exit", false)
          && getDrawerLayout() != null
          && getDrawerLayout().isDrawerOpen(GravityCompat.START)) {
        getDrawerLayout().closeDrawer(GravityCompat.START);
      } else {
        super.onBackPressed();
      }
      return;
    }
    super.onBackPressed();
  }
Ejemplo n.º 20
0
 /** Show {@link android.app.AlertDialog} when reply content is not empty. */
 @Override
 public void onBackPressed() {
   if (mReplyFragment.isEmoticonKeyboardShowing()) {
     mReplyFragment.hideEmoticonKeyboard();
   } else if (mReplyFragment.isReplyEmpty()) {
     super.onBackPressed();
   } else {
     new ReplyDiscardPromptDialogFragment()
         .show(getSupportFragmentManager(), ReplyDiscardPromptDialogFragment.TAG);
   }
 }
Ejemplo n.º 21
0
 @Override
 public void onBackPressed() {
   if (getFragmentManager().getBackStackEntryCount() == 0) {
     super.onBackPressed();
   } else {
     BaseFragment currentFragment =
         (BaseFragment) getFragmentManager().findFragmentById(getMainFragmentContainerId());
     if (currentFragment.onBackPress()) {
       return;
     }
     getFragmentManager().popBackStack();
   }
 }
Ejemplo n.º 22
0
 @Override
 public void onBackPressed() {
   // TODO Auto-generated method stub
   if (mCurrentFrag instanceof CourseFinishedFrag
       || mCurrentFrag instanceof CourseFinishFrag
       || mCurrentFrag instanceof FlowerFrag
       || mCurrentFrag instanceof CourseGuideFrag
       || mCurrentFrag instanceof CourseReadFrag) {
     return;
   } else if (mCurrentFrag instanceof CoursePrimaryFrag) {
     exitActivity();
   }
   super.onBackPressed();
 }
Ejemplo n.º 23
0
 @Override
 public void onBackPressed() {
   Log.d(TAG, "onBackPressed!");
   if (RecordVoiceBtnController.mIsPressed) {
     mChatView.dismissRecordDialog();
     mChatView.releaseRecorder();
     RecordVoiceBtnController.mIsPressed = false;
   }
   if (mChatView.getMoreMenu().getVisibility() == View.VISIBLE) {
     mChatView.dismissMoreMenu();
   } else {
     mChatController.resetUnreadMsg();
   }
   super.onBackPressed();
 }
Ejemplo n.º 24
0
  @Override
  public void onBackPressed() {
    // DrawerLayout打开时,返回键不会退出
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);

    if (drawer.isDrawerOpen(GravityCompat.START)) {
      drawer.closeDrawer(GravityCompat.START);

    } else if (System.currentTimeMillis() - lastTime > 1000) {
      showToast("再按一次退出程序");
      lastTime = System.currentTimeMillis();

    } else {
      super.onBackPressed();
    }
  }
Ejemplo n.º 25
0
  @Override
  public void onBackPressed() {
    Log.d(TAG, "BACK PRESSED");
    if (this.mode == ConstantManager.MODE_EDIT_RECORD) {
      AlertDialog.Builder dialog = new AlertDialog.Builder(this);
      dialog.setTitle(getString(R.string.dialog_item_title));
      dialog.setMessage("Вы уверены что хотите выйти без сохранения ?");
      dialog.setIcon(android.R.drawable.ic_dialog_info);
      dialog.setPositiveButton(R.string.dialog_yes, myDialogClickListener);
      dialog.setNegativeButton(R.string.dialog_no, myDialogClickListener);
      // dialog.create();
      dialog.show();

      return;
    }
    super.onBackPressed();
  }
Ejemplo n.º 26
0
  @Override
  public void onBackPressed() {
    if (isStickersFrameVisible) {
      setStickersFrameVisible(false);
      stickerButton.setImageResource(R.drawable.ic_action_insert_emoticon);
    } else {
      try {
        chat.release();
      } catch (XMPPException e) {
        Log.e(TAG, "failed to release chat", e);
      }
      super.onBackPressed();

      Intent intent = new Intent(ChatActivity.this, BusinessDetailsActivity.class);
      startActivity(intent);
      finish();
    }
  }
Ejemplo n.º 27
0
 @Override
 public void onBackPressed() {
   super.onBackPressed();
   AppManager.getAppManager().AppExit(getApplicationContext());
 }
Ejemplo n.º 28
0
 @Override
 public void onBackPressed() {
   super.onBackPressed();
 }
Ejemplo n.º 29
0
 @Override
 public void onBackPressed() {
   // TODO Auto-generated method stub
   super.onBackPressed();
 }
Ejemplo n.º 30
0
 @Override
 public void onBackPressed() {
   super.onBackPressed();
   overridePendingTransition(R.anim.fade_in, R.anim.slide_out_right);
 }