Skip to content

Commit

Permalink
去除okgo中AndroidAnnotation的依赖。修改demo混淆配置
Browse files Browse the repository at this point in the history
  • Loading branch information
jeasonlzy committed Oct 14, 2016
1 parent d88e499 commit c5112e7
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 41 deletions.
34 changes: 29 additions & 5 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,47 @@
#-------------------------------------------------------------------------

#---------------------------------2.第三方包-------------------------------
#okgo
-dontwarn com.lzy.okgo.**
-keep class com.lzy.okgo.**{*;}

#okhttputils
-dontwarn com.lzy.okhttputils.**
-keep class com.lzy.okhttputils.**{*;}
#okrx
-dontwarn com.lzy.okrx.**
-keep class com.lzy.okrx.**{*;}

#okserver
-dontwarn okserver.**
-keep class okserver.**{*;}
-dontwarn com.lzy.okserver.**
-keep class com.lzy.okserver.**{*;}

#okhttp
-dontwarn okhttp3.**
-keep class okhttp3.**{*;}

-keepattributes SourceFile,LineNumberTable
-keep class com.parse.*{ *; }
-dontwarn com.parse.**
-dontwarn com.squareup.picasso.**
-keepclasseswithmembernames class * {
native <methods>;
}

#okio
-dontwarn okio.**
-keep class okio.**{*;}

#rxjava
-dontwarn sun.misc.**
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
long producerIndex;
long consumerIndex;
}
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
rx.internal.util.atomic.LinkedQueueNode producerNode;
}
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef {
rx.internal.util.atomic.LinkedQueueNode consumerNode;
}

#imagepicker
-dontwarn com.lzy.imagepicker.**
-keep class com.lzy.imagepicker.**{*;}
Expand Down
1 change: 0 additions & 1 deletion okgo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-annotations:24.2.1'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
}

Expand Down
3 changes: 1 addition & 2 deletions okgo/src/main/java/com/lzy/okgo/OkGo.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.Nullable;

import com.lzy.okgo.cache.CacheEntity;
import com.lzy.okgo.cache.CacheMode;
Expand Down Expand Up @@ -254,7 +253,7 @@ public OkGo addCommonHeaders(HttpHeaders commonHeaders) {
}

