GreatApo / GreatFit

Amazfit APK watchface sources with many additional features and settings
MIT License
116 stars 54 forks source link

Large delay before displaying weather data #68

Closed rain-bipper closed 4 years ago

rain-bipper commented 4 years ago

I can set the weather data by calling Settings.System.putString(context.getApplicationContext ().getContentResolver (), "WeatherInfo", jsonData) and these data are instantly displayed by standard clock widgets: a weather widget and an information screen that slides out from the top of the main screen. However, GreatFit displays new data with a large delay. Unlocking the screen does not help, the data is not updated. Inside the code, 'WatchDataListener.onDataUpdate` is not called by the host for some reason.

I tried to call ISpringBoardHostStub.postDataToProvider(this, 8, new Bundle ()) from my plugin, after calling System.putString but unsuccessfully, WatchDataListener.onDataUpdate is still not called.

Then I added ContentObserver to catch changes in Settings.System and call WatchDataListener.onDataUpdate from there - the weather data began to be updated, but only on the unlocked screen, on the locked one is still not updated. Even if you unlock the screen and see new data - after locking the screen, old data will still be shown.

How can I force to weather data on locked screen to be updated? Please take a look on my PR

GreatApo commented 4 years ago

The weather observer for the watchfaces is registered on "WeatherCheckedSummary" and not on "WeatherInfo" (take a look at com.huami.watch.watchface.AbstractWatchFace in the libs). This is probably why your change doesn't trigger an update.

Try updating that value too... I will also try to test it...

GreatApo commented 4 years ago

I can confirm that updating WeatherCheckSummary instantly refreshes GreatFit. The same way stock watchfaces work, thus I would suggest updating that system value too.

rain-bipper commented 4 years ago

Great, the use of WeatherCheckSummary really works! Thank you. I will then cancel the PR and update my weather plugin.