Android Open Source - RSSFeedReader-App Settings Fragment






From Project

Back to project page RSSFeedReader-App.

License

The source code is released under:

GNU General Public License

If you think the Android project RSSFeedReader-App listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package tan.chesley.rssfeedreader;
//from   w  w w  .j  a  va2 s.c  o  m
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


public class SettingsFragment extends PreferenceFragment {
  
  private ListPreference sortFeedByListPreference;
    private ListPreference feedDateFormatPreference;
    private NumberPickerDialogPreference maxArticleNumberPickerDialogPreference;
    private CheckBoxPreference articleAgeLimitCheckBoxPreference;
    private NumberPickerDialogPreference articleAgeLimitNumberPickerDialogPreference;
    private NumberPickerDialogPreference syncTimeoutNumberPickerDialogPreference;
    private NumberPickerDialogPreference maxDatabaseSizeNumberPickerDialogPreference;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);
    sortFeedByListPreference = (ListPreference) findPreference("pref_feedSortBy_type");
    sortFeedByListPreference.setSummary(sortFeedByListPreference.getEntry());
    sortFeedByListPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

      @Override
      public boolean onPreferenceChange(Preference preference,
          Object newValue) {
        ListPreference pref = (ListPreference) preference;
        pref.setValue(newValue.toString());
        pref.setSummary(pref.getEntry());
        return false;
      }
      
    });
        feedDateFormatPreference = (ListPreference) findPreference("pref_feedDateFormat_type");
        feedDateFormatPreference.setSummary(feedDateFormatPreference.getEntry());
        feedDateFormatPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
            @Override
            public boolean onPreferenceChange (Preference preference, Object newValue) {
                ListPreference pref = (ListPreference) preference;
                pref.setValue(newValue.toString());
                pref.setSummary(pref.getEntry());
                return false;
            }
        });
        maxArticleNumberPickerDialogPreference = (NumberPickerDialogPreference) findPreference("pref_id_maxArticleNumberPickerDialog");
        maxArticleNumberPickerDialogPreference.setSummary(Integer.toString(PreferenceManager.getDefaultSharedPreferences(getActivity()).getInt(SettingsActivity.KEY_PREF_MAX_ARTICLE_NUMBER, getResources().getInteger(R.integer.max_article_number_default))));
      articleAgeLimitCheckBoxPreference = (CheckBoxPreference) findPreference("pref_articleAgeLimitCheckBox");
        articleAgeLimitNumberPickerDialogPreference = (NumberPickerDialogPreference) findPreference("pref_id_articleAgeLimitNumberPickerDialog");
        if (articleAgeLimitCheckBoxPreference.isChecked()) {
            articleAgeLimitNumberPickerDialogPreference.setSummary(Integer.toString(PreferenceManager.getDefaultSharedPreferences(getActivity()).getInt(SettingsActivity.KEY_PREF_ARTICLE_AGE_LIMIT, getResources().getInteger(R.integer.article_age_limit_default))));
        }
        syncTimeoutNumberPickerDialogPreference = (NumberPickerDialogPreference) findPreference("pref_id_syncTimeoutNumberPickerDialog");
        syncTimeoutNumberPickerDialogPreference.setSummary(Integer.toString(PreferenceManager.getDefaultSharedPreferences(getActivity()).getInt(SettingsActivity.KEY_PREF_SYNC_TIMEOUT, getResources().getInteger(R.integer.sync_timeout_default))));
      maxDatabaseSizeNumberPickerDialogPreference = (NumberPickerDialogPreference) findPreference("pref_id_maxDatabaseSizeNumberPickerDialog");
        maxDatabaseSizeNumberPickerDialogPreference.setSummary(Integer.toString(PreferenceManager.getDefaultSharedPreferences(getActivity()).getInt(SettingsActivity.KEY_PREF_MAX_DATABASE_SIZE, getResources().getInteger(R.integer.max_database_size_default))));
    }

    @Override
    public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = super.onCreateView(inflater, container, savedInstanceState);
        // Remove default padding on the preferences
        view.findViewById(android.R.id.list).setPadding(0, 0, 0, 0);
        return view;
    }
}




Java Source Code List

android.support.v4.app.FixedFragmentStatePagerAdapter.java
tan.chesley.rssfeedreader.AddSourceDialogFragment.java
tan.chesley.rssfeedreader.ArticleAgeLimitNumberPickerDialog.java
tan.chesley.rssfeedreader.ArticleViewFragment.java
tan.chesley.rssfeedreader.ArticleView.java
tan.chesley.rssfeedreader.AutosyncTimePickerDialog.java
tan.chesley.rssfeedreader.BrightnessControl.java
tan.chesley.rssfeedreader.DepthPageTransformer.java
tan.chesley.rssfeedreader.HeadlinesFragment.java
tan.chesley.rssfeedreader.MaxArticlesNumberPickerDialog.java
tan.chesley.rssfeedreader.MaxDatabaseSizeNumberPickerDialog.java
tan.chesley.rssfeedreader.ModifySourceDialogFragment.java
tan.chesley.rssfeedreader.ModifySources.java
tan.chesley.rssfeedreader.NumberPickerDialogPreference.java
tan.chesley.rssfeedreader.RSSDataBundleOpenHelper.java
tan.chesley.rssfeedreader.RSSDataBundle.java
tan.chesley.rssfeedreader.RSSFeed.java
tan.chesley.rssfeedreader.RSSHandler.java
tan.chesley.rssfeedreader.RssSyncService.java
tan.chesley.rssfeedreader.SettingsActivity.java
tan.chesley.rssfeedreader.SettingsFragment.java
tan.chesley.rssfeedreader.SourcesOpenHelper.java
tan.chesley.rssfeedreader.SyncTimeoutNumberPickerDialog.java
tan.chesley.rssfeedreader.TaskFragment.java
tan.chesley.rssfeedreader.TimePickerDialogPreference.java
tan.chesley.rssfeedreader.Toaster.java