Skip to content

Commit

Permalink
android: remove enter and exit transition
Browse files Browse the repository at this point in the history
  • Loading branch information
weihuoya committed Oct 27, 2018
1 parent 61821b0 commit 1e3a297
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,6 @@ private void startGame(GameFile game)
LocalBroadcastManager.getInstance(this).unregisterReceiver(directoryStateReceiver);
directoryStateReceiver = null;
}
EmulationActivity.launch(this, game, -1, null);
EmulationActivity.launch(this, game);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import android.os.Handler;
import android.preference.PreferenceManager;
import android.support.annotation.IntDef;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
Expand All @@ -25,14 +24,10 @@
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;

import com.squareup.picasso.Callback;
import com.squareup.picasso.Picasso;

import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
Expand All @@ -45,7 +40,6 @@
import org.dolphinemu.dolphinemu.ui.main.MainActivity;
import org.dolphinemu.dolphinemu.ui.main.MainPresenter;
import org.dolphinemu.dolphinemu.ui.platform.Platform;
import org.dolphinemu.dolphinemu.utils.Animations;
import org.dolphinemu.dolphinemu.utils.ControllerMappingHelper;
import org.dolphinemu.dolphinemu.utils.FileBrowserHelper;
import org.dolphinemu.dolphinemu.utils.Java_GCAdapter;
Expand All @@ -64,24 +58,19 @@ public final class EmulationActivity extends AppCompatActivity
public static final int REQUEST_CHANGE_DISC = 1;

private View mDecorView;
private ImageView mImageView;
private EmulationFragment mEmulationFragment;

private SharedPreferences mPreferences;
private ControllerMappingHelper mControllerMappingHelper;

private Settings mSettings;

// So that MainActivity knows which view to invalidate before the return animation.
private int mPosition;

private boolean mDeviceHasTouchScreen;
private boolean mMenuVisible;

private static boolean sIsGameCubeGame;

private boolean activityRecreated;
private String mScreenPath;
private String mSelectedTitle;
private int mPlatform;
private String mPath;
Expand All @@ -90,8 +79,6 @@ public final class EmulationActivity extends AppCompatActivity
public static final String EXTRA_SELECTED_GAME = "SelectedGame";
public static final String EXTRA_SELECTED_TITLE = "SelectedTitle";
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)
@IntDef({MENU_ACTION_EDIT_CONTROLS_PLACEMENT, MENU_ACTION_TOGGLE_CONTROLS, MENU_ACTION_ADJUST_SCALE,
Expand Down Expand Up @@ -178,28 +165,15 @@ public final class EmulationActivity extends AppCompatActivity
.append(R.id.menu_emulation_reset_overlay, EmulationActivity.MENU_ACTION_RESET_OVERLAY);
}

public static void launch(FragmentActivity activity, GameFile gameFile, int position,
View sharedView)
public static void launch(FragmentActivity activity, GameFile gameFile)
{
Intent launcher = new Intent(activity, EmulationActivity.class);

launcher.putExtra(EXTRA_SELECTED_GAME, gameFile.getPath());
launcher.putExtra(EXTRA_SELECTED_TITLE, gameFile.getTitle());
launcher.putExtra(EXTRA_PLATFORM, gameFile.getPlatform());
launcher.putExtra(EXTRA_SCREEN_PATH, gameFile.getScreenshotPath());
launcher.putExtra(EXTRA_GRID_POSITION, position);
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
//noinspection RestrictedApi
activity.startActivityForResult(launcher, MainPresenter.REQUEST_EMULATE_GAME, options);
Expand All @@ -217,8 +191,6 @@ protected void onCreate(Bundle savedInstanceState)
mPath = gameToEmulate.getStringExtra(EXTRA_SELECTED_GAME);
mSelectedTitle = gameToEmulate.getStringExtra(EXTRA_SELECTED_TITLE);
mPlatform = gameToEmulate.getIntExtra(EXTRA_PLATFORM, 0);
mScreenPath = gameToEmulate.getStringExtra(EXTRA_SCREEN_PATH);
mPosition = gameToEmulate.getIntExtra(EXTRA_GRID_POSITION, -1);
activityRecreated = false;
}
else
Expand Down Expand Up @@ -280,8 +252,6 @@ protected void onCreate(Bundle savedInstanceState)

setContentView(R.layout.activity_emulation);

mImageView = (ImageView) findViewById(R.id.image_screenshot);

// Find or create the EmulationFragment
mEmulationFragment = (EmulationFragment) getSupportFragmentManager()
.findFragmentById(R.id.frame_emulation_fragment);
Expand All @@ -293,41 +263,6 @@ protected void onCreate(Bundle savedInstanceState)
.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)
{
setTitle(mSelectedTitle);
Expand All @@ -344,8 +279,6 @@ protected void onSaveInstanceState(Bundle outState)
outState.putString(EXTRA_SELECTED_GAME, mPath);
outState.putString(EXTRA_SELECTED_TITLE, mSelectedTitle);
outState.putInt(EXTRA_PLATFORM, mPlatform);
outState.putString(EXTRA_SCREEN_PATH, mScreenPath);
outState.putInt(EXTRA_GRID_POSITION, mPosition);
super.onSaveInstanceState(outState);
}

