diff --git a/nohttputils/src/main/java/com/liqi/nohttputils/nohttp/RxNoHttp.java b/nohttputils/src/main/java/com/liqi/nohttputils/nohttp/RxNoHttp.java index a3ad1af..1953ccb 100644 --- a/nohttputils/src/main/java/com/liqi/nohttputils/nohttp/RxNoHttp.java +++ b/nohttputils/src/main/java/com/liqi/nohttputils/nohttp/RxNoHttp.java @@ -7,6 +7,7 @@ import com.liqi.nohttputils.R; import com.liqi.nohttputils.interfa.DialogGetListener; import com.liqi.nohttputils.interfa.OnIsRequestListener; +import com.yanzhenjie.nohttp.Logger; import com.yanzhenjie.nohttp.NoHttp; import com.yanzhenjie.nohttp.error.NetworkError; import com.yanzhenjie.nohttp.error.NotFoundCacheError; @@ -106,6 +107,13 @@ public void onError(Throwable e) { } else if (e instanceof ProtocolException) { show(R.string.error_system_unsupport_method); } else { + Logger.e("NoHttpUtils捕获异常:"+e.toString()); + StackTraceElement[] stackTrace = e.getStackTrace(); + if (null!=stackTrace) { + for (StackTraceElement traceElement : stackTrace) { + Logger.e("NoHttpUtils捕获异常:"+traceElement.toString()); + } + } show(R.string.error_unknow); } dialog = null; diff --git a/nohttputils/src/main/java/com/liqi/nohttputils/nohttp/RxThreadInterchange.java b/nohttputils/src/main/java/com/liqi/nohttputils/nohttp/RxThreadInterchange.java index 2211e02..f33073a 100644 --- a/nohttputils/src/main/java/com/liqi/nohttputils/nohttp/RxThreadInterchange.java +++ b/nohttputils/src/main/java/com/liqi/nohttputils/nohttp/RxThreadInterchange.java @@ -34,7 +34,7 @@ * Created by LiQi on 2017/3/20. */ - public class RxThreadInterchange implements RxThreadDispatch.OnRunDataDisListener { +public class RxThreadInterchange implements RxThreadDispatch.OnRunDataDisListener { //Rx线程池并发数量处理值 private static final int RUNSIZE = RxUtilsConfig.ConfigBuilder.getConfigBuilder().getRxUtilsConfig().getRunRequestSize(); private static RxThreadInterchange mRxThreadInterchange; @@ -65,7 +65,7 @@ static RxThreadInterchange getRxThreadInterchange() { * @param onRxMessageGetListener 数据源对内暴露接口 * @param */ - void start(@NonNull OnRxMessageGetListener onRxMessageGetListener) { + void start(@NonNull OnRxMessageGetListener onRxMessageGetListener) { if (null == mOnRxMessageDisListener) { selectOkState(onRxMessageGetListener); } else { @@ -163,12 +163,14 @@ public void onError(Throwable e) { } else if (e instanceof ProtocolException) { show(dialog, R.string.error_system_unsupport_method); } else { - //撤销请求 - if (e.getMessage().contains(REQUEST_REVOCATION)) { - Logger.e(e.getMessage()); - } else { - show(dialog, R.string.error_unknow); + Logger.e("NoHttpUtils捕获异常:"+e.toString()); + StackTraceElement[] stackTrace = e.getStackTrace(); + if (null!=stackTrace) { + for (StackTraceElement traceElement : stackTrace) { + Logger.e("NoHttpUtils捕获异常:"+traceElement.toString()); + } } + show(dialog, R.string.error_unknow); } diff --git a/nohttputils/src/main/java/com/liqi/nohttputils/nohttp/rx_threadpool/thread/RxThreadDispatch.java b/nohttputils/src/main/java/com/liqi/nohttputils/nohttp/rx_threadpool/thread/RxThreadDispatch.java index 4d11285..f7d695a 100644 --- a/nohttputils/src/main/java/com/liqi/nohttputils/nohttp/rx_threadpool/thread/RxThreadDispatch.java +++ b/nohttputils/src/main/java/com/liqi/nohttputils/nohttp/rx_threadpool/thread/RxThreadDispatch.java @@ -14,7 +14,9 @@ */ public class RxThreadDispatch extends Thread { - //并发最大值 + //固定并发最大值 + private int mFixedRunSize; + //要操作的并发最大值 private int mRunSize; //数据源 private List mList; @@ -29,6 +31,7 @@ public class RxThreadDispatch extends Thread { public RxThreadDispatch(int runSize, @NonNull List list) { this.mRunSize = runSize; + this.mFixedRunSize = runSize; this.mList = list; } @@ -126,6 +129,10 @@ public void run() { public void addRunSize() { synchronized (this) { ++mRunSize; + + if (mRunSize > mFixedRunSize) { + mRunSize = mFixedRunSize; + } //Logger.e("运行次数:++运行次数相加" + mRunSize); } } diff --git a/sample/src/main/java/com/liqi/nohttprxutils/GetPostDemoActivity.java b/sample/src/main/java/com/liqi/nohttprxutils/GetPostDemoActivity.java index eb0dc17..3343168 100644 --- a/sample/src/main/java/com/liqi/nohttprxutils/GetPostDemoActivity.java +++ b/sample/src/main/java/com/liqi/nohttprxutils/GetPostDemoActivity.java @@ -25,6 +25,10 @@ protected void onCreate() { mPost.setOnClickListener(this); mPost.setAlpha(0.6f); mContent = $(R.id.content); + //清除对应的key的缓存数据 + // RxNoHttpUtils.removeKeyCacheData("Cachekey"); + //清除所有缓存数据 + // RxNoHttpUtils.removeAllCacheData(); } @Override @@ -47,6 +51,34 @@ public void onClick(View v) { //.setCacheKey("get请求Key") //单个请求设置缓存模式 // .setCacheMode(CacheMode.REQUEST_NETWORK_FAILED_READ_CACHE) + //设置请求bodyEntity为StringEntity,并传请求类型。 + //.requestStringEntity(Content-Type) + //为StringEntity添加body中String值 + //.addStringEntityParameter("请求的String") + //从bodyEntity切换到请求配置对象 + // .transitionToRequest() + //设置请求bodyEntity为JsonObjectEntity.json格式:{"xx":"xxx","yy":"yyy"} + // .requestJsonObjectEntity() + //给JsonObjectEntity添加参数和值 + //.addEntityParameter("key","Valu") + //从bodyEntity切换到请求配置对象 + // .transitionToRequest() + //设置请求bodyEntity为JsonListEntity.json格式:[{"xx":"xxx"},{"yy":"yyy"}] + //.requestJsonListEntity() + //给JsonList创造对象,并传键值参数 + //.addObjectEntityParameter("key","Valu") + //在创造对象的上添加键值参数 + //.addEntityParameter("key","Valu") + //把创造对象刷进进JsonList里面 + //.objectBrushIntoList() + //从bodyEntity切换到请求配置对象 + //.transitionToRequest() + //设置请求bodyEntity为InputStreamEntity + //.requestInputStreamEntity(Content-Type) + //给InputStreamEntity添加输入流 + //.addEntityInputStreamParameter(InputStream) + //从bodyEntity切换到请求配置对象 + //.transitionToRequest() .builder(String.class, this) .requestRxNoHttp(); break; @@ -63,7 +95,7 @@ public void onClick(View v) { .setSign(this) .builder(String.class, this) .requestRxNoHttp(); - RxNoHttpUtils.cancel(this); + //RxNoHttpUtils.cancel(this); break; } }