Merge branch 'fix/GHZSCY-6778' into 'dev'
fix: 分类页面展示异常 https://jira.shanqu.cc/browse/GHZSCY-6778 See merge request halo/android/assistant-android!1921
This commit is contained in:
@ -65,7 +65,7 @@ public class InstallUtils {
|
||||
if (!TextUtils.isEmpty(installVersion) && downloadEntity != null &&
|
||||
installVersion.equals(downloadEntity.getVersionName())) {
|
||||
if (!downloadEntity.isPluggable() || PackageUtils.isSignedByGh(context, packageName)) {
|
||||
EventBus.getDefault().post(new EBPackage(EBPackage.TYPE_INSTALLED, packageName, installVersion));
|
||||
EventBus.getDefault().post(new EBPackage(EBPackage.TYPE_INSTALLED, packageName, installVersion, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -82,7 +82,7 @@ public class InstallUtils {
|
||||
keys.add(packageName);
|
||||
} else if (!list.contains(packageName)) {
|
||||
keys.add(packageName);
|
||||
EventBus.getDefault().post(new EBPackage("卸载", packageName, ""));
|
||||
EventBus.getDefault().post(new EBPackage("卸载", packageName, "", false));
|
||||
}
|
||||
}
|
||||
for (String key : keys) {
|
||||
|
||||
@ -309,7 +309,8 @@ class CategoryV2ListFragment : ListFragment<GameEntity, CategoryV2ListViewModel>
|
||||
// 安装/卸载 事件
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEventMainThread(busFour: EBPackage) {
|
||||
if (busFour.isInstalledOrUninstalled()) {
|
||||
// 忽略首次初始化触发的事件
|
||||
if (!busFour.fromInit && busFour.isInstalledOrUninstalled()) {
|
||||
mAdapter?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
@ -220,7 +220,7 @@ class NewInstalledGameFragment : ToolbarFragment() {
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEventMainThread(packageEb: EBPackage) {
|
||||
if (packageEb.isInstalledOrUninstalled()) {
|
||||
if (!packageEb.fromInit && packageEb.isInstalledOrUninstalled()) {
|
||||
mInstallGameViewModel.initData(
|
||||
PackagesManager.filterSameApk(
|
||||
PackagesManager.filterDownloadBlackPackage(mPackageViewModel?.getGameInstalledLiveData()?.value as MutableList<GameInstall>?)
|
||||
|
||||
@ -1,6 +1,12 @@
|
||||
package com.gh.gamecenter.eventbus
|
||||
|
||||
class EBPackage(var type: String, var packageName: String, var versionName: String?) {
|
||||
/**
|
||||
* @param fromInit 实体生成是否来自于初始化
|
||||
*/
|
||||
class EBPackage(var type: String,
|
||||
var packageName: String,
|
||||
var versionName: String?,
|
||||
val fromInit: Boolean = false) {
|
||||
var gameId: String? = null
|
||||
var isVGame: Boolean = false // 是否是畅玩游戏
|
||||
|
||||
|
||||
@ -968,7 +968,7 @@ class GameCollectionDetailFragment :
|
||||
// 安装/卸载 事件
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEventMainThread(busFour: EBPackage) {
|
||||
if (busFour.isInstalledOrUninstalled()) {
|
||||
if (!busFour.fromInit && busFour.isInstalledOrUninstalled()) {
|
||||
if (EBPackage.TYPE_INSTALLED == busFour.type
|
||||
&& UserManager.getInstance().isLoggedIn
|
||||
&& (mEntity?.count?.playedGame ?: 0) < (mEntity?.count?.game ?: 0)
|
||||
|
||||
@ -119,7 +119,8 @@ object PackageRepository {
|
||||
packageKey = packageFilterManager.packageKey,
|
||||
filteredList = filteredList,
|
||||
isVGame = false,
|
||||
updateInstallStatus = true
|
||||
updateInstallStatus = true,
|
||||
fromInit = true
|
||||
)
|
||||
}
|
||||
},
|
||||
@ -256,13 +257,15 @@ object PackageRepository {
|
||||
* @param onWorkerThreadOnly 是否在工作线程执行
|
||||
* @param isVGame 包名列表是否为畅玩游戏
|
||||
* @param updateInstallStatus 更新安装状态 (通过 EventBus 来进行)
|
||||
* @param fromInit 是否来自数据首次初始化
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
private fun loadInstalledGameDigestAndNotifyData(
|
||||
packageKey: String,
|
||||
filteredList: ArrayList<String>,
|
||||
isVGame: Boolean = false,
|
||||
updateInstallStatus: Boolean = false
|
||||
updateInstallStatus: Boolean = false,
|
||||
fromInit: Boolean = false
|
||||
) {
|
||||
var isNotifyUpdate = false
|
||||
val maxPageCount = (filteredList.size / PAGE_SIZE) + 1
|
||||
@ -291,7 +294,7 @@ object PackageRepository {
|
||||
|
||||
for (game in validGames) {
|
||||
val shouldNotifyChanges =
|
||||
validateGameAndPostChanges(gh_id, game, pkgName, isVGame, updateInstallStatus)
|
||||
validateGameAndPostChanges(gh_id, game, pkgName, isVGame, updateInstallStatus, fromInit)
|
||||
if (!isNotifyUpdate && shouldNotifyChanges) {
|
||||
isNotifyUpdate = true
|
||||
}
|
||||
@ -317,7 +320,8 @@ object PackageRepository {
|
||||
game: GameEntity,
|
||||
pkgName: String,
|
||||
isVGame: Boolean,
|
||||
updateInstallStatus: Boolean
|
||||
updateInstallStatus: Boolean,
|
||||
fromInit: Boolean = false
|
||||
): Boolean {
|
||||
if (ghId == null || ghId == game.id) {
|
||||
gameInstalled.add(GameInstall.transformGameInstall(game, pkgName, isVGame))
|
||||
@ -328,7 +332,7 @@ object PackageRepository {
|
||||
|
||||
if (updateInstallStatus) {
|
||||
EventBus.getDefault()
|
||||
.post(EBPackage(EBPackage.TYPE_INSTALLED, pkgName, game.getApk().firstOrNull()?.version))
|
||||
.post(EBPackage(EBPackage.TYPE_INSTALLED, pkgName, game.getApk().firstOrNull()?.version, fromInit))
|
||||
}
|
||||
|
||||
if (isCanUpdate || isCanPluggable) {
|
||||
|
||||
@ -72,7 +72,7 @@ public class PackageChangeBroadcastReceiver extends BroadcastReceiver {
|
||||
PackageHelper.refreshLocalPackageList();
|
||||
|
||||
String versionName = PackageUtils.getVersionNameByPackageName(packageName);
|
||||
EBPackage installEb = new EBPackage(EBPackage.TYPE_INSTALLED, packageName, versionName);
|
||||
EBPackage installEb = new EBPackage(EBPackage.TYPE_INSTALLED, packageName, versionName, false);
|
||||
if (PackageUtils.isAppOnForeground(context)) {
|
||||
PackageObserver.onPackageChanged(installEb, null);
|
||||
EventBus.getDefault().post(installEb);
|
||||
@ -102,7 +102,7 @@ public class PackageChangeBroadcastReceiver extends BroadcastReceiver {
|
||||
InstallUtils.getInstance().removeUninstall(packageName);
|
||||
PackageHelper.refreshLocalPackageList();
|
||||
|
||||
EBPackage uninstallEb = new EBPackage(EBPackage.TYPE_UNINSTALLED, packageName, "");
|
||||
EBPackage uninstallEb = new EBPackage(EBPackage.TYPE_UNINSTALLED, packageName, "", false);
|
||||
PackageObserver.onPackageChanged(uninstallEb, null);
|
||||
EventBus.getDefault().post(uninstallEb);
|
||||
if (webviewPackageName.equals(packageName)) {
|
||||
@ -118,7 +118,7 @@ public class PackageChangeBroadcastReceiver extends BroadcastReceiver {
|
||||
Utils.log(TAG, "替换了:" + packageName + "包名的程序");
|
||||
String versionName = PackageUtils.getVersionNameByPackageName(packageName);
|
||||
|
||||
EBPackage updateEb = new EBPackage(EBPackage.TYPE_REPLACED, packageName, versionName);
|
||||
EBPackage updateEb = new EBPackage(EBPackage.TYPE_REPLACED, packageName, versionName, false);
|
||||
EventBus.getDefault().post(updateEb);
|
||||
PackageObserver.onPackageChanged(updateEb, null);
|
||||
if (webviewPackageName.equals(packageName)) {
|
||||
|
||||
@ -214,7 +214,7 @@ class SearchGameIndexFragment : ListFragment<GameEntity, SearchGameResultViewMod
|
||||
// 安装/卸载 事件
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEventMainThread(busFour: EBPackage) {
|
||||
if (busFour.isInstalledOrUninstalled()) {
|
||||
if (!busFour.fromInit && busFour.isInstalledOrUninstalled()) {
|
||||
mAdapter?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
@ -424,7 +424,7 @@ open class SearchGameResultFragment : ListFragment<GameEntity, SearchGameResultV
|
||||
// 安装/卸载 事件
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEventMainThread(busFour: EBPackage) {
|
||||
if (busFour.isInstalledOrUninstalled()) {
|
||||
if (!busFour.fromInit && busFour.isInstalledOrUninstalled()) {
|
||||
mAdapter?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
@ -207,7 +207,7 @@ open class SubjectListFragment : LazyListFragment<GameEntity, SubjectListViewMod
|
||||
// 安装/卸载 事件
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEventMainThread(busFour: EBPackage) {
|
||||
if (busFour.isInstalledOrUninstalled()) {
|
||||
if (!busFour.fromInit && busFour.isInstalledOrUninstalled()) {
|
||||
mAdapter?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
@ -197,7 +197,7 @@ class TagsListFragment : ListFragment<GameEntity, TagsListViewModel>() {
|
||||
// 安装/卸载 事件
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEventMainThread(busFour: EBPackage) {
|
||||
if (busFour.isInstalledOrUninstalled()) {
|
||||
if (!busFour.fromInit && busFour.isInstalledOrUninstalled()) {
|
||||
mAdapter?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user