コード例 #1
0
ファイル: PodcastApp.java プロジェクト: arantius/AntennaPod
 @Override
 public void onCreate() {
   super.onCreate();
   singleton = this;
   LOGICAL_DENSITY = getResources().getDisplayMetrics().density;
   SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
   displayOnlyEpisodes = prefs.getBoolean(PREF_DISPLAY_ONLY_EPISODES, false);
   currentlyPlayingMediaId =
       prefs.getLong(
           PlaybackService.PREF_CURRENTLY_PLAYING_MEDIA, PlaybackService.NO_MEDIA_PLAYING);
   readThemeValue();
   createImportDirectory();
   createNoMediaFile();
   prefs.registerOnSharedPreferenceChangeListener(this);
   FeedManager manager = FeedManager.getInstance();
   manager.loadDBData(getApplicationContext());
 }
コード例 #2
0
ファイル: PodcastApp.java プロジェクト: arantius/AntennaPod
 /**
  * Listens for changes in the 'update intervall'-preference and changes the alarm if necessary.
  */
 @Override
 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
   if (AppConfig.DEBUG) Log.d(TAG, "Registered change of application preferences");
   if (key.equals(PREF_UPDATE_INTERVALL)) {
     AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
     int hours = Integer.parseInt(sharedPreferences.getString(PREF_UPDATE_INTERVALL, "0"));
     PendingIntent updateIntent =
         PendingIntent.getBroadcast(
             this, 0, new Intent(FeedUpdateReceiver.ACTION_REFRESH_FEEDS), 0);
     alarmManager.cancel(updateIntent);
     if (hours != 0) {
       long newIntervall = TimeUnit.HOURS.toMillis(hours);
       alarmManager.setRepeating(
           AlarmManager.RTC_WAKEUP, newIntervall, newIntervall, updateIntent);
       if (AppConfig.DEBUG) Log.d(TAG, "Changed alarm to new intervall");
     } else {
       if (AppConfig.DEBUG) Log.d(TAG, "Automatic update was deactivated");
     }
   } else if (key.equals(PREF_DISPLAY_ONLY_EPISODES)) {
     if (AppConfig.DEBUG) Log.d(TAG, "PREF_DISPLAY_ONLY_EPISODES changed");
     displayOnlyEpisodes = sharedPreferences.getBoolean(PREF_DISPLAY_ONLY_EPISODES, false);
   } else if (key.equals(PlaybackService.PREF_LAST_PLAYED_ID)) {
     if (AppConfig.DEBUG) Log.d(TAG, "PREF_LAST_PLAYED_ID changed");
     long mediaId = sharedPreferences.getLong(PlaybackService.PREF_AUTODELETE_MEDIA_ID, -1);
     if (mediaId != -1) {
       FeedManager manager = FeedManager.getInstance();
       FeedMedia media = manager.getFeedMedia(mediaId);
       if (media != null) {
         manager.autoDeleteIfPossible(this, media);
       }
     }
   } else if (key.equals(PlaybackService.PREF_CURRENTLY_PLAYING_MEDIA)) {
     long id =
         sharedPreferences.getLong(
             PlaybackService.PREF_CURRENTLY_PLAYING_MEDIA, PlaybackService.NO_MEDIA_PLAYING);
     if (AppConfig.DEBUG) Log.d(TAG, "Currently playing media set to " + id);
     if (id != currentlyPlayingMediaId) {
       currentlyPlayingMediaId = id;
     }
   } else if (key.equals(PREF_THEME)) {
     readThemeValue();
   }
 }