Merge pull request #7518 from weihuoya/remove-animation

[Android] Remove enter and exit transition
This commit is contained in:
Pierre Bourdon 2018-10-28 23:53:06 +01:00 committed by GitHub
commit 1cb0900a10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 7 additions and 141 deletions

View File

@ -132,6 +132,6 @@ public class AppLinkActivity extends FragmentActivity
LocalBroadcastManager.getInstance(this).unregisterReceiver(directoryStateReceiver); LocalBroadcastManager.getInstance(this).unregisterReceiver(directoryStateReceiver);
directoryStateReceiver = null; directoryStateReceiver = null;
} }
EmulationActivity.launch(this, game, -1, null); EmulationActivity.launch(this, game);
} }
} }

View File

@ -11,7 +11,6 @@ import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.annotation.IntDef; import android.support.annotation.IntDef;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
@ -25,14 +24,10 @@ import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.widget.ImageView;
import android.widget.SeekBar; import android.widget.SeekBar;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.squareup.picasso.Callback;
import com.squareup.picasso.Picasso;
import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting; import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
@ -45,7 +40,6 @@ import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.ui.main.MainActivity; import org.dolphinemu.dolphinemu.ui.main.MainActivity;
import org.dolphinemu.dolphinemu.ui.main.MainPresenter; import org.dolphinemu.dolphinemu.ui.main.MainPresenter;
import org.dolphinemu.dolphinemu.ui.platform.Platform; import org.dolphinemu.dolphinemu.ui.platform.Platform;
import org.dolphinemu.dolphinemu.utils.Animations;
import org.dolphinemu.dolphinemu.utils.ControllerMappingHelper; import org.dolphinemu.dolphinemu.utils.ControllerMappingHelper;
import org.dolphinemu.dolphinemu.utils.FileBrowserHelper; import org.dolphinemu.dolphinemu.utils.FileBrowserHelper;
import org.dolphinemu.dolphinemu.utils.Java_GCAdapter; import org.dolphinemu.dolphinemu.utils.Java_GCAdapter;
@ -64,7 +58,6 @@ public final class EmulationActivity extends AppCompatActivity
public static final int REQUEST_CHANGE_DISC = 1; public static final int REQUEST_CHANGE_DISC = 1;
private View mDecorView; private View mDecorView;
private ImageView mImageView;
private EmulationFragment mEmulationFragment; private EmulationFragment mEmulationFragment;
private SharedPreferences mPreferences; private SharedPreferences mPreferences;
@ -72,16 +65,12 @@ public final class EmulationActivity extends AppCompatActivity
private Settings mSettings; private Settings mSettings;
// So that MainActivity knows which view to invalidate before the return animation.
private int mPosition;
private boolean mDeviceHasTouchScreen; private boolean mDeviceHasTouchScreen;
private boolean mMenuVisible; private boolean mMenuVisible;
private static boolean sIsGameCubeGame; private static boolean sIsGameCubeGame;
private boolean activityRecreated; private boolean activityRecreated;
private String mScreenPath;
private String mSelectedTitle; private String mSelectedTitle;
private int mPlatform; private int mPlatform;
private String mPath; private String mPath;
@ -90,8 +79,6 @@ public final class EmulationActivity extends AppCompatActivity
public static final String EXTRA_SELECTED_GAME = "SelectedGame"; public static final String EXTRA_SELECTED_GAME = "SelectedGame";
public static final String EXTRA_SELECTED_TITLE = "SelectedTitle"; public static final String EXTRA_SELECTED_TITLE = "SelectedTitle";
public static final String EXTRA_PLATFORM = "Platform"; public static final String EXTRA_PLATFORM = "Platform";
public static final String EXTRA_SCREEN_PATH = "ScreenPath";
public static final String EXTRA_GRID_POSITION = "GridPosition";
@Retention(SOURCE) @Retention(SOURCE)
@IntDef({MENU_ACTION_EDIT_CONTROLS_PLACEMENT, MENU_ACTION_TOGGLE_CONTROLS, MENU_ACTION_ADJUST_SCALE, @IntDef({MENU_ACTION_EDIT_CONTROLS_PLACEMENT, MENU_ACTION_TOGGLE_CONTROLS, MENU_ACTION_ADJUST_SCALE,
@ -178,28 +165,15 @@ public final class EmulationActivity extends AppCompatActivity
.append(R.id.menu_emulation_reset_overlay, EmulationActivity.MENU_ACTION_RESET_OVERLAY); .append(R.id.menu_emulation_reset_overlay, EmulationActivity.MENU_ACTION_RESET_OVERLAY);
} }
public static void launch(FragmentActivity activity, GameFile gameFile, int position, public static void launch(FragmentActivity activity, GameFile gameFile)
View sharedView)
{ {
Intent launcher = new Intent(activity, EmulationActivity.class); Intent launcher = new Intent(activity, EmulationActivity.class);
launcher.putExtra(EXTRA_SELECTED_GAME, gameFile.getPath()); launcher.putExtra(EXTRA_SELECTED_GAME, gameFile.getPath());
launcher.putExtra(EXTRA_SELECTED_TITLE, gameFile.getTitle()); launcher.putExtra(EXTRA_SELECTED_TITLE, gameFile.getTitle());
launcher.putExtra(EXTRA_PLATFORM, gameFile.getPlatform()); launcher.putExtra(EXTRA_PLATFORM, gameFile.getPlatform());
launcher.putExtra(EXTRA_SCREEN_PATH, gameFile.getScreenshotPath());
launcher.putExtra(EXTRA_GRID_POSITION, position);
Bundle options = new Bundle(); Bundle options = new Bundle();
// Will be null if launched from homescreen
if (sharedView != null)
{
ActivityOptionsCompat transition = ActivityOptionsCompat.makeSceneTransitionAnimation(
activity,
sharedView,
"image_game_screenshot");
options = transition.toBundle();
}
// I believe this warning is a bug. Activities are FragmentActivity from the support lib // I believe this warning is a bug. Activities are FragmentActivity from the support lib
//noinspection RestrictedApi //noinspection RestrictedApi
activity.startActivityForResult(launcher, MainPresenter.REQUEST_EMULATE_GAME, options); activity.startActivityForResult(launcher, MainPresenter.REQUEST_EMULATE_GAME, options);
@ -217,8 +191,6 @@ public final class EmulationActivity extends AppCompatActivity
mPath = gameToEmulate.getStringExtra(EXTRA_SELECTED_GAME); mPath = gameToEmulate.getStringExtra(EXTRA_SELECTED_GAME);
mSelectedTitle = gameToEmulate.getStringExtra(EXTRA_SELECTED_TITLE); mSelectedTitle = gameToEmulate.getStringExtra(EXTRA_SELECTED_TITLE);
mPlatform = gameToEmulate.getIntExtra(EXTRA_PLATFORM, 0); mPlatform = gameToEmulate.getIntExtra(EXTRA_PLATFORM, 0);
mScreenPath = gameToEmulate.getStringExtra(EXTRA_SCREEN_PATH);
mPosition = gameToEmulate.getIntExtra(EXTRA_GRID_POSITION, -1);
activityRecreated = false; activityRecreated = false;
} }
else else
@ -280,8 +252,6 @@ public final class EmulationActivity extends AppCompatActivity
setContentView(R.layout.activity_emulation); setContentView(R.layout.activity_emulation);
mImageView = (ImageView) findViewById(R.id.image_screenshot);
// Find or create the EmulationFragment // Find or create the EmulationFragment
mEmulationFragment = (EmulationFragment) getSupportFragmentManager() mEmulationFragment = (EmulationFragment) getSupportFragmentManager()
.findFragmentById(R.id.frame_emulation_fragment); .findFragmentById(R.id.frame_emulation_fragment);
@ -293,41 +263,6 @@ public final class EmulationActivity extends AppCompatActivity
.commit(); .commit();
} }
if (savedInstanceState == null)
{
// Picasso will take a while to load these big-ass screenshots. So don't run
// the animation until we say so.
postponeEnterTransition();
Picasso.with(this)
.load(mScreenPath)
.noFade()
.noPlaceholder()
.into(mImageView, new Callback()
{
@Override
public void onSuccess()
{
supportStartPostponedEnterTransition();
}
@Override
public void onError()
{
// Still have to do this, or else the app will crash.
supportStartPostponedEnterTransition();
}
});
Animations.fadeViewOut(mImageView)
.setStartDelay(2000)
.withEndAction(() -> mImageView.setVisibility(View.GONE));
}
else
{
mImageView.setVisibility(View.GONE);
}
if (mDeviceHasTouchScreen) if (mDeviceHasTouchScreen)
{ {
setTitle(mSelectedTitle); setTitle(mSelectedTitle);
@ -347,8 +282,6 @@ public final class EmulationActivity extends AppCompatActivity
outState.putString(EXTRA_SELECTED_GAME, mPath); outState.putString(EXTRA_SELECTED_GAME, mPath);
outState.putString(EXTRA_SELECTED_TITLE, mSelectedTitle); outState.putString(EXTRA_SELECTED_TITLE, mSelectedTitle);
outState.putInt(EXTRA_PLATFORM, mPlatform); outState.putInt(EXTRA_PLATFORM, mPlatform);
outState.putString(EXTRA_SCREEN_PATH, mScreenPath);
outState.putInt(EXTRA_GRID_POSITION, mPosition);
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
} }
@ -357,8 +290,6 @@ public final class EmulationActivity extends AppCompatActivity
mPath = savedInstanceState.getString(EXTRA_SELECTED_GAME); mPath = savedInstanceState.getString(EXTRA_SELECTED_GAME);
mSelectedTitle = savedInstanceState.getString(EXTRA_SELECTED_TITLE); mSelectedTitle = savedInstanceState.getString(EXTRA_SELECTED_TITLE);
mPlatform = savedInstanceState.getInt(EXTRA_PLATFORM); mPlatform = savedInstanceState.getInt(EXTRA_PLATFORM);
mScreenPath = savedInstanceState.getString(EXTRA_SCREEN_PATH);
mPosition = savedInstanceState.getInt(EXTRA_GRID_POSITION);
} }
@Override @Override
@ -378,7 +309,7 @@ public final class EmulationActivity extends AppCompatActivity
if (backPressedOnce) if (backPressedOnce)
{ {
mEmulationFragment.stopEmulation(); mEmulationFragment.stopEmulation();
exitWithAnimation(); finish();
} }
else else
{ {
@ -443,50 +374,6 @@ public final class EmulationActivity extends AppCompatActivity
} }
} }
public void exitWithAnimation()
{
runOnUiThread(() ->
{
Picasso.with(EmulationActivity.this)
.invalidate(mScreenPath);
Picasso.with(EmulationActivity.this)
.load(mScreenPath)
.noFade()
.noPlaceholder()
.into(mImageView, new Callback()
{
@Override
public void onSuccess()
{
showScreenshot();
}
@Override
public void onError()
{
finish();
}
});
});
}
private void showScreenshot()
{
Animations.fadeViewIn(mImageView)
.withEndAction(afterShowingScreenshot);
}
private Runnable afterShowingScreenshot = new Runnable()
{
@Override
public void run()
{
setResult(mPosition);
supportFinishAfterTransition();
}
};
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) public boolean onCreateOptionsMenu(Menu menu)
{ {
@ -676,7 +563,6 @@ public final class EmulationActivity extends AppCompatActivity
if (TvUtil.isLeanback(getApplicationContext())) if (TvUtil.isLeanback(getApplicationContext()))
toggleMenu(); // Hide the menu (it will be showing since we just clicked it) toggleMenu(); // Hide the menu (it will be showing since we just clicked it)
mEmulationFragment.stopEmulation(); mEmulationFragment.stopEmulation();
exitWithAnimation();
return; return;
} }
} }

