Android: Save screenshot at end of an emulation session.

This commit is contained in:
sigmabeta
2015-06-18 21:28:40 -04:00
committed by Eder Bastos
parent 2cea910431
commit a028805626
11 changed files with 62 additions and 17 deletions

View File

@ -274,6 +274,12 @@ public final class NativeLibrary
});
}
public static void endEmulationActivity()
{
Log.v("DolphinEmu", "Ending EmulationActivity.");
mEmulationActivity.finish();
}
public static void setEmulationActivity(EmulationActivity emulationActivity)
{
Log.v("DolphinEmu", "Registering EmulationActivity.");

View File

@ -150,7 +150,11 @@ public final class EmulationActivity extends AppCompatActivity
else
{
// Let the system handle it; i.e. quit the activity TODO or show "are you sure?" dialog.
super.onBackPressed();
EmulationFragment fragment = (EmulationFragment) getFragmentManager()
.findFragmentByTag(EmulationFragment.FRAGMENT_TAG);
fragment.notifyEmulationStopped();
NativeLibrary.StopEmulation();
}
}

View File

@ -127,6 +127,13 @@ public final class MainActivity extends AppCompatActivity implements LoaderManag
}
}
@Override
protected void onResume()
{
super.onResume();
mAdapter.notifyDataSetChanged();
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{

View File

@ -119,7 +119,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
public void onDestroyView()
{
super.onDestroyView();
if (getActivity().isFinishing())
if (getActivity().isFinishing() && mEmulationStarted)
{
NativeLibrary.StopEmulation();
}
@ -195,6 +195,16 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
mEmulationRunning = false;
}
/**
* Called by containing activity to tell the Fragment emulation is already stopping,
* so it doesn't try to stop emulation on its way to the garbage collector.
*/
public void notifyEmulationStopped()
{
mEmulationStarted = false;
mEmulationRunning = false;
}
private Runnable mEmulationRunner = new Runnable()
{
@Override

View File

@ -113,21 +113,7 @@ public final class Game
{
ContentValues values = new ContentValues();
// TODO Come up with a way of finding the most recent screenshot that doesn't involve counting files
String screenshotFolderPath = PATH_SCREENSHOT_FOLDER + gameId + "/";
// Count how many screenshots are available, so we can use the most recent one.
File screenshotFolder = new File(screenshotFolderPath.substring(screenshotFolderPath.indexOf('s') - 1));
int screenCount = 0;
if (screenshotFolder.isDirectory())
{
screenCount = screenshotFolder.list().length;
}
String screenPath = screenshotFolderPath
+ gameId + "-"
+ screenCount + ".png";
String screenPath = PATH_SCREENSHOT_FOLDER + gameId + "/thumb.png";
values.put(GameDatabase.KEY_GAME_PLATFORM, platform);
values.put(GameDatabase.KEY_GAME_TITLE, title);