fix: 处理弹窗 dismiss 问题
This commit is contained in:
@ -1343,7 +1343,6 @@ object VHelper {
|
||||
VSpace32DialogFragment.showDownloadDialog(
|
||||
context,
|
||||
getVSpaceDownloadEntity(false),
|
||||
autoDownload = true,
|
||||
gameId = gameId,
|
||||
gameName = gameName
|
||||
)
|
||||
|
||||
@ -165,7 +165,7 @@ class VSpace32DialogFragment : BaseDraggableDialogFragment() {
|
||||
|
||||
// 上面监听安装包名变化的 LiveData 监听有可能被冲掉了
|
||||
// 手动再检查一下安装状态,避免出现已安装但是没有 dismiss 弹窗的问题
|
||||
if (PackageUtils.isInstalled(requireContext(), VHelper.VSPACE_32BIT_PACKAGENAME)) {
|
||||
if (PackageUtils.isInstalledFromAllPackage(requireContext(), VHelper.VSPACE_32BIT_PACKAGENAME)) {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
@ -260,15 +260,11 @@ class VSpace32DialogFragment : BaseDraggableDialogFragment() {
|
||||
|
||||
companion object {
|
||||
const val KEY_APP_ENTITY_32 = "app_entity_32"
|
||||
const val KEY_AUTO_DOWNLOAD = "auto_download"
|
||||
const val KEY_IS_UPDATE = "is_update"
|
||||
|
||||
@JvmStatic
|
||||
fun showDownloadDialog(
|
||||
context: Context?,
|
||||
appEntity32: AppEntity,
|
||||
autoDownload: Boolean = false,
|
||||
isUpdate: Boolean = false,
|
||||
gameId: String = "",
|
||||
gameName: String = ""
|
||||
) {
|
||||
@ -291,8 +287,6 @@ class VSpace32DialogFragment : BaseDraggableDialogFragment() {
|
||||
putParcelable(KEY_APP_ENTITY_32, appEntity32)
|
||||
putString(EntranceConsts.KEY_GAME_ID, gameId)
|
||||
putString(EntranceConsts.KEY_GAME_NAME, gameName)
|
||||
putBoolean(KEY_AUTO_DOWNLOAD, autoDownload)
|
||||
putBoolean(KEY_IS_UPDATE, isUpdate)
|
||||
}
|
||||
}
|
||||
downloadDialog.show(
|
||||
@ -301,24 +295,6 @@ class VSpace32DialogFragment : BaseDraggableDialogFragment() {
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun showDownloadDialog(
|
||||
context: Context?,
|
||||
appEntity32: AppEntity,
|
||||
gameEntity: GameEntity?,
|
||||
autoDownload: Boolean = false,
|
||||
isUpdate: Boolean = false
|
||||
) {
|
||||
showDownloadDialog(
|
||||
context,
|
||||
appEntity32,
|
||||
autoDownload,
|
||||
isUpdate,
|
||||
gameEntity?.id ?: "",
|
||||
gameEntity?.name ?: ""
|
||||
)
|
||||
}
|
||||
|
||||
private fun hasDialogDisplayedInCurrentActivity(fragmentActivity: FragmentActivity): Boolean {
|
||||
val fragments: List<Fragment> = fragmentActivity.supportFragmentManager.fragments
|
||||
fragments.forEach { fragment ->
|
||||
|
||||
@ -39,6 +39,13 @@ import com.lightgame.download.DownloadStatus.*
|
||||
import com.lightgame.utils.AppManager
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* 1. 单独的 64 位组件的下载和更新使用本 VSpaceDialogFragment
|
||||
* 2. 已经安装了 64 位组件,后续操作所调起的 32 位组件的首次下载使用亦 VSpace32DialogFragment
|
||||
* 3. 64 位组件已安装且 64 位组件无需更新时,32 位组件需要更新时,使用本 VSpaceDialogFragment
|
||||
* 4. 64 位组件已安装且 64,32 位都需要更新时,64 位更新使用本 VSpaceDialogFragment
|
||||
* (同时下载64位组件和32位组件,但是32位在64位安装完成之前不触发安装), 32 位安装使用跳转 VSpaceUpdate32DialogFragment 进行
|
||||
*/
|
||||
class VSpaceDialogFragment : BaseDraggableDialogFragment() {
|
||||
|
||||
private var mAppEntity64: AppEntity? = null
|
||||
@ -92,6 +99,7 @@ class VSpaceDialogFragment : BaseDraggableDialogFragment() {
|
||||
|
||||
val mViewModel = viewModelProvider<VSpaceDialogViewModel>()
|
||||
mViewModel.packageLiveData.observe(this) {
|
||||
show32BitRelatedDialogIfNeeded()
|
||||
dismissDialogIfInstalled()
|
||||
}
|
||||
|
||||
@ -198,7 +206,16 @@ class VSpaceDialogFragment : BaseDraggableDialogFragment() {
|
||||
super.onStart()
|
||||
DownloadManager.getInstance().addObserver(mDataWatcher)
|
||||
|
||||
if (PackageUtils.isInstalledFromAllPackage(requireContext(), VHelper.DEFAULT_VSPACE_PACKAGENAME)) {
|
||||
show32BitRelatedDialogIfNeeded()
|
||||
|
||||
// 检查安装状态,避免出现已安装但是没有 dismiss 弹窗的问题
|
||||
dismissDialogIfInstalled()
|
||||
}
|
||||
|
||||
// 弹下载/更新 32 位组件,前提是 64 位组件已经安装并安装了指定的版本
|
||||
private fun show32BitRelatedDialogIfNeeded() {
|
||||
if (PackageUtils.isInstalledFromAllPackage(requireContext(), VHelper.DEFAULT_VSPACE_PACKAGENAME)
|
||||
&& mAppEntity64?.version == PackageUtils.getVersionNameByPackageName(VHelper.DEFAULT_VSPACE_PACKAGENAME)) {
|
||||
// 该游戏需要 32 位组件,且后台配置的 32 位组件不为空
|
||||
if (mBit == "32" && mAppEntity32 != null && !mAppEntity32?.url.isNullOrEmpty()) {
|
||||
if (mIsUpdate) {
|
||||
@ -208,9 +225,6 @@ class VSpaceDialogFragment : BaseDraggableDialogFragment() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 检查安装状态,避免出现已安装但是没有 dismiss 弹窗的问题
|
||||
dismissDialogIfInstalled()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -141,7 +141,7 @@ class VSpaceUpdate32DialogFragment : BaseDialogFragment() {
|
||||
|
||||
// 上面监听安装包名变化的 LiveData 监听有可能被冲掉了
|
||||
// 手动再检查一下安装状态,避免出现已安装但是没有 dismiss 弹窗的问题
|
||||
if (PackageUtils.isInstalled(requireContext(), VHelper.VSPACE_32BIT_PACKAGENAME)) {
|
||||
if (PackageUtils.isInstalledFromAllPackage(requireContext(), VHelper.VSPACE_32BIT_PACKAGENAME)) {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user