Splash screen is not dismissable during first time initialization or crash reporting

This commit is contained in:
Aaron Culliney
2015-11-03 22:47:35 -08:00
parent a6ac111707
commit fb4d6f466b
3 changed files with 45 additions and 16 deletions

View File

@@ -148,11 +148,12 @@ public class Apple2Activity extends Activity {
String dataDir = Apple2DisksMenu.getDataDir(this);
nativeOnCreate(dataDir, sampleRate, monoBufferSize, stereoBufferSize);
showSplashScreen();
Apple2CrashHandler.getInstance().checkForCrashes(Apple2Activity.this);
final boolean firstTime = !Apple2Preferences.FIRST_TIME_CONFIGURED.booleanValue(this);
Apple2Preferences.FIRST_TIME_CONFIGURED.saveBoolean(this, true);
showSplashScreen(!firstTime);
Apple2CrashHandler.getInstance().checkForCrashes(this);
mGraphicsInitializedRunnable = new Runnable() {
@Override
public void run() {
@@ -165,7 +166,14 @@ public class Apple2Activity extends Activity {
// first-time initializations
if (firstTime) {
Apple2DisksMenu.firstTime(this);
new Thread(new Runnable() {
@Override
public void run() {
Apple2DisksMenu.firstTime(Apple2Activity.this);
mSplashScreen.setDismissable(true);
Log.d(TAG, "Finished first time copying...");
}
}).start();
}
mSettingsMenu = new Apple2SettingsMenu(this);
@@ -193,8 +201,8 @@ public class Apple2Activity extends Activity {
}
Log.d(TAG, "onResume()");
showSplashScreen();
Apple2CrashHandler.getInstance().checkForCrashes(Apple2Activity.this); // NOTE : needs to be called again to clean-up
showSplashScreen(/*dismissable:*/true);
Apple2CrashHandler.getInstance().checkForCrashes(this); // NOTE : needs to be called again to clean-up
}
@Override
@@ -428,11 +436,15 @@ public class Apple2Activity extends Activity {
});
}
private void showSplashScreen() {
public Apple2SplashScreen getSplashScreen() {
return mSplashScreen;
}
private void showSplashScreen(boolean dismissable) {
if (mSplashScreen != null) {
return;
}
mSplashScreen = new Apple2SplashScreen(this, /*dismissable:*/true);
mSplashScreen = new Apple2SplashScreen(this, dismissable);
mSplashScreen.show();
}

View File

@@ -181,14 +181,12 @@ public class Apple2CrashHandler {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
final Button startButton = (Button) activity.findViewById(R.id.startButton);
final Button prefsButton = (Button) activity.findViewById(R.id.prefsButton);
final Button disksButton = (Button) activity.findViewById(R.id.disksButton);
final Apple2SplashScreen splashScreen = activity.getSplashScreen();
if (splashScreen != null) {
splashScreen.setDismissable(false);
}
final ProgressBar bar = (ProgressBar) activity.findViewById(R.id.crash_progressBar);
try {
startButton.setEnabled(false);
prefsButton.setEnabled(false);
disksButton.setEnabled(false);
bar.setVisibility(View.VISIBLE);
} catch (NullPointerException npe) {
/* could happen on early lifecycle crashes */
@@ -354,9 +352,7 @@ public class Apple2CrashHandler {
public void run() {
try {
bar.setVisibility(View.INVISIBLE);
startButton.setEnabled(true);
prefsButton.setEnabled(true);
disksButton.setEnabled(true);
splashScreen.setDismissable(true);
} catch (NullPointerException npe) {
/* could happen on early lifecycle crashes */
}

View File

@@ -30,6 +30,7 @@ import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.RadioButton;
import org.json.JSONArray;
@@ -135,6 +136,14 @@ public class Apple2DisksMenu implements Apple2MenuView {
}
public static void firstTime(Apple2Activity activity) {
final ProgressBar bar = (ProgressBar) activity.findViewById(R.id.crash_progressBar);
try {
bar.setVisibility(View.VISIBLE);
bar.setIndeterminate(true);
} catch (NullPointerException npe) {
Log.v(TAG, "Whoa, avoided NPE in first time #1");
}
getDataDir(activity);
Log.d(TAG, "First time copying stuff-n-things out of APK for ease-of-NDK access...");
@@ -149,6 +158,18 @@ public class Apple2DisksMenu implements Apple2MenuView {
if (sExternalFilesDir != null) {
recursivelyCopyAPKAssets(activity, /*from APK directory:*/"keyboards", /*to location:*/sExternalFilesDir.getAbsolutePath());
}
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
try {
bar.setVisibility(View.INVISIBLE);
bar.setIndeterminate(false);
} catch (NullPointerException npe) {
Log.v(TAG, "Whoa, avoided NPE in first time #2");
}
}
});
}
public static void exposeSymbols(Apple2Activity activity) {