Merge pull request #3493 from sigmabeta/android-tv-screenshot-bugfix

[Android] Minor refactor + bugfix
This commit is contained in:
Ryan Houdek 2016-01-11 16:04:56 -05:00
commit bd31b1411b
6 changed files with 47 additions and 45 deletions

View File

@ -39,7 +39,7 @@
</activity> </activity>
<activity <activity
android:name=".activities.TvMainActivity" android:name=".ui.main.TvMainActivity"
android:theme="@style/DolphinTvGamecube"> android:theme="@style/DolphinTvGamecube">
<!-- This intentfilter marks this Activity as the one that gets launched from Home screen. --> <!-- This intentfilter marks this Activity as the one that gets launched from Home screen. -->

View File

@ -1,5 +1,7 @@
package org.dolphinemu.dolphinemu.activities; package org.dolphinemu.dolphinemu.activities;
import android.app.Activity;
import android.app.ActivityOptions;
import android.app.Fragment; import android.app.Fragment;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; 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.LoadStateFragment;
import org.dolphinemu.dolphinemu.fragments.MenuFragment; import org.dolphinemu.dolphinemu.fragments.MenuFragment;
import org.dolphinemu.dolphinemu.fragments.SaveStateFragment; import org.dolphinemu.dolphinemu.fragments.SaveStateFragment;
import org.dolphinemu.dolphinemu.ui.main.MainPresenter;
import java.util.List; import java.util.List;
@ -662,4 +665,21 @@ public final class EmulationActivity extends AppCompatActivity
{ {
return mSelectedTitle; 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());
}
} }

View File

