补偿Workingnote类的注释

syh
19960030627 2 years ago
parent 4ba7e00fc1
commit 374a2d33a3

@ -61,7 +61,7 @@ public class WorkingNote {
private boolean mIsDeleted;
private NoteSettingChangedListener mNoteSettingStatusListener;
// 声明 DATA_PROJECTION字符串数组
public static final String[] DATA_PROJECTION = new String[]{
DataColumns.ID,
DataColumns.CONTENT,
@ -71,7 +71,9 @@ public class WorkingNote {
DataColumns.DATA3,
DataColumns.DATA4,
};
/**
* // 声明 NOTE_PROJECTION字符串数组
*/
public static final String[] NOTE_PROJECTION = new String[]{
NoteColumns.PARENT_ID,
NoteColumns.ALERTED_DATE,
@ -124,11 +126,17 @@ public class WorkingNote {
loadNote();
}
/**
* Note
* query
*/
private void loadNote() {
Cursor cursor = mContext.getContentResolver().query(
ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, mNoteId), NOTE_PROJECTION, null,
null, null);
/**
*
*/
if (cursor != null) {
if (cursor.moveToFirst()) {
mFolderId = cursor.getLong(NOTE_PARENT_ID_COLUMN);
@ -139,6 +147,9 @@ public class WorkingNote {
mModifiedDate = cursor.getLong(NOTE_MODIFIED_DATE_COLUMN);
}
cursor.close();
/**
*
*/
} else {
Log.e(TAG, "No note with id:" + mNoteId);
throw new IllegalArgumentException("Unable to find note with id " + mNoteId);
@ -146,6 +157,10 @@ public class WorkingNote {
loadNoteData();
}
/**
* Notedata
*/
private void loadNoteData() {
Cursor cursor = mContext.getContentResolver().query(Notes.CONTENT_DATA_URI, DATA_PROJECTION,
DataColumns.NOTE_ID + "=?", new String[]{
@ -153,7 +168,13 @@ public class WorkingNote {
}, null);
if (cursor != null) {
/**
*
*/
if (cursor.moveToFirst()) {
/**
*
*/
do {
String type = cursor.getString(DATA_MIME_TYPE_COLUMN);
if (DataConstants.NOTE.equals(type)) {
@ -166,6 +187,9 @@ public class WorkingNote {
Log.d(TAG, "Wrong note type with type:" + type);
}
} while (cursor.moveToNext());
/**
*
*/
}
cursor.close();
} else {
@ -174,9 +198,22 @@ public class WorkingNote {
}
}
/**
* Note
* contextidwidget
* @param context
* @param folderId
* @param widgetId
* @param widgetType
* @param defaultBgColorId
* @return
*/
public static WorkingNote createEmptyNote(Context context, long folderId, int widgetId,
int widgetType, int defaultBgColorId) {
WorkingNote note = new WorkingNote(context, folderId);
/**
*
*/
note.setBgColorId(defaultBgColorId);
note.setWidgetId(widgetId);
note.setWidgetType(widgetType);
@ -186,10 +223,19 @@ public class WorkingNote {
public static WorkingNote load(Context context, long id) {
return new WorkingNote(context, id, 0);
}
/**
* note
*/
public synchronized boolean saveNote() {
if (isWorthSaving()) {
/**
*
*/
if (!existInDatabase()) {
/**
*
*/
if ((mNoteId = Note.getNewNoteId(mContext, mFolderId)) == 0) {
Log.e(TAG, "Create new note fail with id:" + mNoteId);
return false;
@ -211,12 +257,23 @@ public class WorkingNote {
return false;
}
}
/**
*
*/
public boolean existInDatabase() {
return mNoteId > 0;
}
/**
*
* @return
*/
private boolean isWorthSaving() {
/**
*
*/
if (mIsDeleted || (!existInDatabase() && TextUtils.isEmpty(mContent))
|| (existInDatabase() && !mNote.isLocalModified())) {
return false;
@ -225,10 +282,22 @@ public class WorkingNote {
}
}
/**
* mNoteSettingStatusListener
* @param l
*/
public void setOnSettingStatusChangedListener(NoteSettingChangedListener l) {
mNoteSettingStatusListener = l;
}
/**
* AlertDate
* mAlertDatedatamAlertDateNoteValue
* @param date
* @param set
*/
public void setAlertDate(long date, boolean set) {
if (date != mAlertDate) {
mAlertDate = date;
@ -239,7 +308,15 @@ public class WorkingNote {
}
}
/**
*
* @param mark
*/
public void markDeleted(boolean mark) {
/**
*
*/
mIsDeleted = mark;
if (mWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID
&& mWidgetType != Notes.TYPE_WIDGET_INVALIDE && mNoteSettingStatusListener != null) {
@ -247,6 +324,11 @@ public class WorkingNote {
}
}
/**
*
* @param id
*/
public void setBgColorId(int id) {
if (id != mBgColorId) {
mBgColorId = id;
@ -257,6 +339,10 @@ public class WorkingNote {
}
}
/**
*
* @param mode
*/
public void setCheckListMode(int mode) {
if (mMode != mode) {
if (mNoteSettingStatusListener != null) {
@ -267,6 +353,12 @@ public class WorkingNote {
}
}
/**
* // 设定WidgetType
* // 参数type
* @param type
*/
public void setWidgetType(int type) {
if (type != mWidgetType) {
mWidgetType = type;
@ -274,6 +366,10 @@ public class WorkingNote {
}
}
/**
* widgetid
* @param id
*/
public void setWidgetId(int id) {
if (id != mWidgetId) {
mWidgetId = id;
@ -281,12 +377,20 @@ public class WorkingNote {
}
}
/**
* NotesetNoteValueWidgetId
* @param text
*/
public void setWorkingText(String text) {
if (!TextUtils.equals(mContent, text)) {
mContent = text;
mNote.setTextData(DataColumns.CONTENT, mContent);
}
}
/**
* NotesetTextDataWorkingText
*/
public void convertToCallNote(String phoneNumber, long callDate) {
mNote.setCallData(CallNote.CALL_DATE, String.valueOf(callDate));
@ -294,54 +398,115 @@ public class WorkingNote {
mNote.setNoteValue(NoteColumns.PARENT_ID, String.valueOf(Notes.ID_CALL_RECORD_FOLDER));
}
/**
*
* @return
*/
public boolean hasClockAlert() {
return (mAlertDate > 0 ? true : false);
}
/**
* Content
* @return
*/
public String getContent() {
return mContent;
}
/**
* AlertDate
* @return
*/
public long getAlertDate() {
return mAlertDate;
}
/**
* ModifiedDate
* @return
*/
public long getModifiedDate() {
return mModifiedDate;
}
/**
* id
* @return
*/
public int getBgColorResId() {
return NoteBgResources.getNoteBgResource(mBgColorId);
}
/**
* id
* @return
*/
public int getBgColorId() {
return mBgColorId;
}
/**
* id
* @return
*/
public int getTitleBgResId() {
return NoteBgResources.getNoteTitleBgResource(mBgColorId);
}
/**
* CheckListMode
* @return
*/
public int getCheckListMode() {
return mMode;
}
/**
* 便id
* @return
*/
public long getNoteId() {
return mNoteId;
}
/**
* id
* @return
*/
public long getFolderId() {
return mFolderId;
}
/**
* id
* @return
*/
public int getWidgetId() {
return mWidgetId;
}
/**
* WidgetId
* @return
*/
public int getWidgetType() {
return mWidgetType;
}
/**
* WidgetType
*/
public interface NoteSettingChangedListener {
/**
* Called when the background color of current note has just changed

Binary file not shown.

@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading…
Cancel
Save