Android: Run AssetCopyService only once.

This commit is contained in:
sigmabeta 2015-06-07 20:42:30 -04:00
parent cf7178b4c2
commit 36d051d3f9
2 changed files with 21 additions and 3 deletions

View File

@ -5,8 +5,10 @@ import android.app.LoaderManager;
import android.content.CursorLoader;
import android.content.Intent;
import android.content.Loader;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
@ -79,9 +81,16 @@ public final class GameGridActivity extends Activity implements LoaderManager.Lo
// Stuff in this block only happens when this activity is newly created (i.e. not a rotation)
if (savedInstanceState == null)
{
// Copy assets into appropriate locations.
Intent copyAssets = new Intent(this, AssetCopyService.class);
startService(copyAssets);
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
boolean assetsCopied = preferences.getBoolean("assetsCopied", false);
// Only perform these extensive copy operations once.
if (!assetsCopied)
{
// Copy assets into appropriate locations.
Intent copyAssets = new Intent(this, AssetCopyService.class);
startService(copyAssets);
}
}
}

View File

@ -8,6 +8,8 @@ package org.dolphinemu.dolphinemu.services;
import android.app.IntentService;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;
import org.dolphinemu.dolphinemu.NativeLibrary;
@ -63,6 +65,13 @@ public final class AssetCopyService extends IntentService
// Load the configuration keys set in the Dolphin ini and gfx ini files
// into the application's shared preferences.
UserPreferences.LoadIniToPrefs(this);
// Record the fact that we've done this before, so we don't do it on every launch.
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("assetsCopied", true);
editor.commit();
}
private void copyAsset(String asset, String output)