Moved 'last played media' preference into default shared preference

This commit is contained in:
daniel oeh 2012-09-22 14:30:36 +02:00
parent ca9fab8330
commit b54eab8dfc
3 changed files with 18 additions and 11 deletions

View File

@ -23,7 +23,6 @@ public class PodcastApp extends Application implements
SharedPreferences.OnSharedPreferenceChangeListener {
private static final String TAG = "PodcastApp";
public static final String PREF_NAME = "AntennapodPrefs";
public static final String EXPORT_DIR = "export/";
public static final String PREF_PAUSE_ON_HEADSET_DISCONNECT = "prefPauseOnHeadsetDisconnect";

View File

@ -159,8 +159,9 @@ public class PlaybackService extends Service {
return new Intent(context, AudioplayerActivity.class);
}
} else {
SharedPreferences pref = context.getApplicationContext()
.getSharedPreferences(PodcastApp.PREF_NAME, 0);
SharedPreferences pref = PreferenceManager
.getDefaultSharedPreferences(context
.getApplicationContext());
boolean isVideo = pref.getBoolean(PREF_LAST_IS_VIDEO, false);
if (isVideo) {
return new Intent(context, VideoplayerActivity.class);
@ -511,12 +512,17 @@ public class PlaybackService extends Service {
@Override
public void run() {
if (AppConfig.DEBUG) Log.d(TAG, "Starting chapterLoader thread");
ChapterUtils.readID3ChaptersFromFeedMediaDownloadUrl(media.getItem());
if (AppConfig.DEBUG)
Log.d(TAG, "Starting chapterLoader thread");
ChapterUtils
.readID3ChaptersFromFeedMediaDownloadUrl(media
.getItem());
if (media.getItem().getChapters() != null) {
sendNotificationBroadcast(NOTIFICATION_TYPE_RELOAD, 0);
sendNotificationBroadcast(NOTIFICATION_TYPE_RELOAD,
0);
}
if (AppConfig.DEBUG) Log.d(TAG, "ChapterLoaderThread has finished");
if (AppConfig.DEBUG)
Log.d(TAG, "ChapterLoaderThread has finished");
}
};
@ -690,8 +696,9 @@ public class PlaybackService extends Service {
Log.d(TAG, "Audiofocus successfully requested");
if (AppConfig.DEBUG)
Log.d(TAG, "Resuming/Starting playback");
SharedPreferences.Editor editor = getApplicationContext()
.getSharedPreferences(PodcastApp.PREF_NAME, 0).edit();
SharedPreferences.Editor editor = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext())
.edit();
editor.putLong(PREF_LAST_PLAYED_ID, media.getId());
editor.putLong(PREF_LAST_PLAYED_FEED_ID, feed.getId());
editor.putBoolean(PREF_LAST_IS_STREAM, shouldStream);

View File

@ -16,6 +16,7 @@ import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.View;
@ -163,8 +164,8 @@ public abstract class PlaybackController {
private Intent getPlayLastPlayedMediaIntent() {
if (AppConfig.DEBUG)
Log.d(TAG, "Trying to restore last played media");
SharedPreferences prefs = activity.getApplicationContext()
.getSharedPreferences(PodcastApp.PREF_NAME, 0);
SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(activity.getApplicationContext());
long mediaId = prefs.getLong(PlaybackService.PREF_LAST_PLAYED_ID, -1);
long feedId = prefs.getLong(PlaybackService.PREF_LAST_PLAYED_FEED_ID,
-1);