Git Product home page Git Product logo

colorpicker's Introduction

Color Picker

API License Maven Central

Yet another open source color picker for Android. So, why should you use this color picker? It is highly customizable and easy to use. You can simply add the ColorPreference to your preferences and a beautiful color picker dialog will be displayed without additional code. The color picker supports alpha and allows you to set your own presets.

The original ColorPickerView was written by Daniel Nilsson.

Screenshots

GIF    Screenshot

Usage

Add the ColorPreference to your preference XML:

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
                  xmlns:app="http://schemas.android.com/apk/res-auto">

  <PreferenceCategory>

    <com.jaredrummler.android.colorpicker.ColorPreference
        android:defaultValue="@color/color_default"
        android:key="default_color"
        android:summary="@string/color_default_summary"
        android:title="@string/color_default_title"/>

    ...

  </PreferenceCategory>

</PreferenceScreen>

Note: Using AndroidX's PreferenceFragmentCompat? Then use com.jaredrummler.android.colorpicker.ColorPreferenceCompat

You can add attributes to customize the ColorPreference:

name type documentation
cpv_dialogType enum "custom" to show the color picker, "preset" to show pre-defined colors
cpv_showAlphaSlider boolean Show a slider for changing the alpha of a color (adding transparency)
cpv_colorShape enum "square" or "circle" for the shape of the color preview
cpv_colorPresets reference An int-array of pre-defined colors to show in the dialog
cpv_dialogTitle reference The string resource id for the dialog title. By default the title is "Select a Color"
cpv_showColorShades boolean true to show different shades of the selected color
cpv_allowPresets boolean true to add a button to toggle to the custom color picker
cpv_allowCustom boolean true to add a button to toggle to the presets color picker
cpv_showDialog boolean true to let the ColorPreference handle showing the dialog

You can also show a ColorPickerDialog without using the ColorPreference:

ColorPickerDialog.newBuilder().setColor(color).show(activity);

All the attributes above can also be applied to the ColorPickerDialog. The activity that shows the dialog must implement ColorPickerDialogListener to get a callback when a color is selected.

For further doumentation about how to use the library, check the demo app included in this project.

Download

Download the latest AAR or grab via Gradle:

implementation 'com.jaredrummler:colorpicker:1.1.0'

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

colorpicker's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

colorpicker's Issues

Localization

Can we use other Language for menu ?

  • Select a Color
  • Presets
  • Select
  • Custom

I want to change all to Japanese.

Orientation Changes aren't handled

Click on ColorPreference -> rotate > rotate back -> click on ColorPreference -> Exceptions thrown...

java.lang.NullPointerException: Attempt to invoke interface method 'void com.jaredrummler.android.colorpicker.ColorPickerDialogListener.onDialogDismissed(int)' on a null object reference
at com.jaredrummler.android.colorpicker.ColorPickerDialog.onDismiss(ColorPickerDialog.java:248)
at android.app.Dialog$ListenersHandler.handleMessage(Dialog.java:1343)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

What is the purpose of having NestedGridView?

I look at the code of NestedGridView - https://github.com/jaredrummler/ColorPicker/blob/master/library/src/main/java/com/jaredrummler/android/colorpicker/NestedGridView.java

I have been puzzled a while, as I'm not understand the idea behind the following code?

  @Override public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
    super.onMeasure(widthMeasureSpec, expandSpec);
  }

May I know the purpose of having NestedGridView, instead of a standard GridView?

Custom fonts/typefaces

Is there a way to set custom font for dialog title and the buttons?
If so, please explain how to do it.

Feature - select stroke width

I've got a drawing app where the user can select color, alpha and stroke width. It would be useful to have this library also allow the user to select stroke width (and maybe show a dot next to the selection to show how big the stroke would be). This should be a feature, like alpha, that can be turned on or off.

hexEditText contains #

There seems to be an issue with the dialog in 2.1.6, where the TextView with the hex color string also contains the # that is set as the TextView hint. When changing color with the selector, the TextView shows #XXXXX instead of XXXXXX. Closing and reopening it brings it to #XXXXXX.

I'm probably just dumb but...

I have no idea how to get this working. I've tried so many things but they all fail. I'm pretty new to android app development so bear with me. So just putting implementation 'com.jaredrummler:colorpicker:1.0.5' in my gradle file won't compile. I first have to convert everything to androidx. Alright, i've found that one out. But then I made an preference xml to test it but when i use for instance:
<com.jaredrummler.android.colorpicker.ColorPreference android:defaultValue="0xFFEC407A" android:key="custom_only_color" android:summary="A picker that doesn't show the presets" android:title="Custom color"
It won't give a preview. I also tried the compat version and all other kinds of stuff but i can't figure out how to do it. Is there a step I'm missing?

