From 0679e43efec8e9ca8dc690ea2a59bf7c1d045f7c Mon Sep 17 00:00:00 2001 From: sigmabeta Date: Thu, 25 Jun 2015 21:43:00 -0400 Subject: [PATCH 1/3] Android: Show screenshot on EmulationActivity before game starts. --- .../activities/EmulationActivity.java | 30 +++++++++++++++++++ .../dolphinemu/adapters/GameAdapter.java | 1 + .../main/res/layout/activity_emulation.xml | 13 +++++++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java index d1e6f47273..ce3f9624c7 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java @@ -12,6 +12,10 @@ import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; +import android.widget.FrameLayout; +import android.widget.ImageView; + +import com.squareup.picasso.Picasso; import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.R; @@ -22,6 +26,8 @@ import java.util.List; public final class EmulationActivity extends AppCompatActivity { private View mDecorView; + private ImageView mImageView; + private FrameLayout mFrameLayout; private boolean mDeviceHasTouchScreen; private boolean mSystemUiVisible; @@ -79,9 +85,33 @@ public final class EmulationActivity extends AppCompatActivity setContentView(R.layout.activity_emulation); + mImageView = (ImageView) findViewById(R.id.image_screenshot); + mFrameLayout = (FrameLayout) findViewById(R.id.frame_content); + Intent gameToEmulate = getIntent(); String path = gameToEmulate.getStringExtra("SelectedGame"); String title = gameToEmulate.getStringExtra("SelectedTitle"); + String screenPath = gameToEmulate.getStringExtra("ScreenPath"); + + Picasso.with(this) + .load(screenPath) + .fit() + .noFade() + .into(mImageView); + + mImageView.animate() + .setStartDelay(2000) + .setDuration(500) + .alpha(0.0f) + .withEndAction(new Runnable() + { + @Override + public void run() + { + mImageView.setVisibility(View.GONE); + mFrameLayout.setVisibility(View.VISIBLE); + } + }); setTitle(title); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java index a9a7be930e..8b279c52c2 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java @@ -220,6 +220,7 @@ public final class GameAdapter extends RecyclerView.Adapter impl intent.putExtra("SelectedGame", holder.path); intent.putExtra("SelectedTitle", holder.title); + intent.putExtra("ScreenPath", holder.screenshotPath); view.getContext().startActivity(intent); } diff --git a/Source/Android/app/src/main/res/layout/activity_emulation.xml b/Source/Android/app/src/main/res/layout/activity_emulation.xml index 63ea99ba83..5a644b260a 100644 --- a/Source/Android/app/src/main/res/layout/activity_emulation.xml +++ b/Source/Android/app/src/main/res/layout/activity_emulation.xml @@ -1,5 +1,16 @@ + > + + + + \ No newline at end of file From 0fcf0e1d213892dd316bb57e5932c2e77fba691b Mon Sep 17 00:00:00 2001 From: sigmabeta Date: Fri, 26 Jun 2015 08:32:51 -0400 Subject: [PATCH 2/3] Android: Show transition animation while game loads. --- .../activities/EmulationActivity.java | 49 +++++++++++++++++-- .../dolphinemu/adapters/GameAdapter.java | 8 ++- .../main/res/layout/activity_emulation.xml | 14 +++--- .../app/src/main/res/layout/card_game.xml | 2 +- .../res/transition/change_image_transform.xml | 4 ++ .../app/src/main/res/values/styles.xml | 26 +++++++++- 6 files changed, 91 insertions(+), 12 deletions(-) create mode 100644 Source/Android/app/src/main/res/transition/change_image_transform.xml diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java index ce3f9624c7..44bfbb8272 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java @@ -12,9 +12,11 @@ import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; +import android.view.ViewTreeObserver; import android.widget.FrameLayout; import android.widget.ImageView; +import com.squareup.picasso.Callback; import com.squareup.picasso.Picasso; import org.dolphinemu.dolphinemu.NativeLibrary; @@ -51,6 +53,10 @@ public final class EmulationActivity extends AppCompatActivity { super.onCreate(savedInstanceState); + // Picasso will take a while to load these big-ass screenshots. So don't run + // the animation until we say so. + postponeEnterTransition(); + mDeviceHasTouchScreen = getPackageManager().hasSystemFeature("android.hardware.touchscreen"); // Get a handle to the Window containing the UI. @@ -95,21 +101,42 @@ public final class EmulationActivity extends AppCompatActivity Picasso.with(this) .load(screenPath) - .fit() .noFade() - .into(mImageView); + .noPlaceholder() + .into(mImageView, new Callback() + { + @Override + public void onSuccess() + { + scheduleStartPostponedTransition(mImageView); + } + + @Override + public void onError() + { + // Still have to do this, or else the app will crash. + scheduleStartPostponedTransition(mImageView); + } + }); mImageView.animate() .setStartDelay(2000) .setDuration(500) .alpha(0.0f) + .withStartAction(new Runnable() + { + @Override + public void run() + { + mFrameLayout.setVisibility(View.VISIBLE); + } + }) .withEndAction(new Runnable() { @Override public void run() { mImageView.setVisibility(View.GONE); - mFrameLayout.setVisibility(View.VISIBLE); } }); @@ -354,4 +381,20 @@ public final class EmulationActivity extends AppCompatActivity hideSystemUiAfterDelay(); } + + + private void scheduleStartPostponedTransition(final View sharedElement) + { + sharedElement.getViewTreeObserver().addOnPreDrawListener( + new ViewTreeObserver.OnPreDrawListener() + { + @Override + public boolean onPreDraw() + { + sharedElement.getViewTreeObserver().removeOnPreDrawListener(this); + startPostponedEnterTransition(); + return true; + } + }); + } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java index 8b279c52c2..3cb832f91b 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java @@ -1,6 +1,7 @@ package org.dolphinemu.dolphinemu.adapters; import android.app.Activity; +import android.app.ActivityOptions; import android.content.Intent; import android.database.Cursor; import android.database.DataSetObserver; @@ -222,7 +223,12 @@ public final class GameAdapter extends RecyclerView.Adapter impl intent.putExtra("SelectedTitle", holder.title); intent.putExtra("ScreenPath", holder.screenshotPath); - view.getContext().startActivity(intent); + ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation( + (Activity) view.getContext(), + holder.imageScreenshot, + "image_game_screenshot"); + + view.getContext().startActivity(intent, options.toBundle()); } /** diff --git a/Source/Android/app/src/main/res/layout/activity_emulation.xml b/Source/Android/app/src/main/res/layout/activity_emulation.xml index 5a644b260a..c686c6191e 100644 --- a/Source/Android/app/src/main/res/layout/activity_emulation.xml +++ b/Source/Android/app/src/main/res/layout/activity_emulation.xml @@ -3,14 +3,16 @@ android:layout_height="match_parent" > - - + android:visibility="invisible"/> + + + \ No newline at end of file diff --git a/Source/Android/app/src/main/res/layout/card_game.xml b/Source/Android/app/src/main/res/layout/card_game.xml index b18bc9e7ee..9b172b6871 100644 --- a/Source/Android/app/src/main/res/layout/card_game.xml +++ b/Source/Android/app/src/main/res/layout/card_game.xml @@ -20,7 +20,7 @@ android:id="@+id/image_game_screen" android:layout_width="match_parent" android:layout_height="0dp" - android:transitionName="image_game_screen" + android:transitionName="image_game_screenshot" android:layout_weight="1" tools:src="@drawable/placeholder_screenshot" tools:scaleType="centerCrop"/> diff --git a/Source/Android/app/src/main/res/transition/change_image_transform.xml b/Source/Android/app/src/main/res/transition/change_image_transform.xml new file mode 100644 index 0000000000..3ee92bd7c4 --- /dev/null +++ b/Source/Android/app/src/main/res/transition/change_image_transform.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Source/Android/app/src/main/res/values/styles.xml b/Source/Android/app/src/main/res/values/styles.xml index 98cf984807..dc81c173a7 100644 --- a/Source/Android/app/src/main/res/values/styles.xml +++ b/Source/Android/app/src/main/res/values/styles.xml @@ -7,6 +7,18 @@ @color/dolphin_blue @color/dolphin_blue_dark + + @@ -66,6 +78,19 @@ @color/dolphin_blue @color/dolphin_blue_dark true + + + true + + + @android:transition/explode + @android:transition/explode + + + @transition/change_image_transform + + @transition/change_image_transform + @@ -81,7 +106,6 @@ @color/dolphin_accent_wiiware - @@ -74,23 +67,17 @@ @color/dolphin_accent_wiiware -