Fixed Video list cache

This commit is contained in:
Joshua Bahnsen 2013-06-04 01:13:47 -07:00
parent 47849c34e9
commit ac500a7169
6 changed files with 26 additions and 20 deletions

View File

@ -2,8 +2,8 @@
<manifest xmlns:a="http://schemas.android.com/apk/res/android"
package="com.thejoshwa.ultrasonic.androidapp"
a:installLocation="auto"
a:versionCode="29"
a:versionName="1.2.0.2" >
a:versionCode="30"
a:versionName="1.2.0.3" >
<uses-permission a:name="android.permission.INTERNET" />
<uses-permission a:name="android.permission.READ_PHONE_STATE" />

View File

@ -39,11 +39,6 @@
a:key="discAndTrackSort"
a:summary="@string/settings.disc_sort_summary"
a:title="@string/settings.disc_sort" />
<CheckBoxPreference
a:defaultValue="true"
a:key="showNowPlaying"
a:summary="@string/settings.show_now_playing_summary"
a:title="@string/settings.show_now_playing" />
</PreferenceCategory>
<PreferenceCategory a:title="@string/settings.playback_control_title" >
<CheckBoxPreference
@ -89,6 +84,11 @@
a:title="@string/settings.increment_time" />
</PreferenceCategory>
<PreferenceCategory a:title="@string/settings.notifications_title" >
<CheckBoxPreference
a:defaultValue="true"
a:key="showNowPlaying"
a:summary="@string/settings.show_now_playing_summary"
a:title="@string/settings.show_now_playing" />
<CheckBoxPreference
a:defaultValue="true"
a:key="showNotification"

View File

@ -468,7 +468,8 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
new LoadTask() {
@Override
protected MusicDirectory load(MusicService service) throws Exception {
return service.getVideos(SelectAlbumActivity.this, this);
boolean refresh = getIntent().getBooleanExtra(Constants.INTENT_EXTRA_NAME_REFRESH, false);
return service.getVideos(refresh, SelectAlbumActivity.this, this);
}
}.execute();
}

View File

@ -40,6 +40,7 @@ import com.thejoshwa.ultrasonic.androidapp.domain.SearchResult;
import com.thejoshwa.ultrasonic.androidapp.domain.Share;
import com.thejoshwa.ultrasonic.androidapp.domain.Version;
import com.thejoshwa.ultrasonic.androidapp.util.CancellableTask;
import com.thejoshwa.ultrasonic.androidapp.util.Constants;
import com.thejoshwa.ultrasonic.androidapp.util.LRUCache;
import com.thejoshwa.ultrasonic.androidapp.util.ProgressListener;
import com.thejoshwa.ultrasonic.androidapp.util.TimeLimitedCache;
@ -392,15 +393,19 @@ public class CachedMusicService implements MusicService {
}
@Override
public MusicDirectory getVideos(Context context, ProgressListener progressListener) throws Exception {
checkSettingsChanged(context);
MusicDirectory result = cachedVideos.get();
if (result == null) {
result = musicService.getVideos(context, progressListener);
cachedVideos.set(result);
}
return result;
public MusicDirectory getVideos(boolean refresh, Context context, ProgressListener progressListener) throws Exception {
checkSettingsChanged(context);
TimeLimitedCache<MusicDirectory> cache = refresh ? null : cachedMusicDirectories.get(Constants.INTENT_EXTRA_NAME_VIDEOS);
MusicDirectory dir = cache == null ? null : cache.get();
if (dir == null) {
dir = musicService.getVideos(refresh, context, progressListener);
cache = new TimeLimitedCache<MusicDirectory>(Util.getDirectoryCacheTime(context), TimeUnit.SECONDS);
cache.set(dir);
cachedMusicDirectories.put(Constants.INTENT_EXTRA_NAME_VIDEOS, cache);
}
return dir;
}
}

View File

@ -136,5 +136,5 @@ public interface MusicService {
void createBookmark(String id, int position, Context context, ProgressListener progressListener) throws Exception;
MusicDirectory getVideos(Context context, ProgressListener progressListener) throws Exception;
MusicDirectory getVideos(boolean refresh, Context context, ProgressListener progressListener) throws Exception;
}

View File

@ -1274,7 +1274,7 @@ public class RESTMusicService implements MusicService {
}
@Override
public MusicDirectory getVideos(Context context, ProgressListener progressListener) throws Exception {
public MusicDirectory getVideos(boolean refresh, Context context, ProgressListener progressListener) throws Exception {
checkServerVersion(context, "1.8", "Videos not supported.");
Reader reader = getReader(context, progressListener, "getVideos", null);