Dialog Layout doesn't fit in Landscape

Samsung N7000, API 16+. Color picker dialog does not fit vertically when device is Landscape, the color selection area is too big (see scrollbars when scrolled to the bottom). The screen resolution is 1280x800, stock firmware, no large font or any accessibility options, etc.

picker-bug

Cannot setColorPickerDialogListener

I would like to be able to set my own listener so that the included Activity does not need to listen for the color result. Something like this:

var dlg = ColorPickerDialog.newBuilder()
dlg.setColorPickerDialogListener(object : ColorPickerDialogListener{

    override fun onColorSelected(dialogId: Int, color: Int) {
        mood_color_text.setTextColor(color)
    }

    override fun onDialogDismissed(dialogId: Int) {
        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
    }
})

I notice that I can use setColorPickerDialogListener when I don't use the builder, but then I can't figure out how to set all the parameters and load it correctly. What is the best way to set my listener? Thanks.

Updating value for ColorPreference not reflected by preview.

I have a ListPreference I am using to allow a user to select a 'theme' that updates the color value for several ColorPreferences. However after setting the value for each key I have to refresh the fragment (go back and come in) for the preview to update. It would be extremely useful if there were a method to update the preference preview or if someone knows of a way to get the preference to refresh.

<PreferenceCategory android:title="Widgets"
    android:key="widget_category">
    <ListPreference
        android:key="widget_presets"
        android:defaultValue="1"
        android:title="Widget Themes"
        android:summary="Select from a few default widget themes or create your own."
        android:entries="@array/widget_presets"
        android:entryValues="@array/widget_presets_values"/>
    <com.jaredrummler.android.colorpicker.ColorPreference
        android:defaultValue="0x26000000"
        android:key="widget_background_color"
        android:summary="Select background color for widgets."
        android:title="Widget Background"
        app:cpv_allowPresets="true"
        app:cpv_showColorShades="false"
        app:cpv_previewSize="large"
        app:cpv_showAlphaSlider="true"/>
    <com.jaredrummler.android.colorpicker.ColorPreference
        android:defaultValue="@color/white"
        android:key="widget_text_color"
        android:summary="Select the primary text color for widgets."
        android:title="Primary Text Color"
        app:cpv_showColorShades="false"
        app:cpv_previewSize="large"/>
    <com.jaredrummler.android.colorpicker.ColorPreference
        android:defaultValue="@color/white"
        android:key="widget_secondary_text_color"
        android:summary="Select the secondary text color for widgets."
        android:title="Secondary Text Color"
        app:cpv_showColorShades="false"
        app:cpv_previewSize="large"/>
    <SwitchPreference
        android:defaultValue="false"
        android:key="widget_theme_round_corner"
        android:summary="Enable round corners for widgets."
        android:title="Round Corners" />
</PreferenceCategory>

Failed to resolve: ColorPicker:colorpicker:unspecified

Implementing the compat library (v1.0.4) causes this error when attempting to sync the project.

Implementation:

implementation 'com.jaredrummler:colorpicker-compat:1.0.4'

Error:

Failed to resolve: ColorPicker:colorpicker:unspecified
Open File
Show in Project Structure dialog

Dependency tree:

\--- com.jaredrummler:colorpicker-compat:1.0.4
     +--- ColorPicker:colorpicker:unspecified FAILED
     \--- androidx.preference:preference:1.0.0 (*)

Also happens on:

  • 1.0.3

Normal version syncs fine.

Spanish translations

Add to values-es:

<resources>
  <!-- Default title for color picker dialog [CHAR LIMIT=30] -->
  <string name="cpv_default_title">Selecciona un color</string>
  <string name="cpv_presets">Predeterminados</string>
  <string name="cpv_custom">Personalizar</string>
  <string name="cpv_select">Seleccionar</string>
  <string name="cpv_transparency">Transparencia</string>
</resources>

Language support

Is there a way to change the 'SELECT' button text in the color picker dialog (ColorPreference)?

NullpointerException Issue

Getting null pointer exception when selecting the color like this--
java.lang.NullPointerException: Attempt to invoke interface method 'void com.jrummyapps.android.colorpicker.ColorPickerDialogListener.onColorSelected(int, int)' on a null object reference
at com.jrummyapps.android.colorpicker.ColorPickerDialog$1.onClick(ColorPickerDialog.java:172)

Crash

I got this crash report from the Play Store:

