mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 10: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:
@@ -71,14 +71,20 @@ public class Forge implements ApplicationListener {
|
||||
public static boolean hdstart = false;
|
||||
public static boolean isPortraitMode = false;
|
||||
public static boolean gameInProgress = false;
|
||||
public static int cacheSize = 400;
|
||||
public static int totalDeviceRAM = 0;
|
||||
|
||||
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean value, boolean androidOrientation) {
|
||||
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean value, boolean androidOrientation, int totalRAM) {
|
||||
if (GuiBase.getInterface() == null) {
|
||||
clipboard = clipboard0;
|
||||
deviceAdapter = deviceAdapter0;
|
||||
GuiBase.setInterface(new GuiMobile(assetDir0));
|
||||
GuiBase.enablePropertyConfig(value);
|
||||
isPortraitMode = androidOrientation;
|
||||
totalDeviceRAM = totalRAM;
|
||||
//increase cacheSize for devices with RAM more than 5GB, default is 400. Some phones have more than 10GB RAM (Mi 10, OnePlus 8, S20, etc..)
|
||||
if (totalDeviceRAM>5000) //devices with more than 10GB RAM will have 1000 Cache size, 700 Cache size for morethan 5GB RAM
|
||||
cacheSize = totalDeviceRAM>10000 ? 1000: 700;
|
||||
}
|
||||
return app;
|
||||
}
|
||||
@@ -142,8 +148,12 @@ public class Forge implements ApplicationListener {
|
||||
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblFinishingStartup"));
|
||||
|
||||
//add reminder to preload
|
||||
if (enablePreloadExtendedArt)
|
||||
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblPreloadExtendedArt"));
|
||||
if (enablePreloadExtendedArt) {
|
||||
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblPreloadExtendedArt")+"\nDetected RAM: " +totalDeviceRAM+"MB. Cache size: "+cacheSize);
|
||||
} else {
|
||||
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblFinishingStartup")+"\nDetected RAM: " +totalDeviceRAM+"MB. Cache size: "+cacheSize);
|
||||
}
|
||||
|
||||
Gdx.app.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -69,7 +69,7 @@ public class ImageCache {
|
||||
|
||||
private static final Set<String> missingIconKeys = new HashSet<>();
|
||||
private static final LoadingCache<String, Texture> cache = CacheBuilder.newBuilder()
|
||||
.maximumSize(400)
|
||||
.maximumSize(Forge.cacheSize)
|
||||
.expireAfterAccess(15, TimeUnit.MINUTES)
|
||||
.removalListener(new RemovalListener<String, Texture>() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user