// Path: app/src/main/java/com/yoga/oneweather/util/LogUtil.java
// public class LogUtil {
//     public static final int VERBOSE = 1;
//     public static final int DEBUG = 2 ;
//     public static final int INFO = 3 ;
//     public static final int WARN = 4 ;
//     public static final int ERROR = 5 ;
//     public static final int NOTHING = 6 ;
// 
//     public static int level = VERBOSE ;
//     public static void v(String tag, String msg){
//         if(level == VERBOSE){
//             Log.v(tag, msg);
//         }
//     }
//     public static void d(String tag,String msg){
//         if(level <= DEBUG){
//             Log.d(tag, msg);
//         }
//     }
// 
//     public static void i(String tag,String msg){
//         if(level <= INFO){
//             Log.i(tag, msg);
//         }
//     }
// 
// 
//     public static void w(String tag,String msg){
//         if(level <= WARN){
//             Log.w(tag, msg);
//         }
//     }
// 
//     public static void e(String tag,String msg){
//         if(level <= ERROR){
//             Log.e(tag, msg);
//         }
//     }
// 
// }


import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.support.annotation.Nullable;
import com.yoga.oneweather.R;
import com.yoga.oneweather.util.LogUtil;
package com.yoga.oneweather.ui;



/**
 * Created by wyg on 2017/8/12.
 */

public class SettingFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener{


    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.setting);
    }


    @Override
    public void onResume() {
        super.onResume();
        getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
    }

    @Override
    public void onPause() {
        super.onPause();
        getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
    }

    @Override
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
        if("auto_update_rate".equals(key)){
            Preference update_rate = findPreference(key);
            update_rate.setSummary(sharedPreferences.getString(key,"6")+"小时");
// Path: app/src/main/java/com/yoga/oneweather/util/LogUtil.java
// public class LogUtil {
//     public static final int VERBOSE = 1;
//     public static final int DEBUG = 2 ;
//     public static final int INFO = 3 ;
//     public static final int WARN = 4 ;
//     public static final int ERROR = 5 ;
//     public static final int NOTHING = 6 ;
// 
//     public static int level = VERBOSE ;
//     public static void v(String tag, String msg){
//         if(level == VERBOSE){
//             Log.v(tag, msg);
//         }
//     }
//     public static void d(String tag,String msg){
//         if(level <= DEBUG){
//             Log.d(tag, msg);
//         }
//     }
// 
//     public static void i(String tag,String msg){
//         if(level <= INFO){
//             Log.i(tag, msg);
//         }
//     }
// 
// 
//     public static void w(String tag,String msg){
//         if(level <= WARN){
//             Log.w(tag, msg);
//         }
//     }
// 
//     public static void e(String tag,String msg){
//         if(level <= ERROR){
//             Log.e(tag, msg);
//         }
//     }
// 
// }


// Path: app/src/main/java/com/yoga/oneweather/ui/SettingFragment.java
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.support.annotation.Nullable;
import com.yoga.oneweather.R;
import com.yoga.oneweather.util.LogUtil;

package com.yoga.oneweather.ui;



/**
 * Created by wyg on 2017/8/12.
 */

public class SettingFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener{


    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.setting);
    }


    @Override
    public void onResume() {
        super.onResume();
        getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
    }

    @Override
    public void onPause() {
        super.onPause();
        getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
    }

    @Override
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
        if("auto_update_rate".equals(key)){
            Preference update_rate = findPreference(key);
            update_rate.setSummary(sharedPreferences.getString(key,"6")+"小时");
            LogUtil.d("SettingFragment", "onSharedPreferenceChanged: ");