java.lang.IllegalStateException:
at android.app.FragmentManagerImpl.checkStateLoss (FragmentManagerImpl.java:1858)
at android.app.FragmentManagerImpl.enqueueAction (FragmentManagerImpl.java:1881)
at android.app.BackStackRecord.commitInternal (BackStackRecord.java:688)
at android.app.BackStackRecord.commit (BackStackRecord.java:646)
at android.app.DialogFragment.show (DialogFragment.java:230)
at com.jaredrummler.android.colorpicker.ColorPreference.onClick (ColorPreference.java:175)
at android.preference.Preference.performClick (Preference.java:1135)
at android.preference.PreferenceScreen.onItemClick (PreferenceScreen.java:249)
at android.widget.AdapterView.performItemClick (AdapterView.java:318)
at android.widget.AbsListView.performItemClick (AbsListView.java:1158)
at android.widget.AbsListView$PerformClick.run (AbsListView.java:3127)
at android.widget.AbsListView$3.run (AbsListView.java:4042)
at android.os.Handler.handleCallback (Handler.java:790)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loop (Looper.java:164)
at android.app.ActivityThread.main (ActivityThread.java:6494)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:807)

image

Don't know any further details.

I just use the preference this way in the preference xml file:

<com.jaredrummler.android.colorpicker.ColorPreference
    android:defaultValue="@color/pref__background_color_default" android:key="@string/pref__background_color"
    android:summary="@string/pref__background_color_desc" android:title="@string/pref__background_color_title"
    app:cpv_allowPresets="true" app:cpv_dialogType="custom"/>

ColorPickerDialog color circles are blank (0% alpha I think)

Hi I started using your color picker in my preferences and it work very well I must say.
I have an listview if items with a button to call the ColorPickerDialog like this

      private void showColorPickerDialog(int id,  int color) {
		ColorPickerDialog dialog = ColorPickerDialog.newBuilder()
				.setDialogId(id)
				.setColor(color)
				.setSelectedButtonText(android.R.string.ok)
				.create();

		dialog.setColorPickerDialogListener(this);
		dialog.show(mContext.getFragmentManager(), "Color_picker");
    }

the problem is that all the color circles are blank i.e. they show the white / grey grid wich seems to indicate that every color in 0% alpha. the circle outlines do show color.
The custom screen also shows the two color boxes as blank.

I fiddled around with options and looked at your source code but could not find any thing.

Any Idea what would cause this?
If I cannot resolve this I will have to use another color picker all together since it does not make sense to use two different ones in the same applications

Thanks a lot for your help and very nice work BTW

Possible bug: Fatal Exception: java.lang.IllegalStateException: The activity must implement ColorPickerDialogListener

I'm using ColorPreferenceCompat , and recently I got this crash from the play console:

Fatal Exception: java.lang.IllegalStateException: The activity must implement ColorPickerDialogListener
at com.jaredrummler.android.colorpicker.c.a(ColorPickerDialog.java:19583)
at com.jaredrummler.android.colorpicker.c$3.onClick(ColorPickerDialog.java:190)
at androidx.appcompat.app.AlertController$b.handleMessage(AlertController.java:167)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6626)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811)

screencapture-console-firebase-google-project-lwp-plus-crashlytics-app-android-com-lb-lwp_plus-issues-5bf84c2df8b88c2963275d39-2018-11-24-12_51_08

link: https://console.firebase.google.com/project/lwp-plus/crashlytics/app/android:com.lb.lwp_plus/issues/5bf84c2df8b88c2963275d39?time=last-seven-days&sessionId=5BF8338A006500010FAF6123A067FB12_DNE_0_v2

I didn't set any special listener. Right on onCreatePreferences, I just call : setOnPreferenceChangeListener

strange dialog behavior on attach

In com.jrummyapps.android.colorpicker.ColorPickerDialog#onAttach:

This strange code works properly only on some situations:

if (colorPickerDialogListener == null && activity instanceof ColorPickerDialogListener) {
    colorPickerDialogListener = (ColorPickerDialogListener) activity;
}

Separating the dialog callback interface

Can't the dialog callback interface be separated from the activity such that I can supply my own implementation of the ColorPickerDialogListener independent of the activity I'm using it in? Maybe something like this:
ColorPickerDialog.newBuilder().setColor(color).show(Activity); can be changed to ColorPickerDialog.newBuilder().setColor(color).show(Activity, ColorPickerDialogListener);

java.lang.ClassCastException my.package.SettingsActivity cannot be cast to androidx.fragment.app.FragmentActivity

Using ColorPicker version 1.1.0 with an Android app that makes use of AndroidX, I am getting the following ClassCastException:

