Skip to content

Commit

Permalink
update v.2.0.6
Browse files Browse the repository at this point in the history
update v.2.0.6
  • Loading branch information
LiqiNew committed Nov 2, 2018
1 parent f2b7d82 commit 239b150
Show file tree
Hide file tree
Showing 29 changed files with 228 additions and 207 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
[中文版文档](https://github.com/LiqiNew/NoHttpRxUtils/blob/master/README_CHINESE.md) <br><br>
[![](https://jitpack.io/v/liqinew/nohttprxutils.svg)](https://jitpack.io/#liqinew/nohttprxutils)
[![](https://img.shields.io/badge/%E4%BD%9C%E8%80%85-%E6%9D%8E%E5%A5%87-orange.svg)](https://github.com/LiqiNew)
<br>**---- v.2.0.6 New in version ----**
* **Compatible to NoHttp-v.1.1.11**
* **Repair BUG**Fix bug that download file is not available because the file name was not passed in at the time of download
* **NohttpDownloadUtils** File download tool object added (getDownloadRequestsUrl() Get the path method corresponding to the download request What value)

### Because NoHttpRxUtils through the RxJava face NoHttp network framework for a series of bundle.First of all against RxJava and NoHttp network framework to do a brief introduction
# What is the RxJava framework?
RxJava is a responsive programming design frame.<br>
Expand Down Expand Up @@ -67,12 +72,12 @@ repositories {
**2:The project directory build.gradle relies on the NoHttpRxUtils framework**<br>
* RxJava-1 project depends on
```gradle
compile 'com.github.liqinew:nohttprxutils:v.1.3.6'
compile 'com.github.liqinew:nohttprxutils:v.2.0.5'
```

* RxJava-2 project depends on
```gradle
compile 'com.github.liqinew:nohttprxutils:v.2.0.1'
compile 'com.github.liqinew:nohttprxutils:v.2.0.6'
```
NoHttpRxUtils use method
-----
Expand Down
10 changes: 8 additions & 2 deletions README_CHINESE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
[![](https://jitpack.io/v/liqinew/nohttprxutils.svg)](https://jitpack.io/#liqinew/nohttprxutils)
[![](https://img.shields.io/badge/%E4%BD%9C%E8%80%85-%E6%9D%8E%E5%A5%87-orange.svg)](https://github.com/LiqiNew)
<br>**---- v.2.0.6版本新增功能 ----**
* **兼容到NoHttp-v.1.1.11**
* **修复BUG**修复因为下载时未传入文件名称而导致下载文件不可用的BUG
* **NohttpDownloadUtils** 文件下载工具对象新增(getDownloadRequestsUrl()获取下载请求What值对应的路径方法)


### 由于NoHttpRxUtils是通过RxJava对NoHttp网络框架操作进行一系列封装。<br>首先对RxJava和NoHttp网络框架做一个简介
# RxJava框架是什么?
RxJava是响应式程序设计的一种实现。<br>
Expand Down Expand Up @@ -66,12 +72,12 @@ repositories {
**2:项目目录build.gradle中依赖NoHttpRxUtils框架**<br>
* 使用RxJava-1的项目请依赖
```gradle
compile 'com.github.liqinew:nohttprxutils:v.1.3.6'
compile 'com.github.liqinew:nohttprxutils:v.2.0.5'
```

* 使用RxJava-2的项目请依赖
```gradle
compile 'com.github.liqinew:nohttprxutils:v.2.0.1'
compile 'com.github.liqinew:nohttprxutils:v.2.0.6'
```

NoHttpRxUtils使用简介
Expand Down
2 changes: 1 addition & 1 deletion nohttputils-r2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.yanzhenjie.nohttp:okhttp:1.1.4'
compile 'com.yanzhenjie.nohttp:okhttp:1.1.11'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'io.reactivex.rxjava2:rxjava:2.1.5'
compile 'com.google.code.gson:gson:2.8.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ public void setFileName(String fileName) {
*/
private String urlGetName() {
String[] split = mDownloadUrL.split("/");
if (null != split && split.length > 0) {
String name = split[split.length - 1];
return name + ".nohttpDownload";
if (split.length > 0) {
return split[split.length - 1];
} else {
Logger.e("下载地址按“/”切割错误,无法获取存储文件名");
return "ErrorDownloading";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,22 @@ int getWhat(String downloadUrl) {
what = mBindService.getWhat(downloadUrl);
return what;
}
/**
* 获取下载请求What值对应的路径
* <p>
* 如果有重复的值,那么获取数据源最后一位路径值。
* </p>
*
* @param what What值
* @return 下载请求What值对应的路径值
*/
String getDownloadRequestsUrl(int what) {
String downloadRequestsUrl = "";
if (null != mBindService)
downloadRequestsUrl = mBindService.getDownloadRequestsUrl(what);

return downloadRequestsUrl;
}
/**
* 把指定的What从容器里面移除
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ public static void clearAll() {
public static int getDownloadRequestsWhat(String downloadUrl) {
return NohttpDownload.getNohttpDownload().getWhat(downloadUrl);
}
/**
* 获取下载请求What值对应的路径
* <p>
* 如果有重复的值,那么获取数据源最后一位路径值。
* </p>
*
* @param what What值
* @return 下载请求What值对应的路径值
*/
public static String getDownloadRequestsUrl(int what) {
return NohttpDownload.getNohttpDownload().getDownloadRequestsUrl(what);
}

/**
* 移除下载地址对应的What
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,27 @@ public int getWhat(String downloadUrl) {
}
return -1;
}

/**
* 获取下载请求What值对应的路径
* <p>
* 如果有重复的值,那么获取数据源最后一位路径值。
*</p>
* @param what What值
* @return 下载请求What值对应的路径值
*/
public String getDownloadRequestsUrl(int what) {
String downloadRequestsUrl = "";
if (null != mWhats && !mWhats.isEmpty()) {
if (mWhats.containsValue(what))
for (Map.Entry<String, Integer> entry : mWhats.entrySet()) {
Integer value = entry.getValue();
if (value == what) {
downloadRequestsUrl = entry.getKey();
}
}
}
return downloadRequestsUrl;
}
/**
* 把指定的What从容器里面移除
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* 获取dialog
* Created by LiQi on 2016/12/8.
*/
public interface DialogGetListener {
public interface OnDialogGetListener {
/**
* 获取dialog
* @return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.content.Context;

import com.liqi.nohttputils.interfa.DialogGetListener;
import com.liqi.nohttputils.interfa.OnDialogGetListener;
import com.yanzhenjie.nohttp.InitializationConfig;
import com.yanzhenjie.nohttp.Logger;
import com.yanzhenjie.nohttp.NetworkExecutor;
Expand Down Expand Up @@ -33,7 +33,7 @@ public class NoHttpInit {
/**
* 加载框获取接口
*/
private DialogGetListener mDialogGetListener;
private OnDialogGetListener mOnDialogGetListener;

private NoHttpInit() {

Expand All @@ -43,8 +43,8 @@ static NoHttpInit getNoHttpInit() {
return mNoHttpInit = null == mNoHttpInit ? new NoHttpInit() : mNoHttpInit;
}

public DialogGetListener getDialogGetListener() {
return mDialogGetListener;
public OnDialogGetListener getOnDialogGetListener() {
return mOnDialogGetListener;
}

/**
Expand Down Expand Up @@ -100,9 +100,9 @@ void init(RxUtilsConfig rxUtilsConfig) {
SSLSocketFactory socketFactory;
//是否有证书
if (null != inputStreamSSL) {
socketFactory = SSLContextUtil.getSSLContext(inputStreamSSL).getSocketFactory();
socketFactory = SSLUtils.fixSSLLowerThanLollipop(SSLContextUtil.getSSLContext(inputStreamSSL).getSocketFactory());
} else {
socketFactory =SSLContextUtil.getDefaultSLLContext().getSocketFactory();
socketFactory =SSLContextUtil.getDefaultSLLContext();
}
builder.sslSocketFactory(socketFactory);
//主机名验证
Expand All @@ -118,7 +118,7 @@ void init(RxUtilsConfig rxUtilsConfig) {
NoHttp.initialize(builder.build());
Logger.setDebug(rxUtilsConfig.isDebug());// 开启NoHttp的调试模式, 配置后可看到请求过程、日志和错误信息。
Logger.setTag(rxUtilsConfig.getDebugName());// 设置NoHttp打印Log的tag。
mDialogGetListener = rxUtilsConfig.getDialogGetListener();
mOnDialogGetListener = rxUtilsConfig.getOnDialogGetListener();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import com.yanzhenjie.nohttp.Headers;
import com.yanzhenjie.nohttp.Logger;
import com.yanzhenjie.nohttp.RequestMethod;
import com.yanzhenjie.nohttp.rest.RestRequest;
import com.yanzhenjie.nohttp.rest.Request;
import com.yanzhenjie.nohttp.rest.StringRequest;

import org.json.JSONArray;
Expand All @@ -37,7 +37,7 @@
* @param <T> 请求成功后的数据转换对象
* Created by Liqi on 2016/10/15.
*/
class RequestBeanObj<T> extends RestRequest<T> {
class RequestBeanObj<T> extends Request<T> {

/**
* Decoding lock so that we don't decode more than one image at a time (to avoid OOM's).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import android.widget.Toast;

import com.liqi.nohttputils.R;
import com.liqi.nohttputils.interfa.DialogGetListener;
import com.liqi.nohttputils.interfa.OnDialogGetListener;
import com.liqi.nohttputils.interfa.OnIsRequestListener;
import com.yanzhenjie.nohttp.Logger;
import com.yanzhenjie.nohttp.NoHttp;
Expand All @@ -15,7 +15,7 @@
import com.yanzhenjie.nohttp.error.TimeoutError;
import com.yanzhenjie.nohttp.error.URLError;
import com.yanzhenjie.nohttp.error.UnKnownHostError;
import com.yanzhenjie.nohttp.rest.ProtocolRequest;
import com.yanzhenjie.nohttp.rest.Request;
import com.yanzhenjie.nohttp.rest.Response;

import java.net.ConnectException;
Expand Down Expand Up @@ -49,11 +49,11 @@ synchronized static RxNoHttp getRxNoHttp() {
/**
* 通过nohttp去请求
*
* @param mDialogGetListener dialog获取接口
* @param mOnDialogGetListener dialog获取接口
* @param responseInterfa 请求成功或者失败回调对象
*/
<T> void request(final ProtocolRequest<?, T> request, DialogGetListener mDialogGetListener, final OnIsRequestListener<T> responseInterfa, final String anUnknownErrorHint) {
final Dialog dialog = null == mDialogGetListener ? null : mDialogGetListener.getDialog();
<T> void request(final Request<T> request, OnDialogGetListener mOnDialogGetListener, final OnIsRequestListener<T> responseInterfa, final String anUnknownErrorHint) {
final Dialog dialog = null == mOnDialogGetListener ? null : mOnDialogGetListener.getDialog();
if (null != dialog && !dialog.isShowing()) {
try {
dialog.show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.liqi.nohttputils.nohttp.rx_poll.interfa.OnRxPollConfigBuilderListener;
import com.liqi.nohttputils.nohttp.rx_poll.model.RxInformationModel;
import com.liqi.nohttputils.nohttp.rx_poll.operators.OnObserverEventListener;
import com.yanzhenjie.nohttp.rest.RestRequest;
import com.yanzhenjie.nohttp.rest.Request;

import io.reactivex.functions.Consumer;
import io.reactivex.functions.Predicate;
Expand All @@ -33,7 +33,7 @@ public class RxPollNoHttpConfig<T> {
/**
* 被观察者产生的行为事件监听器
*/
private OnObserverEventListener<RestRequest<T>, RxInformationModel<T>> mOnObserverEventListener;
private OnObserverEventListener<Request<T>, RxInformationModel<T>> mOnObserverEventListener;
/**
* 观察者根据被观察产生的行为做出相应处理监听器
*/
Expand Down Expand Up @@ -66,7 +66,7 @@ public Consumer<RxInformationModel<T>> getRxInformationModelAction1() {
return mRxInformationModelAction1;
}

public OnObserverEventListener<RestRequest<T>, RxInformationModel<T>> getOnObserverEventListener() {
public OnObserverEventListener<Request<T>, RxInformationModel<T>> getOnObserverEventListener() {
return mOnObserverEventListener;
}

Expand Down Expand Up @@ -145,7 +145,7 @@ public ConfigBuilder<T> setRxInformationModelAction1(Consumer<RxInformationModel
* @param onObserverEventListener 被观察者产生的行为事件监听器
* @return 构建轮询配置类
*/
public OnRxPollConfigBuilderListener<T> setOnObserverEventListener(OnObserverEventListener<RestRequest<T>, RxInformationModel<T>> onObserverEventListener) {
public OnRxPollConfigBuilderListener<T> setOnObserverEventListener(OnObserverEventListener<Request<T>, RxInformationModel<T>> onObserverEventListener) {
mRxPollNoHttpConfig.mOnObserverEventListener = onObserverEventListener;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import android.support.annotation.NonNull;
import android.widget.ImageView;

import com.liqi.nohttputils.interfa.DialogGetListener;
import com.liqi.nohttputils.interfa.OnDialogGetListener;
import com.liqi.nohttputils.interfa.OnIsRequestListener;
import com.liqi.nohttputils.interfa.OnRequestRxNoHttpListener;
import com.liqi.nohttputils.nohttp.interfa.OnToInputStreamEntityMethodListener;
Expand Down Expand Up @@ -33,7 +33,7 @@ public class RxRequestConfig<T> {
private int mMaxHeight = -1;
private Bitmap.Config mDecodeConfig;
private ImageView.ScaleType mScaleType;
private DialogGetListener mDialogGetListener;
private OnDialogGetListener mOnDialogGetListener;
private OnIsRequestListener<T> mOnIsRequestListener;
private Class<T> mClazz;
private Object mSign;
Expand Down Expand Up @@ -131,8 +131,8 @@ public boolean isQueue() {
return isQueue;
}

public DialogGetListener getDialogGetListener() {
return mDialogGetListener = null == mDialogGetListener ? NoHttpInit.getNoHttpInit().getDialogGetListener() : mDialogGetListener;
public OnDialogGetListener getOnDialogGetListener() {
return mOnDialogGetListener = null == mOnDialogGetListener ? NoHttpInit.getNoHttpInit().getOnDialogGetListener() : mOnDialogGetListener;
}

public OnIsRequestListener<T> getOnIsRequestListener() {
Expand Down Expand Up @@ -179,7 +179,7 @@ public static class ConfigBuilder {
/**
* 加载框获取接口
*/
private DialogGetListener mDialogGetListener;
private OnDialogGetListener mOnDialogGetListener;
/**
* 请求标识
*/
Expand Down Expand Up @@ -406,11 +406,11 @@ public ConfigBuilder setBitmapConfigType(Bitmap.Config config, ImageView.ScaleTy
/**
* 设置请求加载框
*
* @param dialogGetListener 加载框获取接口
* @param onDialogGetListener 加载框获取接口
* @return
*/
public ConfigBuilder setDialogGetListener(DialogGetListener dialogGetListener) {
mDialogGetListener = dialogGetListener;
public ConfigBuilder setOnDialogGetListener(OnDialogGetListener onDialogGetListener) {
mOnDialogGetListener = onDialogGetListener;
return this;
}

Expand Down Expand Up @@ -621,7 +621,7 @@ private <T> RxRequestConfig<T> getRxRequestConfig(@NonNull Class<T> clazz, OnIsR
requestConfig.mMaxHeight = mMaxHeight;
requestConfig.mDecodeConfig = mDecodeConfig;
requestConfig.mScaleType = mScaleType;
requestConfig.mDialogGetListener = mDialogGetListener;
requestConfig.mOnDialogGetListener = mOnDialogGetListener;
requestConfig.mSign = mSign;
requestConfig.isQueue = isQueue;
requestConfig.mConnectTimeout = mConnectTimeout;
Expand Down
Loading

0 comments on commit 239b150

Please sign in to comment.