private View CreatePickerView() { var contentView = View.Inflate(Activity, Resource.Layout.cpv_dialog_color_picker, null); _colorPicker = contentView.FindViewById <ColorPickerView>(Resource.Id.cpv_color_picker_view); var oldColorPanel = contentView.FindViewById <ColorPanelView>(Resource.Id.cpv_color_panel_old); _newColorPanel = contentView.FindViewById <ColorPanelView>(Resource.Id.cpv_color_panel_new); var arrowRight = contentView.FindViewById <ImageView>(Resource.Id.cpv_arrow_right); _hexEditText = contentView.FindViewById <EditText>(Resource.Id.cpv_hex); try { var value = new TypedValue(); var typedArray = Activity.ObtainStyledAttributes(value.Data, new[] { Android.Resource.Attribute.TextColorPrimary }); var arrowColor = typedArray.GetColor(0, Color.Black); typedArray.Recycle(); arrowRight.SetColorFilter(arrowColor); } catch (Exception) { // ignored } _colorPicker.SetAlphaSliderVisible(_showAlphaSlider); oldColorPanel.SetColor(new Color(Arguments.GetInt(ARG_COLOR))); _colorPicker.SetColor(_color, true); _newColorPanel.SetColor(_color); SetHex(_color); if (!_showAlphaSlider) { _hexEditText.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(6) }); } _newColorPanel.SetOnClickListener(new OnClickListener(v => { if (_newColorPanel.GetColor() == _color) { OnColorSelected(); Dismiss(); } })); contentView.SetOnTouchListener(this); _colorPicker.SetOnColorChangedListener(this); _hexEditText.AddTextChangedListener(this); _hexEditText.OnFocusChangeListener = new OnFocusChangeListener((v, hasFocus) => { if (hasFocus) { var imm = (InputMethodManager)Activity.GetSystemService(Context.InputMethodService); imm.ShowSoftInput(_hexEditText, ShowFlags.Implicit); } }); return(contentView); }
public ViewHolder(Context context, ColorPaletteAdapter colorpaletteadapter) { _colorPaletteAdapter = colorpaletteadapter; var layoutResId = _colorPaletteAdapter._colorShape == ColorShape.Square ? Resource.Layout.cpv_color_item_square : Resource.Layout.cpv_color_item_circle; view = View.Inflate(context, layoutResId, null); _colorPanelView = view.FindViewById <ColorPanelView>(Resource.Id.cpv_color_panel_view); _imageView = view.FindViewById <ImageView>(Resource.Id.cpv_color_image_view); _originalBorderColor = _colorPanelView.GetBorderColor(); view.Tag = this; }
public override void OnBindViewHolder(PreferenceViewHolder view) { base.OnBindViewHolder(view); _preview = (ColorPanelView)view.FindViewById(Resource.Id.cpv_preference_preview_color_panel); _preview?.SetColor(_color); }