java.lang.ClassCastException: my.package.SettingsActivity cannot be cast to androidx.fragment.app.FragmentActivity
at com.jaredrummler.android.colorpicker.ColorPreference.onAttachedToActivity(ColorPreference.java:118)
at android.preference.PreferenceGroup.onAttachedToActivity(PreferenceGroup.java:281)
at android.preference.PreferenceGroup.onAttachedToActivity(PreferenceGroup.java:281)
at android.preference.PreferenceScreen.bind(PreferenceScreen.java:169)
at android.preference.PreferenceFragment.bindPreferences(PreferenceFragment.java:391)
at android.preference.PreferenceFragment.onActivityCreated(PreferenceFragment.java:214)
at android.app.Fragment.performActivityCreated(Fragment.java:2531)

See https://github.com/jaredrummler/ColorPicker/blob/master/library/src/main/java/com/jaredrummler/android/colorpicker/ColorPreference.java#L118.

The class my.package.SettingsActivity extends android.preference.PreferenceActivity.

The same code works perfect with version 1.0.2. Starting with version 1.0.3 the issue appears. Versions 1.0.4 and 1.0.5 are also affected.

Configurable buttons labels

Hi,

First thanks for this very nice library that perfectly fit my needs :)

Do you think that you can make the dialog buttons configurable like the dialog title?
Reason is that most of the buttons strings are already translated in many languages in my app, that use external translations tools.

Avoiding necessary strings and allowing more complete names to help translators would be really cool.

Bug: unable to use with android-x preference library

All classes here extend from android.preference.Preference instead of from androidx.preference.Preference , while using this in gradle file:

implementation 'androidx.preference:preference:1.0.0'

This means that if I use this repository within a class that extends PreferenceFragmentCompat, I get a crash of this sort:

    android.view.InflateException: Binary XML file line #15: Error inflating class com.jaredrummler.android.colorpicker.ColorPreference
        at androidx.preference.PreferenceInflater.createItem(PreferenceInflater.java:266)
        at androidx.preference.PreferenceInflater.createItemFromTag(PreferenceInflater.java:295)
        at androidx.preference.PreferenceInflater.rInflate(PreferenceInflater.java:362)
        at androidx.preference.PreferenceInflater.inflate(PreferenceInflater.java:170)
        at androidx.preference.PreferenceInflater.inflate(PreferenceInflater.java:120)
        at androidx.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:138)
        at androidx.preference.PreferenceFragmentCompat.setPreferencesFromResource(PreferenceFragmentCompat.java:445)

Please fix this. This is the only reason I've forked this repository into mine:

https://github.com/AndroidDeveloperLB/ColorPicker

Save custom selections in presets

Here's the use case

  • select a custom color (it appears as checked in presets)
  • go back to color picker (custom color is shown checked in upper left)
  • pick a different color
  • go back to color picker (custom color is gone)

I'd like custom colors to stay in the presets (bumping off the least used color).

Is something like this possible?

Bug: crash report from Play Store - IllegalStateException

I got this crash report:

java.lang.IllegalStateException:
at android.app.FragmentManagerImpl.checkStateLoss (FragmentManagerImpl.java:1858)
at android.app.FragmentManagerImpl.enqueueAction (FragmentManagerImpl.java:1881)
at android.app.BackStackRecord.commitInternal (BackStackRecord.java:688)
at android.app.BackStackRecord.commit (BackStackRecord.java:646)
at android.app.DialogFragment.show (DialogFragment.java:230)
at com.jaredrummler.android.colorpicker.ColorPreference.onClick (ColorPreference.java:109)
at android.preference.Preference.performClick (Preference.java:1135)
at android.preference.PreferenceScreen.onItemClick (PreferenceScreen.java:249)
at android.widget.AdapterView.performItemClick (AdapterView.java:318)
at android.widget.AbsListView.performItemClick (AbsListView.java:1158)
at android.widget.AbsListView$PerformClick.run (AbsListView.java:3127)
at android.widget.AbsListView$3.run (AbsListView.java:4042)
at android.os.Handler.handleCallback (Handler.java:790)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loop (Looper.java:164)
at android.app.ActivityThread.main (ActivityThread.java:6494)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:807)

image

All I do is have normal preferences of this library, such as this one:

    <com.jaredrummler.android.colorpicker.ColorPreference
        android:defaultValue="@color/pref__os_color_primary_default" app:cpv_showAlphaSlider="true"
        android:dependency="@string/pref__use_custom_colors" android:key="@string/pref__os_color_primary"
        android:summary="@string/pref__os_primary_color_desc" android:title="@string/pref__os_primary_color_title"
        app:cpv_allowPresets="true" app:cpv_dialogTitle="@string/pref__os_primary_color_title"
        app:cpv_dialogType="custom"/>

