This commit is contained in:
lyr
2021-09-08 18:46:17 +08:00
parent 7881edaf21
commit 9beaf93595
22 changed files with 340 additions and 445 deletions

View File

@ -429,20 +429,8 @@ public class BindingAdapters {
@Nullable String entrance,
@Nullable String location) {
ReserveDialogFragment reserveDialogFragment =
((ReserveDialogFragment)((AppCompatActivity) progressBar.getContext()).getSupportFragmentManager().findFragmentByTag("reserve"));
if (reserveDialogFragment != null) {
reserveDialogFragment.setSuccessCallback(() -> {
LogUtils.logReservation(gameEntity, traceEvent);
updateReservation(progressBar, gameEntity);
});
}
GamePermissionDialogFragment gamePermissionDialogFragment =
((GamePermissionDialogFragment)((AppCompatActivity) progressBar.getContext()).getSupportFragmentManager().findFragmentByTag(GamePermissionDialogFragment.class.getSimpleName()));
if (gamePermissionDialogFragment != null) {
gamePermissionDialogFragment.dismissAllowingStateLoss();
}
// 恢复DialogFragment
restoreDialogFragment(progressBar, gameEntity, traceEvent);
// 判断是否显示按钮
if (gameEntity != null
@ -690,6 +678,27 @@ public class BindingAdapters {
}
}
/**
* 当页面完全重建时若存在重建的DialogFragment则需要手动恢复该DialogFragment之前配置的回调(因为DialogFragment重建时只会从arguments中获取之前的配置内容
* 而arguments无法传递回调)或者dismiss该DialogFragment
*/
private static void restoreDialogFragment(DownloadProgressBar progressBar, GameEntity gameEntity, ExposureEvent traceEvent) {
ReserveDialogFragment reserveDialogFragment =
((ReserveDialogFragment)((AppCompatActivity) progressBar.getContext()).getSupportFragmentManager().findFragmentByTag("reserve"));
if (reserveDialogFragment != null) {
reserveDialogFragment.setSuccessCallback(() -> {
LogUtils.logReservation(gameEntity, traceEvent);
updateReservation(progressBar, gameEntity);
});
}
GamePermissionDialogFragment gamePermissionDialogFragment =
((GamePermissionDialogFragment)((AppCompatActivity) progressBar.getContext()).getSupportFragmentManager().findFragmentByTag(GamePermissionDialogFragment.class.getSimpleName()));
if (gamePermissionDialogFragment != null) {
gamePermissionDialogFragment.dismissAllowingStateLoss();
}
}
/*private static void download(DownloadProgressBar progressBar, GameEntity gameEntity, ExposureEvent traceEvent, @Nullable String entrance, @Nullable String location, View v) {
if (gameEntity.getApk().size() == 1) {
ApkEntity apk = gameEntity.getApk().get(0);