View File

@ -121,10 +121,7 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
{ {
GameViewHolder holder = (GameViewHolder) view.getTag(); GameViewHolder holder = (GameViewHolder) view.getTag();
EmulationActivity.launch((FragmentActivity) view.getContext(), EmulationActivity.launch((FragmentActivity) view.getContext(), holder.gameFile);
holder.gameFile,
holder.getAdapterPosition(),
holder.imageScreenshot);
} }
/** /**

View File

@ -63,7 +63,7 @@ public final class GameDetailsDialog extends DialogFragment
buttonLaunch.setOnClickListener(view -> buttonLaunch.setOnClickListener(view ->
{ {
// Start the emulation activity and send the path of the clicked ROM to it. // Start the emulation activity and send the path of the clicked ROM to it.
EmulationActivity.launch(getActivity(), gameFile, -1, imageGameScreen); EmulationActivity.launch(getActivity(), gameFile);
}); });
// Fill in the view contents. // Fill in the view contents.

View File

@ -116,10 +116,7 @@ public final class TvMainActivity extends FragmentActivity implements MainView
TvGameViewHolder holder = (TvGameViewHolder) itemViewHolder; TvGameViewHolder holder = (TvGameViewHolder) itemViewHolder;
// Start the emulation activity and send the path of the clicked ISO to it. // Start the emulation activity and send the path of the clicked ISO to it.
EmulationActivity.launch(TvMainActivity.this, EmulationActivity.launch(TvMainActivity.this, holder.gameFile);
holder.gameFile,
-1,
holder.imageScreenshot);
} }
}); });
} }

View File

@ -14,13 +14,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"/> android:layout_height="match_parent"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/image_screenshot"
android:transitionName="image_game_screenshot"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"

View File

@ -8,10 +8,4 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"/> android:layout_height="match_parent"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/image_screenshot"
android:transitionName="image_game_screenshot"/>
</FrameLayout> </FrameLayout>

View File

@ -278,7 +278,6 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_StopEmulatio
jobject obj) jobject obj)
{ {
std::lock_guard<std::mutex> guard(s_host_identity_lock); std::lock_guard<std::mutex> guard(s_host_identity_lock);
Core::SaveScreenShot("thumb", true);
Core::Stop(); Core::Stop();
s_update_main_frame_event.Set(); // Kick the waiting event s_update_main_frame_event.Set(); // Kick the waiting event
} }