private void saveNote() { view.hideKeyBoard(); if (TextUtils.isEmpty(view.getLabelText())) { note.setLabel(mContext.getString(R.string.default_label)); } else { note.setLabel(view.getLabelText()); } note.setContent(view.getContentText()); note.setLastOprTime(TimeUtils.getCurrentTimeInLong()); note.setStatus(SNote.Status.NEED_PUSH.getValue()); event = new MainPresenter.NotifyEvent<>(); switch (operateMode) { case CREATE_NOTE_MODE: note.setCreateTime(TimeUtils.getCurrentTimeInLong()); event.setType(MainPresenter.NotifyEvent.CREATE_NOTE); mFinalDb.saveBindId(note); break; default: event.setType(MainPresenter.NotifyEvent.UPDATE_NOTE); mFinalDb.update(note); break; } event.setData(note); view.finishView(); }
public boolean onKeyDown(int keyCode) { if (keyCode == KeyEvent.KEYCODE_BACK) { view.hideKeyBoard(); if (view.isDoneMenuItemVisible()) { view.showNotSaveNoteDialog(); return true; } } return false; }
public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.done: saveNote(); return true; case android.R.id.home: view.hideKeyBoard(); if (view.isDoneMenuItemVisible()) { view.showNotSaveNoteDialog(); return true; } view.finishView(); default: return false; } }
@Override public void onStop() { view.hideKeyBoard(); }