Fix duplicate calls to update_minute_1()
This commit is contained in:
21
src/c/main.c
21
src/c/main.c
@@ -129,8 +129,6 @@ static void destroy_animation_handler(Animation *animation, bool finished, void
|
|||||||
animation_destroy(animation);
|
animation_destroy(animation);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool first_minute_update = true;
|
|
||||||
|
|
||||||
static void update_minute_1() {
|
static void update_minute_1() {
|
||||||
// get a tm structure
|
// get a tm structure
|
||||||
time_t temp = time(NULL);
|
time_t temp = time(NULL);
|
||||||
@@ -164,7 +162,7 @@ static void update_minute_1() {
|
|||||||
//// calculate new positions
|
//// calculate new positions
|
||||||
s_date_grect_b = GRect(s_ones_offset[ones], s_date_pos_y, s_date_bt_width, s_date_height);
|
s_date_grect_b = GRect(s_ones_offset[ones], s_date_pos_y, s_date_bt_width, s_date_height);
|
||||||
s_bt_grect_b = GRect(s_bt_pos_x - s_ones_offset[ones], s_bt_pos_y, s_date_bt_width, s_bt_height);
|
s_bt_grect_b = GRect(s_bt_pos_x - s_ones_offset[ones], s_bt_pos_y, s_date_bt_width, s_bt_height);
|
||||||
if (!first_minute_update) {
|
if (!s_first_tick) {
|
||||||
//// configure animations
|
//// configure animations
|
||||||
////// date
|
////// date
|
||||||
PropertyAnimation *date_center_prop = property_animation_create_layer_frame(text_layer_get_layer(s_date_layer), &s_date_grect_a, &s_date_grect_b);
|
PropertyAnimation *date_center_prop = property_animation_create_layer_frame(text_layer_get_layer(s_date_layer), &s_date_grect_a, &s_date_grect_b);
|
||||||
@@ -187,7 +185,6 @@ static void update_minute_1() {
|
|||||||
s_date_grect_a = s_date_grect_b;
|
s_date_grect_a = s_date_grect_b;
|
||||||
s_bt_grect_a = s_bt_grect_b;
|
s_bt_grect_a = s_bt_grect_b;
|
||||||
}
|
}
|
||||||
first_minute_update = false;
|
|
||||||
|
|
||||||
// DEBUG memory usage layer
|
// DEBUG memory usage layer
|
||||||
// static char s_memory_buffer[32];
|
// static char s_memory_buffer[32];
|
||||||
@@ -226,11 +223,6 @@ static void update_minute_30_out_handler(Animation *animation, bool finished, vo
|
|||||||
bitmap_layer_set_bitmap(s_guy_head_layer, s_head);
|
bitmap_layer_set_bitmap(s_guy_head_layer, s_head);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_minute_30() {
|
|
||||||
update_minute_1();
|
|
||||||
schedule_guy_animation(s_butt_raise_template, s_butt_out_template, s_butt_in_template, update_minute_30_out_handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void update_minute_60_out_handler(Animation *animation, bool finished, void *context) {
|
static void update_minute_60_out_handler(Animation *animation, bool finished, void *context) {
|
||||||
// destroy and reassign
|
// destroy and reassign
|
||||||
gbitmap_destroy(s_head);
|
gbitmap_destroy(s_head);
|
||||||
@@ -248,11 +240,6 @@ static void update_minute_60_out_handler(Animation *animation, bool finished, vo
|
|||||||
bitmap_layer_set_bitmap(s_guy_butt_layer, s_butt);
|
bitmap_layer_set_bitmap(s_guy_butt_layer, s_butt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_minute_60() {
|
|
||||||
update_minute_1();
|
|
||||||
schedule_guy_animation(s_head_raise_template, s_head_out_template, s_head_in_template, update_minute_60_out_handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void minute_handler(struct tm *tick_time, TimeUnits units_changed) {
|
static void minute_handler(struct tm *tick_time, TimeUnits units_changed) {
|
||||||
update_minute_1();
|
update_minute_1();
|
||||||
if (s_first_tick) {
|
if (s_first_tick) {
|
||||||
@@ -261,11 +248,9 @@ static void minute_handler(struct tm *tick_time, TimeUnits units_changed) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tick_time->tm_min % 60 == 0) {
|
if (tick_time->tm_min % 60 == 0) {
|
||||||
update_minute_60();
|
schedule_guy_animation(s_head_raise_template, s_head_out_template, s_head_in_template, update_minute_60_out_handler);
|
||||||
} else if (tick_time->tm_min % 30 == 0) {
|
} else if (tick_time->tm_min % 30 == 0) {
|
||||||
update_minute_30();
|
schedule_guy_animation(s_butt_raise_template, s_butt_out_template, s_butt_in_template, update_minute_30_out_handler);
|
||||||
} else {
|
|
||||||
update_minute_1();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user