@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); } }
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(); }
private String getOprTimeLineText(SNote note) { if (note == null || note.getLastOprTime() == 0) return ""; String create = mContext.getString(R.string.create); String edit = mContext.getString(R.string.last_update); StringBuilder sb = new StringBuilder(); if (note.getLastOprTime() <= note.getCreateTime() || note.getCreateTime() == 0) { sb.append( mContext.getString( R.string.note_log_text, create, TimeUtils.getTime(note.getLastOprTime()))); return sb.toString(); } sb.append( mContext.getString(R.string.note_log_text, edit, TimeUtils.getTime(note.getLastOprTime()))); sb.append("\n"); sb.append( mContext.getString( R.string.note_log_text, create, TimeUtils.getTime(note.getCreateTime()))); return sb.toString(); }