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 04b5149a0e..1f16e39592 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 @@ -1,5 +1,7 @@ package org.dolphinemu.dolphinemu.activities; +import android.app.Activity; +import android.app.ActivityOptions; import android.app.Fragment; import android.content.Intent; import android.os.Bundle; @@ -30,6 +32,7 @@ import org.dolphinemu.dolphinemu.fragments.EmulationFragment; import org.dolphinemu.dolphinemu.fragments.LoadStateFragment; import org.dolphinemu.dolphinemu.fragments.MenuFragment; import org.dolphinemu.dolphinemu.fragments.SaveStateFragment; +import org.dolphinemu.dolphinemu.ui.main.MainPresenter; import java.util.List; @@ -659,4 +662,21 @@ public final class EmulationActivity extends AppCompatActivity { return mSelectedTitle; } + + public static void launch(Activity activity, String path, String title, String screenshotPath, int position, View sharedView) + { + Intent launcher = new Intent(activity, EmulationActivity.class); + + launcher.putExtra("SelectedGame", path); + launcher.putExtra("SelectedTitle", title); + launcher.putExtra("ScreenPath", screenshotPath); + launcher.putExtra("GridPosition", position); + + ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation( + activity, + sharedView, + "image_game_screenshot"); + + activity.startActivityForResult(launcher, MainPresenter.REQUEST_EMULATE_GAME, options.toBundle()); + } } 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 205447e054..fd8784f81c 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,8 +1,6 @@ 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; import android.graphics.Bitmap; @@ -19,7 +17,6 @@ import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.activities.EmulationActivity; import org.dolphinemu.dolphinemu.dialogs.GameDetailsDialog; import org.dolphinemu.dolphinemu.model.GameDatabase; -import org.dolphinemu.dolphinemu.ui.main.MainPresenter; import org.dolphinemu.dolphinemu.viewholders.GameViewHolder; /** @@ -217,22 +214,12 @@ public final class GameAdapter extends RecyclerView.Adapter impl { GameViewHolder holder = (GameViewHolder) view.getTag(); - // Start the emulation activity and send the path of the clicked ISO to it. - Intent intent = new Intent(view.getContext(), EmulationActivity.class); - - intent.putExtra("SelectedGame", holder.path); - intent.putExtra("SelectedTitle", holder.title); - intent.putExtra("ScreenPath", holder.screenshotPath); - intent.putExtra("GridPosition", holder.getAdapterPosition()); - - ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation( - (Activity) view.getContext(), - holder.imageScreenshot, - "image_game_screenshot"); - - ((Activity) view.getContext()).startActivityForResult(intent, - MainPresenter.REQUEST_EMULATE_GAME, - options.toBundle()); + EmulationActivity.launch((Activity) view.getContext(), + holder.path, + holder.title, + holder.screenshotPath, + holder.getAdapterPosition(), + holder.imageScreenshot); } /** diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameRowPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameRowPresenter.java index 3b0b8095ce..40228ac19c 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameRowPresenter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameRowPresenter.java @@ -14,7 +14,7 @@ import org.dolphinemu.dolphinemu.viewholders.TvGameViewHolder; /** * The Leanback library / docs call this a Presenter, but it works very - * similarly to a RecyclerView.ViewHolder. + * similarly to a RecyclerView.Adapter. */ public final class GameRowPresenter extends Presenter { diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java index ac193c9fb1..714db42e9f 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java @@ -4,7 +4,6 @@ package org.dolphinemu.dolphinemu.dialogs; import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; -import android.content.Intent; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.view.View; @@ -70,18 +69,19 @@ public final class GameDetailsDialog extends DialogFragment textDescription.setText(getArguments().getString(ARGUMENT_GAME_DESCRIPTION)); textCountry.setText(country); textDate.setText(getArguments().getString(ARGUMENT_GAME_DATE)); + buttonLaunch.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Start the emulation activity and send the path of the clicked ROM to it. - Intent intent = new Intent(view.getContext(), EmulationActivity.class); - - intent.putExtra("SelectedGame", getArguments().getString(ARGUMENT_GAME_PATH)); - intent.putExtra("SelectedTitle", getArguments().getString(ARGUMENT_GAME_TITLE)); - - startActivity(intent); + EmulationActivity.launch(getActivity(), + getArguments().getString(ARGUMENT_GAME_PATH), + getArguments().getString(ARGUMENT_GAME_TITLE), + getArguments().getString(ARGUMENT_GAME_SCREENSHOT_PATH), + -1, + imageGameScreen); } }); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/TvMainActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/TvMainActivity.java index 27ccfa2f9d..543c3ddacd 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/TvMainActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/TvMainActivity.java @@ -1,7 +1,6 @@ package org.dolphinemu.dolphinemu.ui.main; import android.app.Activity; -import android.app.ActivityOptions; import android.app.FragmentManager; import android.content.Intent; import android.database.Cursor; @@ -73,19 +72,14 @@ public final class TvMainActivity extends Activity implements MainView else { TvGameViewHolder holder = (TvGameViewHolder) itemViewHolder; + // Start the emulation activity and send the path of the clicked ISO to it. - Intent intent = new Intent(TvMainActivity.this, EmulationActivity.class); - - intent.putExtra("SelectedGame", holder.path); - intent.putExtra("SelectedTitle", holder.title); - intent.putExtra("ScreenPath", holder.screenshotPath); - - ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation( - TvMainActivity.this, - holder.imageScreenshot, - "image_game_screenshot"); - - startActivity(intent, options.toBundle()); + EmulationActivity.launch(TvMainActivity.this, + holder.path, + holder.title, + holder.screenshotPath, + -1, + holder.imageScreenshot); } } });