Skip to content

Commit

Permalink
迁移版本至androidx版本
Browse files Browse the repository at this point in the history
  • Loading branch information
xuexiangjys committed Jul 12, 2020
1 parent a051707 commit 2777faa
Show file tree
Hide file tree
Showing 29 changed files with 92 additions and 69 deletions.
3 changes: 0 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ buildscript {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
repositories {
google()
}
}

allprojects {
Expand Down
7 changes: 6 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ org.gradle.jvmargs=-Xmx1536m
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# 是否打包APK
isNeedPackage=false
isNeedPackage=false

# 表示主工程使用AndroidX形式
android.useAndroidX=true
# 表示针对主工程中使用到的三方库,也会自动执行AndroidX的替换过程。
android.enableJetifier=true
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon May 28 01:44:36 CST 2018
#Sun Jul 12 23:55:52 CST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-all.zip
17 changes: 13 additions & 4 deletions versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
**/
ext.deps = [:]
def versions = [:]
versions.android_gradle_plugin = "3.2.1"
versions.android_gradle_plugin = '3.2.1'
versions.android_maven_gradle_plugin = "2.0"
versions.gradle_bintray_plugin = "1.8.0"
versions.arch_core = "2.0.0"
versions.room = "2.1.0-alpha03"
versions.lifecycle = "2.0.0"
versions.support = "28.0.0"
versions.androidx = "1.1.0"
versions.dagger = "2.16"
versions.junit = "4.12"
versions.espresso = "3.0.2"
Expand All @@ -22,7 +23,7 @@ versions.mockito = "2.7.19"
versions.mockito_all = "1.10.19"
versions.dexmaker = "2.2.0"
versions.constraint_layout = "1.1.3"
versions.glide = "4.8.0"
versions.glide = "4.11.0"
versions.timber = "4.5.1"
versions.rxjava2 = "2.1.3"
versions.rx_android = "2.0.1"
Expand All @@ -31,7 +32,7 @@ versions.atsl_rules = "1.0.1"
versions.hamcrest = "1.3"
versions.kotlin = "1.2.20"
versions.paging = "1.0.0-alpha5"
versions.butterknife = "8.8.1"
versions.butterknife = "10.1.0"
versions.runner = "1.0.2"
versions.gson = "2.8.5"
versions.okhttp3 = "3.13.1"
Expand All @@ -51,6 +52,14 @@ support.v4 = "com.android.support:support-v4:$versions.support"
support.core_utils = "com.android.support:support-core-utils:$versions.support"
deps.support = support

def androidx = [:]
androidx.annotations = "androidx.annotation:annotation:$versions.androidx"
androidx.appcompat = "androidx.appcompat:appcompat:$versions.androidx"
androidx.recyclerview = "androidx.recyclerview:recyclerview:$versions.androidx"
androidx.design = "com.google.android.material:material:$versions.androidx"
androidx.multidex = 'androidx.multidex:multidex:2.0.1'
deps.androidx = androidx

def room = [:]
room.runtime = "android.arch.persistence.room:runtime:$versions.room"
room.compiler = "android.arch.persistence.room:compiler:$versions.room"
Expand Down Expand Up @@ -138,7 +147,7 @@ deps.dexmaker = "com.linkedin.dexmaker:dexmaker-mockito:$versions.dexmaker"
deps.constraint_layout = "com.android.support.constraint:constraint-layout:$versions.constraint_layout"
deps.timber = "com.jakewharton.timber:timber:$versions.timber"
deps.junit = "junit:junit:$versions.junit"
deps.runner = "com.android.support.test:runner:$versions.runner"
deps.runner = 'androidx.test:runner:1.1.0'
deps.mock_web_server = "com.squareup.okhttp3:mockwebserver:$versions.mockwebserver"
deps.rxjava2 = "io.reactivex.rxjava2:rxjava:$versions.rxjava2"
deps.rx_android = "io.reactivex.rxjava2:rxandroid:$versions.rx_android"
Expand Down
7 changes: 4 additions & 3 deletions xhttp2-lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ android {
}

dependencies {
compileOnly deps.support.app_compat
compileOnly deps.androidx.appcompat

//使用retrofit的依赖包
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'

//RxJava
compileOnly 'io.reactivex.rxjava2:rxjava:2.1.12'
compileOnly 'io.reactivex.rxjava2:rxandroid:2.0.2'
compileOnly 'io.reactivex.rxjava2:rxjava:2.2.0'
compileOnly 'io.reactivex.rxjava2:rxandroid:2.1.0'
//OkHttp的依赖包
compileOnly 'com.squareup.okhttp3:okhttp:3.10.0'
//Gson序列化反序列化的依赖包
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.xuexiang.xhttp2;

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

import com.google.gson.Gson;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.xuexiang.xhttp2;

import android.support.annotation.NonNull;
import androidx.annotation.NonNull;

import java.util.Iterator;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.xuexiang.xhttp2.annotation;

import android.support.annotation.StringDef;
import androidx.annotation.StringDef;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.xuexiang.xhttp2.callback;

import android.support.annotation.NonNull;
import androidx.annotation.NonNull;

import com.google.gson.internal.$Gson$Types;
import com.xuexiang.xhttp2.cache.model.CacheResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.xuexiang.xhttp2.exception;

import android.support.annotation.NonNull;
import androidx.annotation.NonNull;

/**
* 错误信息处理
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.xuexiang.xhttp2.logs;

import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import android.text.TextUtils;
import android.util.Log;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.xuexiang.xhttp2.logs;

import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import android.util.Log;

import java.io.PrintWriter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* @author xuexiang
* @since 2018/6/24 下午11:16
*/
@SuppressWarnings(value = {"unchecked"})
@SuppressWarnings(value={"unchecked"})
public abstract class BaseBodyRequest<R extends BaseBodyRequest> extends BaseRequest<R> {
protected String mString; //上传的文本内容
protected MediaType mMediaType; //上传文本的类型
Expand Down Expand Up @@ -270,11 +270,9 @@ private MultipartBody.Part addFile(String key, HttpParams.FileWrapper fileWrappe
Utils.checkNotNull(requestBody, "requestBody==null fileWrapper.file must is File/InputStream/byte[]");
if (fileWrapper.responseCallBack != null) {
UploadProgressRequestBody uploadProgressRequestBody = new UploadProgressRequestBody(requestBody, fileWrapper.responseCallBack);
MultipartBody.Part part = MultipartBody.Part.createFormData(key, fileWrapper.fileName, uploadProgressRequestBody);
return part;
return MultipartBody.Part.createFormData(key, fileWrapper.fileName, uploadProgressRequestBody);
} else {
MultipartBody.Part part = MultipartBody.Part.createFormData(key, fileWrapper.fileName, requestBody);
return part;
return MultipartBody.Part.createFormData(key, fileWrapper.fileName, requestBody);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
* @author xuexiang
* @since 2018/5/23 上午10:03
*/
@SuppressWarnings(value = {"unchecked"})
@SuppressWarnings(value={"unchecked"})
public abstract class BaseRequest<R extends BaseRequest> {
protected Context mContext;
//====请求地址=====//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import android.annotation.SuppressLint;
import android.net.Uri;
import android.os.Build;
import android.support.annotation.RequiresApi;
import androidx.annotation.RequiresApi;
import android.text.TextUtils;

import com.xuexiang.xhttp2.callback.CallBack;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package com.xuexiang.xhttp2.transform.func;

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

import com.google.gson.Gson;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package com.xuexiang.xhttp2.utils;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.google.gson.Gson;
import com.xuexiang.xhttp2.annotation.ParamKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import android.os.storage.StorageManager;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import android.text.TextUtils;

import com.xuexiang.xhttp2.XHttp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import android.os.Build;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.annotation.RequiresApi;
import androidx.annotation.RequiresApi;

import com.xuexiang.xhttp2.XHttp;

Expand Down
31 changes: 18 additions & 13 deletions xhttp2demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android {
targetSdkVersion build_versions.target_sdk
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

javaCompileOptions {
annotationProcessorOptions {
Expand Down Expand Up @@ -55,6 +55,11 @@ android {
lintOptions {
abortOnError false
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

}

Expand All @@ -65,9 +70,9 @@ dependencies {
androidTestImplementation deps.espresso.core

//SmartRefreshLayout
implementation deps.support.app_compat
implementation deps.support.recyclerview
implementation deps.support.design
implementation deps.androidx.appcompat
implementation deps.androidx.recyclerview
implementation deps.androidx.design
implementation 'com.github.xuexiangjys.SmartRefreshLayout:refresh-layout:1.1.5'

//XUtil
Expand All @@ -77,25 +82,25 @@ dependencies {
implementation 'com.jakewharton.rxbinding2:rxbinding:2.1.1'
implementation 'com.github.xuexiangjys:rxutil2:1.1.5'
//XAOP
implementation 'com.github.xuexiangjys.XAOP:xaop-runtime:1.0.5'
implementation 'com.github.xuexiangjys.XAOP:xaop-runtime:x1.0.5'
//XRouter
implementation 'com.github.xuexiangjys.XRouter:xrouter-runtime:1.0.1'
annotationProcessor 'com.github.xuexiangjys.XRouter:xrouter-compiler:1.0.1'
//XPage
implementation 'com.github.xuexiangjys.XPage:xpage-lib:2.3.0'
annotationProcessor 'com.github.xuexiangjys.XPage:xpage-compiler:2.3.0'
implementation 'com.github.xuexiangjys.XPage:xpage-lib:3.0.0'
annotationProcessor 'com.github.xuexiangjys.XPage:xpage-compiler:3.0.0'
//butterKnife的sdk
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'com.jakewharton:butterknife:10.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'

//XHttp
// implementation project(':xhttp2-lib')
implementation project(':xhttp2-lib')

implementation 'com.github.xuexiangjys:XHttp2:1.0.4'
// implementation 'com.github.xuexiangjys:XHttp2:1.0.4'

//RxJava
implementation 'io.reactivex.rxjava2:rxjava:2.1.12'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'io.reactivex.rxjava2:rxjava:2.2.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
//OkHttp的依赖包
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
//Gson序列化反序列化的依赖包
Expand Down
12 changes: 12 additions & 0 deletions xhttp2demo/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,18 @@
#如果引用了v4或者v7包
-dontwarn android.support.**

# AndroidX 防止混淆
-dontwarn com.google.android.material.**
-dontnote com.google.android.material.**
-dontwarn androidx.**
-keep class com.google.android.material.** {*;}
-keep class androidx.** {*;}
-keep public class * extends androidx.**
-keep interface androidx.** {*;}
-keepclassmembers class * {
@androidx.annotation.Keep *;
}

# zxing
-dontwarn com.google.zxing.**
-keep class com.google.zxing.**{*;}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.MotionEvent;
import android.view.View;
import android.widget.EditText;

import androidx.annotation.Nullable;

import com.xuexiang.xhttp2.XHttpProxy;
import com.xuexiang.xhttp2.exception.ApiException;
import com.xuexiang.xhttp2.subsciber.ProgressDialogLoader;
Expand All @@ -32,7 +33,6 @@
import com.xuexiang.xhttp2demo.entity.LoginInfo;
import com.xuexiang.xhttp2demo.http.TestApi;
import com.xuexiang.xhttp2demo.manager.TokenManager;
import com.xuexiang.xpage.annotation.Page;
import com.xuexiang.xpage.utils.TitleBar;
import com.xuexiang.xpage.utils.TitleUtils;
import com.xuexiang.xrouter.annotation.Router;
Expand Down
Loading

0 comments on commit 2777faa

Please sign in to comment.