Android: Run AssetCopyService only once.
This commit is contained in:
parent
cf7178b4c2
commit
36d051d3f9
|
@ -5,8 +5,10 @@ import android.app.LoaderManager;
|
||||||
import android.content.CursorLoader;
|
import android.content.CursorLoader;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.Loader;
|
import android.content.Loader;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v7.widget.GridLayoutManager;
|
import android.support.v7.widget.GridLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -78,12 +80,19 @@ 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)
|
// Stuff in this block only happens when this activity is newly created (i.e. not a rotation)
|
||||||
if (savedInstanceState == null)
|
if (savedInstanceState == null)
|
||||||
|
{
|
||||||
|
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.
|
// Copy assets into appropriate locations.
|
||||||
Intent copyAssets = new Intent(this, AssetCopyService.class);
|
Intent copyAssets = new Intent(this, AssetCopyService.class);
|
||||||
startService(copyAssets);
|
startService(copyAssets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback from AddDirectoryActivity. Applies any changes necessary to the GameGridActivity.
|
* Callback from AddDirectoryActivity. Applies any changes necessary to the GameGridActivity.
|
||||||
|
|
|
@ -8,6 +8,8 @@ package org.dolphinemu.dolphinemu.services;
|
||||||
|
|
||||||
import android.app.IntentService;
|
import android.app.IntentService;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.dolphinemu.dolphinemu.NativeLibrary;
|
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
|
// Load the configuration keys set in the Dolphin ini and gfx ini files
|
||||||
// into the application's shared preferences.
|
// into the application's shared preferences.
|
||||||
UserPreferences.LoadIniToPrefs(this);
|
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)
|
private void copyAsset(String asset, String output)
|
||||||
|
|
Loading…
Reference in New Issue