Skip to content

Commit

Permalink
Merge pull request #3 from Zhenhui-Jin/develop
Browse files Browse the repository at this point in the history
更新库
  • Loading branch information
Zhenhui-Jin committed Feb 19, 2020
2 parents 8dd9aab + 9653462 commit 1a19655
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 34 deletions.
10 changes: 5 additions & 5 deletions AppBaseLibrary/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//targetSdkVersion 29 要迁移androidx https://developer.android.com/jetpack/androidx/migrate
api 'androidx.multidex:multidex:2.0.1'//'com.android.support:multidex:1.0.3'
api 'androidx.appcompat:appcompat:1.1.0-rc01'
api 'androidx.appcompat:appcompat:1.1.0'
api 'androidx.constraintlayout:constraintlayout:1.1.3'
api 'androidx.fragment:fragment:1.2.0-alpha02'//"com.android.support:support-fragment:28.0.0"
api 'com.google.android.material:material:1.1.0-alpha09'//'com.android.support:design:28.0.0'
api 'androidx.fragment:fragment:1.2.1'//"com.android.support:support-fragment:28.0.0"
api 'com.google.android.material:material:1.1.0'//'com.android.support:design:28.0.0'
api 'io.reactivex.rxjava2:rxandroid:2.1.1'
api 'io.reactivex.rxjava2:rxjava:2.2.11'

