aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-01-16 19:11:01 -0800
committerScott Jackson <daneren2005@gmail.com>2014-01-16 19:11:01 -0800
commita0befc8d40b01b903ee0fa67a0ef32d6403888bb (patch)
treede1aa2fb7b8767674380c58be8a7856dc158161a /src
parent9f874cf673ee8ed82c70c5ae35b0ab4a0a2aa6ef (diff)
downloaddsub-a0befc8d40b01b903ee0fa67a0ef32d6403888bb.tar.gz
dsub-a0befc8d40b01b903ee0fa67a0ef32d6403888bb.tar.bz2
dsub-a0befc8d40b01b903ee0fa67a0ef32d6403888bb.zip
#254 cache whether license is valid or not
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/service/CachedMusicService.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/github/daneren2005/dsub/service/CachedMusicService.java b/src/github/daneren2005/dsub/service/CachedMusicService.java
index b93a6e1e..4da3aec2 100644
--- a/src/github/daneren2005/dsub/service/CachedMusicService.java
+++ b/src/github/daneren2005/dsub/service/CachedMusicService.java
@@ -82,7 +82,16 @@ public class CachedMusicService implements MusicService {
checkSettingsChanged(context);
Boolean result = cachedLicenseValid.get();
if (result == null) {
- result = musicService.isLicenseValid(context, progressListener);
+ result = FileUtil.deserialize(context, getCacheName(context, "license"), Boolean.class);
+
+ if(result == null) {
+ result = musicService.isLicenseValid(context, progressListener);
+
+ // Only save a copy license is valid
+ if(result == true) {
+ FileUtil.serialize(context, (Boolean) result, getCacheName(context, "license"));
+ }
+ }
cachedLicenseValid.set(result, result ? 30L * 60L : 2L * 60L, TimeUnit.SECONDS);
}
return result;