|
|
这段代码是一个Android应用程序中的Java类,名为`TaskList`,继承自`Node`类,用于表示与Google Tasks相关的任务列表。以下是代码的注释:
|
|
|
|
|
|
```java
|
|
|
/*
|
|
|
* Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
|
|
|
*
|
|
|
* 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
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
* See the License for the specific language governing permissions and
|
|
|
* limitations under the License.
|
|
|
*/
|
|
|
|
|
|
package net.micode.notes.gtask.data;
|
|
|
|
|
|
import android.database.Cursor;
|
|
|
import android.util.Log;
|
|
|
|
|
|
import net.micode.notes.data.Notes;
|
|
|
import net.micode.notes.data.Notes.NoteColumns;
|
|
|
import net.micode.notes.gtask.exception.ActionFailureException;
|
|
|
import net.micode.notes.tool.GTaskStringUtils;
|
|
|
|
|
|
import org.json.JSONException;
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
// TaskList类继承自Node类,用于表示一个任务列表
|
|
|
public class TaskList extends Node {
|
|
|
// 类的标签,用于日志记录
|
|
|
private static final String TAG = TaskList.class.getSimpleName();
|
|
|
|
|
|
// 成员变量
|
|
|
private int mIndex; // 任务列表的索引
|
|
|
private ArrayList<Task> mChildren; // 任务列表中的子任务
|
|
|
|
|
|
// 构造函数,初始化TaskList对象
|
|
|
public TaskList() {
|
|
|
super();
|
|
|
mChildren = new ArrayList<Task>();
|
|
|
mIndex = 1;
|
|
|
}
|
|
|
|
|
|
// 获取创建任务列表的JSON对象
|
|
|
public JSONObject getCreateAction(int actionId) {
|
|
|
// ... 创建任务列表的JSON对象
|
|
|
}
|
|
|
|
|
|
// 获取更新任务列表的JSON对象
|
|
|
public JSONObject getUpdateAction(int actionId) {
|
|
|
// ... 更新任务列表的JSON对象
|
|
|
}
|
|
|
|
|
|
// 根据远程JSON对象设置任务列表内容
|
|
|
public void setContentByRemoteJSON(JSONObject js) {
|
|
|
// ... 从远程JSON对象设置任务列表内容
|
|
|
}
|
|
|
|
|
|
// 根据本地JSON对象设置任务列表内容
|
|
|
public void setContentByLocalJSON(JSONObject js) {
|
|
|
// ... 从本地JSON对象设置任务列表内容
|
|
|
}
|
|
|
|
|
|
// 从任务列表内容获取本地JSON对象
|
|
|
public JSONObject getLocalJSONFromContent() {
|
|
|
// ... 从任务列表内容获取本地JSON对象
|
|
|
}
|
|
|
|
|
|
// 获取同步操作
|
|
|
public int getSyncAction(Cursor c) {
|
|
|
// ... 根据数据库游标获取同步操作
|
|
|
}
|
|
|
|
|
|
// 获取子任务的数量
|
|
|
public int getChildTaskCount() {
|
|
|
return mChildren.size();
|
|
|
}
|
|
|
|
|
|
// 添加子任务
|
|
|
public boolean addChildTask(Task task) {
|
|
|
// ... 添加子任务到任务列表
|
|
|
}
|
|
|
|
|
|
// 在指定索引处添加子任务
|
|
|
public boolean addChildTask(Task task, int index) {
|
|
|
// ... 在指定索引处添加子任务到任务列表
|
|
|
}
|
|
|
|
|
|
// 移除子任务
|
|
|
public boolean removeChildTask(Task task) {
|
|
|
// ... 从任务列表移除子任务
|
|
|
}
|
|
|
|
|
|
// 移动子任务到指定索引
|
|
|
public boolean moveChildTask(Task task, int index) {
|
|
|
// ... 移动子任务到指定索引
|
|
|
}
|
|
|
|
|
|
// 根据GID查找子任务
|
|
|
public Task findChildTaskByGid(String gid) {
|
|
|
// ... 根据GID查找子任务
|
|
|
}
|
|
|
|
|
|
// 获取子任务的索引
|
|
|
public int getChildTaskIndex(Task task) {
|
|
|
return mChildren.indexOf(task);
|
|
|
}
|
|
|
|
|
|
// 根据索引获取子任务
|
|
|
public Task getChildTaskByIndex(int index) {
|
|
|
// ... 根据索引获取子任务
|
|
|
}
|
|
|
|
|
|
// 根据GID获取子任务
|
|
|
public Task getChilTaskByGid(String gid) {
|
|
|
// ... 根据GID获取子任务
|
|
|
}
|
|
|
|
|
|
// 获取子任务列表
|
|
|
public ArrayList<Task> getChildTaskList() {
|
|
|
return this.mChildren;
|
|
|
}
|
|
|
|
|
|
// 设置和获取方法
|
|
|
public void setIndex(int index) {
|
|
|
this.mIndex = index;
|
|
|
}
|
|
|
|
|
|
public int getIndex() {
|
|
|
return this.mIndex;
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|