Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initColor method #53

Closed
Lasicaine opened this issue Aug 25, 2020 · 5 comments
Closed

Add initColor method #53

Lasicaine opened this issue Aug 25, 2020 · 5 comments
Assignees
Labels
enhancement New feature or request Released Released already on the latest version.

Comments

@Lasicaine
Copy link

Lasicaine commented Aug 25, 2020

Hello! Could you please add initColor method for ColorPickerDialog builder's for initialize set start color for ColorPickerView?

For example:

new ColorPickerDialog.Builder(this)
.setTitle("ColorPicker Dialog")
.setPreferenceName("MyColorPickerDialog")
.setPositiveButton(getString(R.string.confirm),
new ColorEnvelopeListener() {
@OverRide
public void onColorSelected(ColorEnvelope envelope, boolean fromUser) {
setLayoutColor(envelope);
}
})
.setNegativeButton(getString(R.string.cancel),
new DialogInterface.OnClickListener() {
@OverRide
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
})
.attachAlphaSlideBar(true) // the default value is true.
.attachBrightnessSlideBar(true) // the default value is true.
.setBottomSpace(12) // set a bottom space between the last slidebar and buttons.
.setInitColor(here color in Int or Hex) // This method is neeeded for set initialize color. <------------
.show();

@skydoves skydoves self-assigned this Aug 25, 2020
@skydoves skydoves added enhancement New feature or request Release Next This feature will be released on next version labels Aug 25, 2020
@skydoves
Copy link
Owner

Hi, @Lasicaine!
Thank you for your issue.
I will add some methods and attributes related to initialColor.
But you can implement it using the below method.

colorPickerView.post(new Runnable() {
      @Override public void run() {
        try {
          selectByHsvColor(color);
        } catch (IllegalAccessException e) {
          e.printStackTrace();
        }
      }
    });

@Lasicaine
Copy link
Author

Great! Thank you!

@skydoves skydoves added Released Released already on the latest version. and removed Release Next This feature will be released on next version labels Sep 3, 2020
@skydoves
Copy link
Owner

skydoves commented Sep 3, 2020

Hi, @Lasicaine !
It is released in the new version 2.2.0
Thanks for your issue :)

@skydoves skydoves closed this as completed Sep 5, 2020
@rolud
Copy link

rolud commented Dec 30, 2020

Hello @skydoves! In version 2.2.2 I don't find any initColor method for ColorPickerDialog.Builder. Is there an alternative method?

@skydoves
Copy link
Owner

Hi, @rolud
You might use the below method.

ColorPickerView colorPickerView = builder.getColorPickerView();

// set an initial position of the selector using a specific color. This attribute will work with only a default HSV palette.
colorPickerView.setInitialColor(color);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Released Released already on the latest version.
Projects
None yet
Development

No branches or pull requests

3 participants