/** 添加全局拦截器 */
public OkGo addInterceptor(@Nullable Interceptor interceptor) {
public OkGo addInterceptor(Interceptor interceptor) {
okHttpClientBuilder.addInterceptor(interceptor);
return this;
}
Expand Down
4 changes: 1 addition & 3 deletions okgo/src/main/java/com/lzy/okgo/callback/AbsCallback.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.lzy.okgo.callback;

import android.support.annotation.Nullable;

import com.lzy.okgo.cache.CacheMode;
import com.lzy.okgo.convert.Converter;
import com.lzy.okgo.request.BaseRequest;
Expand Down Expand Up @@ -65,7 +63,7 @@ public void parseError(Call call, Exception e) {
}

/** 请求网络结束后,UI线程 */
public void onAfter(@Nullable T t, @Nullable Exception e) {
public void onAfter(T t, Exception e) {
if (e != null) e.printStackTrace();
}

Expand Down
4 changes: 1 addition & 3 deletions okgo/src/main/java/com/lzy/okgo/request/BaseBodyRequest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.lzy.okgo.request;

import android.support.annotation.NonNull;

import com.lzy.okgo.model.HttpParams;
import com.lzy.okgo.utils.HttpUtils;

Expand Down Expand Up @@ -35,7 +33,7 @@ public BaseBodyRequest(String url) {

@SuppressWarnings("unchecked")
@Override
public R requestBody(@NonNull RequestBody requestBody) {
public R requestBody(RequestBody requestBody) {
this.requestBody = requestBody;
return (R) this;
}
Expand Down
9 changes: 4 additions & 5 deletions okgo/src/main/java/com/lzy/okgo/request/BaseRequest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.lzy.okgo.request;

import android.support.annotation.NonNull;
import android.text.TextUtils;

import com.lzy.okgo.OkGo;
Expand Down Expand Up @@ -85,7 +84,7 @@ public BaseRequest(String url) {
}

@SuppressWarnings("unchecked")
public R url(@NonNull String url) {
public R url(String url) {
this.url = url;
return (R) this;
}
Expand Down Expand Up @@ -249,21 +248,21 @@ public R removeAllParams() {
}

@SuppressWarnings("unchecked")
public R addCookie(@NonNull String name, @NonNull String value) {
public R addCookie(String name, String value) {
Cookie.Builder builder = new Cookie.Builder();
Cookie cookie = builder.name(name).value(value).domain(httpUrl.host()).build();
userCookies.add(cookie);
return (R) this;
}

@SuppressWarnings("unchecked")
public R addCookie(@NonNull Cookie cookie) {
public R addCookie(Cookie cookie) {
userCookies.add(cookie);
return (R) this;
}

@SuppressWarnings("unchecked")
public R addCookies(@NonNull List<Cookie> cookies) {
public R addCookies(List<Cookie> cookies) {
userCookies.addAll(cookies);
return (R) this;
}
Expand Down
4 changes: 1 addition & 3 deletions okgo/src/main/java/com/lzy/okgo/request/HasBody.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.lzy.okgo.request;

import android.support.annotation.NonNull;

import com.lzy.okgo.model.HttpParams;

import java.io.File;
Expand All @@ -20,7 +18,7 @@
* ================================================
*/
public interface HasBody<R> {
R requestBody(@NonNull RequestBody requestBody);
R requestBody(RequestBody requestBody);

R params(String key, File file);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

import android.content.ContentValues;
import android.database.Cursor;
import android.support.annotation.NonNull;

import com.lzy.okserver.download.db.DownloadRequest;
import com.lzy.okserver.listener.DownloadListener;
import com.lzy.okgo.request.BaseRequest;
import com.lzy.okgo.utils.OkLogger;
import com.lzy.okserver.download.db.DownloadRequest;
import com.lzy.okserver.listener.DownloadListener;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -284,7 +283,8 @@ public boolean equals(Object o) {

/** 两个任务排序按照 id 的大小排序 */
@Override
public int compareTo(@NonNull DownloadInfo another) {
public int compareTo(DownloadInfo another) {
if (another == null) return 0;
return ((Integer) getId()).compareTo(another.getId());
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.lzy.okserver.download;

import android.os.Environment;
import android.support.annotation.NonNull;
import android.text.TextUtils;

import com.lzy.okgo.request.BaseRequest;
import com.lzy.okserver.download.db.DownloadDBManager;
import com.lzy.okserver.listener.DownloadListener;
import com.lzy.okserver.task.ExecutorWithListener;
import com.lzy.okgo.request.BaseRequest;

import java.io.File;
import java.util.ArrayList;
Expand Down Expand Up @@ -76,12 +75,12 @@ private DownloadManager() {
}

/** 添加一个下载任务,一句taskTag标识是否属于同一个任务 */
public void addTask(String taskTag, @NonNull BaseRequest request, DownloadListener listener) {
public void addTask(String taskTag, BaseRequest request, DownloadListener listener) {
addTask(null, taskTag, request, listener, false);
}

/** 添加一个下载任务,一句taskTag标识是否属于同一个任务 */
public void addTask(String fileName, String taskTag, @NonNull BaseRequest request, DownloadListener listener) {
public void addTask(String fileName, String taskTag, BaseRequest request, DownloadListener listener) {
addTask(fileName, taskTag, request, listener, false);
}

Expand All @@ -92,7 +91,7 @@ public void addTask(String fileName, String taskTag, @NonNull BaseRequest reques
* @param listener 下载监听
* @param isRestart 是否重新开始下载
*/
private void addTask(String fileName, String taskTag, @NonNull BaseRequest request, DownloadListener listener, boolean isRestart) {
private void addTask(String fileName, String taskTag, BaseRequest request, DownloadListener listener, boolean isRestart) {
DownloadInfo downloadInfo = getDownloadInfo(taskTag);
if (downloadInfo == null) {
downloadInfo = new DownloadInfo();
Expand Down Expand Up @@ -212,7 +211,7 @@ public void onTaskEnd(Runnable r) {
}

/** 重新开始下载任务 */
private void restartTaskByKey(@NonNull String taskKey) {
private void restartTaskByKey(String taskKey) {
DownloadInfo downloadInfo = getDownloadInfo(taskKey);
if (downloadInfo == null) return;
if (downloadInfo.getState() != DOWNLOADING) {
Expand All @@ -222,7 +221,7 @@ private void restartTaskByKey(@NonNull String taskKey) {
}

/** 获取一个任务 */
public DownloadInfo getDownloadInfo(@NonNull String taskKey) {
public DownloadInfo getDownloadInfo(String taskKey) {
for (DownloadInfo downloadInfo : mDownloadInfoList) {
if (taskKey.equals(downloadInfo.getTaskKey())) {
return downloadInfo;
Expand All @@ -232,7 +231,7 @@ public DownloadInfo getDownloadInfo(@NonNull String taskKey) {
}

/** 移除一个任务 */
private void removeTaskByKey(@NonNull String taskKey) {
private void removeTaskByKey(String taskKey) {
ListIterator<DownloadInfo> iterator = mDownloadInfoList.listIterator();
while (iterator.hasNext()) {
DownloadInfo info = iterator.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.support.annotation.Nullable;

import com.lzy.okgo.OkGo;

Expand All @@ -21,7 +20,7 @@
* ================================================
*/
public class DownloadService extends Service {
@Nullable

@Override
public IBinder onBind(Intent intent) {
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.lzy.okserver.upload;

import android.support.annotation.NonNull;

import com.lzy.okserver.listener.UploadListener;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.request.BaseBodyRequest;
import com.lzy.okgo.request.PostRequest;
import com.lzy.okserver.listener.UploadListener;

import java.io.File;
import java.util.ArrayList;
Expand Down Expand Up @@ -53,13 +51,13 @@ private UploadManager() {

/** 添加一个上传任务,默认使用post请求 */
@Deprecated
public <T> void addTask(String url, @NonNull File resource, @NonNull String key, UploadListener<T> listener) {
public <T> void addTask(String url, File resource, String key, UploadListener<T> listener) {
PostRequest request = OkGo.post(url).params(key, resource);
addTask(url, request, listener);
}

/** 添加一个上传任务 */
public <T> void addTask(String taskKey, @NonNull BaseBodyRequest request, UploadListener<T> listener) {
public <T> void addTask(String taskKey, BaseBodyRequest request, UploadListener<T> listener) {
UploadInfo uploadInfo = new UploadInfo();
uploadInfo.setTaskKey(taskKey);
uploadInfo.setState(UploadManager.NONE);
Expand Down

0 comments on commit c5112e7

Please sign in to comment.