package fr.masciulli.drinks.fragment;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import de.keyboardsurfer.android.widget.crouton.Crouton;
import de.keyboardsurfer.android.widget.crouton.Style;
import fr.masciulli.drinks.R;
import fr.masciulli.drinks.data.DrinksProvider;

public class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Load the preferences from an XML resource
        addPreferencesFromResource(R.xml.preferences);
        PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(this);
    }

    @Override
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
        if (!isAdded()) {
            return;
        }
        if (key == getString(R.string.pref_apiendpoint_key)) {
            String server = sharedPreferences.getString(key, getString(R.string.pref_apiendpoint_default));
            DrinksProvider.updateServer(server);
            Crouton.makeText(getActivity(), getString(R.string.server_updated), Style.INFO).show();
        }
    }
}

@@ -1030,12 +1030,16 @@
 (key
- == 
+.equals(
 getS
@@ -1075,16 +1075,17 @@
 nt_key))
+)
  %7B%0A     

Compare strings correctly