-
Notifications
You must be signed in to change notification settings - Fork 488
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev_androidx' into dev
# Conflicts: # build.gradle # library/build.gradle # library/src/main/java/com/allenliu/versionchecklib/utils/FileHelper.java # library/src/main/java/com/allenliu/versionchecklib/v2/builder/DownloadBuilder.java # library/src/main/java/com/allenliu/versionchecklib/v2/ui/AllenBaseActivity.java # library/src/main/java/com/allenliu/versionchecklib/v2/ui/DownloadFailedActivity.java # library/src/main/java/com/allenliu/versionchecklib/v2/ui/DownloadingActivity.java # library/src/main/java/com/allenliu/versionchecklib/v2/ui/NotificationHelper.java # library/src/main/java/com/allenliu/versionchecklib/v2/ui/UIActivity.java # library/src/main/java/com/allenliu/versionchecklib/v2/ui/VersionService.java # sample/build.gradle
- Loading branch information
Showing
35 changed files
with
1,234 additions
and
1,507 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -373,4 +373,5 @@ public void showCustomDialog() { | |
|
||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
library/src/main/java/com/allenliu/versionchecklib/v2/builder/BuilderManager.java
This file was deleted.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
library/src/main/java/com/allenliu/versionchecklib/v2/builder/BuilderManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.allenliu.versionchecklib.v2.builder | ||
|
||
import android.content.Context | ||
import com.allenliu.versionchecklib.R | ||
import com.allenliu.versionchecklib.core.DownloadManager | ||
import com.allenliu.versionchecklib.utils.ALog | ||
import com.allenliu.versionchecklib.v2.AllenVersionChecker | ||
import java.io.File | ||
|
||
/** | ||
* @author : shengliu7 | ||
* @e-mail : shengliu7@iflytek.com | ||
* @date : 2020/12/19 12:34 PM | ||
* @desc : | ||
* | ||
*/ | ||
object BuilderManager { | ||
private var downloadBuilder: DownloadBuilder? = null | ||
lateinit var context: Context | ||
fun getDownloadBuilder(): DownloadBuilder? { | ||
return downloadBuilder | ||
} | ||
|
||
fun init(context: Context, downloadBuilder: DownloadBuilder): BuilderManager { | ||
this.context = context | ||
this.downloadBuilder = downloadBuilder | ||
return this | ||
} | ||
|
||
fun destroy() { | ||
downloadBuilder = null | ||
} | ||
|
||
/** | ||
* 验证安装包是否存在,并且在安装成功情况下删除安装包 | ||
*/ | ||
fun checkAndDeleteAPK() { | ||
doWhenNotNull { | ||
//判断versioncode与当前版本不一样的apk是否存在,存在删除安装包 | ||
try { | ||
val downloadPath: String = downloadAPKPath + context.getString(R.string.versionchecklib_download_apkname, context.packageName) | ||
if (!DownloadManager.checkAPKIsExists(context, downloadPath)) { | ||
ALog.e("删除本地apk") | ||
File(downloadPath).delete() | ||
} | ||
} catch (e: Exception) { | ||
e.printStackTrace() | ||
} | ||
} | ||
|
||
} | ||
|
||
fun checkForceUpdate() { | ||
doWhenNotNull { | ||
forceUpdateListener?.onShouldForceUpdate() | ||
} | ||
} | ||
|
||
fun <T> doWhenNotNull(nullBlock: (() -> T)? = null, block: DownloadBuilder.() -> T): T? { | ||
val builder = downloadBuilder | ||
if (builder != null) { | ||
return builder.block() | ||
|
||
} else { | ||
nullBlock?.invoke() | ||
AllenVersionChecker.getInstance().cancelAllMission() | ||
} | ||
return null | ||
} | ||
|
||
} |
Oops, something went wrong.