Git Product home page Git Product logo

Comments (8)

attenzione avatar attenzione commented on June 2, 2024

this code:
mysharedPreferences.getInt("mechanism_color",R.integer.COLOR_Fuchsia);
even not part of ColorPickerPreference, it's part of android.content.SharedPreferences.
The problem is, when you don't have any preferences saved in your app, this code should return default value from second param

from android-colorpickerpreference.

peterwebb avatar peterwebb commented on June 2, 2024

Thanks, yes. I know its my code, so entirely my problem.

However, I am using the ColorPickerPreference in exactly the same way as I am using ListPreference, CheckBoxPreference etc. These all return the correct values (ie the correct DefaultValue) whether I have used the Preference or not. For my ColorPicker Preference, the correct value is not returned until after I have used the Preference the first time. The incorrect value has Red = 5, Blue = 0, Green =1 which is very nearly black, which is a very bad default color. It does not return the default value in my settings.xml, set up as follows:

<com.test.ColorPickerPreference
android:key="mechanism_color" android:title="Mechanism Color"
android:summary="Your preferred mechanism color" android:defaultValue="@integer/COLOR_Fuchsia" />

With COLOR_Fuchsia = 0xffff00ff in my values/integer

Whilst acknowledging that the problem must be mine, I am using the ColorPickerPreference in exactly the same way as all my other Preferences, but it does function differently.

Any suggestions would be welcome.

Peter Webb

from android-colorpickerpreference.

attenzione avatar attenzione commented on June 2, 2024

ListPreference, stores value as String & CheckBoxPreference stores value as Boolean, so u call mysharedPreferences.getString & mysharedPreferences.getBoolean respectively. Maybe it's some issue with SharedPreferences.getInt..
but shouldn't, it's one of android's important function :)
later i'll try to recreate your problem

from android-colorpickerpreference.

peterwebb avatar peterwebb commented on June 2, 2024

I am already in your debt for producing such a terrific
colorpickerPreference, which apart from the problem I am having is great -
it is the only one I know which shows the color directly in the Preference
screen. Very attractive.

Whatever help you may care to provide would be most welcome, but I know from
my own experience that it is almost always something I have done wrong. It
is just that in this case what I am doing seems exactly the same as what I
do for other preferences, which seems to work, so I don't really know where
to go.

Thanks again for your help thus far.

Peter Webb

----- Original Message -----
From: "attenzione"
[email protected]
To: [email protected]
Sent: Monday, April 04, 2011 3:47 PM
Subject: Re: [GitHub] Color Preference default incorrect?
[attenzione/android-ColorPickerPreference GH-7]

ListPreference, stores value as String & CheckBoxPreference stores value
as Boolean, so u call mysharedPreferences.getString &
mysharedPreferences.getBoolean respectively. Maybe it's some issue with
SharedPreferences.getInt..
but shouldn't, it's one of android's important function :)
later i'll try to recreate your problem

Reply to this email directly or view it on GitHub:
#7 (comment)

from android-colorpickerpreference.

attenzione avatar attenzione commented on June 2, 2024

glad to read this strings :)

from android-colorpickerpreference.

henwoods avatar henwoods commented on June 2, 2024

You need to override onSetInitialValue:
@OverRide
protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
onColorChanged(restoreValue ? getValue() : (Integer) defaultValue);
}

from android-colorpickerpreference.

attenzione avatar attenzione commented on June 2, 2024

Thanx roflharrison, i will add this in near future, when i will be available for some programming actions :)
at this time i'm not able to do this.
btw someone can modify code & make pull request, so i'll accept it

from android-colorpickerpreference.

 avatar commented on June 2, 2024

Same problem here, the color:

<color name="colorPrimary">#FF2196F3</color>

Getting recognized as: #FF2096F3 (the 1 is a 0)

Any idea how to fix this?

from android-colorpickerpreference.

Related Issues (20)

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.