From a21912b8847b710a76968a85fc67c686de505028 Mon Sep 17 00:00:00 2001 From: izzy2lost Date: Wed, 8 Oct 2025 00:18:28 -0400 Subject: [PATCH] another fix attempt - adding periodic BIOS check --- .../psx2/SetupWizardDialogFragment.java | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/app/src/main/java/com/izzy2lost/psx2/SetupWizardDialogFragment.java b/app/src/main/java/com/izzy2lost/psx2/SetupWizardDialogFragment.java index 11fc0ac..e31b062 100644 --- a/app/src/main/java/com/izzy2lost/psx2/SetupWizardDialogFragment.java +++ b/app/src/main/java/com/izzy2lost/psx2/SetupWizardDialogFragment.java @@ -26,6 +26,8 @@ public class SetupWizardDialogFragment extends DialogFragment { private MaterialButton btnDone; private TextView titleView; private TextView hintView; + private Runnable mPeriodicCheck; + private boolean mHasAutoAdvanced = false; @NonNull @Override @@ -45,6 +47,15 @@ public class SetupWizardDialogFragment extends DialogFragment { // Auto-advance if all steps are complete checkAndAutoAdvance(); } catch (Throwable ignored) {} + + // Start periodic checking for BIOS files (in case onResume doesn't catch the import) + startPeriodicCheck(); + } + + @Override + public void onPause() { + super.onPause(); + stopPeriodicCheck(); } @Override @@ -242,8 +253,52 @@ public class SetupWizardDialogFragment extends DialogFragment { } + private void startPeriodicCheck() { + stopPeriodicCheck(); + View root = getView(); + if (root != null) { + mPeriodicCheck = new Runnable() { + @Override + public void run() { + try { + if (isAdded() && !mHasAutoAdvanced) { + updateUi(); + checkAndAutoAdvance(); + // Keep checking every 500ms until auto-advance happens + if (getView() != null && !mHasAutoAdvanced) { + getView().postDelayed(this, 500); + } + } + } catch (Throwable ignored) {} + } + }; + root.postDelayed(mPeriodicCheck, 500); + } + } + + private void stopPeriodicCheck() { + View root = getView(); + if (root != null && mPeriodicCheck != null) { + root.removeCallbacks(mPeriodicCheck); + } + mPeriodicCheck = null; + } + + // Public method to manually refresh UI (can be called from MainActivity after BIOS import) + public void refreshUi() { + try { + updateUi(); + checkAndAutoAdvance(); + } catch (Throwable ignored) {} + } + private void checkAndAutoAdvance() { + if (mHasAutoAdvanced) return; // Prevent multiple auto-advances + if (isDataFolderPicked() && isGamesFolderPicked() && isBiosPresent()) { + mHasAutoAdvanced = true; + stopPeriodicCheck(); + // All steps complete, auto-advance with delay to let BIOS processing finish View decor = getDialog() != null && getDialog().getWindow() != null ? getDialog().getWindow().getDecorView() : null; if (decor != null) {