Skip to content

@LuckyJayce LuckyJayce released this Nov 3, 2018 · 3 commits to master since this release

将task代码抽离出单独 一个类库,https://github.com/LuckyJayce/Task
MVCHelper_Library专注于下拉刷新,加载布局切换和列表加载更多
MVCHelper_Library依赖 com.shizhefei:task-core:1.0.0类库实现执行task逻辑

Assets 2

@LuckyJayce LuckyJayce released this Aug 11, 2017 · 28 commits to master since this release

TaskHelper添加setThreadExecutor方法,可以指定ITask执行的Executor

Assets 2

@LuckyJayce LuckyJayce released this Jun 1, 2017 · 31 commits to master since this release

  1. MVCHelper 添加cancel 方法
  2. 修复MVCCoolHelper 执行 refresh() 的方法时 循环执行refresh的bug
Assets 2

@LuckyJayce LuckyJayce released this Apr 17, 2017 · 35 commits to master since this release

一、修改了MVCHelper内部由TaskHelper创建执行dataSource

1.添加TaskExecutor接口类,代表Task+Callback的执行处理
2.TaskHelper添加createExecutor创建TaskExecutor
3.解耦ResponseSender和task,datasource的耦合,callback的耦合,避免ResponseSender被线程持有后不能及时释放

二、添加MVCHelper-Tasks类库 Task的操作符

比如先初始化token,然后再调用获取用户信息task

 IAsyncTask<User> task = Tasks
                    .create(new InitTokenTask())
                    .concatWith(new GetUserTask()));

Tasks提供:
1.同步task转异步task

Tasks.async(ITask<DATA> task)

2.按两个task先后顺序执行

Tasks.concatWith(IAsyncTask<D> task, final IAsyncTask<DATA> task2)

3.按两个task先后顺序执行,task1的结果可以作为task的参数

Tasks.concatMap(IAsyncTask<D> task, Func1<D, IAsyncTask<DATA>> func) 

4.合并两个task,两个task一起执行,其中一个报错就停止执行,func将两个d1和d2的结果转化成最终的data

combine(IAsyncTask<D1> task1, IAsyncTask<D2> task2, Func2<D1, D2, DATA> func)

DataSources提供:
1.先执行task,再执行dataSource,该函数会返回新的dataSource

concatWith(IAsyncTask<Void> task, IDataSource<DATA> dataSource)
Assets 2

@LuckyJayce LuckyJayce released this Feb 11, 2017 · 46 commits to master since this release

1.修复刷新的时候 闪出 加载更多的布局影响体验

2.添加setAdapter2(Object viewAdapter, IDataAdapter dataAdapter) 方法

/**
 * 分别设置两种适配器,viewAdapter设置到对应的view上,IDataAdapter 处理显示的逻辑
 *
 * @param viewAdapter ListView,RecyclerView等view的适配器
 *                  如果ContentView是ListView那么viewAdapter就要继承于ListAdapter,如果是RecyclerView,那么viewAdapter就要继承于RecyclerView.Adapter
 * @param dataAdapter 接收数据,并显示数据的适配器
 */
public void setAdapter2(Object viewAdapter, IDataAdapter<DATA> dataAdapter){

将之前的setAdapter(IDataAdapter adapter)分成两个Adapter设置

例如

    mvcHelper.setDataSource(new BooksOkHttp_AsyncDataSource());
    // mvcHelper.setAdapter(adapter = new ReBooksAdapter(getContext()));
    //这里模拟viewAdapter 和 dataAdapter不是同一个的情况
    mvcHelper.setAdapter2(adapter = new BooksAdapter(getContext()), new IDataAdapter<List<Book>>() {
        @Override
        public void notifyDataChanged(List<Book> books, boolean isRefresh) {
            if (books.size() > 5) {
                adapter.notifyDataChanged(books.subList(0, 5), isRefresh);
            } else {
                adapter.notifyDataChanged(books, isRefresh);
            }
        }

        @Override
        public List<Book> getData() {
            return adapter.getData();
        }

        @Override
        public boolean isEmpty() {
            return adapter.isEmpty();
        }
    });
Assets 2

@LuckyJayce LuckyJayce released this Dec 15, 2016 · 56 commits to master since this release

修复1.0.8的 setAdapter 导致非listView且非RecyclerView的View的refresh不调用

Assets 2

@LuckyJayce LuckyJayce released this Nov 26, 2016 · 63 commits to master since this release

添加了ExpandableListView的设置适配器的判断
去除掉RecyclerView代理Adapter的点击item监听

Assets 2

@LuckyJayce LuckyJayce released this Oct 16, 2016 · 69 commits to master since this release

修复TaskHelper.cancelAll() 的ConcurrentModificationException 异常

Assets 3

@LuckyJayce LuckyJayce released this Jul 21, 2016 · 80 commits to master since this release

重构了Task,TaskHelper

MVCHelper可以直接执行MVCHelper.setDataSource(task);
TaskHelper可以直接执行TaskHelper.execute(datasource);

   //执行task,handle可以取消task
   <1>TaskHandle handle=taskHelper.execute(task,callback);
   //执行task
   <2>TaskHandle handle=taskHelper.execute(datasource,callback);
   //执行task,如果缓存可以用,使用缓存数据
   <3>TaskHandle handle=taskHelper.executeCahche(datasource,callback,cacheConfig);
   //执行task,如果缓存可以用,使用缓存数据
   <4>TaskHandle handle=taskHelper.executeCahche(task,callback,cacheConfig);
   //注册全局回调
   <5>taskHelper.registerCallback(callback);
   //取消全部task
   <6>taskHelper.cancleAll();
   //一般在Acitivity的onDestroy执行,取消全部task
   <7>taskHelper.destroy();
Assets 3

@LuckyJayce LuckyJayce released this May 26, 2016 · 80 commits to master since this release

为了更好的适应OKhttp
ResponseSender 支持子线程调用sendData哦,调用后自动在UI线程更新通知UI,比如

 call.enqueue(new Callback() {

        @Override
        public void onFailure(Request request, IOException e) {
            sender.sendError(e);
        }

        @Override
        public void onResponse(Response response) throws IOException {
            sender.sendData(books);
        }
});
Assets 3
You can’t perform that action at this time.