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; }
private void initEditText() { switch (operateMode) { case EDIT_NOTE_MODE: view.initViewOnEditMode(note); break; case VIEW_NOTE_MODE: view.initViewOnViewMode(note); break; default: view.initViewOnCreateMode(note); 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; } }
private void initToolbar() { view.setToolbarTitle(R.string.view_note); switch (operateMode) { case CREATE_NOTE_MODE: view.setToolbarTitle(R.string.new_note); break; case EDIT_NOTE_MODE: view.setToolbarTitle(R.string.edit_note); break; case VIEW_NOTE_MODE: view.setToolbarTitle(R.string.view_note); break; default: break; } }
@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; } }
@Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (view.isDoneMenuItemNull()) return; String labelSrc = view.getLabelText(); String contentSrc = view.getContentText(); // String label = labelSrc.replaceAll("\\s*|\t|\r|\n", ""); String content = contentSrc.replaceAll("\\s*|\t|\r|\n", ""); if (!TextUtils.isEmpty(content)) { if (TextUtils.equals(labelSrc, note.getLabel()) && TextUtils.equals(contentSrc, note.getContent())) { view.setDoneMenuItemVisible(false); return; } view.setDoneMenuItemVisible(true); } else { view.setDoneMenuItemVisible(false); } }
@Override public void onStop() { view.hideKeyBoard(); }
public void onPrepareOptionsMenu() { view.setDoneMenuItemVisible(false); }
@Override public void onFocusChange(android.view.View v, boolean hasFocus) { if (hasFocus) { view.setToolbarTitle(R.string.edit_note); } }
private void initTextView() { view.setOperateTimeLineTextView(getOprTimeLineText(note)); }