Skip to content

Commit b3e7fba

Browse files
committedMay 22, 2024
Improve CSS Theme
1 parent 9ea60d1 commit b3e7fba

File tree

1 file changed

+10
-8
lines changed
  • app/src/main/java/com/wmods/wppenhacer/xposed/features/customization

1 file changed

+10
-8
lines changed
 

‎app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/CustomView.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.util.ArrayList;
3030
import java.util.Arrays;
3131
import java.util.HashMap;
32+
import java.util.Objects;
3233
import java.util.concurrent.TimeUnit;
3334

3435
import cz.vutbr.web.css.CSSFactory;
@@ -300,34 +301,35 @@ public String getPluginName() {
300301
return "Custom View";
301302
}
302303

303-
public class DrawableCache {
304-
private LoadingCache<String, Drawable> drawableCache;
304+
public static class DrawableCache {
305+
private final LoadingCache<String, Drawable> drawableCache;
305306

306307
public DrawableCache() {
307308
drawableCache = CacheBuilder.newBuilder()
308309
.maximumSize(100)
309310
.expireAfterWrite(30, TimeUnit.MINUTES)
310311
.build(new CacheLoader<>() {
312+
@NonNull
311313
@Override
312-
public Drawable load(String key) throws Exception {
313-
return loadDrawableFromFile(key);
314+
public Drawable load(@NonNull String key) throws Exception {
315+
return Objects.requireNonNull(loadDrawableFromFile(key));
314316
}
315317
});
316318
}
317319

318320
private Drawable loadDrawableFromFile(String filePath) {
319321
File file = new File(filePath);
320-
if (!file.exists()) return null;
322+
if (!file.exists()) return new ColorDrawable(0);
321323
return Drawable.createFromPath(file.getAbsolutePath());
322324
}
323325

324326
public Drawable getDrawable(String key) {
325327
return drawableCache.getUnchecked(key);
326328
}
327329

328-
public void invalidateCache() {
329-
drawableCache.invalidateAll();
330-
}
330+
// public void invalidateCache() {
331+
// drawableCache.invalidateAll();
332+
// }
331333
}
332334

333335
}

0 commit comments

Comments
 (0)
Please sign in to comment.