Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support rxjava2 #2

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.7 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.5'
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.7'
```
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.7版本新增功能 ----**
* **兼容到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.5'
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.7'
```

NoHttpRxUtils使用简介
Expand Down

This file was deleted.

10 changes: 5 additions & 5 deletions nohttputils-r1/build.gradle → nohttputils-r2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
defaultConfig {
minSdkVersion 11
targetSdkVersion 22
versionCode 1
versionName "1"
versionCode 2
versionName "2"
}
buildTypes {
release {
Expand All @@ -23,8 +23,8 @@ 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 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.1.9'
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'
}
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
Loading