修复安装/卸载后游戏插件化区域无法更新问题

This commit is contained in:
kehaoyuan
2018-01-23 14:50:41 +08:00
parent 5680b8508d
commit 2d1bb6435f

View File

@ -11,7 +11,6 @@ import com.facebook.drawee.backends.pipeline.Fresco;
import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
import com.gh.base.OnRequestCallBackListener;
import com.gh.base.fragment.BaseFragment;
import com.gh.common.util.ApkActiveUtils;
import com.gh.common.util.DownloadItemUtils;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.MainActivity;
@ -80,7 +79,7 @@ public class GameFragment extends BaseFragment implements SwipeRefreshLayout.OnR
for (Integer locationPlugin : locationPluginList) {
gameEntity = adapter.getPluginList().get(locationPlugin);
RecyclerView.Adapter<? extends RecyclerView.ViewHolder> pluginAdapter = adapter.getPluginAdapter();
if (gameEntity != null && pluginAdapter != null ) {
if (gameEntity != null && pluginAdapter != null) {
DownloadItemUtils.processDate(getActivity(), gameEntity,
downloadEntity, pluginAdapter, locationPlugin);
}
@ -224,48 +223,46 @@ public class GameFragment extends BaseFragment implements SwipeRefreshLayout.OnR
if (locationList != null) {
GameEntity gameEntity;
for (int location : locationList) {
gameEntity = adapter.getGameEntityByLocation(location);
if (gameEntity != null) {
ApkActiveUtils.filterHideApk(gameEntity);
if (gameEntity.isPluggable()) {
// 插件化列表
if ("安装".equals(busFour.getType()) || "卸载".equals(busFour.getType())) {
List<GameEntity> list = adapter.getPluginList();
for (int i = 0; i < list.size(); i++) {
final GameEntity entity = list.get(i);
final ArrayList<ApkEntity> apkEntities = entity.getApk();
final ApkEntity normalApkEntity = apkEntities.get(0);
if (location == 1) {
List<GameEntity> pluginList = adapter.getPluginList();
for (int i = 0; i < pluginList.size(); i++) {
final GameEntity entity = pluginList.get(i);
final ArrayList<ApkEntity> apkEntities = entity.getApk();
final ApkEntity pluginApkEntity = apkEntities.get(0);
if (normalApkEntity.getPackageName().equals(busFour.getPackageName())) {
// 安装完成 插件化区域消失
list.remove(i);
if (list.isEmpty()) {
adapter.initItemCount();
adapter.notifyItemRemoved(1);
} else {
adapter.initPlugin();
adapter.initLocationMap();
adapter.notifyItemChanged(1);
}
// }
break;
if (pluginApkEntity.getPackageName().equals(busFour.getPackageName())) {
if ("卸载".equals(busFour.getType()) && // 插件化过程中 卸载卸载原包后 更新下载按钮
DownloadManager.getInstance(getContext()).getDownloadEntityByUrl(pluginApkEntity.getUrl()) != null) {
adapter.notifyItemChanged(1);
} else {
// 安装完成 插件化区域消失
pluginList.remove(i);
if (pluginList.isEmpty()) {
adapter.initItemCount();
adapter.notifyItemRemoved(1);
} else {
adapter.initPlugin();
adapter.initLocationMap();
adapter.notifyItemChanged(1);
}
}
break;
}
} else {
if ("安装".equals(busFour.getType())) {
for (ApkEntity apkEntity : gameEntity.getApk()) {
if (apkEntity.getPackageName().equals(busFour.getPackageName())) {
if (gameEntity.getEntryMap() != null) {
gameEntity.getEntryMap().remove(apkEntity.getPlatform());
}
adapter.notifyItemChanged(location);
break;
}
} else {
gameEntity = adapter.getGameEntityByLocation(location);
if ("安装".equals(busFour.getType())) {
for (ApkEntity apkEntity : gameEntity.getApk()) {
if (apkEntity.getPackageName().equals(busFour.getPackageName())) {
if (gameEntity.getEntryMap() != null) {
gameEntity.getEntryMap().remove(apkEntity.getPlatform());
}
adapter.notifyItemChanged(location);
break;
}
} else if ("卸载".equals(busFour.getType())) {
adapter.notifyItemChanged(location);
}
} else if ("卸载".equals(busFour.getType())) {
adapter.notifyItemChanged(location);
}
}
}