Update MetaData.java

master
pasky49wx 4 weeks ago
parent 02228f5605
commit f5f47dbdbe

@ -24,56 +24,87 @@ import net.micode.notes.tool.GTaskStringUtils;
import org.json.JSONException;
import org.json.JSONObject;
/**
* TaskGoogle Tasks
* JSONGID
*/
public class MetaData extends Task {
private final static String TAG = MetaData.class.getSimpleName();
// 关联的Google Tasks的GID全局唯一标识符
private String mRelatedGid = null;
/**
*
* @param gid Google TasksGID
* @param metaInfo JSON
*/
public void setMeta(String gid, JSONObject metaInfo) {
try {
// 在元数据JSON中添加GID头部信息
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);
}
/**
* Google TasksGID
* @return GIDnull
*/
public String getRelatedGid() {
return mRelatedGid;
}
/**
* 便
* @return 便nulltruefalse
*/
@Override
public boolean isWorthSaving() {
return getNotes() != null;
}
/**
* JSON
* @param js JSON
*/
@Override
public void setContentByRemoteJSON(JSONObject js) {
super.setContentByRemoteJSON(js);
super.setContentByRemoteJSON(js); // 先调用父类解析逻辑
if (getNotes() != null) {
try {
// 解析便签内容中的元数据JSON
JSONObject metaInfo = new JSONObject(getNotes().trim());
// 提取关联的GID
mRelatedGid = metaInfo.getString(GTaskStringUtils.META_HEAD_GTASK_ID);
} catch (JSONException e) {
Log.w(TAG, "failed to get related gid");
mRelatedGid = null;
mRelatedGid = null; // 解析失败时清空GID
}
}
}
/**
* JSON
* @throws IllegalAccessError 使
*/
@Override
public void setContentByLocalJSON(JSONObject js) {
// this function should not be called
throw new IllegalAccessError("MetaData:setContentByLocalJSON should not be called");
}
/**
* JSON
* @throws IllegalAccessError 使
*/
@Override
public JSONObject getLocalJSONFromContent() {
throw new IllegalAccessError("MetaData:getLocalJSONFromContent should not be called");
}
/**
*
* @param c 使
* @throws IllegalAccessError 使
*/
@Override
public int getSyncAction(Cursor c) {
throw new IllegalAccessError("MetaData:getSyncAction should not be called");

Loading…
Cancel
Save