android.support.v7.preference.PreferenceGroupAdapter Java Examples

The following examples show how to use android.support.v7.preference.PreferenceGroupAdapter. 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: BasePreferenceFragmentCompat.java    From Focus with GNU General Public License v3.0 7 votes vote down vote up
@Override
protected RecyclerView.Adapter onCreateAdapter(PreferenceScreen preferenceScreen) {
    return new PreferenceGroupAdapter(preferenceScreen) {
        @SuppressLint("RestrictedApi")
        @Override
        public void onBindViewHolder(PreferenceViewHolder holder, int position) {
            super.onBindViewHolder(holder, position);
            Preference preference = getItem(position);
            if (preference instanceof PreferenceCategory)
                setZeroPaddingToLayoutChildren(holder.itemView);
            else {
                View iconFrame = holder.itemView.findViewById(R.id.icon_frame);
                if (iconFrame != null) {
                    iconFrame.setVisibility(preference.getIcon() == null ? View.GONE : View.VISIBLE);
                }
            }
        }
    };
}
 
Example #2
Source File: BasePreferenceFragmentCompat.java    From Focus with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected RecyclerView.Adapter onCreateAdapter(PreferenceScreen preferenceScreen) {
    return new PreferenceGroupAdapter(preferenceScreen) {
        @SuppressLint("RestrictedApi")
        @Override
        public void onBindViewHolder(PreferenceViewHolder holder, int position) {
            super.onBindViewHolder(holder, position);
            Preference preference = getItem(position);
            if (preference instanceof PreferenceCategory)
                setZeroPaddingToLayoutChildren(holder.itemView);
            else {
                View iconFrame = holder.itemView.findViewById(R.id.icon_frame);
                if (iconFrame != null) {
                    iconFrame.setVisibility(preference.getIcon() == null ? View.GONE : View.VISIBLE);
                }
            }
        }
    };
}
 
Example #3
Source File: SettingsFragment.java    From sleep-cycle-alarm with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected RecyclerView.Adapter onCreateAdapter(PreferenceScreen preferenceScreen) {
    return new PreferenceGroupAdapter(preferenceScreen) {
        @SuppressLint("RestrictedApi")
        @Override
        public void onBindViewHolder(PreferenceViewHolder holder, int position) {
            super.onBindViewHolder(holder, position);
            Preference preference = getItem(position);
            if (preference instanceof PreferenceCategory)
                setZeroPaddingToLayoutChildren(holder.itemView);
            else {
                View iconFrame = holder.itemView.findViewById(R.id.icon_frame);
                if (iconFrame != null) {
                    iconFrame.setVisibility(preference.getIcon() == null
                            ? View.GONE
                            : View.VISIBLE);
                }
            }
        }
    };
}
 
Example #4
Source File: SettingsFragmentView.java    From FastAccess with GNU General Public License v3.0 6 votes vote down vote up
@Override public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    setDivider(ActivityCompat.getDrawable(getActivity(), R.drawable.list_divider));
    setDividerHeight(1);
    PreferenceGroupAdapter adapter = (PreferenceGroupAdapter) getListView().getAdapter();
    for (int i = 0; i < getListView().getAdapter().getItemCount(); i++) {//lazy global setOnPreferenceClickListener
        Preference preference = adapter.getItem(i);
        if (preference != null && !InputHelper.isEmpty(preference.getKey())) {
            if (preference.getKey().equalsIgnoreCase("version")) {
                preference.setSummary(BuildConfig.VERSION_NAME);
            } else if (!(preference instanceof SwitchPreference) && !(preference instanceof ListPreference)) {
                preference.setOnPreferenceClickListener(this);
            }
        }
    }
}
 
Example #5
Source File: NGPreferenceFragment.java    From android_maplibui with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected RecyclerView.Adapter onCreateAdapter(PreferenceScreen preferenceScreen) {
    return new PreferenceGroupAdapter(preferenceScreen) {
        @SuppressLint("RestrictedApi")
        @Override
        public void onBindViewHolder(PreferenceViewHolder holder, int position) {
            super.onBindViewHolder(holder, position);
            Preference preference = getItem(position);
            if (preference instanceof PreferenceCategory)
                setZeroPaddingToLayoutChildren(holder.itemView);
            else {
                View iconFrame = holder.itemView.findViewById(R.id.icon_frame);
                if (iconFrame != null) {
                    iconFrame.setVisibility(preference.getIcon() == null ? View.GONE : View.VISIBLE);
                }
            }
        }
    };
}