1616
1717#include "quota_window.h"
1818#include "usage_layer.h"
19- #include "../util/thinking_layer .h"
19+ #include "../util/vector_sequence_layer .h"
2020#include "../util/style.h"
2121
2222#include <pebble.h>
2525typedef struct {
2626 UsageLayer * usage_layer ;
2727 TextLayer * explanation_layer ;
28- ThinkingLayer * thinking_layer ;
28+ GDrawCommandSequence * loading_sequence ;
29+ VectorSequenceLayer * loading_layer ;
2930 EventHandle app_message_handle ;
3031 ScrollLayer * scroll_layer ;
3132 StatusBarLayer * status_bar ;
@@ -63,10 +64,14 @@ static void prv_window_load(Window* window) {
6364 text_layer_set_font (data -> explanation_layer , fonts_get_system_font (FONT_KEY_GOTHIC_24 ));
6465 scroll_layer_add_child (data -> scroll_layer , (Layer * )data -> explanation_layer );
6566 scroll_layer_add_child (data -> scroll_layer , (Layer * )data -> usage_layer );
66- // We need to look up the quota, so we'll show the thinking layer while we do that.
67- data -> thinking_layer = thinking_layer_create (GRect (bounds .size .w / 2 - THINKING_LAYER_WIDTH / 2 , bounds .size .h / 2 - THINKING_LAYER_HEIGHT / 2 , THINKING_LAYER_WIDTH , THINKING_LAYER_HEIGHT ));
68- layer_add_child (root_layer , data -> thinking_layer );
67+ // We need to look up the quota, so we'll show a running pony while we do that.
68+ data -> loading_sequence = gdraw_command_sequence_create_with_resource (RESOURCE_ID_RUNNING_PONY );
69+ GSize pony_size = gdraw_command_sequence_get_bounds_size (data -> loading_sequence );
70+ data -> loading_layer = vector_sequence_layer_create (GRect (bounds .size .w / 2 - pony_size .w / 2 , bounds .size .h / 2 - pony_size .h / 2 , pony_size .w , pony_size .h ));
71+ vector_sequence_layer_set_sequence (data -> loading_layer , data -> loading_sequence );
72+ layer_add_child (root_layer , data -> loading_layer );
6973 layer_add_child (root_layer , (Layer * )data -> status_bar );
74+ vector_sequence_layer_play (data -> loading_layer );
7075 data -> app_message_handle = events_app_message_register_inbox_received (prv_app_message_received , window );
7176 prv_fetch_quota (window );
7277}
@@ -75,7 +80,8 @@ static void prv_window_unload(Window* window) {
7580 QuotaWindowData * data = window_get_user_data (window );
7681 usage_layer_destroy (data -> usage_layer );
7782 text_layer_destroy (data -> explanation_layer );
78- thinking_layer_destroy (data -> thinking_layer );
83+ vector_sequence_layer_destroy (data -> loading_layer );
84+ gdraw_command_sequence_destroy (data -> loading_sequence );
7985 events_app_message_unsubscribe (data -> app_message_handle );
8086 free (data );
8187}
@@ -105,6 +111,7 @@ static void prv_app_message_received(DictionaryIterator* iter, void* context) {
105111 snprintf (data -> explanation , sizeof (data -> explanation ), "You've used %d%% of your Bobby quota for this month. Once you've used 100%%, Bobby will stop working until next month. Quota resets on the first day of each month." , ((used * 100 ) / (used + remaining )));
106112 text_layer_set_text (data -> explanation_layer , data -> explanation );
107113 usage_layer_set_percentage (data -> usage_layer , (int16_t )((used * PERCENTAGE_MAX ) / (used + remaining )));
108- layer_remove_from_parent (data -> thinking_layer );
114+ vector_sequence_layer_stop (data -> loading_layer );
115+ layer_remove_from_parent (data -> loading_layer );
109116 layer_add_child (root_layer , (Layer * )data -> scroll_layer );
110117}
0 commit comments