Search in sources :

Example 1 with MemoryCacheStore

use of com.shizhefei.task.imp.MemoryCacheStore in project MVCHelper by LuckyJayce.

the class ListTaskActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ultrarecyclerview);
    PtrClassicFrameLayout mPtrFrameLayout = (PtrClassicFrameLayout) findViewById(R.id.rotate_header_list_view_frame);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    taskHelper = new TaskHelper<>(new MemoryCacheStore(200));
    //注册全局的task执行回调
    taskHelper.registerCallBack(new ICallback<MovieAmount>() {

        @Override
        public void onPreExecute(Object task) {
            Log.d("pppp", "task:" + task);
        }

        @Override
        public void onProgress(Object task, int percent, long current, long total, Object extraData) {
        }

        @Override
        public void onPostExecute(Object task, Code code, Exception exception, MovieAmount movieAmount) {
            Log.d("pppp", "task:" + task + " code:" + code);
        }
    });
    mvcHelper = new MVCUltraHelper<>(mPtrFrameLayout);
    // 设置数据源
    mvcHelper.setDataSource(new MoviesDataSource());
    // 设置适配器
    mvcHelper.setAdapter(new MoviesAdapter(taskHelper));
    // 加载数据
    mvcHelper.refresh();
}
Also used : MemoryCacheStore(com.shizhefei.task.imp.MemoryCacheStore) MoviesAdapter(com.shizhefei.test.view.adapters.MoviesAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Code(com.shizhefei.task.Code) MoviesDataSource(com.shizhefei.test.models.datasource.MoviesDataSource) PtrClassicFrameLayout(in.srain.cube.views.ptr.PtrClassicFrameLayout) MovieAmount(com.shizhefei.test.models.enties.MovieAmount) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 Code (com.shizhefei.task.Code)1 MemoryCacheStore (com.shizhefei.task.imp.MemoryCacheStore)1 MoviesDataSource (com.shizhefei.test.models.datasource.MoviesDataSource)1 MovieAmount (com.shizhefei.test.models.enties.MovieAmount)1 MoviesAdapter (com.shizhefei.test.view.adapters.MoviesAdapter)1 PtrClassicFrameLayout (in.srain.cube.views.ptr.PtrClassicFrameLayout)1