Java Code Examples for android.support.v7.preference.PreferenceGroup#getPreference()

The following examples show how to use android.support.v7.preference.PreferenceGroup#getPreference() . 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: GsPreferenceFragmentCompat.java    From memetastic with GNU General Public License v3.0 6 votes vote down vote up
private void tintPrefIconsRecursive(PreferenceGroup prefGroup, @ColorInt int iconColor) {
    if (prefGroup != null && isAdded()) {
        int prefCount = prefGroup.getPreferenceCount();
        for (int i = 0; i < prefCount; i++) {
            Preference pref = prefGroup.getPreference(i);
            if (pref != null) {
                if (isAllowedToTint(pref)) {
                    pref.setIcon(_cu.tintDrawable(pref.getIcon(), iconColor));
                }
                if (pref instanceof PreferenceGroup) {
                    tintPrefIconsRecursive((PreferenceGroup) pref, iconColor);
                }
            }
        }
    }
}
 
Example 2
Source File: GsPreferenceFragmentCompat.java    From memetastic with GNU General Public License v3.0 6 votes vote down vote up
protected PreferenceGroup getPreferenceParent(PreferenceGroup prefGroup, Preference pref) {
    for (int i = 0; i < prefGroup.getPreferenceCount(); ++i) {
        Preference prefChild = prefGroup.getPreference(i);
        if (prefChild == pref) {
            return prefGroup;
        }
        if (prefChild instanceof PreferenceGroup) {
            PreferenceGroup childGroup = (PreferenceGroup) prefChild;
            PreferenceGroup result = getPreferenceParent(childGroup, pref);
            if (result != null) {
                return result;
            }
        }
    }
    return null;
}
 
Example 3
Source File: SettingsBaseFragment.java    From openlauncher with Apache License 2.0 6 votes vote down vote up
public void updateIcons(PreferenceGroup prefGroup) {
    if (prefGroup != null && isAdded()) {
        int prefCount = prefGroup.getPreferenceCount();
        for (int i = 0; i < prefCount; i++) {
            Preference preference = prefGroup.getPreference(i);
            if (preference != null) {
                Drawable drawable = preference.getIcon();
                if (drawable != null) {
                    TypedValue color = new TypedValue();
                    getContext().getTheme().resolveAttribute(android.R.attr.textColor, color, true);
                    drawable.mutate().setColorFilter(getResources().getColor(color.resourceId), PorterDuff.Mode.SRC_IN);
                }

                if (preference instanceof PreferenceGroup) {
                    updateIcons((PreferenceGroup) preference);
                }
            }
        }
    }
}
 
Example 4
Source File: GsPreferenceFragmentCompat.java    From openlauncher with Apache License 2.0 6 votes vote down vote up
private void tintPrefIconsRecursive(PreferenceGroup prefGroup, @ColorInt int iconColor) {
    if (prefGroup != null && isAdded()) {
        int prefCount = prefGroup.getPreferenceCount();
        for (int i = 0; i < prefCount; i++) {
            Preference pref = prefGroup.getPreference(i);
            if (pref != null) {
                if (isAllowedToTint(pref)) {
                    pref.setIcon(_cu.tintDrawable(pref.getIcon(), iconColor));
                }
                if (pref instanceof PreferenceGroup) {
                    tintPrefIconsRecursive((PreferenceGroup) pref, iconColor);
                }
            }
        }
    }
}
 
Example 5
Source File: GsPreferenceFragmentCompat.java    From openlauncher with Apache License 2.0 6 votes vote down vote up
protected PreferenceGroup getPreferenceParent(PreferenceGroup prefGroup, Preference pref) {
    for (int i = 0; i < prefGroup.getPreferenceCount(); ++i) {
        Preference prefChild = prefGroup.getPreference(i);
        if (prefChild == pref) {
            return prefGroup;
        }
        if (prefChild instanceof PreferenceGroup) {
            PreferenceGroup childGroup = (PreferenceGroup) prefChild;
            PreferenceGroup result = getPreferenceParent(childGroup, pref);
            if (result != null) {
                return result;
            }
        }
    }
    return null;
}
 
Example 6
Source File: GsPreferenceFragmentCompat.java    From Stringlate with MIT License 6 votes vote down vote up
private void tintPrefIconsRecursive(PreferenceGroup prefGroup, @ColorInt int iconColor) {
    if (prefGroup != null && isAdded()) {
        int prefCount = prefGroup.getPreferenceCount();
        for (int i = 0; i < prefCount; i++) {
            Preference pref = prefGroup.getPreference(i);
            if (pref != null) {
                if (isAllowedToTint(pref)) {
                    pref.setIcon(_cu.tintDrawable(pref.getIcon(), iconColor));
                }
                if (pref instanceof PreferenceGroup) {
                    tintPrefIconsRecursive((PreferenceGroup) pref, iconColor);
                }
            }
        }
    }
}
 
Example 7
Source File: GsPreferenceFragmentCompat.java    From Stringlate with MIT License 6 votes vote down vote up
protected PreferenceGroup getPreferenceParent(PreferenceGroup prefGroup, Preference pref) {
    for (int i = 0; i < prefGroup.getPreferenceCount(); ++i) {
        Preference prefChild = prefGroup.getPreference(i);
        if (prefChild == pref) {
            return prefGroup;
        }
        if (prefChild instanceof PreferenceGroup) {
            PreferenceGroup childGroup = (PreferenceGroup) prefChild;
            PreferenceGroup result = getPreferenceParent(childGroup, pref);
            if (result != null) {
                return result;
            }
        }
    }
    return null;
}
 
Example 8
Source File: GsPreferenceFragmentCompat.java    From kimai-android with MIT License 6 votes vote down vote up
private void tintPrefIconsRecursive(PreferenceGroup prefGroup, @ColorInt int iconColor) {
    if (prefGroup != null && isAdded()) {
        int prefCount = prefGroup.getPreferenceCount();
        for (int i = 0; i < prefCount; i++) {
            Preference pref = prefGroup.getPreference(i);
            if (pref != null) {
                if (isAllowedToTint(pref)) {
                    pref.setIcon(_cu.tintDrawable(pref.getIcon(), iconColor));
                }
                if (pref instanceof PreferenceGroup) {
                    tintPrefIconsRecursive((PreferenceGroup) pref, iconColor);
                }
            }
        }
    }
}
 
Example 9
Source File: GsPreferenceFragmentCompat.java    From kimai-android with MIT License 6 votes vote down vote up
protected PreferenceGroup getPreferenceParent(PreferenceGroup prefGroup, Preference pref) {
    for (int i = 0; i < prefGroup.getPreferenceCount(); ++i) {
        Preference prefChild = prefGroup.getPreference(i);
        if (prefChild == pref) {
            return prefGroup;
        }
        if (prefChild instanceof PreferenceGroup) {
            PreferenceGroup childGroup = (PreferenceGroup) prefChild;
            PreferenceGroup result = getPreferenceParent(childGroup, pref);
            if (result != null) {
                return result;
            }
        }
    }
    return null;
}