Skip to content
This repository was archived by the owner on Jun 28, 2022. It is now read-only.
This repository was archived by the owner on Jun 28, 2022. It is now read-only.

[!] Symbol changes are not saving correctly to disk SharedPreferences #32

@bumxu

Description

@bumxu

When a stock symbol is added or removed, the change is applied immediately to the current view, however, when the app is restarted, none of the previous changes in stock list exist.
Reproduced on three devices.

Sample cases:

On first run, AAPL, FB, MSFT and YHOO are stored, then, we add A and B, app syncs correctly, if we swipe to refresh app syncs correctly too. Now we finish the activity and reopen Stock Hawk, app syncs, but only AAPL, FB, MSFT and YHOO are updated from Internet.

On first run, AAPL, FB, MSFT and YHOO are stored, then, we removed AAPL, if we swipe to refresh the behavior is the expected. Now we finish the activity and reopen Stock Hawk, app syncs, but ALL them AAPL, FB, MSFT and YHOO are updated from Internet.

Screen record (toast shows the updated symbols):

https://www.youtube.com/watch?v=8t31WMCwzpE

Possible approah:

From Android docs:

Note that you must not modify the set instance returned by this call. The consistency of the stored data is not guaranteed if you do, nor is your ability to modify the instance at all.

Maybe this is not relevant with the case, but replacing PrefUtils.js : editStockPref : 2 seems to fix the entire problem.

Set<String> stocks = getStocks(context);

to

Set<String> stocks = new HashSet<>(getStocks(context));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions