{"action":"closed","issue":{"url":"https://api.github.com/repos/martin-stone/hsv-alpha-color-picker-android/issues/42","repository_url":"https://api.github.com/repos/martin-stone/hsv-alpha-color-picker-android","labels_url":"https://api.github.com/repos/martin-stone/hsv-alpha-color-picker-android/issues/42/labels{/name}","comments_url":"https://api.github.com/repos/martin-stone/hsv-alpha-color-picker-android/issues/42/comments","events_url":"https://api.github.com/repos/martin-stone/hsv-alpha-color-picker-android/issues/42/events","html_url":"https://github.com/martin-stone/hsv-alpha-color-picker-android/issues/42","id":304103114,"number":42,"title":"getColor() doesn't always return latest value","user":{"login":"ZeevoX","id":8385172,"avatar_url":"https://avatars1.githubusercontent.com/u/8385172?v=4","gravatar_id":"","url":"https://api.github.com/users/ZeevoX","html_url":"https://github.com/ZeevoX","followers_url":"https://api.github.com/users/ZeevoX/followers","following_url":"https://api.github.com/users/ZeevoX/following{/other_user}","gists_url":"https://api.github.com/users/ZeevoX/gists{/gist_id}","starred_url":"https://api.github.com/users/ZeevoX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ZeevoX/subscriptions","organizations_url":"https://api.github.com/users/ZeevoX/orgs","repos_url":"https://api.github.com/users/ZeevoX/repos","events_url":"https://api.github.com/users/ZeevoX/events{/privacy}","received_events_url":"https://api.github.com/users/ZeevoX/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-03-10T20:40:52Z","updated_at":"2018-03-11T07:44:31Z","closed_at":"2018-03-11T07:44:31Z","author_association":"NONE","body":"I've been battling this problem I've been having and it seemed to me that something was wrong in my code, but according to the debugger it appears to be within this library. \r\n\r\nI am using the latest version of this library (v2.3.0) and I have tried different targetSdk, compileSdk and Support Library revisions to no avail.\r\n\r\nI have a `ColorPreference` on which I am calling `setOnPreferenceChangeListener`, and within that code I call...\r\n``` java\r\nInteger gradientEndColorValue = ((ColorPreference) findPreference(\"gradient_end_color\")).getColor();\r\n```\r\n...so that I can then compare the value of `gradientEndColorValue` to another `Integer` color value.\r\n\r\nBut, according to the debugger, when I press \"OK\" on the dialog, the `onPreferenceChangeListener` is called, but `getColor()` returns the previous value, since `SharedPreferences` [hasn't written the new value to the store yet](https://developer.android.com/reference/android/content/SharedPreferences.Editor.html#apply()) since `SharedPreferences.Editor.apply()` is asynchronous. \r\n\r\nI believe this library reads from SharedPreferences when calling `getColor()` in the following lines of code: [ColorPreference.java#L119-L123](https://github.com/martin-stone/hsv-alpha-color-picker-android/blob/master/colorpicker/src/main/java/com/rarepebble/colorpicker/ColorPreference.java#L119-L123)\r\n\r\nWould it be possible to store the current value in a variable so that `getColor()` returns the latest latest value, something like Android's [ListPreference](https://github.com/aosp-mirror/platform_frameworks_base/blob/master/core/java/android/preference/ListPreference.java#L42)?\r\n\r\nIf you would like any debugger information, then I am happy to share it. Thank you!"}}
{"actor":{"display_login":"ZeevoX"}}