App can be found here:
https://play.google.com/store/apps/details?id=com.lb.lwp_plus

Listeners in fragment

listeners are forced to be included inside activity... inside fragment it gives force close on dismiss and select

Custom dialog style

Can we add custom dialog style ? Like .setDialogStyle(R.style.CustomDialogStyle) and set it as you create the alert dialog.

Add Support for Wallpaper Colors

Would their be a way to create a pallette of colors based on the device's current wallpaper?

Below with the options in the dialog or a button to get wallpaper colors and the pallette of colors be of those with tint options or based on specific dominant colors.

This could be done with either getting the current wallpaper and converting it into a bitmap than using color pallette lib to pull colors or this new Android P wallpaper Colors API?

Crash when initial color is 0

Version:
2.1.5

Code:

ColorPickerDialog dialog = ColorPickerDialog.newBuilder()
                    .setAllowCustom(true)
                    .setAllowPresets(false)
                    .setDialogType(ColorPickerDialog.TYPE_CUSTOM)
                    .setShowAlphaSlider(false)
                    .setDialogTitle(R.string.text_select_color)
                    //HERE! set initial color to 0
                    .setColor(0)
                    .create();

Log:

java.lang.StringIndexOutOfBoundsException: length=1; index=2
at java.lang.String.substring(String.java:1897)
at com.jrummyapps.android.colorpicker.ColorPickerDialog.setHex(ColorPickerDialog.java:354)
at com.jrummyapps.android.colorpicker.ColorPickerDialog.createPickerView(ColorPickerDialog.java:274)
at com.jrummyapps.android.colorpicker.ColorPickerDialog.onCreateDialog(ColorPickerDialog.java:163)
at android.app.DialogFragment.getLayoutInflater(DialogFragment.java:406)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:995)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1171)
at android.app.BackStackRecord.run(BackStackRecord.java:815)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1578)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:483)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

Conflicting style attribute with Preference Support Library

When trying to use the lib while also using the Preference Support Library the build results in a conflict.

Error:(1000) Attribute "dialogTitle" already defined with incompatible format.

You can easily test this by adding the preference support lib to the dependencies of the demo app:
compile "com.android.support:preference-v14:25.1.0"

To solve this i think it would be good to prefix the custom style attributes defined by this library.

How can I use this in Fragment?

How can I use this in Fragment? I have added listener in parent activity of fragment and its working but I want to listen onColorSelected in fragment.
Please help.

npe if colorPickerDialogListener is null

in com.jrummyapps.android.colorpicker.ColorPickerDialog need to add check colorPickerDialogListener not null.
For example, simply throw exception if listener is null on build chain.
Or add checks on every listener methods calls

onColorSelected doesn't work

Looks like onColorSelected is never called, neither when i press "select button" or double-click on colors.

I also implemented ColorPickerDialogListener into fragmente-generator-activity, but nothing happened.

public class Fragment_ColorPicker extends PreferenceFragment implements ColorPickerDialogListener {

    public Fragment_ColorPicker() {
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.color_preferences);
    }

    @Override
    public void onColorSelected(int dialogId, @ColorInt int color) {

        System.out.println("Hello");
    }

    @Override
    public void onDialogDismissed(int dialogId) {

    }
}

Could you help me, please?

Selecting a colour from ColorPickerDialog is causing Null Pointer Exception

Error:
Attempt to invoke interface method 'void com.jaredrummler.android.colorpicker.ColorPickerDialogListener.onColorSelected(int, int)' on a null object reference

This is how I am creating my ColorPickerDialog and I am also setting ColorPickerDialogListener.

  ColorPickerDialog.Builder builder = ColorPickerDialog.newBuilder();
   builder.setDialogType(ColorPickerDialog.TYPE_PRESETS)
           .setAllowPresets(false)
            .setDialogId(12)
            .setColor(Color.BLACK)
            .create().setColorPickerDialogListener(new ColorPickerDialogListener() {
        @Override
        public void onColorSelected(int dialogId, int color) {
            
        }

        @Override
        public void onDialogDismissed(int dialogId) {

        }
    });

    builder.show((Activity)mContext);

Color is an unknown color

This is probably just a google map api incompatibility issue but I tried using this color picker to pick a color for the markers but the color is not valid and an exception is thrown, app crashes

Portuguesese translations

   <string name="cpv_default_title">Selecionar uma cor</string>
    <string name="cpv_presets">Predefinidos</string>
    <string name="cpv_custom">Personalizar</string>
    <string name="cpv_select">Selecionar</string>
    <string name="cpv_transparency">Transparência</string>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.