Skip to content

Commit

Permalink
Fix weather data not update properly
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanDam committed Apr 25, 2020
1 parent 9f5a477 commit 40115c9
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions source/HuwaiiView.mc
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ class HuwaiiView extends WatchUi.WatchFace {
restore_from_resume = true;
last_resume_mili = System.getTimer();

if (HuwaiiApp has :checkPendingWebRequests) { // checkPendingWebRequests() can be excluded to save memory.
App.getApp().checkPendingWebRequests(); // Depends on mDataFields.hasField().
}
checkBackgroundRequest();
}

// Update the view
Expand Down Expand Up @@ -148,6 +146,7 @@ class HuwaiiView extends WatchUi.WatchFace {
// System.println("update");
// System.println("" + clockTime.min + ":" + clockTime.sec);

// Calculate battery consumtion in days
var time_now = Time.now();
if (last_battery_hour == null) {
last_battery_hour = time_now;
Expand Down Expand Up @@ -223,6 +222,7 @@ class HuwaiiView extends WatchUi.WatchFace {
restore_from_resume = false;
}
// in resume time
checkBackgroundRequest();
mainDrawComponents(dc);
force_render_component = false;
} else {
Expand All @@ -231,14 +231,14 @@ class HuwaiiView extends WatchUi.WatchFace {
// continue
last_draw_minute = current_minute;
// minute turn
checkBackgroundRequest();
mainDrawComponents(dc);
} else {
// only draw spatial
// return;
}
}
} else {
last_draw_minute = -1;
// normal power mode
if (restore_from_resume) {
var current_mili = current_tick;
Expand All @@ -249,7 +249,12 @@ class HuwaiiView extends WatchUi.WatchFace {
}
}
force_render_component = true;
if (clockTime.min != last_draw_minute) {
// Only check background web request every 1 minute
checkBackgroundRequest();
}
mainDrawComponents(dc);
last_draw_minute = clockTime.min;
force_render_component = false;
}
force_render_component = false;
Expand All @@ -258,6 +263,7 @@ class HuwaiiView extends WatchUi.WatchFace {
}

function mainDrawComponents(dc) {

checkTheme();

if (force_render_component) {
Expand Down Expand Up @@ -375,9 +381,7 @@ class HuwaiiView extends WatchUi.WatchFace {
var dialDisplay = View.findDrawableById("analog");
dialDisplay.enableSecondHand();

if (HuwaiiApp has :checkPendingWebRequests) { // checkPendingWebRequests() can be excluded to save memory.
App.getApp().checkPendingWebRequests(); // Depends on mDataFields.hasField().
}
checkBackgroundRequest();
}

// Terminate any active timers and prepare for slow updates.
Expand All @@ -401,5 +405,11 @@ class HuwaiiView extends WatchUi.WatchFace {
gbar_color_1 = theme[7];
}
}

function checkBackgroundRequest() {
if (HuwaiiApp has :checkPendingWebRequests) { // checkPendingWebRequests() can be excluded to save memory.
App.getApp().checkPendingWebRequests(); // Depends on mDataFields.hasField().
}
}

}

0 comments on commit 40115c9

Please sign in to comment.