From 36d051d3f9373379b03969663b9f1bf2bbbf6b3a Mon Sep 17 00:00:00 2001 From: sigmabeta Date: Sun, 7 Jun 2015 20:42:30 -0400 Subject: [PATCH] Android: Run AssetCopyService only once. --- .../dolphinemu/activities/GameGridActivity.java | 15 ++++++++++++--- .../dolphinemu/services/AssetCopyService.java | 9 +++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/GameGridActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/GameGridActivity.java index 619e9c647e..1c838ad18d 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/GameGridActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/GameGridActivity.java @@ -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); + } } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/AssetCopyService.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/AssetCopyService.java index ac39b0da0c..6c3f4fd643 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/AssetCopyService.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/AssetCopyService.java @@ -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)