添加了data包的注释。还有remote注释,以及gtask一部分注释

master
jjjzyhbx 2 years ago
parent 7dc7907812
commit 9d98342f0f

@ -1 +0,0 @@
Notes-master

@ -3,8 +3,8 @@ apply plugin: 'com.android.application'
android {
useLibrary 'org.apache.http.legacy'
namespace "net.micode.notes"
compileSdkVersion 33
buildToolsVersion "33.0.2"
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "net.micode.notes"

@ -4,7 +4,6 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@ -27,19 +26,24 @@ import org.json.JSONObject;
public class MetaData extends Task {
private final static String TAG = MetaData.class.getSimpleName();
//相关GTask任务的ID
private String mRelatedGid = null;
//设置元数据,传入gid和元数据的JSONObject
public void setMeta(String gid, JSONObject metaInfo) {
//向元数据中加入相关GTaskID
try {
metaInfo.put(GTaskStringUtils.META_HEAD_GTASK_ID, gid);
} catch (JSONException e) {
Log.e(TAG, "failed to put related gid");
}
//设置笔记内容为元数据的JSON字符串
setNotes(metaInfo.toString());
//设置笔记名称
setName(GTaskStringUtils.META_NOTE_NAME);
}
//获取相关GTask任务的ID
public String getRelatedGid() {
return mRelatedGid;
}
@ -49,11 +53,15 @@ public class MetaData extends Task {
return getNotes() != null;
}
//从远程同步的数据中获取内容
@Override
public void setContentByRemoteJSON(JSONObject js) {
//调用父类方法
super.setContentByRemoteJSON(js);
//如果有笔记内容
if (getNotes() != null) {
try {
//解析笔记内容,获取相关GTask任务ID
JSONObject metaInfo = new JSONObject(getNotes().trim());
mRelatedGid = metaInfo.getString(GTaskStringUtils.META_HEAD_GTASK_ID);
} catch (JSONException e) {
@ -65,17 +73,19 @@ public class MetaData extends Task {
@Override
public void setContentByLocalJSON(JSONObject js) {
// this function should not be called
//此方法不应被调用,抛出异常
throw new IllegalAccessError("MetaData:setContentByLocalJSON should not be called");
}
@Override
public JSONObject getLocalJSONFromContent() {
//此方法不应被调用,抛出异常
throw new IllegalAccessError("MetaData:getLocalJSONFromContent should not be called");
}
@Override
public int getSyncAction(Cursor c) {
//此方法不应被调用,抛出异常
throw new IllegalAccessError("MetaData:getSyncAction should not be called");
}

@ -88,7 +88,7 @@ public class SqlData {
loadFromCursor(c);
mDiffDataValues = new ContentValues();
}
//加载数据
private void loadFromCursor(Cursor c) {
mDataId = c.getLong(DATA_ID_COLUMN);
mDataMimeType = c.getString(DATA_MIME_TYPE_COLUMN);
@ -96,7 +96,11 @@ public class SqlData {
mDataContentData1 = c.getLong(DATA_CONTENT_DATA_1_COLUMN);
mDataContentData3 = c.getString(DATA_CONTENT_DATA_3_COLUMN);
}
/**
*
* @param js JSON
* @throws JSONException
*/
public void setContent(JSONObject js) throws JSONException {
long dataId = js.has(DataColumns.ID) ? js.getLong(DataColumns.ID) : INVALID_ID;
if (mIsCreate || mDataId != dataId) {
@ -129,7 +133,11 @@ public class SqlData {
}
mDataContentData3 = dataContentData3;
}
/**
*
* @return JSON
* @throws JSONException
*/
public JSONObject getContent() throws JSONException {
if (mIsCreate) {
Log.e(TAG, "it seems that we haven't created this in database yet");
@ -144,6 +152,12 @@ public class SqlData {
return js;
}
/**
*
* @param noteId ID
* @param validateVersion
* @param version
*/
public void commit(long noteId, boolean validateVersion, long version) {
if (mIsCreate) {

@ -199,7 +199,9 @@ public class SqlNote {
mWidgetType = c.getInt(WIDGET_TYPE_COLUMN);
mVersion = c.getLong(VERSION_COLUMN);
}
/**
*
*/
private void loadDataContent() {
Cursor c = null;
mDataList.clear();
@ -225,7 +227,11 @@ public class SqlNote {
c.close();
}
}
/**
*
* @param js JSON
* @return
*/
public boolean setContent(JSONObject js) {
try {
JSONObject note = js.getJSONObject(GTaskStringUtils.META_HEAD_NOTE);
@ -358,7 +364,10 @@ public class SqlNote {
}
return true;
}
/**
*
* @return JSON
*/
public JSONObject getContent() {
try {
JSONObject js = new JSONObject();
@ -439,7 +448,10 @@ public class SqlNote {
public boolean isNoteType() {
return mType == Notes.TYPE_NOTE;
}
/**
*
* @param validateVersion
*/
public void commit(boolean validateVersion) {
if (mIsCreate) {
if (mId == INVALID_ID && mDiffNoteValues.containsKey(NoteColumns.ID)) {

@ -53,7 +53,11 @@ public class Task extends Node {
mParent = null;
mMetaInfo = null;
}
/**
* JSON
* @param actionId ID
* @return JSON
*/
public JSONObject getCreateAction(int actionId) {
JSONObject js = new JSONObject();
@ -102,7 +106,11 @@ public class Task extends Node {
return js;
}
/**
* JSON
* @param actionId ID
* @return JSON
*/
public JSONObject getUpdateAction(int actionId) {
JSONObject js = new JSONObject();
@ -134,7 +142,10 @@ public class Task extends Node {
return js;
}
/**
* JSON
* @param js JSON
*/
public void setContentByRemoteJSON(JSONObject js) {
if (js != null) {
try {
@ -174,7 +185,10 @@ public class Task extends Node {
}
}
}
/**
* JSON
* @param js JSON
*/
public void setContentByLocalJSON(JSONObject js) {
if (js == null || !js.has(GTaskStringUtils.META_HEAD_NOTE)
|| !js.has(GTaskStringUtils.META_HEAD_DATA)) {
@ -203,7 +217,10 @@ public class Task extends Node {
e.printStackTrace();
}
}
/**
* JSON
* @return JSON
*/
public JSONObject getLocalJSONFromContent() {
String name = getName();
try {
@ -246,7 +263,10 @@ public class Task extends Node {
return null;
}
}
/**
*
* @param metaData
*/
public void setMetaInfo(MetaData metaData) {
if (metaData != null && metaData.getNotes() != null) {
try {

@ -42,7 +42,11 @@ public class TaskList extends Node {
mChildren = new ArrayList<Task>();
mIndex = 1;
}
/**
* JSON
* @param actionId ID
* @return JSON
*/
public JSONObject getCreateAction(int actionId) {
JSONObject js = new JSONObject();
@ -73,7 +77,11 @@ public class TaskList extends Node {
return js;
}
/**
* JSON
* @param actionId ID
* @return JSON
*/
public JSONObject getUpdateAction(int actionId) {
JSONObject js = new JSONObject();
@ -102,7 +110,10 @@ public class TaskList extends Node {
return js;
}
/**
* JSON
* @param js JSON
*/
public void setContentByRemoteJSON(JSONObject js) {
if (js != null) {
try {
@ -128,7 +139,10 @@ public class TaskList extends Node {
}
}
}
/**
* JSON
* @param js JSON
*/
public void setContentByLocalJSON(JSONObject js) {
if (js == null || !js.has(GTaskStringUtils.META_HEAD_NOTE)) {
Log.w(TAG, "setContentByLocalJSON: nothing is avaiable");
@ -156,7 +170,10 @@ public class TaskList extends Node {
e.printStackTrace();
}
}
/**
* JSON
* @return JSON
*/
public JSONObject getLocalJSONFromContent() {
try {
JSONObject js = new JSONObject();
@ -182,7 +199,11 @@ public class TaskList extends Node {
return null;
}
}
/**
*
* @param c Cursor
* @return
*/
public int getSyncAction(Cursor c) {
try {
if (c.getInt(SqlNote.LOCAL_MODIFIED_COLUMN) == 0) {
@ -215,11 +236,18 @@ public class TaskList extends Node {
return SYNC_ACTION_ERROR;
}
/**
*
* @return
*/
public int getChildTaskCount() {
return mChildren.size();
}
/**
*
* @param task
* @return
*/
public boolean addChildTask(Task task) {
boolean ret = false;
if (task != null && !mChildren.contains(task)) {
@ -233,7 +261,12 @@ public class TaskList extends Node {
}
return ret;
}
/**
*
* @param task
* @param index
* @return
*/
public boolean addChildTask(Task task, int index) {
if (index < 0 || index > mChildren.size()) {
Log.e(TAG, "add child task: invalid index");
@ -259,7 +292,11 @@ public class TaskList extends Node {
return true;
}
/**
*
* @param task
* @return
*/
public boolean removeChildTask(Task task) {
boolean ret = false;
int index = mChildren.indexOf(task);
@ -280,7 +317,12 @@ public class TaskList extends Node {
}
return ret;
}
/**
*
* @param task
* @param index
* @return
*/
public boolean moveChildTask(Task task, int index) {
if (index < 0 || index >= mChildren.size()) {
@ -298,7 +340,11 @@ public class TaskList extends Node {
return true;
return (removeChildTask(task) && addChildTask(task, index));
}
/**
* GID
* @param gid GID
* @return
*/
public Task findChildTaskByGid(String gid) {
for (int i = 0; i < mChildren.size(); i++) {
Task t = mChildren.get(i);
@ -308,11 +354,19 @@ public class TaskList extends Node {
}
return null;
}
/**
*
* @param task
* @return
*/
public int getChildTaskIndex(Task task) {
return mChildren.indexOf(task);
}
/**
*
* @param index
* @return
*/
public Task getChildTaskByIndex(int index) {
if (index < 0 || index >= mChildren.size()) {
Log.e(TAG, "getTaskByIndex: invalid index");
@ -320,7 +374,11 @@ public class TaskList extends Node {
}
return mChildren.get(index);
}
/**
* GID
* @param gid GID
* @return
*/
public Task getChilTaskByGid(String gid) {
for (Task task : mChildren) {
if (task.getGid().equals(gid))

@ -15,7 +15,9 @@
*/
package net.micode.notes.gtask.exception;
/**
*
*/
public class ActionFailureException extends RuntimeException {
private static final long serialVersionUID = 4425249765923293627L;
@ -26,7 +28,11 @@ public class ActionFailureException extends RuntimeException {
public ActionFailureException(String paramString) {
super(paramString);
}
/**
*
* @param paramString
* @param paramThrowable
*/
public ActionFailureException(String paramString, Throwable paramThrowable) {
super(paramString, paramThrowable);
}

@ -15,7 +15,9 @@
*/
package net.micode.notes.gtask.exception;
/**
*
*/
public class NetworkFailureException extends Exception {
private static final long serialVersionUID = 2107610287180234136L;
@ -26,7 +28,11 @@ public class NetworkFailureException extends Exception {
public NetworkFailureException(String paramString) {
super(paramString);
}
/**
*
* @param paramString
* @param paramThrowable
*/
public NetworkFailureException(String paramString, Throwable paramThrowable) {
super(paramString, paramThrowable);
}

@ -27,7 +27,10 @@ import android.os.AsyncTask;
import net.micode.notes.R;
import net.micode.notes.ui.NotesListActivity;
import net.micode.notes.ui.NotesPreferenceActivity;
/**
* GTask
*
*/
public class GTaskASyncTask extends AsyncTask<Void, String, Integer> {
@ -44,7 +47,11 @@ public class GTaskASyncTask extends AsyncTask<Void, String, Integer> {
private GTaskManager mTaskManager;
private OnCompleteListener mOnCompleteListener;
/**
*
* @param context
* @param listener
*/
public GTaskASyncTask(Context context, OnCompleteListener listener) {
mContext = context;
mOnCompleteListener = listener;
@ -52,17 +59,25 @@ public class GTaskASyncTask extends AsyncTask<Void, String, Integer> {
.getSystemService(Context.NOTIFICATION_SERVICE);
mTaskManager = GTaskManager.getInstance();
}
public void cancelSync() {
/**
*
*/ public void cancelSync() {
mTaskManager.cancelSync();
}
/**
*
* @param message
*/
public void publishProgess(String message) {
publishProgress(new String[] {
message
});
}
/**
*
* @param tickerId ID
* @param content
*/
private void showNotification(int tickerId, String content) {
Notification notification = new Notification(R.drawable.notification, mContext
.getString(tickerId), System.currentTimeMillis());

@ -14,6 +14,17 @@
* limitations under the License.
*/
/**
* 1. Note便,:
* - mNoteDiffValues:便,,SQLitenotes
* - mNoteData:便,SQLitedata
* 2. NotemNoteDiffValuesmNoteData,便
* 3. NotesyncNote便notes,data
* 4. NoteData,(mTextDataValues)(mCallDataValues)
* 5. NoteDatamTextDataValuesmCallDataValues
* 6. NoteDatapushIntoContentResolvermTextDataValuesmCallDataValuesdata
*/
package net.micode.notes.model;
import android.content.ContentProviderOperation;
import android.content.ContentProviderResult;
@ -41,6 +52,13 @@ public class Note {
/**
* Create a new note id for adding a new note to databases
*/
/**
* 便ID
*
* @param context
* @param folderId ID
* @return 便ID
*/
public static synchronized long getNewNoteId(Context context, long folderId) {
// Create a new note in the database
ContentValues values = new ContentValues();
@ -70,24 +88,49 @@ public class Note {
mNoteData = new NoteData();
}
/**
* 便
*
* @param key
* @param value
*/
public void setNoteValue(String key, String value) {
mNoteDiffValues.put(key, value);
mNoteDiffValues.put(NoteColumns.LOCAL_MODIFIED, 1);
mNoteDiffValues.put(NoteColumns.MODIFIED_DATE, System.currentTimeMillis());
}
/**
*
*
* @param key
* @param value
*/
public void setTextData(String key, String value) {
mNoteData.setTextData(key, value);
}
/**
* ID
*
* @param id ID
*/
public void setTextDataId(long id) {
mNoteData.setTextDataId(id);
}
/**
* ID
*
* @param id ID
*/
public long getTextDataId() {
return mNoteData.mTextDataId;
}
/**
*
*
* @param key
* @param value
*/
public void setCallDataId(long id) {
mNoteData.setCallDataId(id);
}
@ -95,11 +138,17 @@ public class Note {
public void setCallData(String key, String value) {
mNoteData.setCallData(key, value);
}
/**是否本地修改*/
public boolean isLocalModified() {
return mNoteDiffValues.size() > 0 || mNoteData.isLocalModified();
}
/**
* 便
*
* @param context
* @param noteId 便ID
* @return
*/
public boolean syncNote(Context context, long noteId) {
if (noteId <= 0) {
throw new IllegalArgumentException("Wrong note id:" + noteId);

Loading…
Cancel
Save