调整 DialogFragment 的实例化代码(优化)https://git.ghzs.com/halo/android/assistant-android/-/issues/38#note_117062
This commit is contained in:
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user