package net.sharermax.m_news.fragment;

import android.app.Activity;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;

import net.sharermax.m_news.R;
import net.sharermax.m_news.support.Setting;


/**
 * Author: SharerMax
 * Time  : 2015/4/16
 * E-Mail: mdcw1103@gmail.com
 */
public class SubscriptionFragment extends PreferenceFragment
        implements Preference.OnPreferenceChangeListener {

    private CheckBoxPreference mStartUpPre;
    private CheckBoxPreference mGeekPre;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.subscription);
        initPreferenceItem();
    }

    private void initPreferenceItem() {
        mStartUpPre = (CheckBoxPreference)findPreference(Setting.KEY_SUB_STARTUP);
        mGeekPre = (CheckBoxPreference)findPreference(Setting.KEY_SUB_HACKERNEWS);
        mStartUpPre.setOnPreferenceChangeListener(this);
        mGeekPre.setOnPreferenceChangeListener(this);

    }

    @Override
    public boolean onPreferenceChange(Preference preference, Object newValue) {
        getActivity().setResult(Activity.RESULT_OK);
        return true;
    }

}

@@ -574,22 +574,95 @@
 erence m
-GeekPr
+HackerPre;%0A    private boolean mStartUpEnable;%0A    private boolean mHackerEnabl
 e;%0A    @
@@ -993,20 +993,22 @@
        m
-Geek
+Hacker
 Pre = (C
@@ -1139,12 +1139,14 @@
    m
-Geek
+Hacker
 Pre.
@@ -1186,160 +1186,804 @@
 s);%0A
-%0A    %7D%0A%0A    @Override%0A    public boolean onPreferenceChange(Preference preference, Object newValue) %7B%0A        getActivity().setResult(Activity.RESULT_OK
+        mStartUpEnable = Setting.getInstance(getActivity()).getBoolen(Setting.KEY_SUB_STARTUP, true);%0A        mHackerEnable = Setting.getInstance(getActivity()).getBoolen(Setting.KEY_SUB_HACKERNEWS, true);%0A%0A    %7D%0A%0A    @Override%0A    public boolean onPreferenceChange(Preference preference, Object newValue) %7B%0A        if (preference.getKey().equals(Setting.KEY_SUB_STARTUP) &&%0A                mStartUpEnable != (boolean)newValue) %7B%0A            getActivity().setResult(Activity.RESULT_OK);%0A            return true;%0A        %7D%0A%0A        if (preference.getKey().equals(Setting.KEY_SUB_HACKERNEWS) &&%0A                mHackerEnable != (boolean)newValue) %7B%0A            getActivity().setResult(Activity.RESULT_OK);%0A            return true;%0A        %7D%0A%0A        getActivity().setResult(Activity.RESULT_CANCELED
 );%0A 

improve subscription feature