MCPcopy Create free account
hub / github.com/Card-Forge/forge / loadGame

Method loadGame

forge-gui-android/src/forge/app/Main.java:382–485  ·  view source on GitHub ↗
(final HWInfo hwInfo, final String title, final String steps, boolean isLandscape, AndroidAdapter adapter, boolean permissiongranted, boolean isTabletDevice, AndroidApplicationConfiguration config, boolean exception, String msg)

Source from the content-addressed store, hash-verified

380 }
381
382 private void loadGame(final HWInfo hwInfo, final String title, final String steps, boolean isLandscape, AndroidAdapter adapter, boolean permissiongranted, boolean isTabletDevice, AndroidApplicationConfiguration config, boolean exception, String msg) {
383 try {
384 final Handler handler = new Handler();
385 forgeLogo = findViewById(resId("id", "logo_id"));
386 activeView = findViewById(resId("id", "mainview"));
387 activeView.setBackgroundColor(Color.WHITE);
388 forgeView = initializeForView(Forge.getApp(hwInfo, getAndroidClipboard(), adapter, ASSETS_DIR, !isLandscape, isTabletDevice, Build.VERSION.SDK_INT), config);
389
390 getAnimator(ObjectAnimator.ofFloat(forgeLogo, "alpha", 1f, 1f).setDuration(800), ObjectAnimator.ofObject(activeView, "backgroundColor", new ArgbEvaluator(), Color.WHITE, Color.BLACK).setDuration(1600), new AnimatorListenerAdapter() {
391 @Override
392 public void onAnimationEnd(Animator animation) {
393 super.onAnimationEnd(animation);
394 handler.postDelayed(() -> {
395 if (!permissiongranted || exception) {
396 displayMessage(forgeLogo, adapter, exception, msg, false);
397 } else if (title.isEmpty() && steps.isEmpty()) {
398 if (isLandscape) {
399 Main.this.setRequestedOrientation(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ?
400 ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : //Oreo and above has virtual back/menu buttons
401 ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
402 } else {
403 Main.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
404 }
405 crossfade(forgeView, forgeLogo);
406 } else {
407 if (sharedPreferences.getBoolean("run_anyway", false)) {
408 crossfade(forgeView, forgeLogo);
409 return;
410 }
411 TableLayout TL = new TableLayout(getContext());
412 TL.setBackgroundResource(android.R.color.black);
413 TableRow messageRow = new TableRow(getContext());
414 TableRow checkboxRow = new TableRow(getContext());
415 TableRow buttonRow = new TableRow(getContext());
416 TextView text = new TextView(getContext());
417 text.setGravity(Gravity.LEFT);
418 text.setTypeface(Typeface.SERIF);
419
420 SpannableString ss1 = new SpannableString(title);
421 ss1.setSpan(new StyleSpan(Typeface.BOLD), 0, ss1.length(), 0);
422 text.append(ss1);
423 text.append(steps + "\n");
424 messageRow.addView(text);
425 messageRow.setGravity(Gravity.CENTER);
426
427 CheckBox checkBox = new CheckBox(getContext());
428 checkBox.setTypeface(Typeface.SERIF);
429 checkBox.setGravity(Gravity.TOP);
430 checkBox.setChecked(false);
431 checkBox.setPadding(30, 30, 30, 30);
432 checkBox.setTypeface(Typeface.SERIF);
433 checkBox.setText(" Don't remind me next time. ");
434 checkBox.setScaleX(0.9f);
435 checkBox.setScaleY(0.9f);
436 checkBox.setOnCheckedChangeListener((buttonView, isChecked) ->
437 sharedPreferences.edit().putBoolean("run_anyway", isChecked).apply());
438 checkboxRow.addView(checkBox);
439 checkboxRow.setGravity(Gravity.CENTER);

Callers 1

initForgeMethod · 0.95

Calls 6

resIdMethod · 0.95
getAppMethod · 0.95
getAndroidClipboardMethod · 0.95
getAnimatorMethod · 0.95
initializeForViewMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected