Skip to content

Commit

Permalink
okhttpgo一次更名完成
Browse files Browse the repository at this point in the history
  • Loading branch information
jeasonlzy committed Sep 10, 2016
1 parent dc49c31 commit 877b02b
Show file tree
Hide file tree
Showing 81 changed files with 324 additions and 328 deletions.
12 changes: 5 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ android {
}
signingConfigs {
appkey {
keyAlias 'okhttputils'
keyAlias 'okhttpgo'
keyPassword '111111'
storeFile file('../appkey.jks')
storePassword '111111'
Expand All @@ -38,11 +38,11 @@ android {
}
productFlavors {
miui {
proguardFile '/Users/jeasonlzy/Android/github/OkHttpUtils/app/proguard-rules.pro'
proguardFile './proguard-rules.pro'
signingConfig signingConfigs.appkey
}
qihu360 {
proguardFile '/Users/jeasonlzy/Android/github/OkHttpUtils/app/proguard-rules.pro'
proguardFile './proguard-rules.pro'
signingConfig signingConfigs.appkey
}
}
Expand All @@ -51,7 +51,7 @@ android {
task makeApk {
doLast {
def versionName = android.defaultConfig.versionName
def appName = "okhttputils_v${versionName}.apk"
def appName = "okhttpgo_v${versionName}.apk"
copy {
from "./build/outputs/apk/app-miui-debug.apk"
into "../"
Expand All @@ -73,13 +73,11 @@ 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:imagepicker:0.3.2'
compile 'com.lzy.widget:view-core:0.2.1'

// compile 'com.lzy.net:okhttputils:+'
// compile 'com.lzy.net:okhttpserver:+'
compile project(':okhttputils')
compile project(':okhttpgo')
compile project(':okhttpserver')
}
24 changes: 12 additions & 12 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@
</intent-filter>
</activity>

<activity android:name=".okhttputils.MethodActivity"/>
<activity android:name=".okhttputils.JsonRequestActivity"/>
<activity android:name=".okhttputils.BitmapRequestActivity"/>
<activity android:name=".okhttputils.PostTextActivity"/>
<activity android:name=".okhttputils.FormUploadActivity"/>
<activity android:name=".okhttputils.FileDownloadActivity"/>
<activity android:name=".okhttputils.CacheActivity"/>
<activity android:name=".okhttputils.HttpsActivity"/>
<activity android:name=".okhttputils.SyncActivity"/>
<activity android:name=".okhttputils.RedirectActivity"/>
<activity android:name=".okhttputils.TestActivity"/>
<activity android:name=".okhttpgo.MethodActivity"/>
<activity android:name=".okhttpgo.JsonRequestActivity"/>
<activity android:name=".okhttpgo.BitmapRequestActivity"/>
<activity android:name=".okhttpgo.PostTextActivity"/>
<activity android:name=".okhttpgo.FormUploadActivity"/>
<activity android:name=".okhttpgo.FileDownloadActivity"/>
<activity android:name=".okhttpgo.CacheActivity"/>
<activity android:name=".okhttpgo.HttpsActivity"/>
<activity android:name=".okhttpgo.SyncActivity"/>
<activity android:name=".okhttpgo.RedirectActivity"/>
<activity android:name=".okhttpgo.TestActivity"/>
<activity
android:name=".cache.CacheDemoActivity"
android:theme="@style/AppTheme.NoActionBar"/>
<activity
android:name=".WebActivity"
android:theme="@style/AppTheme.NoActionBar"/>
<activity
android:name=".okhttputils.OkHttpActivity"
android:name=".okhttpgo.OkHttpActivity"
android:theme="@style/AppTheme.NoActionBar"/>
<activity
android:name=".okhttpserver.DownloadManagerActivity"
Expand Down
24 changes: 12 additions & 12 deletions app/src/main/java/com/lzy/okhttpdemo/GApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import android.app.Application;

import com.lzy.okhttputils.OkHttpUtils;
import com.lzy.okhttputils.cache.CacheEntity;
import com.lzy.okhttputils.cache.CacheMode;
import com.lzy.okhttputils.cookie.store.PersistentCookieStore;
import com.lzy.okhttputils.model.HttpHeaders;
import com.lzy.okhttputils.model.HttpParams;
import com.lzy.okhttpgo.OkHttpGo;
import com.lzy.okhttpgo.cache.CacheEntity;
import com.lzy.okhttpgo.cache.CacheMode;
import com.lzy.okhttpgo.cookie.store.PersistentCookieStore;
import com.lzy.okhttpgo.model.HttpHeaders;
import com.lzy.okhttpgo.model.HttpParams;

/**
* ================================================
Expand All @@ -34,21 +34,21 @@ public void onCreate() {
//-----------------------------------------------------------------------------------//

//必须调用初始化
OkHttpUtils.init(this);
OkHttpGo.init(this);

//以下设置的所有参数是全局参数,同样的参数可以在请求的时候再设置一遍,那么对于该请求来讲,请求中的参数会覆盖全局参数
//好处是全局参数统一,特定请求可以特别定制参数
try {
//以下都不是必须的,根据需要自行选择,一般来说只需要 debug,缓存相关,cookie相关的 就可以了
OkHttpUtils.getInstance()
OkHttpGo.getInstance()

//打开该调试开关,控制台会使用 红色error 级别打印log,并不是错误,是为了显眼,不需要就不要加入该行
.debug("OkHttpUtils")
.debug("OkHttpGo")

//如果使用默认的 60秒,以下三行也不需要传
.setConnectTimeout(OkHttpUtils.DEFAULT_MILLISECONDS) //全局的连接超时时间
.setReadTimeOut(OkHttpUtils.DEFAULT_MILLISECONDS) //全局的读取超时时间
.setWriteTimeOut(OkHttpUtils.DEFAULT_MILLISECONDS) //全局的写入超时时间
.setConnectTimeout(OkHttpGo.DEFAULT_MILLISECONDS) //全局的连接超时时间
.setReadTimeOut(OkHttpGo.DEFAULT_MILLISECONDS) //全局的读取超时时间
.setWriteTimeOut(OkHttpGo.DEFAULT_MILLISECONDS) //全局的写入超时时间

//可以全局统一设置缓存模式,默认是不使用缓存,可以不传,具体其他模式看 github 介绍 https://github.com/jeasonlzy0216/
.setCacheMode(CacheMode.NO_CACHE)
Expand Down
22 changes: 11 additions & 11 deletions app/src/main/java/com/lzy/okhttpdemo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
import com.lzy.okhttpdemo.cache.CacheDemoActivity;
import com.lzy.okhttpdemo.okhttpserver.DownloadActivity;
import com.lzy.okhttpdemo.okhttpserver.UploadActivity;
import com.lzy.okhttpdemo.okhttputils.FileDownloadActivity;
import com.lzy.okhttpdemo.okhttputils.FormUploadActivity;
import com.lzy.okhttpdemo.okhttputils.JsonRequestActivity;
import com.lzy.okhttpdemo.okhttputils.OkHttpActivity;
import com.lzy.okhttpdemo.okhttpgo.FileDownloadActivity;
import com.lzy.okhttpdemo.okhttpgo.FormUploadActivity;
import com.lzy.okhttpdemo.okhttpgo.JsonRequestActivity;
import com.lzy.okhttpdemo.okhttpgo.OkHttpActivity;

import java.util.ArrayList;

Expand Down Expand Up @@ -55,12 +55,12 @@ private void initData() {
items = new ArrayList<>();
OkHttpModel model1 = new OkHttpModel();
model1.title = "";
model1.des = "下面是OkHttpUtils包的使用方法";
model1.des = "下面是OkHttpGo包的使用方法";
model1.type = 1;
items.add(model1);

OkHttpModel model2 = new OkHttpModel();
model2.title = "基本功能(OkHttpUtils)";
model2.title = "基本功能(OkHttpGo)";
model2.des = "1.GET,HEAD,OPTIONS,POST,PUT,DELETE 请求方法演示\n" +
"2.请求服务器返回bitmap对象\n" +
"3.支持https请求\n" +
Expand Down Expand Up @@ -96,7 +96,7 @@ private void initData() {

OkHttpModel model6 = new OkHttpModel();
model6.title = "强大的缓存示例 -- 先联网获取数据,然后断开网络再进试试";
model6.des = "1.OkHttpUtils的强大的缓存功能,让你代码无需关心数据来源,专注于业务逻辑的实现\n" +
model6.des = "1.OkHttpGo的强大的缓存功能,让你代码无需关心数据来源,专注于业务逻辑的实现\n" +
"2.共有五种缓存模式满足你各种使用场景\n" +
"3.支持自定义缓存过期时间";
model6.type = 0;
Expand All @@ -110,16 +110,16 @@ private void initData() {

OkHttpModel model8 = new OkHttpModel();
model8.title = "下载管理(OkHttpServer)";
model8.des = "1.这个属于OkHttpServer依赖中的功能,并不属于OkHttpUtils\n" +
"2.这个包维护较少,一般情况下,不做特殊的下载管理功能,OkHttpUtils完全可以胜任\n" +
"3.相比OkHttpUtils主要是多了断点下载和下载状态的管理";
model8.des = "1.这个属于OkHttpServer依赖中的功能,并不属于OkHttpGo\n" +
"2.这个包维护较少,一般情况下,不做特殊的下载管理功能,OkHttpGo完全可以胜任\n" +
"3.相比OkHttpGo主要是多了断点下载和下载状态的管理";
model8.type = 0;
items.add(model8);

OkHttpModel model9 = new OkHttpModel();
model9.title = "上传管理(OkHttpServer)";
model9.des = "1.这个同上,也属于OkHttpServer依赖中的功能\n" +
"2.同样该包的功能OkHttpUtils完全可以胜任\n" +
"2.同样该包的功能OkHttpGo完全可以胜任\n" +
"3.上传只是简单上传管理,不支持断点上传或者分片上传";
model9.type = 0;
items.add(model9);
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/lzy/okhttpdemo/cache/NewsCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import com.google.gson.Gson;
import com.lzy.okhttpdemo.utils.Urls;
import com.lzy.okhttputils.callback.AbsCallback;
import com.lzy.okhttputils.request.BaseRequest;
import com.lzy.okhttpgo.callback.AbsCallback;
import com.lzy.okhttpgo.request.BaseRequest;

import org.json.JSONObject;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import com.lzy.okhttpdemo.base.BaseFragment;
import com.lzy.okhttpdemo.model.NewsModel;
import com.lzy.okhttpdemo.utils.Urls;
import com.lzy.okhttputils.OkHttpUtils;
import com.lzy.okhttputils.cache.CacheMode;
import com.lzy.okhttpgo.OkHttpGo;
import com.lzy.okhttpgo.cache.CacheMode;

import butterknife.Bind;
import butterknife.ButterKnife;
Expand Down Expand Up @@ -74,7 +74,7 @@ protected void initData() {
/** 下拉刷新 */
@Override
public void onRefresh() {
OkHttpUtils.get(Urls.NEWS)//
OkHttpGo.get(Urls.NEWS)//
.params("channelName", fragmentTitle)//
.params("page", String.valueOf(1)) //初始化或者下拉刷新,默认加载第一页
.cacheKey("TabFragment_" + fragmentTitle) //由于该fragment会被复用,必须保证key唯一,否则数据会发生覆盖
Expand Down Expand Up @@ -122,7 +122,7 @@ public void onAfter(@Nullable NewsModel newsModel, @Nullable Exception e) {
/** 上拉加载 */
@Override
public void onLoadMoreRequested() {
OkHttpUtils.get(Urls.NEWS)//
OkHttpGo.get(Urls.NEWS)//
.params("channelName", fragmentTitle)//
.params("page", String.valueOf(currentPage + 1)) //上拉加载更多
.cacheMode(CacheMode.NO_CACHE) //上拉不需要缓存
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import android.support.annotation.Nullable;
import android.view.Window;

import com.lzy.okhttputils.callback.BitmapCallback;
import com.lzy.okhttputils.request.BaseRequest;
import com.lzy.okhttpgo.callback.BitmapCallback;
import com.lzy.okhttpgo.request.BaseRequest;

/**
* ================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import android.support.annotation.Nullable;
import android.view.Window;

import com.lzy.okhttputils.request.BaseRequest;
import com.lzy.okhttpgo.request.BaseRequest;

import java.lang.reflect.Type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import android.text.TextUtils;

import com.google.gson.Gson;
import com.lzy.okhttputils.callback.AbsCallback;
import com.lzy.okhttputils.request.BaseRequest;
import com.lzy.okhttpgo.callback.AbsCallback;
import com.lzy.okhttpgo.request.BaseRequest;

import org.json.JSONObject;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import android.support.annotation.Nullable;
import android.view.Window;

import com.lzy.okhttputils.callback.StringCallback;
import com.lzy.okhttputils.request.BaseRequest;
import com.lzy.okhttpgo.callback.StringCallback;
import com.lzy.okhttpgo.request.BaseRequest;

/**
* ================================================
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lzy.okhttpdemo.okhttputils;
package com.lzy.okhttpdemo.okhttpgo;

import android.graphics.Bitmap;
import android.os.Bundle;
Expand All @@ -9,7 +9,7 @@
import com.lzy.okhttpdemo.base.BaseDetailActivity;
import com.lzy.okhttpdemo.callback.BitmapDialogCallback;
import com.lzy.okhttpdemo.utils.Urls;
import com.lzy.okhttputils.OkHttpUtils;
import com.lzy.okhttpgo.OkHttpGo;

import butterknife.Bind;
import butterknife.ButterKnife;
Expand All @@ -32,12 +32,12 @@ protected void onActivityCreate(Bundle savedInstanceState) {
protected void onDestroy() {
super.onDestroy();
//Activity销毁时,取消网络请求
OkHttpUtils.getInstance().cancelTag(this);
OkHttpGo.getInstance().cancelTag(this);
}

@OnClick(R.id.requestImage)
public void requestJson(View view) {
OkHttpUtils.get(Urls.URL_IMAGE)//
OkHttpGo.get(Urls.URL_IMAGE)//
.tag(this)//
.headers("header1", "headerValue1")//
.params("param1", "paramValue1")//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lzy.okhttpdemo.okhttputils;
package com.lzy.okhttpdemo.okhttpgo;

import android.app.Activity;
import android.app.AlertDialog;
Expand All @@ -10,10 +10,10 @@
import com.lzy.okhttpdemo.callback.DialogCallback;
import com.lzy.okhttpdemo.model.ServerModel;
import com.lzy.okhttpdemo.utils.Urls;
import com.lzy.okhttputils.OkHttpUtils;
import com.lzy.okhttputils.cache.CacheEntity;
import com.lzy.okhttputils.cache.CacheManager;
import com.lzy.okhttputils.cache.CacheMode;
import com.lzy.okhttpgo.OkHttpGo;
import com.lzy.okhttpgo.cache.CacheEntity;
import com.lzy.okhttpgo.cache.CacheManager;
import com.lzy.okhttpgo.cache.CacheMode;

import java.util.List;

Expand All @@ -35,7 +35,7 @@ protected void onActivityCreate(Bundle savedInstanceState) {
protected void onDestroy() {
super.onDestroy();
//Activity销毁时,取消网络请求
OkHttpUtils.getInstance().cancelTag(this);
OkHttpGo.getInstance().cancelTag(this);
}

@OnClick(R.id.getAll)
Expand All @@ -60,7 +60,7 @@ public void clear(View view) {

@OnClick(R.id.no_cache)
public void no_cache(View view) {
OkHttpUtils.get(Urls.URL_CACHE)//
OkHttpGo.get(Urls.URL_CACHE)//
.tag(this)//
.cacheMode(CacheMode.NO_CACHE)//
.cacheKey("no_cache") //对于无缓存模式,该参数无效
Expand All @@ -72,7 +72,7 @@ public void no_cache(View view) {

@OnClick(R.id.cache_default)
public void cache_default(View view) {
OkHttpUtils.get(Urls.URL_CACHE)//
OkHttpGo.get(Urls.URL_CACHE)//
.tag(this)//
.cacheMode(CacheMode.DEFAULT)//
.cacheKey("cache_default")//
Expand All @@ -84,7 +84,7 @@ public void cache_default(View view) {

@OnClick(R.id.request_failed_read_cache)
public void request_failed_read_cache(View view) {
OkHttpUtils.get(Urls.URL_CACHE)//
OkHttpGo.get(Urls.URL_CACHE)//
.tag(this)//
.cacheMode(CacheMode.REQUEST_FAILED_READ_CACHE)//
.cacheKey("request_failed_read_cache")//
Expand All @@ -96,7 +96,7 @@ public void request_failed_read_cache(View view) {

@OnClick(R.id.if_none_cache_request)
public void if_none_cache_request(View view) {
OkHttpUtils.get(Urls.URL_CACHE)//
OkHttpGo.get(Urls.URL_CACHE)//
.tag(this)//
.cacheMode(CacheMode.IF_NONE_CACHE_REQUEST)//
.cacheKey("if_none_cache_request")//
Expand All @@ -108,7 +108,7 @@ public void if_none_cache_request(View view) {

@OnClick(R.id.first_cache_then_request)
public void first_cache_then_request(View view) {
OkHttpUtils.get(Urls.URL_CACHE)//
OkHttpGo.get(Urls.URL_CACHE)//
.tag(this)//
.cacheMode(CacheMode.FIRST_CACHE_THEN_REQUEST)//
.cacheKey("only_read_cache")//
Expand Down
Loading

0 comments on commit 877b02b

Please sign in to comment.