preferator icon indicating copy to clipboard operation
preferator copied to clipboard

registerOnSharedPreferenceChangeListener behavior

Open tanwarsatya opened this issue 7 years ago • 1 comments

Hi Sloy,

Thanks for the amazing work you did, it has reduced a good amount of time in development of our settings module. We are noticing an issue when we have registered a listener to added SharedPreferences. The listener is working fine, but in certain cases where we are updating a string or int it's raising the callback on each key press. The normal behavior we were expecting was to receive a callback once uses completes the editing one field and moves out of the textview.

Any idea what might be happening here, i haven't looked into the code yet. Again thx a lot for great piece of work.

tanwarsatya avatar Mar 31 '18 02:03 tanwarsatya

Hi @tanwarsatya, I'm glad it's helping you :)

The behaviour you're seeing is consistent with how things are working internally. The preferences are saved on each key press. It was done that way to simplify things, but maybe it would work just as fine with other callback in the EditText, like focus change or something like that. Would you like to try that out?

Sloy avatar Mar 31 '18 08:03 Sloy