android.support.v7.preference.PreferenceViewHolder Java Examples

The following examples show how to use android.support.v7.preference.PreferenceViewHolder. 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: TwoTargetPreference.java    From notification-channel-compat with Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    final ImageView icon = holder.itemView.findViewById(android.R.id.icon);
    switch (mIconSize) {
        case ICON_SIZE_SMALL:
            icon.setLayoutParams(new LinearLayout.LayoutParams(mSmallIconSize, mSmallIconSize));
            break;
        case ICON_SIZE_MEDIUM:
            icon.setLayoutParams(
                    new LinearLayout.LayoutParams(mMediumIconSize, mMediumIconSize));
            break;
    }
    final View divider = holder.findViewById(R.id.two_target_divider);
    final View widgetFrame = holder.findViewById(android.R.id.widget_frame);
    final boolean shouldHideSecondTarget = shouldHideSecondTarget();
    if (divider != null) {
        divider.setVisibility(shouldHideSecondTarget ? View.GONE : View.VISIBLE);
    }
    if (widgetFrame != null) {
        widgetFrame.setVisibility(shouldHideSecondTarget ? View.GONE : View.VISIBLE);
    }
}
 
Example #3
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 #4
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 #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);
                }
            }
        }
    };
}
 
Example #6
Source File: ColorPickerPreference.java    From openlauncher with Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
	super.onBindViewHolder(view);

	int tmpColor = isEnabled()
			? selectedColor
			: darken(selectedColor, .5f);

	colorIndicator = (ImageView) view.findViewById(R.id.color_indicator);

	ColorCircleDrawable colorChoiceDrawable = null;
	Drawable currentDrawable = colorIndicator.getDrawable();
	if (currentDrawable != null && currentDrawable instanceof ColorCircleDrawable)
		colorChoiceDrawable = (ColorCircleDrawable) currentDrawable;

	if (colorChoiceDrawable == null)
		colorChoiceDrawable = new ColorCircleDrawable(tmpColor);

	colorIndicator.setImageDrawable(colorChoiceDrawable);
}
 
Example #7
Source File: AppCompatColorPreference.java    From FastAccess with GNU General Public License v3.0 6 votes vote down vote up
@Override public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    View view = holder.itemView;
    mColorView = new View(getContext());
    mColorView.setId("ID".hashCode());
    int size = (int) dpToPx(32);
    mColorView.setLayoutParams(new ViewGroup.LayoutParams(size, size));
    ViewGroup frame = (ViewGroup) view.findViewById(android.R.id.widget_frame);
    frame.setVisibility(View.VISIBLE);
    addView(frame, mColorView);
    if (mMaterial) {
        TextView textTitle = (TextView) view.findViewById(android.R.id.title);
        TextView textSummary = (TextView) view.findViewById(android.R.id.summary);
        textTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
        textSummary.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
        textTitle.setTextColor(getColor(android.R.attr.textColor));
        textSummary.setTextColor(getColor(android.R.attr.textColorSecondary));
        View parent = (View) textSummary.getParent().getParent();
        parent.setPadding((int) dpToPx(16), 0, (int) dpToPx(16), 0);
    }
}
 
Example #8
Source File: LongTextPreference.java    From android_external_MicroGUiTools with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    TextView view = (TextView) holder.findViewById(android.R.id.summary);
    if (view != null) {
        view.setMaxLines(Integer.MAX_VALUE);
    }
}
 
Example #9
Source File: DestructiveCheckBoxPreference.java    From fdroidclient with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    if (!holder.itemView.isEnabled()) {
        return;
    }
    Resources resources = getContext().getResources();
    if (FDroidApp.isAppThemeLight()) {
        holder.itemView.setBackgroundColor(resources.getColor(R.color.panic_destructive_light));
    } else {
        holder.itemView.setBackgroundColor(resources.getColor(R.color.panic_destructive_dark));
    }
}
 
Example #10
Source File: DestructivePreference.java    From fdroidclient with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    if (FDroidApp.isAppThemeLight()) {
        holder.itemView.setBackgroundColor(getContext().getResources().getColor(R.color.panic_destructive_light));
    } else {
        holder.itemView.setBackgroundColor(getContext().getResources().getColor(R.color.panic_destructive_dark));
    }
}
 
Example #11
Source File: SilenceListPreference.java    From Silence with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
  super.onBindViewHolder(view);

  this.rightSummary = (TextView)view.findViewById(R.id.right_summary);
  setSummary(this.summary);
}
 
Example #12
Source File: SilenceRingtonePreference.java    From Silence with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
  super.onBindViewHolder(view);

  this.rightSummary = (TextView)view.findViewById(R.id.right_summary);
  setSummary(summary);
}
 
