mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-10 06:29:00 +01:00
Android: Show transition animation while game loads.
This commit is contained in:
parent
0679e43efe
commit
0fcf0e1d21
@ -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;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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<GameViewHolder> 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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,14 +3,16 @@
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/image_screenshot"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/frame_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"/>
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/image_screenshot"
|
||||
android:transitionName="image_game_screenshot"/>
|
||||
|
||||
</FrameLayout>
|
@ -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"/>
|
||||
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<transitionSet>
|
||||
<changeImageTransform/>
|
||||
</transitionSet>
|
@ -7,6 +7,18 @@
|
||||
<item name="colorPrimary">@color/dolphin_blue</item>
|
||||
<!-- darker variant for the status bar and contextual app bars -->
|
||||
<item name="colorPrimaryDark">@color/dolphin_blue_dark</item>
|
||||
|
||||
<!--enable window content transitions
|
||||
<item name="android:windowContentTransitions">true</item>
|
||||
|
||||
<!– specify enter and exit transitions –>
|
||||
<item name="android:windowEnterTransition">@android:transition/fade</item>
|
||||
<item name="android:windowExitTransition">@android:transition/fade</item>
|
||||
|
||||
<!– specify shared element transitions –>
|
||||
<item name="android:windowSharedElementEnterTransition">@transition/change_image_transform</item>
|
||||
<item name="android:windowSharedElementExitTransition">@transition/change_image_transform</item>
|
||||
-->
|
||||
</style>
|
||||
|
||||
<!-- Same as above, but use default action bar, and mandate margins. -->
|
||||
@ -66,6 +78,19 @@
|
||||
<item name="colorPrimary">@color/dolphin_blue</item>
|
||||
<item name="colorPrimaryDark">@color/dolphin_blue_dark</item>
|
||||
<item name="android:windowTranslucentNavigation">true</item>
|
||||
|
||||
<!-- enable window content transitions -->
|
||||
<item name="android:windowContentTransitions">true</item>
|
||||
|
||||
<!-- specify enter and exit transitions -->
|
||||
<item name="android:windowEnterTransition">@android:transition/explode</item>
|
||||
<item name="android:windowExitTransition">@android:transition/explode</item>
|
||||
|
||||
<!-- specify shared element transitions -->
|
||||
<item name="android:windowSharedElementEnterTransition">@transition/change_image_transform
|
||||
</item>
|
||||
<item name="android:windowSharedElementExitTransition">@transition/change_image_transform
|
||||
</item>
|
||||
</style>
|
||||
|
||||
<!-- Inherit from the Base Dolphin Emulation Theme-->
|
||||
@ -81,7 +106,6 @@
|
||||
<item name="colorAccent">@color/dolphin_accent_wiiware</item>
|
||||
</style>
|
||||
|
||||
|
||||
<!-- Hax to make Tablayout render icons -->
|
||||
<style name="MyCustomTextAppearance" parent="TextAppearance.Design.Tab">
|
||||
<item name="textAllCaps">false</item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user