Skip to content

Commit a4fc242

Browse files
committed
base 3.0.7
1 parent 2c1936a commit a4fc242

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

lib/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ apply plugin: 'com.github.dcendents.android-maven'
33
group = 'com.github.ithomasoft'
44

55
android {
6-
compileSdkVersion 31
6+
compileSdkVersion 32
77

88
defaultConfig {
99
minSdkVersion 19
10-
targetSdkVersion 31
11-
versionCode 6
12-
versionName "1.4.0"
10+
targetSdkVersion 32
11+
versionCode 7
12+
versionName "1.5.0"
1313
consumerProguardFiles "consumer-rules.pro"
1414
}
1515

@@ -29,5 +29,5 @@ android {
2929
}
3030

3131
dependencies {
32-
compileOnly 'androidx.appcompat:appcompat:1.2.0'
32+
compileOnly 'androidx.appcompat:appcompat:1.4.2'
3333
}

lib/src/main/java/com/thomas/update/manager/DownloadManager.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public class DownloadManager {
7777
*/
7878
private boolean state = false;
7979

80-
private static DownloadManager manager;
80+
private static volatile DownloadManager manager;
8181

8282
/**
8383
* 框架初始化
@@ -114,7 +114,6 @@ public void onActivityDestroyed(@NonNull Activity activity) {
114114
* 供此依赖库自己使用.
115115
*
116116
* @return {@link DownloadManager}
117-
* @hide
118117
*/
119118
public static DownloadManager getInstance() {
120119
return manager;
@@ -295,7 +294,6 @@ public String getApkMD5() {
295294
/**
296295
* 设置当前状态
297296
*
298-
* @hide
299297
*/
300298
public void setState(boolean state) {
301299
this.state = state;
@@ -325,7 +323,11 @@ public void download() {
325323
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
326324
} else {
327325
if (showNewerToast) {
328-
Toast.makeText(context, R.string.latest_version, Toast.LENGTH_SHORT).show();
326+
if (configuration != null && configuration.getOnToastListener() != null) {
327+
getConfiguration().getOnToastListener().showShort(R.string.latest_version);
328+
} else {
329+
Toast.makeText(context, R.string.latest_version, Toast.LENGTH_SHORT).show();
330+
}
329331
}
330332
Log.e(TAG, "当前已是最新版本");
331333
}

lib/src/main/java/com/thomas/update/service/DownloadService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import android.os.Build;
1313
import android.os.Handler;
1414
import android.os.IBinder;
15+
import android.os.Looper;
1516
import android.os.Message;
1617
import android.text.TextUtils;
1718
import android.util.Log;
@@ -58,7 +59,7 @@ public class DownloadService extends Service implements OnDownloadListener {
5859
@Override
5960
public int onStartCommand(Intent intent, int flags, int startId) {
6061
if (null == intent) {
61-
return START_STICKY;
62+
return START_NOT_STICKY;
6263
}
6364
init();
6465
return super.onStartCommand(intent, flags, startId);
@@ -199,7 +200,7 @@ public void error(Exception e) {
199200
}
200201

201202
@SuppressLint("HandlerLeak")
202-
private Handler handler = new Handler() {
203+
private Handler handler = new Handler(Looper.getMainLooper()) {
203204
@Override
204205
public void handleMessage(Message msg) {
205206
switch (msg.what) {

0 commit comments

Comments
 (0)