Example #1
0
static void prv_init(void) {
  if (!s_handler_list) {
    s_handler_list = linked_list_create_root();
  }
  if (linked_list_count(s_handler_list) == 0) {
    battery_state_service_subscribe(prv_handle_state_change);
  }
}
Example #2
0
static void prv_init(void) {
  if (!s_handler_list) {
    s_handler_list = linked_list_create_root();
  }
  if (linked_list_count(s_handler_list) == 0) {
    app_focus_service_subscribe_handlers((AppFocusHandlers) {
      .will_focus = prv_handle_will_focus,
      .did_focus = prv_handle_did_focus,
    });
Example #3
0
static bool prv_init(void) {
  if (!s_handler_list) {
    s_handler_list = linked_list_create_root();
  }
  if (linked_list_count(s_handler_list) == 0) {
    app_message_register_outbox_sent(prv_handle_outbox_sent);
    app_message_register_outbox_failed(prv_handle_outbox_failed);
    app_message_register_inbox_received(prv_handle_inbox_received);
    app_message_register_inbox_dropped(prv_handle_inbox_dropped);
  }
  return true;
}
void localize_init(uint32_t resource_locale) {

  if(s_previous_locale == resource_locale)
    return;

  if(s_root == NULL){
    s_root = linked_list_create_root();
  }
  else {
    linked_list_foreach(s_root, prv_destroy_element, NULL);
    linked_list_clear(s_root);
  }

  s_previous_locale = resource_locale;
}
/**
* Parses messages received from phone and fowards them to correct class for processing
* @params: (see Pebble API for details)
*/
static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
  LOG("Message received!");
  LOG("Size: %i", (int)dict_size(iterator)); 
  Tuple *data_type = dict_find(iterator, MESSAGE_TYPE_INDEX);

  //Parse message
  if (data_type) {
    char * type = data_type->value->cstring;
    LOG("Message received with type: %s", type);

    char* header = dict_find(iterator, MESSAGE_HEADER_INDEX)->value->cstring;

    //Put all data into a linked list and send to handlers.
    LinkedRoot* data = linked_list_create_root();

    for (int i= MESSAGE_DATA_ROOT; i < MESSAGE_DATA_ROOT + MESSAGE_DATA_MAX; i++) {
      Tuple* single_data = dict_find(iterator, i);
      if (single_data){
        linked_list_append(data, single_data->value->cstring);
      }
      else break;
    }

    if (strcmp(type,"READY") == 0) {
      jsReady = true;
      return;
    };
    if (strcmp(type,"MOVES") == 0) {
      workout_parse_message(header, data);
    }
    if (strcmp(type,"WORKOUTS") == 0) {
      storage_store_workouts(header, data);
      vibes_short_pulse();
    }

  }
}
Example #6
0
void timers_init(void) {
  timers_cleanup();
  timers = linked_list_create_root();
  update_handlers = linked_list_create_root();
  highlight_handlers = linked_list_create_root();
}
Example #7
0
void timers_init(void) {
  timers = linked_list_create_root();
}
Example #8
0
/**
 * Initialization function. Registers preset messages, creates the presets list, and sets up the tick timer for preset ETA countdown.
 */
void presets_init(void){
	mqueue_register_handler("PRESET", eta_handler);
	presets = linked_list_create_root();
	tick_timer_service_subscribe(MINUTE_UNIT, tick_callback);
}
Example #9
0
static void before_each(void) {
  root = linked_list_create_root();
}
Example #10
0
void bitmaps_init() {
  bitmaps_cleanup();
  bitmaps = linked_list_create_root();
}
Example #11
0
void persist_init(void) {
  persistence = linked_list_create_root();
}