burhanloey / waktu-solat

Prayer times for Malaysia fetched from e-Solat Portal
BSD 2-Clause "Simplified" License
0 stars 1 forks source link

District spinner does not load previous state #13

Closed burhanloey closed 5 years ago

burhanloey commented 5 years ago

It technically does, but it gets reset back by state spinner.

During onCreate(), when state spinner calls setSelection(), it executes the listener as well, resetting the district spinner to first item. The problem gets worse because the listener execution is highly likely a message queue, meaning there is no way to execute it in order.

One solution, albeit a dirty hack, is to just use postDelayed().

burhanloey commented 5 years ago

Correction: The listener is not a message queue, it's just that the listener will only run after onCreate() is done.

burhanloey commented 5 years ago

Found a neat trick by using TouchListener: https://stackoverflow.com/a/28466880/3987167

burhanloey commented 5 years ago

Fixed by e3d5e4bc39068e8fa318d29bc6b356b4851f202c