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(); }
@Override public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: saveNote(); break; case DialogInterface.BUTTON_NEGATIVE: view.finishView(); break; default: break; } }
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; } }