当前位置: 首页>>代码示例>>Java>>正文


Java ListCache类代码示例

本文整理汇总了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;
                            }
                        }
                    }
                }
            }
        });
    }
}
 
开发者ID:leibing8912,项目名称:JkStepSensor,代码行数:33,代码来源:DataCache.java

示例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);
                        }
                    }
                }
            }
        });
    }
}
 
开发者ID:leibing8912,项目名称:JkstepSensorJarPack,代码行数:19,代码来源:DataCache.java

示例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;
                            }
                        }
                    }
                }
            }
        });
    }
}
 
开发者ID:leibing8912,项目名称:JkstepSensorJarPack,代码行数:23,代码来源:DataCache.java

示例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);
}
 
开发者ID:leibing8912,项目名称:CustomCache,代码行数:19,代码来源:ModelActivity.java

示例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);
}
 
开发者ID:leibing8912,项目名称:CustomCache,代码行数:19,代码来源:StuActivity.java

示例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;
    }
}
 
开发者ID:leibing8912,项目名称:CustomCache,代码行数:34,代码来源:ModelActivity.java

示例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;
    }
}
 
开发者ID:leibing8912,项目名称:CustomCache,代码行数:34,代码来源:StuActivity.java

示例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);
            }
        });
    }
}
 
开发者ID:leibing8912,项目名称:JkStepSensor,代码行数:54,代码来源:DataCache.java

示例9: DataCache

import cn.jianke.customcache.data.ListCache; //导入依赖的package包/类
private DataCache(){
    mListCache = new ListCache<>();
    mCacheList = new ArrayList<>();
    mSpLocalCache = new SpLocalCache<>(ListCache.class, StepModel.class);
}
 
开发者ID:leibing8912,项目名称:JkstepSensorJarPack,代码行数:6,代码来源:DataCache.java

示例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);
            }
        });
    }
}
 
开发者ID:leibing8912,项目名称:JkstepSensorJarPack,代码行数:42,代码来源:DataCache.java

示例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);
}
 
开发者ID:leibing8912,项目名称:CustomCache,代码行数:68,代码来源:MainActivity.java

示例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);
}
 
开发者ID:leibing8912,项目名称:JkStepSensor,代码行数:14,代码来源:DataCache.java


注:本文中的cn.jianke.customcache.data.ListCache类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。