Java 类android.support.v7.preference.PreferenceViewHolder 实例源码

项目:PingWidget    文件:ThemePreference.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    holder.itemView.setClickable(false);    // disable parent click

    //Loop through all the ThemeViews
    for(WidgetTheme widgetTheme : WidgetTheme.values()) {
        final String name = widgetTheme.name();
        final int themeViewId = widgetTheme.getThemeViewId();
        final int summaryRes = widgetTheme.getSummaryRes();

        View button = holder.findViewById(themeViewId);
        button.setClickable(true);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                setSummary(summaryRes);
                persistString(name);
            }
        });
    }
}
项目:materialistic    文件:ThemePreference.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    holder.itemView.setClickable(false);
    for (int i = 0; i < BUTTONS.size(); i++) {
        final int buttonId = BUTTONS.keyAt(i);
        final String value = BUTTONS.valueAt(i);
        View button = holder.findViewById(buttonId);
        button.setClickable(true);
        button.setOnClickListener(v -> {
            mSelectedTheme = value;
            if (shouldDisableDependents()) {
                Preferences.Theme.disableAutoDayNight(getContext());
            }
            setSummary(VALUES.get(value).summary);
            persistString(value);
        });
    }
}
项目:Android-Support-Preference-V7-Fix    文件:SimpleMenuPreference.java   
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
    super.onBindViewHolder(view);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        return;
    }

    mItemView = view.itemView;
    mAnchor = view.itemView.findViewById(android.R.id.empty);

    if (mAnchor == null) {
        throw new IllegalStateException("SimpleMenuPreference item layout must contain" +
                "a view id is android.R.id.empty to support iconSpaceReserved");
    }
}
项目:FastAccess    文件:AppCompatColorPreference.java   
@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);
    }
}
项目:apps-android-wikipedia    文件:PreferenceMultiLine.java   
@Override
public void onBindViewHolder(@NonNull PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    // Intercept the click listener for this preference, and if the preference has an intent,
    // launch the intent ourselves, so that we can catch the exception if the intent fails.
    // (but only do this if the preference doesn't already have a click listener)
    if (this.getOnPreferenceClickListener() == null) {
        this.setOnPreferenceClickListener(new OnPreferenceClickListener() {
            @Override
            public boolean onPreferenceClick(Preference preference) {
                if (preference.getIntent() != null) {
                    try {
                        getContext().startActivity(preference.getIntent());
                    } catch (ActivityNotFoundException e) {
                        Toast.makeText(getContext(), getContext().getString(R.string.error_browser_not_found), Toast.LENGTH_LONG).show();
                    }
                    return true;
                }
                return false;
            }
        });
    }
}
项目:GitHub    文件:SizePreferences.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
  super.onBindViewHolder(holder);
  // We get the reference to the mSeekBar
  mSeekBar = (SeekBar) holder.findViewById(R.id.size_seek_bar);
  mSeekBar.setMax(mMaxValue);
  mSeekBar.setOnSeekBarChangeListener(this);
  mSeekBarValueTextView = (TextView) holder.findViewById(R.id.seek_bar_value);
  mTitleView = (TextView) holder.findViewById(R.id.title);
  mTitleView.setText(getTitle());
  // This is called after the initial value is set
  mSeekBar.setProgress(mProgressValue);
  updateCurrentValue(mProgressValue);
}
项目:MyCalendar    文件:ColorPickerPreference.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);

    colorWidget = (ImageView) holder.findViewById(R.id.color_picker_widget);
    setColorOnWidget(color);
}
项目:GracefulMovies    文件:ColorPickerPreference.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    if (primary) {
        ((CircularView) holder.findViewById(R.id.color_indicator)).setColor(getContext().getResources().getColor(Colorful.getThemeDelegate().getPrimaryColor().getColorRes()));
    } else if (accent) {
        ((CircularView) holder.findViewById(R.id.color_indicator)).setColor(getContext().getResources().getColor(Colorful.getThemeDelegate().getAccentColor().getColorRes()));
    }
}
项目:Sega    文件:ColorPickerPreference.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    if (primary) {
        ((CircularView) holder.findViewById(R.id.color_indicator)).setColor(getContext().getResources().getColor(Colorful.getThemeDelegate().getPrimaryColor().getColorRes()));
    } else if (accent) {
        ((CircularView) holder.findViewById(R.id.color_indicator)).setColor(getContext().getResources().getColor(Colorful.getThemeDelegate().getAccentColor().getColorRes()));
    }
}
项目:OpenHub    文件:ColorChooserPreference.java   
@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);
}
项目:10-bitClockWidget    文件:ColorPickerPreference.java   
@Override
public void onBindViewHolder(PreferenceViewHolder viewHolder) {
    super.onBindViewHolder(viewHolder);
    colorView = viewHolder.findViewById(R.id.color_preview);

    ((GradientDrawable)
            ((LayerDrawable) colorView.getBackground())
                    .findDrawableByLayerId(R.id.color))
            .setColor(color);
}
项目:ConnectU    文件:ProfilePreference.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    App app = (App) getContext().getApplicationContext();
    TextView user = (TextView) holder.findViewById(R.id.user_Name);
    ImageView picture = (ImageView) holder.findViewById(R.id.user_Profile);
    String name = app.account.getName();
    if (name == null) {
        name = "User";
    }
    user.setText(name);
    Picasso.with(getContext()).load(app.account.getPictureURL()).placeholder(R.drawable.ic_placeholder).into(picture);
}
项目:Muzesto    文件:SpectrumPreferenceCompat.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);

    mColorView = holder.findViewById(com.thebluealliance.spectrum.R.id.color_preference_widget);
    updateColorView();
}
项目:ProjectOxford-Apps-MimickerAlarm    文件:NamePreference.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object o) {
            String changedText = (String) o;
            if (getText() == null || getText().compareTo(changedText) != 0) {
                setChanged(true);
                setSummary(changedText);
            }
            return true;
        }
    });
}
项目:ProjectOxford-Apps-MimickerAlarm    文件:RepeatingDaysPreference.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    LinearLayout container = (LinearLayout) holder.findViewById(R.id.pref_repeating_container);
    container.removeAllViews();
    for(int i = 0; i < mRepeatingDays.length; i++) {
        DayView dayView = new DayView(getContext(), this, i);
        dayView.setText(mDayNames[i]);
        dayView.setRepeating(mRepeatingDays[i]);
        container.addView(dayView);
    }
    super.onBindViewHolder(holder);
}
项目:ProjectOxford-Apps-MimickerAlarm    文件:VibratePreference.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object o) {
            setChanged(mInitiallyChecked != (boolean) o);
            return true;
        }
    });
}
项目:ProjectOxford-Apps-MimickerAlarm    文件:VolumeSliderPreference.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);

    mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
    int maxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM);
    int currentVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_ALARM);

    mVolumeLevel = (SeekBar) holder.findViewById(R.id.volume_level);
    mVolumeLevel.setMax(maxVolume);
    mVolumeLevel.setProgress(currentVolume);
    mVolumeLevel.setOnSeekBarChangeListener(this);
}
项目:spectrum    文件:SpectrumPreferenceCompat.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);

    mColorView = holder.findViewById(R.id.color_preference_widget);
    updateColorView();
}
项目:android_external_MicroGUiTools    文件:DimmableIconPreference.java   
@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());
}
项目:android_external_MicroGUiTools    文件:TintIconPreference.java   
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
    super.onBindViewHolder(view);
    Drawable icon = getIcon();
    if (icon != null) {
        DrawableCompat.setTint(icon, getThemeAccentColor(getContext()));
    }
}
项目:android_external_MicroGUiTools    文件:LongTextPreference.java   
@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);
    }
}
项目:android_external_MicroGUiTools    文件:DialogPreference.java   
@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;
        }
    }
}
项目:Colorful    文件:ColorPickerPreference.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    if (primary) {
        ((CircularView) holder.findViewById(R.id.color_indicator)).setColor(getContext().getResources().getColor(Colorful.getThemeDelegate().getPrimaryColor().getColorRes()));
    } else if (accent) {
        ((CircularView) holder.findViewById(R.id.color_indicator)).setColor(getContext().getResources().getColor(Colorful.getThemeDelegate().getAccentColor().getColorRes()));
    }
}
项目:libretorrent    文件:ColorPreference.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder)
{
    super.onBindViewHolder(holder);

    LightColorView color = (LightColorView) holder.findViewById(R.id.lightColor);
    if (color != null) {
        color.setColor(value);
    }
}
项目:Superuser-UI    文件:PreferenceCategoryCustom.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);

    TextView textView = (TextView) holder.findViewById(android.R.id.title);
    textView.setAllCaps(true);
    textView.setTypeface(null, Typeface.BOLD);
    textView.setTextColor(ThemeStore.accentColor(getContext()));
}
项目:Android-Support-Preference-V7-Fix    文件:ColorPickerPreference.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);

    colorWidget = (ImageView) holder.findViewById(R.id.color_picker_widget);
    setColorOnWidget(color);
}
项目:Android-Support-Preference-V7-Fix    文件:PreferenceCategory.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);

    itemView = holder.itemView;

    TextView titleView = (TextView) holder.findViewById(android.R.id.title);

    if (titleView != null) {
        final TypedArray typedArray = getContext().obtainStyledAttributes(CATEGORY_ATTRS);

        if (typedArray.length() > 0 && typedArray.getIndexCount() > 0) {
            final int accentColor = typedArray.getColor(typedArray.getIndex(0), 0xff4081); // defaults to pink
            titleView.setTextColor(color == 0 ? accentColor : color);

            final int marginIdx = typedArray.getIndex(1);
            final TypedValue marginValue = typedArray.peekValue(marginIdx);

            if (typedArray.hasValue(marginIdx) && marginValue != null && marginValue.type == TypedValue.TYPE_DIMENSION) {
                int bottomMargin = typedArray.getDimensionPixelSize(marginIdx, -1);
                if (bottomMargin > -1) {
                    ((ViewGroup.MarginLayoutParams) titleView.getLayoutParams()).bottomMargin = bottomMargin;
                }
            }
        }

        typedArray.recycle();
    }

    boolean isVisible = !TextUtils.isEmpty(getTitle());
    setTitleVisibility(holder.itemView, isVisible);
    /*if (!isVisible) {
        return;
    }*/
}
项目:ProjectOxford-Apps-MimickerAlarm    文件:NamePreference.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object o) {
            String changedText = (String) o;
            if (getText() == null || getText().compareTo(changedText) != 0) {
                setChanged(true);
                setSummary(changedText);
            }
            return true;
        }
    });
}
项目:ProjectOxford-Apps-MimickerAlarm    文件:RepeatingDaysPreference.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    LinearLayout container = (LinearLayout) holder.findViewById(R.id.pref_repeating_container);
    container.removeAllViews();
    for(int i = 0; i < mRepeatingDays.length; i++) {
        DayView dayView = new DayView(getContext(), this, i);
        dayView.setText(mDayNames[i]);
        dayView.setRepeating(mRepeatingDays[i]);
        container.addView(dayView);
    }
    super.onBindViewHolder(holder);
}
项目:ProjectOxford-Apps-MimickerAlarm    文件:VibratePreference.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object o) {
            setChanged(mInitiallyChecked != (boolean) o);
            return true;
        }
    });
}
项目:ProjectOxford-Apps-MimickerAlarm    文件:VolumeSliderPreference.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);

    mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
    int maxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM);
    int currentVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_ALARM);

    mVolumeLevel = (SeekBar) holder.findViewById(R.id.volume_level);
    mVolumeLevel.setMax(maxVolume);
    mVolumeLevel.setProgress(currentVolume);
    mVolumeLevel.setOnSeekBarChangeListener(this);
}
项目:Jockey    文件:PreferenceFragment.java   
@Override
protected RecyclerView.Adapter onCreateAdapter(PreferenceScreen preferenceScreen) {
    return new PreferenceGroupAdapter(preferenceScreen) {
        @Override
        public void onBindViewHolder(PreferenceViewHolder holder, int position) {
            super.onBindViewHolder(holder, position);

            // Override Equalizer preference attachment to add a long click listener
            // and to change the detail text at runtime
            String fragment = getItem(position).getFragment();
            if ("com.marverenic.music.ui.settings.EqualizerFragment".equals(fragment)) {

                ViewGroup itemView = (ViewGroup) holder.itemView;
                TextView title = (TextView) itemView.findViewById(android.R.id.title);
                TextView detail = (TextView) itemView.findViewById(android.R.id.summary);

                boolean hasSystemEq = Util.getSystemEqIntent(getContext()) != null;

                if (hasSystemEq && Util.hasEqualizer()) {
                    // If we have Jockey's Equalizer and another Equalizer
                    itemView.setOnLongClickListener(PreferenceFragment.this);
                    detail.setText(R.string.equalizer_more_options_detail);
                    detail.setVisibility(View.VISIBLE);

                } else if (hasSystemEq && !Util.hasEqualizer()) {
                    // If we don't have any equalizers
                    detail.setText(R.string.equalizer_unsupported);
                    detail.setVisibility(View.VISIBLE);
                    itemView.setEnabled(false);
                    title.setEnabled(false);
                    detail.setEnabled(false);
                }
            }
        }
    };
}
项目:android-testdpc    文件:BaseSearchablePolicyPreferenceFragment.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder, int position) {
    super.onBindViewHolder(holder, position);
    if (position == mHighlightPosition) {
        View v = holder.itemView;
        if (v.getBackground() != null) {
            final int centerX = v.getWidth() / 2;
            final int centerY = v.getHeight() / 2;
            v.getBackground().setHotspot(centerX, centerY);
        }
        v.setPressed(true);
        v.setPressed(false);
        mHighlightPosition = -1;
    }
}
项目:android-testdpc    文件:DpcPreferenceHelper.java   
/**
 * Override the summary with any constraint violation messages.
 */