Example #13
Source File: ColorPickerPreference.java    From Silence with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
  super.onBindViewHolder(holder);

  colorWidget = (ImageView) holder.findViewById(R.id.color_picker_widget);
  setColorOnWidget(color);
}
 
Example #14
Source File: DialogPreference.java    From android_external_MicroGUiTools with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
    super.onBindViewHolder(view);

    ViewGroup.LayoutParams layoutParams = view.findViewById(R.id.icon_frame).getLayoutParams();
    if (layoutParams instanceof LinearLayout.LayoutParams) {
        if (((LinearLayout.LayoutParams) layoutParams).leftMargin < 0) {
            ((LinearLayout.LayoutParams) layoutParams).leftMargin = 0;
        }
    }
}
 
Example #15
Source File: TintIconPreference.java    From android_external_MicroGUiTools with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
    super.onBindViewHolder(view);
    Drawable icon = getIcon();
    if (icon != null) {
        DrawableCompat.setTint(icon, getThemeAccentColor(getContext()));
    }
}
 
Example #16
Source File: DimmableIconPreference.java    From android_external_MicroGUiTools with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
    super.onBindViewHolder(view);
    if (!TextUtils.isEmpty(mContentDescription)) {
        final TextView titleView = (TextView) view.findViewById(android.R.id.title);
        titleView.setContentDescription(mContentDescription);
    }
    ViewGroup.LayoutParams layoutParams = view.findViewById(R.id.icon_frame).getLayoutParams();
    if (layoutParams instanceof LinearLayout.LayoutParams) {
        if (((LinearLayout.LayoutParams) layoutParams).leftMargin < 0) {
            ((LinearLayout.LayoutParams) layoutParams).leftMargin = 0;
        }
    }
    dimIcon(shouldDimIcon());
}
 
Example #17
Source File: MaterialPreferenceCategory.java    From MaterialPreference with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    TextView titleView = (TextView) holder.findViewById(android.R.id.title);

    titleView.setTextColor(Color.parseColor(MaterialPrefUtil.secondaryColor[MaterialPrefUtil.getSecondaryColorPosition()]));
}
 
Example #18
Source File: ColorChooserPreference.java    From MaterialPreference with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    //holder.itemView.setClickable(false); // disable parent click
    ImageView imageView = (ImageView) holder.findViewById(R.id.imageViewIcon);
    //noinspection StatementWithEmptyBody
    if (imageView != null) {
        GradientDrawable gradientDrawable = (GradientDrawable) imageView.getBackground();
        gradientDrawable.setColor(Color.parseColor(MaterialPrefUtil.secondaryColor[MaterialPrefUtil.getSecondaryColorPosition()]));

        imageView.setClickable(true); // enable custom view click

    } else {
    }
}
 
Example #19
Source File: SpectrumPreferenceCompat.java    From Muzesto with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);

    mColorView = holder.findViewById(com.thebluealliance.spectrum.R.id.color_preference_widget);
    updateColorView();
}
 
Example #20
Source File: ColorChooserPreference.java    From OpenHub with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    View colorView = holder.findViewById(R.id.color_view);
    colorView.setBackgroundResource(R.drawable.shape_circle);
    colorView.getBackground().setColorFilter(getSelectedColor(), PorterDuff.Mode.SRC_IN);
}
 
Example #21
Source File: ColorPreferenceSupport.java    From IslamicLibraryAndroid with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
    super.onBindViewHolder(view);
    preview = (ColorPanelView) view.findViewById(R.id.cpv_preference_preview_color_panel);
    if (preview != null) {
        preview.setColor(color);
    }

}
 
Example #22
Source File: TimePreference.java    From RememBirthday with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    updatePreview();
}
 
Example #23
Source File: TextColorPreference.java    From ResearchStack with Apache License 2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    titleView = (TextView) holder.itemView.findViewById(android.R.id.title);
    titleView.setTextColor(color);
}
 
Example #24
Source File: LEDColorListPreference.java    From Silence with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
  super.onBindViewHolder(view);
  this.colorImageView = (ImageView)view.findViewById(R.id.color_view);
  setPreviewColor(getValue());
}
 
Example #25
Source File: ColorPreferenceCategory.java    From openlauncher with Apache License 2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    TextView titleView = (TextView) holder.findViewById(android.R.id.title);
    titleView.setTextColor(AppSettings.get().getPrimaryColor());
}
 
Example #26
Source File: ColorPreference.java    From hsv-alpha-color-picker-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
	View thumbnail = addThumbnail(holder.itemView);
	showColor(thumbnail, getPersistedIntDefaultOrNull());
	super.onBindViewHolder(holder);
}
 
Example #27
Source File: GcmFragment.java    From android_packages_apps_GmsCore with Apache License 2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
    updateViewDetails();
    super.onBindViewHolder(view);
}