Expand All @@ -44,7 +44,7 @@ dependencies {

implementation 'com.google.zxing:core:3.3.3'
implementation 'com.google.zxing:android-core:3.3.0'
api 'com.google.code.gson:gson:2.8.5'
api 'com.google.code.gson:gson:2.8.6'

// //Bus https://github.com/AndroidKnife/RxBus
// implementation 'com.hwangjr.rxbus:rxbus:1.0.6'
Expand All @@ -59,7 +59,7 @@ dependencies {
implementation 'com.gyf.immersionbar:immersionbar:3.0.0-beta05'

//图片加载 https://github.com/bumptech/glide
api('com.github.bumptech.glide:glide:4.9.0') {
api('com.github.bumptech.glide:glide:4.11.0') {
exclude group: "com.android.support"
}
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.app.base.manage;

import android.app.Activity;
import android.util.Log;

import androidx.annotation.NonNull;

import com.kaopiz.kprogresshud.KProgressHUD;

import androidx.annotation.NonNull;

/**
* @Description
* @Author Zhenhui
Expand All @@ -32,6 +31,7 @@ public void showLoadingDialog(@NonNull Activity activity, String label) {
loadCount = 0;
loadingDialog = KProgressHUD.create(activity)
.setStyle(KProgressHUD.Style.SPIN_INDETERMINATE)
.setCancellable(false)
.setLabel(label);
}
loadCount++;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package com.app.base.net;

import androidx.annotation.NonNull;

import com.google.gson.reflect.TypeToken;

import androidx.annotation.NonNull;

/**
* @Description
* @Author Zhenhui
* @Time 2019/8/15 10:32
*/
public interface LibBaseHttpCallback<T> {
String SOCKET_TIMEOUT_CODE = "timeout";
String NETWORK_CONNECTION_ERROR_CODE = "NetworkConnectionError";

@NonNull
TypeToken<T> getTypeToken();
Expand Down
12 changes: 6 additions & 6 deletions AppBaseLibrary/src/main/java/com/app/base/net/LibBaseOkGo.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import android.app.Application;
import android.text.TextUtils;

import androidx.annotation.NonNull;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.cache.CacheEntity;
import com.lzy.okgo.cache.CacheMode;
Expand All @@ -18,11 +16,13 @@
import com.lzy.okgo.request.PostRequest;
import com.lzy.okgo.request.PutRequest;

import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;

import androidx.annotation.NonNull;
import okhttp3.OkHttpClient;

/**
Expand All @@ -41,7 +41,7 @@ public LibBaseOkGo(Application application) {
mApplication = application;
}

protected void init() {
protected void init(InputStream... certificates) {
OkHttpClient.Builder builder = new OkHttpClient.Builder();

int connectTimeOut = getConnectTimeOut();
Expand All @@ -63,14 +63,14 @@ protected void init() {

// //https相关设置,以下几种方案根据需要自己设置
// //方法一:信任所有证书,不安全有风险
HttpsUtils.SSLParams sslParams1 = HttpsUtils.getSslSocketFactory();
// HttpsUtils.SSLParams sslParams1 = HttpsUtils.getSslSocketFactory();
// //方法二:自定义信任规则,校验服务端证书
// HttpsUtils.SSLParams sslParams2 = HttpsUtils.getSslSocketFactory(new SafeTrustManager());
HttpsUtils.SSLParams sslParams = certificates == null ? HttpsUtils.getSslSocketFactory() : HttpsUtils.getSslSocketFactory(certificates);
// //方法三:使用预埋证书,校验服务端证书(自签名证书)
// //HttpsUtils.SSLParams sslParams3 = HttpsUtils.getSslSocketFactory(getAssets().open("srca.cer"));
// //方法四:使用bks证书和密码管理客户端证书(双向认证),使用预埋证书,校验服务端证书(自签名证书)
// //HttpsUtils.SSLParams sslParams4 = HttpsUtils.getSslSocketFactory(getAssets().open("xxx.bks"), "123456", getAssets().open("yyy.cer"));
builder.sslSocketFactory(sslParams1.sSLSocketFactory, sslParams1.trustManager);
builder.sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager);
// //配置https的域名匹配规则,详细看demo的初始化介绍,不需要就不要加入,使用不当会导致https握手失败
// builder.hostnameVerifier(new SafeHostnameVerifier());

Expand Down
11 changes: 8 additions & 3 deletions AppBaseLibrary/src/main/java/com/app/base/net/LibCallback.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package com.app.base.net;

import androidx.annotation.NonNull;

import com.google.gson.Gson;
import com.lzy.okgo.callback.AbsCallback;
import com.lzy.okgo.model.Response;
import com.lzy.okgo.request.base.Request;

import org.apache.http.conn.ConnectTimeoutException;

import java.io.IOException;
import java.net.SocketTimeoutException;

import androidx.annotation.NonNull;
import okhttp3.ResponseBody;

/**
Expand Down Expand Up @@ -56,8 +58,11 @@ public void onError(Response<T> response) {
code = String.valueOf(response.code());
Throwable e = response.getException();
if (e != null) {
if (e instanceof SocketTimeoutException) {
if (e instanceof SocketTimeoutException
|| e instanceof ConnectTimeoutException) {
code = LibBaseHttpCallback.SOCKET_TIMEOUT_CODE;
} else if (e instanceof IOException) {
code = LibBaseHttpCallback.NETWORK_CONNECTION_ERROR_CODE;
}
message = e.getMessage();
}
Expand Down
10 changes: 5 additions & 5 deletions AppBaseLibrary/src/main/res/layout/layout_custom_column_view.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal">

<androidx.constraintlayout.widget.ConstraintLayout
Expand All @@ -25,10 +25,10 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
tools:text="left_text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/iv_left_icon"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
tools:text="left_text" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/right_layout"
Expand All @@ -47,8 +47,8 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
tools:text="right_text"
app:layout_constraintEnd_toStartOf="@+id/iv_right_icon" />
app:layout_constraintEnd_toStartOf="@+id/iv_right_icon"
tools:text="right_text" />

</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal">

<TextView
android:textStyle="bold"
android:id="@+id/tv_title_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:singleLine="true"
android:textStyle="bold"
tools:text="title" />

<ImageView
Expand Down
5 changes: 5 additions & 0 deletions AppBaseLibrary/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="tip_scan_qr_code">扫瞄卡右下角的QR code</string>
<string name="tip_invalid_code">"无效二维码"</string>
</resources>
5 changes: 5 additions & 0 deletions AppBaseLibrary/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="tip_scan_qr_code">掃瞄卡右下角的QR code</string>
<string name="tip_invalid_code">"無效QR code"</string>
</resources>
6 changes: 3 additions & 3 deletions BannerLibrary/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ android {
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.fragment:fragment:1.2.0-alpha02'//"com.android.support:support-fragment:28.0.0"
implementation 'com.google.android.material:material:1.1.0-alpha09'//'com.android.support:design:28.0.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.fragment:fragment:1.2.1'//"com.android.support:support-fragment:28.0.0"
implementation 'com.google.android.material:material:1.1.0'//'com.android.support:design:28.0.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.11'
}
Expand Down
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

implementation project(path: ':AppBaseLibrary')

}
4 changes: 2 additions & 2 deletions app/src/main/java/com/app/base/demo/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.app.base.demo;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

@Override
Expand Down

0 comments on commit 1a19655

Please sign in to comment.