Network request:
in onRespend
EntityCatogory response
The usage of the response object is not introduced
save:
msg.obj = response new thread
EntityCatogory obj = (EntityCatogory)msg.obj;
TBCategory databased = new TBCategory();
databased.key = ... (keyy) ..;
databased.content= JGson.instance().gson().toJson(response);!!!!!! Don't deconstruct and make string directly pass
databased.createAt = System.currentTimeMillis();
Cache is used:
TbCategory databaseCache = DbHelper.queryCategoryCacheByKey (keyy);
if (databaseCache != null && databaseCache.content != null && !DateUtils.isExpire(databaseCache.createdAt)) {
brandData = GsonUtils.parseJsonWithGson(databaseCache.content, EntityCatogory.class);
}
brandData object usage is not introduced
Original text: http://www.cnblogs.com/vitabebeauty/p/7263078.html