diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 36211443..3bfe5437 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -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 ; +} + #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.**{*;} diff --git a/okgo/build.gradle b/okgo/build.gradle index fa79bdfe..0795f8a5 100644 --- a/okgo/build.gradle +++ b/okgo/build.gradle @@ -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' } diff --git a/okgo/src/main/java/com/lzy/okgo/OkGo.java b/okgo/src/main/java/com/lzy/okgo/OkGo.java index b06eb352..e393da00 100644 --- a/okgo/src/main/java/com/lzy/okgo/OkGo.java +++ b/okgo/src/main/java/com/lzy/okgo/OkGo.java @@ -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; @@ -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; } diff --git a/okgo/src/main/java/com/lzy/okgo/callback/AbsCallback.java b/okgo/src/main/java/com/lzy/okgo/callback/AbsCallback.java index 28a476ce..5daec332 100644 --- a/okgo/src/main/java/com/lzy/okgo/callback/AbsCallback.java +++ b/okgo/src/main/java/com/lzy/okgo/callback/AbsCallback.java @@ -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; @@ -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(); } diff --git a/okgo/src/main/java/com/lzy/okgo/request/BaseBodyRequest.java b/okgo/src/main/java/com/lzy/okgo/request/BaseBodyRequest.java index 3c208427..3e4f6448 100644 --- a/okgo/src/main/java/com/lzy/okgo/request/BaseBodyRequest.java +++ b/okgo/src/main/java/com/lzy/okgo/request/BaseBodyRequest.java @@ -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; @@ -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; } diff --git a/okgo/src/main/java/com/lzy/okgo/request/BaseRequest.java b/okgo/src/main/java/com/lzy/okgo/request/BaseRequest.java index c3bd8b07..3dc03185 100644 --- a/okgo/src/main/java/com/lzy/okgo/request/BaseRequest.java +++ b/okgo/src/main/java/com/lzy/okgo/request/BaseRequest.java @@ -1,6 +1,5 @@ package com.lzy.okgo.request; -import android.support.annotation.NonNull; import android.text.TextUtils; import com.lzy.okgo.OkGo; @@ -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; } @@ -249,7 +248,7 @@ 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); @@ -257,13 +256,13 @@ public R addCookie(@NonNull String name, @NonNull String value) { } @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 cookies) { + public R addCookies(List cookies) { userCookies.addAll(cookies); return (R) this; } diff --git a/okgo/src/main/java/com/lzy/okgo/request/HasBody.java b/okgo/src/main/java/com/lzy/okgo/request/HasBody.java index 81b81251..c801c958 100644 --- a/okgo/src/main/java/com/lzy/okgo/request/HasBody.java +++ b/okgo/src/main/java/com/lzy/okgo/request/HasBody.java @@ -1,7 +1,5 @@ package com.lzy.okgo.request; -import android.support.annotation.NonNull; - import com.lzy.okgo.model.HttpParams; import java.io.File; @@ -20,7 +18,7 @@ * ================================================ */ public interface HasBody { - R requestBody(@NonNull RequestBody requestBody); + R requestBody(RequestBody requestBody); R params(String key, File file); diff --git a/okserver/src/main/java/com/lzy/okserver/download/DownloadInfo.java b/okserver/src/main/java/com/lzy/okserver/download/DownloadInfo.java index 33acbb76..4dff3030 100644 --- a/okserver/src/main/java/com/lzy/okserver/download/DownloadInfo.java +++ b/okserver/src/main/java/com/lzy/okserver/download/DownloadInfo.java @@ -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; @@ -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()); } } \ No newline at end of file diff --git a/okserver/src/main/java/com/lzy/okserver/download/DownloadManager.java b/okserver/src/main/java/com/lzy/okserver/download/DownloadManager.java index 93826580..2d6a183a 100644 --- a/okserver/src/main/java/com/lzy/okserver/download/DownloadManager.java +++ b/okserver/src/main/java/com/lzy/okserver/download/DownloadManager.java @@ -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; @@ -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); } @@ -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(); @@ -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) { @@ -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; @@ -232,7 +231,7 @@ public DownloadInfo getDownloadInfo(@NonNull String taskKey) { } /** 移除一个任务 */ - private void removeTaskByKey(@NonNull String taskKey) { + private void removeTaskByKey(String taskKey) { ListIterator iterator = mDownloadInfoList.listIterator(); while (iterator.hasNext()) { DownloadInfo info = iterator.next(); diff --git a/okserver/src/main/java/com/lzy/okserver/download/DownloadService.java b/okserver/src/main/java/com/lzy/okserver/download/DownloadService.java index da7c8cac..1b52f064 100644 --- a/okserver/src/main/java/com/lzy/okserver/download/DownloadService.java +++ b/okserver/src/main/java/com/lzy/okserver/download/DownloadService.java @@ -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; @@ -21,7 +20,7 @@ * ================================================ */ public class DownloadService extends Service { - @Nullable + @Override public IBinder onBind(Intent intent) { return null; diff --git a/okserver/src/main/java/com/lzy/okserver/upload/UploadManager.java b/okserver/src/main/java/com/lzy/okserver/upload/UploadManager.java index 81852da1..da8e28f5 100644 --- a/okserver/src/main/java/com/lzy/okserver/upload/UploadManager.java +++ b/okserver/src/main/java/com/lzy/okserver/upload/UploadManager.java @@ -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; @@ -53,13 +51,13 @@ private UploadManager() { /** 添加一个上传任务,默认使用post请求 */ @Deprecated - public void addTask(String url, @NonNull File resource, @NonNull String key, UploadListener listener) { + public void addTask(String url, File resource, String key, UploadListener listener) { PostRequest request = OkGo.post(url).params(key, resource); addTask(url, request, listener); } /** 添加一个上传任务 */ - public void addTask(String taskKey, @NonNull BaseBodyRequest request, UploadListener listener) { + public void addTask(String taskKey, BaseBodyRequest request, UploadListener listener) { UploadInfo uploadInfo = new UploadInfo(); uploadInfo.setTaskKey(taskKey); uploadInfo.setState(UploadManager.NONE);