Exemple #1
0
 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();
 }
Exemple #2
0
 public boolean onKeyDown(int keyCode) {
   if (keyCode == KeyEvent.KEYCODE_BACK) {
     view.hideKeyBoard();
     if (view.isDoneMenuItemVisible()) {
       view.showNotSaveNoteDialog();
       return true;
     }
   }
   return false;
 }
Exemple #3
0
 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;
   }
 }
Exemple #4
0
 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;
   }
 }
Exemple #5
0
 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;
   }
 }
Exemple #6
0
 @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;
   }
 }
Exemple #7
0
 @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);
   }
 }
Exemple #8
0
 @Override
 public void onStop() {
   view.hideKeyBoard();
 }
Exemple #9
0
 public void onPrepareOptionsMenu() {
   view.setDoneMenuItemVisible(false);
 }
Exemple #10
0
 @Override
 public void onFocusChange(android.view.View v, boolean hasFocus) {
   if (hasFocus) {
     view.setToolbarTitle(R.string.edit_note);
   }
 }
Exemple #11
0
 private void initTextView() {
   view.setOperateTimeLineTextView(getOprTimeLineText(note));
 }