c_master
yijunchao 2 years ago
parent aec80c8d58
commit c9ef1bfd8d

@ -1,104 +1,96 @@
/**
MetaDataTaskGTask
*/
package net.micode.notes.gtask.data; package net.micode.notes.gtask.data;
import android.database.Cursor;
import android.util.Log;
import net.micode.notes.tool.GTaskStringUtils;
import org.json.JSONException;
import org.json.JSONObject;
public class MetaData extends Task { public class MetaData extends Task {
/*
* TAG
* getSimpleName ()
*/
private final static String TAG = MetaData.class.getSimpleName(); private final static String TAG = MetaData.class.getSimpleName();
// 关联的gid
private String mRelatedGid = null; private String mRelatedGid = null;
/*
* /**
* JSONObjectput ()TasksetNotes ()setName () * gid
* *
* @param gid gid
* @param metaInfo
*/ */
public void setMeta(String gid, JSONObject metaInfo) public void setMeta(String gid, JSONObject metaInfo) {
{
//对函数块进行注释
try { try {
// 将关联的gid放入JSONObject中
metaInfo.put(GTaskStringUtils.META_HEAD_GTASK_ID, gid); metaInfo.put(GTaskStringUtils.META_HEAD_GTASK_ID, gid);
/*
* metaInfojsonobject
*/
} catch (JSONException e) { } catch (JSONException e) {
Log.e(TAG, "failed to put related gid"); Log.e(TAG, "failed to put related gid");
/*
*
*/
} }
// 将元数据的相关信息转换为字符串设置为Task的notes
setNotes(metaInfo.toString()); setNotes(metaInfo.toString());
// 设置Task的名称为元数据的名称
setName(GTaskStringUtils.META_NOTE_NAME); setName(GTaskStringUtils.META_NOTE_NAME);
} }
/*
* Gid
*/
public String getRelatedGid() { public String getRelatedGid() {
return mRelatedGid; return mRelatedGid;
} }
/*
* /**
* Made By CuiCan *
* @return truefalse
*/ */
@Override @Override
public boolean isWorthSaving() { public boolean isWorthSaving() {
return getNotes() != null; return getNotes() != null;
} }
/*
* 使json /**
* TasksetContentByRemoteJSON () * JSON
* * @param js JSON
*/ */
@Override @Override
public void setContentByRemoteJSON(JSONObject js) { public void setContentByRemoteJSON(JSONObject js) {
super.setContentByRemoteJSON(js); super.setContentByRemoteJSON(js);
if (getNotes() != null) { if (getNotes() != null) {
try { try {
// 解析备注信息
JSONObject metaInfo = new JSONObject(getNotes().trim()); JSONObject metaInfo = new JSONObject(getNotes().trim());
mRelatedGid = metaInfo.getString(GTaskStringUtils.META_HEAD_GTASK_ID); mRelatedGid = metaInfo.getString(GTaskStringUtils.META_HEAD_GTASK_ID);
} catch (JSONException e) { } catch (JSONException e) {
Log.w(TAG, "failed to get related gid"); Log.w(TAG, "failed to get related gid");
/*
*
*/
mRelatedGid = null; mRelatedGid = null;
} }
} }
} }
/*
* 使json /**
* Made By CuiCan * JSON
* @param js JSON
*/ */
@Override @Override
public void setContentByLocalJSON(JSONObject js) { public void setContentByLocalJSON(JSONObject js) {
// this function should not be called // 不应该被调用的方法
throw new IllegalAccessError("MetaData:setContentByLocalJSON should not be called"); throw new IllegalAccessError("MetaData:setContentByLocalJSON should not be called");
/*
*
*/
} }
/*
* json /**
* Made By CuiCan *
* @return
*/ */
@Override @Override
public JSONObject getLocalJSONFromContent() { public JSONObject getLocalJSONFromContent() {
throw new IllegalAccessError("MetaData:getLocalJSONFromContent should not be called"); throw new IllegalAccessError("MetaData:getLocalJSONFromContent should not be called");
/*
*
* Made By Cui Can
*/
} }
/* /******/
* /* Cursor
* Made By CuiCan
*/ IllegalAccessError "MetaData:getSyncAction should not be called" "MetaData:getSyncAction 不应该被调用"*/
@Override @Override
public int getSyncAction(Cursor c) { public int getSyncAction(Cursor c) {
throw new IllegalAccessError("MetaData:getSyncAction should not be called"); throw new IllegalAccessError("MetaData:getSyncAction should not be called");
/*
*
* Made By Cui Can
*/
} }
} }
Loading…
Cancel
Save