Java Code Examples for android.preference.Preference#equals()

The following examples show how to use android.preference.Preference#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SettingsActivity.java    From your-local-weather with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
                                     Preference preference) {
    if (preference.equals(findPreference(Constants.KEY_PREF_ABOUT_OPEN_SOURCE_LICENSES))) {
        LicensesDialogFragment licensesDialog = LicensesDialogFragment.newInstance();
        licensesDialog.show(getFragmentManager(), "LicensesDialog");
    }
    return super.onPreferenceTreeClick(preferenceScreen, preference);
}
 
Example 2
Source File: SettingsActivity.java    From good-weather with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
                                     Preference preference) {
    if (preference.equals(findPreference(Constants.KEY_PREF_ABOUT_OPEN_SOURCE_LICENSES))) {
        LicensesDialogFragment licensesDialog = LicensesDialogFragment.newInstance();
        licensesDialog.show(getFragmentManager(), "LicensesDialog");
    }
    return super.onPreferenceTreeClick(preferenceScreen, preference);
}
 
Example 3
Source File: SettingsActivity.java    From NBAPlus with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    if(preference.equals(fontSizePre)) {
        String prefsValue = newValue.toString();
        fontSizePre.setSummary(showFontSize(prefsValue));
    }
    return true;
}
 
Example 4
Source File: SettingsActivity.java    From NBAPlus with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onPreferenceClick(Preference preference) {
    if (preference.equals(clearCachePre)) {
        DataClearManager.cleanApplicationData(App.getContext());
        updateCache();
        AppUtils.showSnackBar(view, R.string.data_cleared);
    }
    if(preference.equals(fontSizePre)) {
        fontSizePre.setDefaultValue(PreferenceUtils.getPrefString(getActivity(), "font_size", "16"));
    }
    return false;
}
 
Example 5
Source File: SettingsActivity.java    From VNTFontListPreference with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onPreferenceChange(final Preference preference, final Object newValue) {
    if (preference.equals(preferenceCallback)) {
        final String value = (String) newValue;
        Toast.makeText(getActivity(), "New value is " + value, Toast.LENGTH_SHORT).show();
        return true;
    }

    return false;
}
 
Example 6
Source File: GroupPreferenceFragment.java    From tickmate with GNU General Public License v3.0 5 votes vote down vote up
@Override
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
                                          String key) {
        Preference pref = findPreference(key);

        if (pref instanceof EditTextPreference) {
            EditTextPreference etp = (EditTextPreference) pref;
            if (pref.equals(name)) {
                group.setName(name.getText());
            }
            if (pref.equals(description)) {
                group.setDescription(description.getText());
            }
            pref.setSummary(etp.getText());

            DataSource.getInstance().storeGroup(group);
        } else if (pref instanceof MultiSelectListPreference) {
            MultiSelectListPreference mp = (MultiSelectListPreference) pref;
//            Log.d(TAG, "MultiSelectListPreference changed, with trackIds: " + TextUtils.join(",", mp.getValues()));
            // Convert the Set returned by getValues into a List, as expected by setTrackIdsUsingStrings:
            List<Integer> trackIds = new ArrayList<>();
            for (String value : mp.getValues()) {
                trackIds.add(Integer.valueOf(value));
            }
            mDataSource.linkManyTracksOneGroup(trackIds, group.getId());
//            Log.d(TAG, "\tUser selected: " + TextUtils.join(",", trackIds));

            mTracksPref.setSummary(getTrackNamesForSummary());
//                    + "  \n" + TextUtils.join("\n", mDataSource.getGroups())); // Leaving here for future debugging, until tests are written
//            Log.d(TAG, "Confirm that the group IDs are correct: " + TextUtils.join(",", track.getGroupIdsAsSet()));
//            Log.d(TAG, "Confirm that the group NAMES are correct: " + TextUtils.join(",", track.getGroupNamesAsSet()));

        }
        mDataSource.storeGroup(group);

        // If this was launched simply to edit the track list, then exit at this point.
        if (mOpenTrackList) {
            getActivity().onBackPressed();
        }
    }
 
Example 7
Source File: SettingsActivity.java    From VNTNumberPickerPreference with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onPreferenceChange(final Preference preference, final Object newValue) {
    if (preference.equals(preferenceCallback)) {
        final int value = (int) newValue;
        Toast.makeText(getActivity(), "New value is " + value, Toast.LENGTH_SHORT).show();
        return true;
    }

    return false;
}
 
Example 8
Source File: TrackPreferenceFragment.java    From tickmate with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
        String key) {
    Preference pref = findPreference(key);
    Log.v(TAG, "onSharedPreferenceChanged -- " + pref.getTitle());

    if (pref instanceof IconPreference) {
        if (pref.equals(icon)) {
    		track.setIcon(icon.getText());
            //icon.setSummary(track.getIcon());
    	}
    }
    if (pref instanceof TickColorPreference) {  // TickColorPreference instances are also EditTextPreference
        track.getTickColor().setColorValue(mTickColorPreference.getColorValue());
    } else if (pref instanceof EditTextPreference) {
        EditTextPreference etp = (EditTextPreference) pref;
        if (pref.equals(name)) {
        	track.setName(name.getText());
        }
        if (pref.equals(description)) {
        	track.setDescription(description.getText());
        }
        pref.setSummary(etp.getText());
    }
    else if (pref instanceof CheckBoxPreference) {
    	if (pref.equals(enabled)) {
    		track.setEnabled(enabled.isChecked());
    	}
    	if (pref.equals(multiple_entries_enabled)) {
            track.setMultipleEntriesEnabled(multiple_entries_enabled.isChecked());
        }
    } else if (pref instanceof GroupListPreference) {
        if (pref.equals(mGroupsPref)) {
            // Convert the Set returned by getValues into a List, as expected by setGroupIdsUsingStrings:
            List<Integer> groupIds = new ArrayList<>();
            for (String value : mGroupsPref.getValues()) {
                groupIds.add(Integer.valueOf(value));
            }
            mDataSource.linkOneTrackManyGroups(track.getId(), groupIds);
            mGroupsPref.populate();
        }
    }
    mDataSource.storeTrack(track);
}