@ -1,8 +1,6 @@
package org.dolphinemu.dolphinemu.adapters; package org.dolphinemu.dolphinemu.adapters;
import android.app.Activity; import android.app.Activity;
import android.app.ActivityOptions;
import android.content.Intent;
import android.database.Cursor; import android.database.Cursor;
import android.database.DataSetObserver; import android.database.DataSetObserver;
import android.graphics.Bitmap; import android.graphics.Bitmap;
@ -19,7 +17,6 @@ import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.activities.EmulationActivity; import org.dolphinemu.dolphinemu.activities.EmulationActivity;
import org.dolphinemu.dolphinemu.dialogs.GameDetailsDialog; import org.dolphinemu.dolphinemu.dialogs.GameDetailsDialog;
import org.dolphinemu.dolphinemu.model.GameDatabase; import org.dolphinemu.dolphinemu.model.GameDatabase;
import org.dolphinemu.dolphinemu.ui.main.MainPresenter;
import org.dolphinemu.dolphinemu.viewholders.GameViewHolder; import org.dolphinemu.dolphinemu.viewholders.GameViewHolder;
/** /**
@ -217,22 +214,12 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
{ {
GameViewHolder holder = (GameViewHolder) view.getTag(); GameViewHolder holder = (GameViewHolder) view.getTag();
// Start the emulation activity and send the path of the clicked ISO to it. EmulationActivity.launch((Activity) view.getContext(),
Intent intent = new Intent(view.getContext(), EmulationActivity.class); holder.path,
holder.title,
intent.putExtra("SelectedGame", holder.path); holder.screenshotPath,
intent.putExtra("SelectedTitle", holder.title); holder.getAdapterPosition(),
intent.putExtra("ScreenPath", holder.screenshotPath); holder.imageScreenshot);
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());
} }
/** /**

View File

@ -14,7 +14,7 @@ import org.dolphinemu.dolphinemu.viewholders.TvGameViewHolder;
/** /**
* The Leanback library / docs call this a Presenter, but it works very * 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 public final class GameRowPresenter extends Presenter
{ {

View File

@ -4,7 +4,6 @@ package org.dolphinemu.dolphinemu.dialogs;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.app.DialogFragment; import android.app.DialogFragment;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.view.View; import android.view.View;
@ -70,18 +69,19 @@ public final class GameDetailsDialog extends DialogFragment
textDescription.setText(getArguments().getString(ARGUMENT_GAME_DESCRIPTION)); textDescription.setText(getArguments().getString(ARGUMENT_GAME_DESCRIPTION));
textCountry.setText(country); textCountry.setText(country);
textDate.setText(getArguments().getString(ARGUMENT_GAME_DATE)); textDate.setText(getArguments().getString(ARGUMENT_GAME_DATE));
buttonLaunch.setOnClickListener(new View.OnClickListener() buttonLaunch.setOnClickListener(new View.OnClickListener()
{ {
@Override @Override
public void onClick(View view) public void onClick(View 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.
Intent intent = new Intent(view.getContext(), EmulationActivity.class); EmulationActivity.launch(getActivity(),
getArguments().getString(ARGUMENT_GAME_PATH),
intent.putExtra("SelectedGame", getArguments().getString(ARGUMENT_GAME_PATH)); getArguments().getString(ARGUMENT_GAME_TITLE),
intent.putExtra("SelectedTitle", getArguments().getString(ARGUMENT_GAME_TITLE)); getArguments().getString(ARGUMENT_GAME_SCREENSHOT_PATH),
-1,
startActivity(intent); imageGameScreen);
} }
}); });

View File

@ -1,7 +1,6 @@
package org.dolphinemu.dolphinemu.activities; package org.dolphinemu.dolphinemu.ui.main;
import android.app.Activity; import android.app.Activity;
import android.app.ActivityOptions;
import android.app.FragmentManager; import android.app.FragmentManager;
import android.content.Intent; import android.content.Intent;
import android.database.Cursor; import android.database.Cursor;
@ -19,12 +18,13 @@ import android.support.v17.leanback.widget.Row;
import android.support.v17.leanback.widget.RowPresenter; import android.support.v17.leanback.widget.RowPresenter;
import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.activities.AddDirectoryActivity;
import org.dolphinemu.dolphinemu.activities.EmulationActivity;
import org.dolphinemu.dolphinemu.activities.SettingsActivity;
import org.dolphinemu.dolphinemu.adapters.GameRowPresenter; import org.dolphinemu.dolphinemu.adapters.GameRowPresenter;
import org.dolphinemu.dolphinemu.adapters.SettingsRowPresenter; import org.dolphinemu.dolphinemu.adapters.SettingsRowPresenter;
import org.dolphinemu.dolphinemu.model.Game; import org.dolphinemu.dolphinemu.model.Game;
import org.dolphinemu.dolphinemu.model.TvSettingsItem; import org.dolphinemu.dolphinemu.model.TvSettingsItem;
import org.dolphinemu.dolphinemu.ui.main.MainPresenter;
import org.dolphinemu.dolphinemu.ui.main.MainView;
import org.dolphinemu.dolphinemu.utils.StartupHandler; import org.dolphinemu.dolphinemu.utils.StartupHandler;
import org.dolphinemu.dolphinemu.viewholders.TvGameViewHolder; import org.dolphinemu.dolphinemu.viewholders.TvGameViewHolder;
@ -72,19 +72,14 @@ public final class TvMainActivity extends Activity implements MainView
else else
{ {
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.
Intent intent = new Intent(TvMainActivity.this, EmulationActivity.class); EmulationActivity.launch(TvMainActivity.this,
holder.path,
intent.putExtra("SelectedGame", holder.path); holder.title,
intent.putExtra("SelectedTitle", holder.title); holder.screenshotPath,
intent.putExtra("ScreenPath", holder.screenshotPath); -1,
holder.imageScreenshot);
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(
TvMainActivity.this,
holder.imageScreenshot,
"image_game_screenshot");
startActivity(intent, options.toBundle());
} }
} }
}); });
@ -113,7 +108,7 @@ public final class TvMainActivity extends Activity implements MainView
@Override @Override
public void refreshFragmentScreenshot(int fragmentPosition) public void refreshFragmentScreenshot(int fragmentPosition)
{ {
// No-op (For now) mRowsAdapter.notifyArrayItemRangeChanged(0, mRowsAdapter.size());
} }
@Override @Override