File tree Expand file tree Collapse file tree 3 files changed +14
-11
lines changed
src/main/java/com/thomas/update Expand file tree Collapse file tree 3 files changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -3,13 +3,13 @@ apply plugin: 'com.github.dcendents.android-maven'
33group = ' com.github.ithomasoft'
44
55android {
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
3131dependencies {
32- compileOnly ' androidx.appcompat:appcompat:1.2.0 '
32+ compileOnly ' androidx.appcompat:appcompat:1.4.2 '
3333}
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change 1212import android .os .Build ;
1313import android .os .Handler ;
1414import android .os .IBinder ;
15+ import android .os .Looper ;
1516import android .os .Message ;
1617import android .text .TextUtils ;
1718import 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 ) {
You can’t perform that action at this time.
0 commit comments