hjj is reading

hjj_branch
hejunjie 2 years ago
parent 3d820e6141
commit d625cf783d

@ -33,7 +33,7 @@ import java.util.ArrayList;
public class TaskList extends Node { public class TaskList extends Node {
private static final String TAG = TaskList.class.getSimpleName(); private static final String TAG = TaskList.class.getSimpleName();
private int mIndex; private int mIndex;//当前TaskList的指针
private ArrayList<Task> mChildren; private ArrayList<Task> mChildren;
@ -43,6 +43,7 @@ public class TaskList extends Node {
mIndex = 1; mIndex = 1;
} }
//生成并返回一个半酣了一定数据的JSONObject实体
public JSONObject getCreateAction(int actionId) { public JSONObject getCreateAction(int actionId) {
JSONObject js = new JSONObject(); JSONObject js = new JSONObject();
@ -74,6 +75,7 @@ public class TaskList extends Node {
return js; return js;
} }
//更新JSONObject实体
public JSONObject getUpdateAction(int actionId) { public JSONObject getUpdateAction(int actionId) {
JSONObject js = new JSONObject(); JSONObject js = new JSONObject();
@ -103,6 +105,7 @@ public class TaskList extends Node {
return js; return js;
} }
//通过远程JSON对象实现远程同步
public void setContentByRemoteJSON(JSONObject js) { public void setContentByRemoteJSON(JSONObject js) {
if (js != null) { if (js != null) {
try { try {
@ -129,6 +132,7 @@ public class TaskList extends Node {
} }
} }
//通过本地JSON对象实现本地同步
public void setContentByLocalJSON(JSONObject js) { public void setContentByLocalJSON(JSONObject js) {
if (js == null || !js.has(GTaskStringUtils.META_HEAD_NOTE)) { if (js == null || !js.has(GTaskStringUtils.META_HEAD_NOTE)) {
Log.w(TAG, "setContentByLocalJSON: nothing is avaiable"); Log.w(TAG, "setContentByLocalJSON: nothing is avaiable");
@ -157,6 +161,7 @@ public class TaskList extends Node {
} }
} }
//将本地内容转换为JSONObject
public JSONObject getLocalJSONFromContent() { public JSONObject getLocalJSONFromContent() {
try { try {
JSONObject js = new JSONObject(); JSONObject js = new JSONObject();
@ -183,6 +188,7 @@ public class TaskList extends Node {
} }
} }
//提供同步任务,确定同步操作的类型。
public int getSyncAction(Cursor c) { public int getSyncAction(Cursor c) {
try { try {
if (c.getInt(SqlNote.LOCAL_MODIFIED_COLUMN) == 0) { if (c.getInt(SqlNote.LOCAL_MODIFIED_COLUMN) == 0) {
@ -220,6 +226,7 @@ public class TaskList extends Node {
return mChildren.size(); return mChildren.size();
} }
//在当前任务表末尾添加新的任务
public boolean addChildTask(Task task) { public boolean addChildTask(Task task) {
boolean ret = false; boolean ret = false;
if (task != null && !mChildren.contains(task)) { if (task != null && !mChildren.contains(task)) {
@ -234,6 +241,7 @@ public class TaskList extends Node {
return ret; return ret;
} }
//在当前任务表的指定位置添加新的任务
public boolean addChildTask(Task task, int index) { public boolean addChildTask(Task task, int index) {
if (index < 0 || index > mChildren.size()) { if (index < 0 || index > mChildren.size()) {
Log.e(TAG, "add child task: invalid index"); Log.e(TAG, "add child task: invalid index");
@ -260,6 +268,7 @@ public class TaskList extends Node {
return true; return true;
} }
//删除任务表中的一个任务
public boolean removeChildTask(Task task) { public boolean removeChildTask(Task task) {
boolean ret = false; boolean ret = false;
int index = mChildren.indexOf(task); int index = mChildren.indexOf(task);
@ -281,6 +290,7 @@ public class TaskList extends Node {
return ret; return ret;
} }
//移动任务表中的一个任务
public boolean moveChildTask(Task task, int index) { public boolean moveChildTask(Task task, int index) {
if (index < 0 || index >= mChildren.size()) { if (index < 0 || index >= mChildren.size()) {
@ -299,6 +309,7 @@ public class TaskList extends Node {
return (removeChildTask(task) && addChildTask(task, index)); return (removeChildTask(task) && addChildTask(task, index));
} }
//寻找一个任务
public Task findChildTaskByGid(String gid) { public Task findChildTaskByGid(String gid) {
for (int i = 0; i < mChildren.size(); i++) { for (int i = 0; i < mChildren.size(); i++) {
Task t = mChildren.get(i); Task t = mChildren.get(i);
@ -309,10 +320,12 @@ public class TaskList extends Node {
return null; return null;
} }
//返指定index的任务
public int getChildTaskIndex(Task task) { public int getChildTaskIndex(Task task) {
return mChildren.indexOf(task); return mChildren.indexOf(task);
} }
//返回指定index的任务
public Task getChildTaskByIndex(int index) { public Task getChildTaskByIndex(int index) {
if (index < 0 || index >= mChildren.size()) { if (index < 0 || index >= mChildren.size()) {
Log.e(TAG, "getTaskByIndex: invalid index"); Log.e(TAG, "getTaskByIndex: invalid index");
@ -320,7 +333,8 @@ public class TaskList extends Node {
} }
return mChildren.get(index); return mChildren.get(index);
} }
//返回指定gid的任务
public Task getChilTaskByGid(String gid) { public Task getChilTaskByGid(String gid) {
for (Task task : mChildren) { for (Task task : mChildren) {
if (task.getGid().equals(gid)) if (task.getGid().equals(gid))

Loading…
Cancel
Save