|
|
|
@ -18,7 +18,7 @@ package net.micode.notes.gtask.data;
|
|
|
|
|
|
|
|
|
|
import android.database.Cursor;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
|
|
import javafx.concurrent.Task;
|
|
|
|
|
import net.micode.notes.tool.GTaskStringUtils;
|
|
|
|
|
|
|
|
|
|
import org.json.JSONException;
|
|
|
|
@ -27,37 +27,43 @@ import org.json.JSONObject;
|
|
|
|
|
|
|
|
|
|
public class MetaData extends Task {
|
|
|
|
|
private final static String TAG = MetaData.class.getSimpleName();
|
|
|
|
|
|
|
|
|
|
//调用getSimpleName ()函数,将得到类的简写名称存入字符串TAG中
|
|
|
|
|
private String mRelatedGid = null;
|
|
|
|
|
|
|
|
|
|
public void setMeta(String gid, JSONObject metaInfo) {
|
|
|
|
|
//调用JSONObject库函数put (),Task类中的setNotes ()和setName ()函数生成元数据库
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
metaInfo.put(GTaskStringUtils.META_HEAD_GTASK_ID, gid);
|
|
|
|
|
} catch (JSONException e) {
|
|
|
|
|
Log.e(TAG, "failed to put related gid");
|
|
|
|
|
Log.e(TAG, "failed to put related gid");//输出错误信息
|
|
|
|
|
}
|
|
|
|
|
setNotes(metaInfo.toString());
|
|
|
|
|
setName(GTaskStringUtils.META_NOTE_NAME);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getRelatedGid() {
|
|
|
|
|
//获取相关联的Gid
|
|
|
|
|
return mRelatedGid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isWorthSaving() {
|
|
|
|
|
//判断当前数据是否为空,若为空则返回真即值得保存
|
|
|
|
|
return getNotes() != null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setContentByRemoteJSON(JSONObject js) {
|
|
|
|
|
//使用远程json数据对象设置元数据内容
|
|
|
|
|
super.setContentByRemoteJSON(js);
|
|
|
|
|
if (getNotes() != null) {
|
|
|
|
|
try {
|
|
|
|
|
JSONObject metaInfo = new JSONObject(getNotes().trim());
|
|
|
|
|
mRelatedGid = metaInfo.getString(GTaskStringUtils.META_HEAD_GTASK_ID);
|
|
|
|
|
} catch (JSONException e) {
|
|
|
|
|
Log.w(TAG, "failed to get related gid");
|
|
|
|
|
Log.w(TAG, "failed to get related gid");//输出警告信息
|
|
|
|
|
|
|
|
|
|
mRelatedGid = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -66,16 +72,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");
|
|
|
|
|
//使用本地json数据对象设置元数据内容
|
|
|
|
|
throw new IllegalAccessError("MetaData:setContentByLocalJSON should not be called");//传递非法参数异常
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject getLocalJSONFromContent() {
|
|
|
|
|
//从元数据内容中获取本地json对象
|
|
|
|
|
throw new IllegalAccessError("MetaData:getLocalJSONFromContent should not be called");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getSyncAction(Cursor c) {
|
|
|
|
|
//获取同步动作状态
|
|
|
|
|
throw new IllegalAccessError("MetaData:getSyncAction should not be called");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|