Expand All @@ -354,8 +287,6 @@ protected void restoreState(Bundle savedInstanceState)
mPath = savedInstanceState.getString(EXTRA_SELECTED_GAME);
mSelectedTitle = savedInstanceState.getString(EXTRA_SELECTED_TITLE);
mPlatform = savedInstanceState.getInt(EXTRA_PLATFORM);
mScreenPath = savedInstanceState.getString(EXTRA_SCREEN_PATH);
mPosition = savedInstanceState.getInt(EXTRA_GRID_POSITION);
}

@Override
Expand All @@ -375,7 +306,7 @@ public void onBackPressed()
if (backPressedOnce)
{
mEmulationFragment.stopEmulation();
exitWithAnimation();
finish();
}
else
{
Expand Down Expand Up @@ -440,50 +371,6 @@ private void toggleMenu()
}
}

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
public boolean onCreateOptionsMenu(Menu menu)
{
Expand Down Expand Up @@ -673,7 +560,6 @@ public void handleMenuAction(@MenuAction int menuAction)
if (TvUtil.isLeanback(getApplicationContext()))
toggleMenu(); // Hide the menu (it will be showing since we just clicked it)
mEmulationFragment.stopEmulation();
exitWithAnimation();
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,7 @@ public void onClick(View view)
{
GameViewHolder holder = (GameViewHolder) view.getTag();

EmulationActivity.launch((FragmentActivity) view.getContext(),
holder.gameFile,
holder.getAdapterPosition(),
holder.imageScreenshot);
EmulationActivity.launch((FragmentActivity) view.getContext(), holder.gameFile);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState)
buttonLaunch.setOnClickListener(view ->
{
// 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,7 @@ void setupUI()
TvGameViewHolder holder = (TvGameViewHolder) itemViewHolder;

// Start the emulation activity and send the path of the clicked ISO to it.
EmulationActivity.launch(TvMainActivity.this,
holder.gameFile,
-1,
holder.imageScreenshot);
EmulationActivity.launch(TvMainActivity.this, holder.gameFile);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@
android:layout_width="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
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,4 @@
android:layout_width="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>
1 change: 0 additions & 1 deletion Source/Android/jni/MainAndroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_StopEmulatio
jobject obj)
{
std::lock_guard<std::mutex> guard(s_host_identity_lock);
Core::SaveScreenShot("thumb", true);
Core::Stop();
s_update_main_frame_event.Set(); // Kick the waiting event
}
Expand Down

0 comments on commit 1e3a297

Please sign in to comment.