Skip to content

Commit

Permalink
v2.5.1发布
Browse files Browse the repository at this point in the history
  • Loading branch information
crazysunj committed Nov 2, 2019
1 parent 5e56cd6 commit 2a03256
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 38 deletions.
2 changes: 1 addition & 1 deletion config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ext {
userOrg : 'twsunj',
groupId : 'com.crazysunj',
uploadName : 'MultiTypeRecyclerViewAdapter',
publishVersion: '2.5.0',
publishVersion: '2.5.1',
desc : 'MultiTypeRecyclerViewAdapter For Android',
website : 'https://github.com/crazysunj/MultiTypeRecyclerViewAdapter',
licences : ['Apache-2.0']
Expand Down
2 changes: 0 additions & 2 deletions multitypeadapter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ android {
defaultConfig {
minSdkVersion configs.libMinSdkVersion
targetSdkVersion configs.targetSdkVersion
versionCode 1
versionName bintrays.publishVersion
}

lintOptions {
Expand Down
17 changes: 0 additions & 17 deletions multitypeadapter/proguard-rules.pro

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,29 @@ public void action(RecyclerViewAdapterHelper helper) {
});
}

/**
* 刷新全部数据
* 详细见{@link RecyclerViewAdapterHelper#notifyDataSetDiffChanged(List)}
*
* @param data 传入集合
* @return ActionAdapterHelper
*/
public ActionAdapterHelper allDiff(final List<? extends MultiTypeEntity> data) {
return create(new CallHandler() {
@Override
public void call(final ActionHandler actionHandler, RecyclerViewAdapterHelper helper) {
into(new ActionHandler() {
@SuppressWarnings("unchecked")
@Override
public void action(RecyclerViewAdapterHelper helper) {
helper.notifyDataSetDiffChanged(data);
actionHandler.action(helper);
}
}, helper);
}
});
}

/**
* 刷新全部数据
* 详细见{@link RecyclerViewAdapterHelper#notifyDataSetChanged(SparseArray)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
import com.crazysunj.multitypeadapter.entity.MultiTypeEntity;

import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

/**
* @author: sunjian
Expand All @@ -41,8 +39,7 @@ public class AsynAdapterHelper<T extends MultiTypeEntity> extends RecyclerViewAd

private static final int HANDLE_DATA_UPDATE = 1;

protected ScheduledExecutorService mExecutor = Executors.newSingleThreadScheduledExecutor();
protected ScheduledFuture<?> mFuture;
protected ExecutorService mExecutor = Executors.newSingleThreadExecutor();

@SuppressLint("HandlerLeak")
private Handler mHandler = new Handler() {
Expand All @@ -55,35 +52,31 @@ public void handleMessage(Message msg) {
}
};

public AsynAdapterHelper() {
}

public AsynAdapterHelper(int mode) {
super(mode);
}

@Override
protected void startRefresh(HandleBase<T> refreshData) {
cancelFuture();
mFuture = mExecutor.schedule(new HandleTask(refreshData),
0, TimeUnit.MILLISECONDS);
mExecutor.execute(new HandleTask(refreshData));
}

@Override
public void release() {
cancelFuture();
if (!mExecutor.isShutdown()) {
mExecutor.shutdown();
}
super.release();
}

protected void cancelFuture() {
if (mFuture != null && !mFuture.isCancelled()) {
mFuture.cancel(true);
mFuture = null;
}
}

/**
* 重置刷新队列
*/
public void reset() {
clearQueue();
cancelFuture();
}

private final class HandleTask implements Runnable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,18 @@ public void notifyDataSetChanged(@NonNull List<? extends T> list) {
onEnd();
}

/**
* 专门用于混合模式的diff全局刷新 {@link RecyclerViewAdapterHelper#MODE_MIXED}
*
* @param list List
*/
public void notifyDataSetDiffChanged(@NonNull List<? extends T> list) {
checkAdapterBind();
mCurrentMode = MODE_MIXED;
mNewData.clear();
mNewData.addAll(list);
notifyModuleChanged(mNewData, null, null, REFRESH_TYPE_DATA_ALL, REFRESH_ALL);
}

/**
* 专门用于标准模式的全局刷新 {@link RecyclerViewAdapterHelper#MODE_STANDARD}
Expand Down Expand Up @@ -1996,7 +2008,7 @@ private void checkStandardMode() {
if (mCurrentMode == MODE_MIXED) {
onEnd();
mRefreshQueue.clear();
throw new RefreshException("Current refresh mode can't support random refresh mode !");
throw new RefreshException("Current refresh mode can't support mixed refresh mode !");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@
*/
public class SynAdapterHelper<T extends MultiTypeEntity> extends RecyclerViewAdapterHelper<T> {

public SynAdapterHelper() {
}

public SynAdapterHelper(int mode) {
super(mode);
}

@Override
protected void startRefresh(HandleBase<T> refreshData) {
handleResult(handleRefresh(refreshData.getNewData(), refreshData.getNewHeader(),
Expand Down

0 comments on commit 2a03256

Please sign in to comment.