本文整理汇总了Java中cn.jianke.customcache.data.ListCache类的典型用法代码示例。如果您正苦于以下问题:Java ListCache类的具体用法?Java ListCache怎么用?Java ListCache使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ListCache类属于cn.jianke.customcache.data包,在下文中一共展示了ListCache类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clearCacheByDate
import cn.jianke.customcache.data.ListCache; //导入依赖的package包/类
/**
* 根据日期清除计步数据
* @author leibing
* @createTime 2016/08/31
* @lastModify 2016/08/31
* @param context 上下文
* @return
*/
public void clearCacheByDate(Context context, Date date){
// 日期 格式如2016/08/31
final String dateStr = DateUtils.simpleDateFormat(date);
if (mSpLocalCache != null){
// 读取缓存
mSpLocalCache.read(context, new SpLocalCache.LocalCacheCallBack() {
@Override
public void readCacheComplete(Object obj) {
if (obj != null){
mListCache = (ListCache<StepModel>) obj;
if (mListCache != null) {
mCacheList = mListCache.getObjList();
for (StepModel stepModel : mCacheList) {
if (dateStr.equals(stepModel.getDate())) {
mCacheList.remove(stepModel);
break;
}
}
}
}
}
});
}
}
示例2: getAllCache
import cn.jianke.customcache.data.ListCache; //导入依赖的package包/类
public void getAllCache(Context context,final DataCacheListener mDataCacheListener){
if (mSpLocalCache != null){
mSpLocalCache.read(context, new SpLocalCache.LocalCacheCallBack() {
@Override
public void readCacheComplete(Object obj) {
if (obj != null){
mListCache = (ListCache<StepModel>) obj;
if (mListCache != null && mDataCacheListener != null){
mCacheList = mListCache.getObjList();
if (mCacheList != null && mCacheList.size() != 0) {
mDataCacheListener.readAllCache(mCacheList);
}
}
}
}
});
}
}
示例3: clearCacheByDate
import cn.jianke.customcache.data.ListCache; //导入依赖的package包/类
public void clearCacheByDate(Context context, Date date){
final String dateStr = DateUtils.simpleDateFormat(date);
if (mSpLocalCache != null){
mSpLocalCache.read(context, new SpLocalCache.LocalCacheCallBack() {
@Override
public void readCacheComplete(Object obj) {
if (obj != null){
mListCache = (ListCache<StepModel>) obj;
if (mListCache != null) {
mCacheList = mListCache.getObjList();
for (StepModel stepModel : mCacheList) {
if (dateStr.equals(stepModel.getDate())) {
mCacheList.remove(stepModel);
break;
}
}
}
}
}
});
}
}
示例4: onCreate
import cn.jianke.customcache.data.ListCache; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cache);
// FindView
cacheLv = (ListView) findViewById(R.id.lv_show_cache);
// 初始化缓存对象
mSpLocalCache = new SpLocalCache<>(ListCache.class, Model.class);
// 初始化数据源
mData = new ArrayList<>();
// 初始化Adapter
cacheAdapter = new ModelAdapter(mData, ModelActivity.this);
// 绑定ListView
cacheLv.setAdapter(cacheAdapter);
// onClick
findViewById(R.id.btn_read_cache).setOnClickListener(this);
findViewById(R.id.btn_clear_data).setOnClickListener(this);
}
示例5: onCreate
import cn.jianke.customcache.data.ListCache; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cache);
// FindView
cacheLv = (ListView) findViewById(R.id.lv_show_cache);
// 初始化缓存对象
mSpLocalCache = new SpLocalCache<>(ListCache.class, Stu.class);
// 初始化数据源
mData = new ArrayList<>();
// 初始化Adapter
cacheAdapter = new StuAdapter(mData, StuActivity.this);
// 绑定ListView
cacheLv.setAdapter(cacheAdapter);
// onClick
findViewById(R.id.btn_read_cache).setOnClickListener(this);
findViewById(R.id.btn_clear_data).setOnClickListener(this);
}
示例6: onClick
import cn.jianke.customcache.data.ListCache; //导入依赖的package包/类
@Override
public void onClick(View view) {
switch (view.getId()){
case R.id.btn_read_cache:
// 读取缓存数据
mSpLocalCache.read(ModelActivity.this, new SpLocalCache.LocalCacheCallBack() {
@Override
public void readCacheComplete(Object obj) {
if (obj != null) {
ListCache<Model> mReadCache = (ListCache<Model>) obj;
if (mReadCache != null){
ArrayList<Model> modelArrayList = mReadCache.getObjList();
if (modelArrayList != null){
mData = modelArrayList;
// 更新UI
updateUI(mData);
}
}
}else {
System.out.println("dddddddddddddddddddd 缓存为空,请检查!");
}
}
});
break;
case R.id.btn_clear_data:
mData.clear();
// 更新UI
updateUI(mData);
break;
default:
break;
}
}
示例7: onClick
import cn.jianke.customcache.data.ListCache; //导入依赖的package包/类
@Override
public void onClick(View view) {
switch (view.getId()){
case R.id.btn_read_cache:
// 读取缓存数据
mSpLocalCache.read(StuActivity.this, new SpLocalCache.LocalCacheCallBack() {
@Override
public void readCacheComplete(Object obj) {
if (obj != null) {
ListCache<Stu> mReadCache = (ListCache<Stu>) obj;
if (mReadCache != null){
ArrayList<Stu> modelArrayList = mReadCache.getObjList();
if (modelArrayList != null){
mData = modelArrayList;
// 更新UI
updateUI(mData);
}
}
}else {
System.out.println("dddddddddddddddddddd 缓存为空,请检查!");
}
}
});
break;
case R.id.btn_clear_data:
mData.clear();
// 更新UI
updateUI(mData);
break;
default:
break;
}
}
示例8: addStepCache
import cn.jianke.customcache.data.ListCache; //导入依赖的package包/类
/**
* 添加计步数据
* @author leibing
* @createTime 2016/08/31
* @lastModify 2016/08/31
* @param context 上下文
* @param mStepModel 计步数据
* @return
*/
public void addStepCache(final Context context, final StepModel mStepModel){
if (mSpLocalCache != null){
// 读取缓存
mSpLocalCache.read(context, new SpLocalCache.LocalCacheCallBack() {
@Override
public void readCacheComplete(Object obj) {
if (obj != null){
mListCache = (ListCache<StepModel>) obj;
if (mListCache != null) {
mCacheList = mListCache.getObjList();
if (mCacheList != null ){
if (mCacheList.size() != 0){
for (StepModel stepModel : mCacheList) {
if (mStepModel.getDate().equals(stepModel.getDate())) {
// 新步数与旧步数差值不能为负数
int cha = Integer.parseInt(mStepModel.getStep())
- Integer.parseInt(stepModel.getStep());
if (cha >= 0) {
mCacheList.remove(stepModel);
}
break;
}
}
}
mCacheList.add(mStepModel);
}else {
mCacheList = new ArrayList<>();
mCacheList.add(mStepModel);
}
}else {
mCacheList = new ArrayList<>();
mCacheList.add(mStepModel);
}
}else {
mCacheList = new ArrayList<>();
mCacheList.add(mStepModel);
}
// 保存缓存
mListCache.setObjList(mCacheList);
mSpLocalCache.save(context, mListCache);
}
});
}
}
示例9: DataCache
import cn.jianke.customcache.data.ListCache; //导入依赖的package包/类
private DataCache(){
mListCache = new ListCache<>();
mCacheList = new ArrayList<>();
mSpLocalCache = new SpLocalCache<>(ListCache.class, StepModel.class);
}
示例10: addStepCache
import cn.jianke.customcache.data.ListCache; //导入依赖的package包/类
public void addStepCache(final Context context, final StepModel mStepModel){
if (mSpLocalCache != null){
mSpLocalCache.read(context, new SpLocalCache.LocalCacheCallBack() {
@Override
public void readCacheComplete(Object obj) {
if (obj != null){
mListCache = (ListCache<StepModel>) obj;
if (mListCache != null) {
mCacheList = mListCache.getObjList();
if (mCacheList != null ){
if (mCacheList.size() != 0){
for (StepModel stepModel : mCacheList) {
if (mStepModel.getDate().equals(stepModel.getDate())) {
int cha = Integer.parseInt(mStepModel.getStep())
- Integer.parseInt(stepModel.getStep());
if (cha >= 0) {
mCacheList.remove(stepModel);
}
break;
}
}
}
mCacheList.add(mStepModel);
}else {
mCacheList = new ArrayList<>();
mCacheList.add(mStepModel);
}
}else {
mCacheList = new ArrayList<>();
mCacheList.add(mStepModel);
}
}else {
mCacheList = new ArrayList<>();
mCacheList.add(mStepModel);
}
mListCache.setObjList(mCacheList);
mSpLocalCache.save(context, mListCache);
}
});
}
}
示例11: onCreate
import cn.jianke.customcache.data.ListCache; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// 初始化数据源
modelList = new ArrayList<>();
stuList = new ArrayList<>();
// 模拟数据
mModel = new Model();
mModel.setName("张三");
mModel.setAge(18);
mModel.setAddress("北京");
modelList.add(mModel);
mModel = new Model();
mModel.setName("李四");
mModel.setAge(20);
mModel.setAddress("深圳");
modelList.add(mModel);
mModel = new Model();
mModel.setName("王五");
mModel.setAge(25);
mModel.setAddress("广州");
modelList.add(mModel);
mStu = new Stu();
mStu.setStuName("周杰伦");
mStu.setStuAge(37);
mStu.setStuAddress("台湾");
stuList.add(mStu);
mStu = new Stu();
mStu.setStuName("那英");
mStu.setStuAge(45);
mStu.setStuAddress("沈阳");
stuList.add(mStu);
mStu = new Stu();
mStu.setStuName("庾澄庆");
mStu.setStuAge(49);
mStu.setStuAddress("台湾");
stuList.add(mStu);
mStu = new Stu();
mStu.setStuName("汪峰");
mStu.setStuAge(42);
mStu.setStuAddress("北京");
stuList.add(mStu);
// 初始化缓存对象
mSpLocalCache = new SpLocalCache<>(ListCache.class, Model.class);
lSpLocalCache = new SpLocalCache<>(ListCache.class, Stu.class);
// 缓存List数据
ListCache<Model> mListCache = new ListCache<>();
mListCache.setObjList(modelList);
ListCache<Stu> stuListCache = new ListCache<>();
stuListCache.setObjList(stuList);
// 缓存数据
mSpLocalCache.save(this, mListCache);
lSpLocalCache.save(this, stuListCache);
// onClick
findViewById(R.id.btn_turnto_model).setOnClickListener(this);
findViewById(R.id.btn_turnto_stu).setOnClickListener(this);
}
示例12: DataCache
import cn.jianke.customcache.data.ListCache; //导入依赖的package包/类
/**
* Constructor
* @author leibing
* @createTime 2016/08/31
* @lastModify 2016/08/31
* @param
* @return
*/
private DataCache(){
mListCache = new ListCache<>();
mCacheList = new ArrayList<>();
mSpLocalCache = new SpLocalCache<>(ListCache.class, StepModel.class);
}