mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
[Android] Increase default cache size
-Increase the default cache size depending on the device detected RAM (higher end tablets and phones will have greater benefit for having large RAM).
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package forge.app;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.PendingIntent;
|
||||
@@ -56,9 +57,15 @@ public class Main extends AndroidApplication {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
//get total device RAM in mb
|
||||
ActivityManager actManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
|
||||
ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
|
||||
actManager.getMemoryInfo(memInfo);
|
||||
int totalMemory = Math.round(memInfo.totalMem / 1024f / 1024f);
|
||||
|
||||
boolean permissiongranted = checkPermission();
|
||||
Gadapter = new AndroidAdapter(this.getContext());
|
||||
initForge(Gadapter, permissiongranted);
|
||||
initForge(Gadapter, permissiongranted, totalMemory);
|
||||
|
||||
//permission
|
||||
if(!permissiongranted){
|
||||
@@ -185,7 +192,7 @@ public class Main extends AndroidApplication {
|
||||
builder.show();
|
||||
}
|
||||
|
||||
private void initForge(AndroidAdapter adapter, boolean permissiongranted){
|
||||
private void initForge(AndroidAdapter adapter, boolean permissiongranted, int totalRAM){
|
||||
boolean isPortrait;
|
||||
if (permissiongranted){
|
||||
//establish assets directory
|
||||
@@ -225,12 +232,12 @@ public class Main extends AndroidApplication {
|
||||
Main.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
}
|
||||
|
||||
initialize(Forge.getApp(new AndroidClipboard(), adapter, assetsDir, propertyConfig, isPortrait));
|
||||
initialize(Forge.getApp(new AndroidClipboard(), adapter, assetsDir, propertyConfig, isPortrait, totalRAM));
|
||||
} else {
|
||||
isPortrait = true;
|
||||
//set current orientation
|
||||
Main.this.setRequestedOrientation(Main.this.getResources().getConfiguration().orientation);
|
||||
initialize(Forge.getApp(new AndroidClipboard(), adapter, "", false, isPortrait));
|
||||
initialize(Forge.getApp(new AndroidClipboard(), adapter, "", false, isPortrait, totalRAM));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user