public void onBindViewHolder(PreferenceViewHolder holder) {
    if (!constraintsMet()) {
        final TextView summaryView = (TextView) holder.findViewById(android.R.id.summary);
        if (summaryView != null) {
            summaryView.setText(mConstraintViolationSummary);
            summaryView.setVisibility(View.VISIBLE);
        }
    }
}
项目:fresco    文件:SizePreferences.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
  super.onBindViewHolder(holder);
  // We get the reference to the mSeekBar
  mSeekBar = (SeekBar) holder.findViewById(R.id.size_seek_bar);
  mSeekBar.setMax(mMaxValue);
  mSeekBar.setOnSeekBarChangeListener(this);
  mSeekBarValueTextView = (TextView) holder.findViewById(R.id.seek_bar_value);
  mTitleView = (TextView) holder.findViewById(R.id.title);
  mTitleView.setText(getTitle());
  // This is called after the initial value is set
  mSeekBar.setProgress(mProgressValue);
  updateCurrentValue(mProgressValue);
}
项目:ring-client-android    文件:CodecPreference.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);

    ListView mCodecList = (ListView) holder.findViewById(R.id.dndlistview);
    if (mCodecList.getAdapter() != listAdapter)
        mCodecList.setAdapter(listAdapter);
    mCodecList.setOnItemClickListener((arg0, arg1, pos, arg3) -> {
        listAdapter.getItem(pos).toggleState();
        listAdapter.notifyDataSetChanged();
        callChangeListener(getActiveCodecList());
    });

    setListViewHeight(mCodecList, (LinearLayout) mCodecList.getParent());
}
项目:plusTimer    文件:SettingsActivity.java   
private boolean shouldDrawDividerBelow(View view, RecyclerView parent) {
    PreferenceViewHolder holder = (PreferenceViewHolder) parent.getChildViewHolder(view);
    boolean nextAllowed = true;
    int index = parent.indexOfChild(view);
    if (index < parent.getChildCount() - 1) {
        View nextView = parent.getChildAt(index + 1);
        PreferenceViewHolder nextHolder = (PreferenceViewHolder) parent.getChildViewHolder(nextView);
        nextAllowed = nextHolder.isDividerAllowedAbove();
    }

    return holder.getAdapterPosition() != parent.getAdapter().getItemCount() - 1
            && nextAllowed
            && holder.isDividerAllowedBelow();
}
项目:apps-android-wikipedia    文件:SwitchPreferenceWithLinks.java   
@Override
public void onBindViewHolder(@NonNull PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    TextView view = (TextView) holder.findViewById(android.R.id.summary);
    view.setMovementMethod(movementMethod);
    view.setOnClickListener(onClickListener);
    view.setBackground(ContextCompat.getDrawable(getContext(),
            ResourceUtil.getThemedAttributeId(getContext(), R.attr.selectableItemBackgroundBorderless)));
}
项目:DsaTab    文件:PreferenceWithButton.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);

    mView = holder.findViewById(R.id.pref_btn);
    if (mView != null) {
        mView.setOnClickListener(buttonClickListener);
        mView.setFocusable(false);
        mView.setTag(this);
        mView.setVisibility(widgetVisibility);
    }
}
项目:Cluttr    文件:DualNumberPickerPreference.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    summary = ((TextView) holder.findViewById(R.id.preview_indicator));
    updateSummary();
}