Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
jeasonlzy committed Oct 14, 2016
2 parents c5112e7 + a52d0ba commit a23fa98
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 19 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
![image](https://github.com/jeasonlzy/Screenshots/blob/master/okgo/logo4.jpg)

# OkGo - `OkHttpUtils-2.0.0` 升级后改名 `OKGo`,全新完美支持`RxJava`
# OkGo - `OkHttpUtils-2.0.0` 升级后改名 `OkGo`,全新完美支持`RxJava`

### 该库是封装了okhttp的网络框架,可以与RxJava完美结合,支持大文件上传下载,上传进度回调,下载进度回调,表单上传(多文件和多参数一起上传),链式调用,可以自定义返回对象,支持Https和自签名证书,支持cookie自动管理,支持四种缓存模式缓存网络数据,支持301、302重定向,扩展了统一的上传管理和下载管理功能
### 该库是封装了okhttp的网络框架,可以与RxJava完美结合,比Retrofit更简单易用。支持大文件上传下载,上传进度回调,下载进度回调,表单上传(多文件和多参数一起上传),链式调用,可以自定义返回对象,支持Https和自签名证书,支持cookie自动管理,支持四种缓存模式缓存网络数据,支持301、302重定向,扩展了统一的上传管理和下载管理功能

该项目参考了以下项目:

Expand All @@ -21,7 +21,7 @@
## 演示


![image](https://github.com/jeasonlzy/Screenshots/blob/master/okgo/demo7.gif)![image](https://github.com/jeasonlzy/Screenshots/blob/master/okgo/demo8.gif)![image](https://github.com/jeasonlzy/Screenshots/blob/master/okgo/demo11.gif)![image](https://github.com/jeasonlzy/Screenshots/blob/master/okgo/demo9.gif)![image](https://github.com/jeasonlzy/Screenshots/blob/master/okgo/demo10.gif)![image](https://github.com/jeasonlzy/Screenshots/blob/master/okgo/demo12.gif)
![image](https://github.com/jeasonlzy/Screenshots/blob/master/okgo/demo13.gif)![image](https://github.com/jeasonlzy/Screenshots/blob/master/okgo/demo8.gif)![image](https://github.com/jeasonlzy/Screenshots/blob/master/okgo/demo11.gif)![image](https://github.com/jeasonlzy/Screenshots/blob/master/okgo/demo9.gif)![image](https://github.com/jeasonlzy/Screenshots/blob/master/okgo/demo10.gif)![image](https://github.com/jeasonlzy/Screenshots/blob/master/okgo/demo12.gif)


## 1.用法
Expand All @@ -34,9 +34,11 @@

对于Eclipse不能运行项目的,提供了apk供直接运行

### 或者点击下载Demo [okgo_v2.0.0.apk](https://github.com/jeasonlzy/OkGo/blob/master/okgo_v2.0.0.apk?raw=true)
### 或者点击下载Demo [okgo_v2.0.0.apk](https://github.com/jeasonlzy/okhttp-OkGo/blob/master/okgo_v2.0.0.apk?raw=true)

本项目Demo的网络请求是我自己的服务器,有时候可能不稳定,网速比较慢时请耐心等待。。

以下是最新版本的版本号,如果你想使用以前的版本,请点击这里,[历史版本](https://github.com/jeasonlzy/okhttp-OkGo/releases)

* 对于Android Studio的用户,可以选择添加:
```java
Expand Down
4 changes: 2 additions & 2 deletions README_RX.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
### 2.调用请求代码
我们还是像正常使用OkGo的方式一样,传入我们需要请求的Url,和我们需要的参数,那么最关键的一行就是最后调用`getCall()`这个方法。

> 这里传入的两个参数进行一下说明:
这里传入的两个参数进行一下说明:

* 第一个参数是`Convert`对象,表示需要将服务器返回的数据流解析成什么对象,这里我们先用最简单的`String`做转换,`StringConvert`对象也是库中内置的转换器。
* 第二个参数是`Adapter`对象,表示需要将解析的结果用什么对象包装,该参数可以省略不写,那么默认是`Call<T>`这个对象包装,当然,我们要使用Rx的调用,使用这个肯定是不行的,所以我们传入OkRx扩展的`RxAdapter`对象,同样他需要一个泛型,该泛型必须和`Convert`的泛型一致,否则就发生了类型转换异常。
* 第二个参数是`Adapter`对象,表示需要将解析的结果用什么对象包装,该参数可以省略不写,那么默认是`Call<T>`这个对象包装,当然,我们要使用Rx的调用,使用这个肯定是不行的,所以我们传入OkRx扩展的`RxAdapter`对象,他是使用的`Observable<T>`对象包装的,同样他需要一个泛型,该泛型必须和`Convert`的泛型一致,否则就发生了类型转换异常。

以上两个参数具体的注意事项我们后续详细再说。
```java
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ dependencies {
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.google.code.gson:gson:2.5'
compile 'com.lzy.widget:ninegridview:0.2.0'
compile 'com.lzy.widget:ninegridview:0.2.1'
compile 'com.lzy.widget:imagepicker:0.3.2'
compile 'com.lzy.widget:view-core:0.2.1'
// compile 'com.lzy.net:okgo:2.0.0'
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/lzy/demo/okgo/OkHttpActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class OkHttpActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recycler_view);
setContentView(R.layout.activity_recycler);
initToolBar(toolbar, true, "OkGo功能介绍");

initData();
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/lzy/demo/okrx/RxActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class RxActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recycler_view);
setContentView(R.layout.activity_recycler);
initToolBar(toolbar, true, "OkRx使用示例");

initData();
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/com/lzy/demo/utils/GlideImageLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public class GlideImageLoader implements ImageLoader, NineGridView.ImageLoader {
@Override
public void onDisplayImage(Context context, ImageView imageView, String url) {
Glide.with(context).load(url)//
.placeholder(R.drawable.ic_default_image)// 这行貌似是glide的bug,在部分机型上会导致第一次图片不在中间
.error(R.drawable.ic_default_image)//
.placeholder(R.drawable.ic_default_color)// 这行貌似是glide的bug,在部分机型上会导致第一次图片不在中间
.error(R.drawable.ic_default_color)//
.diskCacheStrategy(DiskCacheStrategy.ALL)//
.into(imageView);
}
Expand All @@ -40,8 +40,8 @@ public Bitmap getCacheImage(String url) {
@Override
public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) {
Glide.with(activity).load(new File(path))//
.placeholder(R.drawable.ic_default_image)//
.error(R.drawable.ic_default_image)//
.placeholder(R.drawable.ic_default_color)//
.error(R.drawable.ic_default_color)//
.diskCacheStrategy(DiskCacheStrategy.ALL)//
.into(imageView);
}
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/com/lzy/demo/utils/PicassoImageLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public class PicassoImageLoader implements ImageLoader, NineGridView.ImageLoader

@Override
public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) {
Picasso.with(activity) //配置上下文
.load(Uri.fromFile(new File(path))) //设置图片路径(fix #8,文件名包含%符号 无法识别和显示)
.error(R.mipmap.default_image) //设置错误图片
.placeholder(R.mipmap.default_image) //设置占位图片
Picasso.with(activity) //配置上下文
.load(Uri.fromFile(new File(path))) //设置图片路径(fix #8,文件名包含%符号 无法识别和显示)
.error(R.drawable.ic_default_color) //设置错误图片
.placeholder(R.drawable.ic_default_color) //设置占位图片
.into(imageView);
}

Expand All @@ -40,8 +40,8 @@ public void clearMemoryCache() {
@Override
public void onDisplayImage(Context context, ImageView imageView, String url) {
Picasso.with(context).load(url)//
.placeholder(R.drawable.ic_default_image)//
.error(R.drawable.ic_default_image)//
.placeholder(R.drawable.ic_default_color)//
.error(R.drawable.ic_default_color)//
.into(imageView);
}

Expand Down
Binary file modified okgo_v2.0.0.apk
Binary file not shown.

0 comments on commit a23fa98

Please sign in to comment.