Languages

Menu
Sites
Language
How to Stop progress bar ? - Native werable SDK 3.0

Hello,

I want to stop progress bar and push new naviframe. I am working on Sample UI Components - Werable SDK3.0.

i just want to know how to use :

Ecore_Timer *p_timer = NULL;
Eina_Bool stop_flag = EINA_TRUE;

//--------------------------------------Progress bar------------------------------------------------------

Ecore_Timer *p_timer = NULL;
Eina_Bool stop_flag = EINA_TRUE;

Evas_Object *
_create_progressbar(appdata_s *ad) {

    Evas_Object *scroller;
	Evas_Object *circle_scroller;
	Evas_Object *nf = ad->nf;
	Evas_Object *progressbar;
	Evas_Object *layout;

	scroller = elm_scroller_add(nf);
	elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE);
	elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF,
			ELM_SCROLLER_POLICY_AUTO);
	evas_object_show(scroller);

	circle_scroller = eext_circle_object_scroller_add(scroller,ad->circle_surface);
	eext_circle_object_scroller_policy_set(circle_scroller,
			ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
	eext_rotary_object_event_activated_set(circle_scroller, EINA_TRUE);

	layout = elm_layout_add(nf);
	elm_layout_file_set(layout, ELM_DEMO_EDJ, "progessbar");
	evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND,
	EVAS_HINT_EXPAND);

	// process style
	progressbar = elm_progressbar_add(layout);
	elm_object_style_set(progressbar, "process");
	evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, 0.5);
	evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND,
	EVAS_HINT_EXPAND);
	evas_object_show(progressbar);
	elm_progressbar_pulse(progressbar, EINA_TRUE);
	elm_object_part_content_set(layout, "process", progressbar);

	progressbar = elm_progressbar_add(layout);
	elm_object_style_set(progressbar, "process/small");
	evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, 0.5);
	evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND,
	EVAS_HINT_EXPAND);
	evas_object_show(progressbar);
	elm_progressbar_pulse(progressbar, EINA_TRUE);
	elm_object_part_content_set(layout, "process/small", progressbar);


	elm_object_content_set(scroller, layout);
	return scroller;
}

void progressbar_cb(void *data, Evas_Object *obj, void *event_info) {
	appdata_s *ad = (appdata_s *) data;
	Evas_Object *scroller;
	Evas_Object *nf = ad->nf;
	Elm_Object_Item *nf_it;

	scroller = _create_progressbar(ad);

	nf_it = elm_naviframe_item_push(nf, "ProgressBar", NULL, NULL, scroller,
			"empty");

	//create_list_view_ble_devices(ad);
}

Regards,

Vrajesh

Edited by: vrajesh s on 05 Apr, 2017

Responses

3 Replies
Shaswati Saha

What are the problems you're facing right now? Please share in detail.

vrajesh s

Hello mam,

Samsung Gear S2 SDK(2.3.2)

I used native circle progress bar. I have one UI . Genlist. Item 1- Scan, Item2 Vibration. Once user press item1 then progress bar will visible. Prgressbar naviframe called.  

Problem1: i want to stop progress bar once BLE scaning is completed. 

Problem2: When progress bar is running with black screen. i want to show progressbar + Scanned Beacon UI where beacons will be listed.

Problem3 ( Genlist issue) : I want to refresh genlist, i intialize genlist  (title, genlist naviframe, etc) before scanning operation is start. once beacon found then i append items to genlist. Here i am facing issue with unique values. If i passed simple text to pointer then get unique values but if i passed pointer value list will be display all values, uniqueness is not there.

 

Problem1:

   
This Create_list_view() called from parent: (item1: BLE Scannig,  Item 2: Vibration)

static void create_list_view(appdata_s *ad) {
    Evas_Object *genlist;
	Evas_Object *circle_genlist;
	Evas_Object *btn;
	//Evas_Object *nf = ad->nf;

	//Elm_Object_Item *nf_it;
	Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
	Elm_Genlist_Item_Class *ttc = elm_genlist_item_class_new();
	Elm_Genlist_Item_Class *ptc = elm_genlist_item_class_new();
	item_data *id;
	int index = 0;

	/* Genlist */
	genlist = elm_genlist_add(ad->nf);
	elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
	evas_object_smart_callback_add(genlist, "selected", gl_selected_cb, NULL);

	circle_genlist = eext_circle_object_genlist_add(genlist,
			ad->circle_surface);
	eext_circle_object_genlist_scroller_policy_set(circle_genlist,
			ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
	eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);

	/* Genlist Title Item style */
	ttc->item_style = "title";
	ttc->func.text_get = _gl_menu_title_text_get;
	ttc->func.content_get = _gl_icon_get;
	ttc->func.del = _gl_menu_del;

	/* Genlist Item style */
	itc->item_style = "default";
	
	itc->func.text_get = _gl_menu_text_get;
	itc->func.content_get = _gl_icon_get;
	itc->func.del = _gl_menu_del;

	/* Genlist Padding Item style */
	ptc->item_style = "padding";
	ptc->func.del = _gl_menu_del;

	/* Title Items Here */
	elm_genlist_item_append(genlist, ttc, NULL, NULL, ELM_GENLIST_ITEM_NONE,
	NULL, NULL);

	/* Main Menu Items Here */

	//pair BLE
	id = calloc(sizeof(item_data), 1);
	id->index = index++;
	id->item = elm_genlist_item_append(genlist, itc, id, NULL,
			ELM_GENLIST_ITEM_NONE, ble_device_list_cb, ad);	//_popup_title_text_2button_cb, //_popup_small_process_cb, progressbar_cb ble_device_list_cb,

	//vibration
	id = calloc(sizeof(item_data), 1);
	id->index = index++;
	id->item = elm_genlist_item_append(genlist, itc, id, NULL,
			ELM_GENLIST_ITEM_NONE, vibration_cb, ad);
	id = calloc(sizeof(item_data), 1);

	elm_genlist_item_append(genlist, ptc, NULL, NULL, ELM_GENLIST_ITEM_NONE,
	NULL, NULL);

	elm_genlist_item_class_free(itc);
	elm_genlist_item_class_free(ttc);
	elm_genlist_item_class_free(ptc);

	/* This button is set for devices which doesn't have H/W back key. */
	btn = elm_button_add(ad->nf);
	elm_object_style_set(btn, "naviframe/end_btn/default");
	elm_naviframe_item_push(ad->nf, NULL, btn, NULL, genlist, "empty");
}

Problem1:

void progressbar_cb(void *data, Evas_Object *obj, void *event_info) {
    appdata_s *ad = (appdata_s *) data;
	Evas_Object *scroller;
	Evas_Object *nf = ad->nf;
	Elm_Object_Item *nf_it;

	scroller = _create_progressbar(ad);

	nf_it = elm_naviframe_item_push(nf, "ProgressBar", NULL, NULL, scroller,
			"empty");

	//create_list_view_ble_devices(ad);

}

//-------------------------------------------Progress bar------------------------------------------------------
Ecore_Timer *p_timer = NULL;
Eina_Bool stop_flag = EINA_TRUE;

Evas_Object *
_create_progressbar(appdata_s *ad) {
    Evas_Object *scroller;
	Evas_Object *circle_scroller;
	Evas_Object *nf = ad->nf;
	Evas_Object *progressbar;
	Evas_Object *layout;
	Evas_Object *label;

	scroller = elm_scroller_add(nf);
	elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE);
	elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF,
			ELM_SCROLLER_POLICY_AUTO);
	evas_object_show(scroller);

	circle_scroller = eext_circle_object_scroller_add(scroller,
			ad->circle_surface);
	eext_circle_object_scroller_policy_set(circle_scroller,
			ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
	eext_rotary_object_event_activated_set(circle_scroller, EINA_TRUE);

	layout = elm_layout_add(nf);
	elm_layout_file_set(layout, ELM_DEMO_EDJ, "progessbar");
	evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND,
	EVAS_HINT_EXPAND);

	// process style
	progressbar = elm_progressbar_add(layout);
	elm_object_style_set(progressbar, "process");
	evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, 0.5);
	evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND,
	EVAS_HINT_EXPAND);
	evas_object_show(progressbar);
	elm_progressbar_pulse(progressbar, EINA_TRUE);
	elm_object_part_content_set(layout, "process", progressbar);

	elm_object_content_set(scroller, layout);
	return scroller;
}

 

Problem3:

//Once i found Bluetooth is on the i will call below callback for scanning process

void __bt_adapter_le_scan_result_cb(int result,
    	bt_adapter_le_device_scan_result_info_s *info, void *user_data) {
	appdata_s *ad = (appdata_s *) user_data;

	//memset(beacon_name1, '\0', sizeof(beacon_name1));

	bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_ADVERTISING;
	if (info == NULL) {
		dlog_print(DLOG_INFO, LOG_TAG, "No discovery_info!");
		return;
	}

	if (info->adv_data_len > 31 || info->scan_data_len > 31) {
		dlog_print(DLOG_INFO, LOG_TAG, "###################");
		bt_adapter_le_stop_scan();
		dlog_print(DLOG_INFO, LOG_TAG, "###################");
		return;
	}

	dlog_print(DLOG_INFO, LOG_TAG, "ad_data_len: %d", info->adv_data_len);

	int addListFlag = 0;

	for (int i = 0; i < info->adv_data_len; i++) {

		//dlog_print(DLOG_INFO, LOG_TAG, "i=%d", i);
		char **uuids;
		char *device_name;
		char device_name1;
		int tx_power_level;
		bt_adapter_le_service_data_s *data_list;
		int appearance;
		int manufacturer_id;
		char *manufacturer_data;
		int manufacturer_data_len;
		int count;

		pkt_type += i;
		if (pkt_type
				== BT_ADAPTER_LE_PACKET_ADVERTISING&& info->adv_data == NULL)
			continue;

		if (pkt_type
				== BT_ADAPTER_LE_PACKET_SCAN_RESPONSE&& info->scan_data == NULL)
			break;

		if (bt_adapter_le_get_scan_result_service_uuids(info, pkt_type, &uuids,
				&count) == BT_ERROR_NONE) {
			int i;
			for (i = 0; i < count; i++) {
				dlog_print(DLOG_INFO, LOG_TAG, "UUID[%d] = %s", i + 1,
						uuids[i]);
				g_free(uuids[i]);
			}
			g_free(uuids);
		}

		//int index = 1;
		if (bt_adapter_le_get_scan_result_device_name(info, pkt_type,
				&device_name) == BT_ERROR_NONE) {

			dlog_print(DLOG_INFO, LOG_TAG, "Device name = %s", device_name);

			dlog_print(DLOG_ERROR, LOG_TAG, "Device name Address = %u",
					&device_name);

			dlog_print(DLOG_INFO, LOG_TAG, "Remote Address: %s",
					info->remote_address);

			dlog_print(DLOG_INFO, LOG_TAG,
					"adv_data: %s, adv_data_lenL:%d, scan_data:%s, scan_data_len:%d, rssi:%d",
					info->adv_data, info->adv_data_len, info->scan_data,
					info->scan_data_len, info->rssi);

			char* chipPrefixStr = "FXXXXp XXX"; // some pattern device found

		    //search - find that chip			
			if (strstr(device_name, chipPrefixStr)) {
				//bt_adapter_le_stop_scan(); //temporary
				char* finalDname = getFinalDeviceName(device_name,chipPrefixStr);
				dlog_print(DLOG_INFO, LOG_TAG1,
						"Formated Final Device name = %s", finalDname);

				int len = sizeof(beacon_name1) / sizeof(beacon_name1[0]);
				dlog_print(DLOG_INFO, LOG_TAG1, "Len= %d", len);

				char simple = finalDname;
				//char *s = "BA-0001";

				char *s=finalDname;
				//char s=device_name;

				dlog_print(DLOG_INFO, LOG_TAG1, "s= %s", s);
				<strong>int flag = arraySearchOpr1(beacon_name1, s);</strong>
				if (flag == 1) {
					dlog_print(DLOG_ERROR, LOG_TAG2, "Found");
					addListFlag = 0;
				} else {
					dlog_print(DLOG_ERROR, LOG_TAG2, "NotFound");
					beacon_name1[counter_ble] = s;
					counter_ble++;
					addListFlag = 1;
				}

				//print array:
				for (int i = 0; i < len; i++) {
					dlog_print(DLOG_ERROR, LOG_TAG2, "beacon_name1[%d]= %s", i,
							beacon_name1[i]);
				}
				//when click any beacon set below method for it.
				//gatt_operation2(info->remote_address);
			}
			//break;
		}

		if (bt_adapter_le_get_scan_result_tx_power_level(info, pkt_type,
				&tx_power_level) == BT_ERROR_NONE) {
			dlog_print(DLOG_INFO, LOG_TAG, "TX Power level = %d",
					tx_power_level);
		}

		if (bt_adapter_le_get_scan_result_service_solicitation_uuids(info,
				pkt_type, &uuids, &count) == BT_ERROR_NONE) {
			int i;
			for (i = 0; i < count; i++) {
				dlog_print(DLOG_INFO, LOG_TAG, "Solicitation UUID[%d] = %s",
						i + 1, uuids[i]);
				g_free(uuids[i]);
			}
			g_free(uuids);
		}

		if (bt_adapter_le_get_scan_result_service_data_list(info, pkt_type,
				&data_list, &count) == BT_ERROR_NONE) {
			int i;
			for (i = 0; i < count; i++) {
				dlog_print(DLOG_INFO, LOG_TAG,
						"Service Data[%d] = [0x%2.2X%2.2X:0x%.2X...]", i + 1,
						data_list[i].service_uuid[0],
						data_list[i].service_uuid[1],
						data_list[i].service_data[0]);
				bt_adapter_le_free_service_data_list(data_list, count);
			}
		}

		if (bt_adapter_le_get_scan_result_appearance(info, pkt_type,
				&appearance) == BT_ERROR_NONE) {
			dlog_print(DLOG_INFO, LOG_TAG, "Appearance = %d", appearance);
		}
		if (bt_adapter_le_get_scan_result_manufacturer_data(info, pkt_type,
				&manufacturer_id, &manufacturer_data, &manufacturer_data_len)
				== BT_ERROR_NONE) {
			dlog_print(DLOG_INFO, LOG_TAG,
					"Manufacturer data[ID:%.4X, 0x%.2X%.2X...(len:%d)]",
					manufacturer_id, manufacturer_data[0], manufacturer_data[1],
					manufacturer_data_len);
			g_free(manufacturer_data);
		}
		//dlog_print(DLOG_INFO, LOG_TAG, "last call for loop %d", i);

	}//for loop ends

//bt_adapter_le_stop_scan();

//display only first time
	item_data *id;
	dlog_print(DLOG_INFO, LOG_TAG1, "outer");
	if (addListFlag == 1) {
		dlog_print(DLOG_ERROR, LOG_TAG1, "if ");
		ad->itc->item_style = "default";
		ad->itc->func.text_get = _gl_menu_text_get_ble;
		ad->itc->func.del = _gl_menu_del;

		int len = sizeof(beacon_name1) / sizeof(beacon_name1[0]);

		for (int i = 0; i < len; i++) {
			if (beacon_name1[i] != NULL) {
				//int flag = arraySearchOpr1(beacon_name1, beacon_name1[i]);
				//notfound

				id = calloc(sizeof(item_data), 1);
				id->index = i;
				id->item = elm_genlist_item_append(ad->genlist_ble, ad->itc, id,
				NULL, ELM_GENLIST_ITEM_NONE, vibration_cb,
						info->remote_address);

				elm_genlist_item_class_free(ad->itc);

			}
		}
		dlog_print(DLOG_ERROR, LOG_TAG1, "end of if");
	}
}

//logic for seach items from array
int arraySearchOpr1(char *arry[], char *s) {
    //char *arr[] = { "100", "200", "300" };
	int size, k, flag;

	size = sizeof(*arry) / sizeof(*arry[0]);
	flag = 0;
	for (k = 0; k < size; k++) {
		/*
		 * If element is found in the array
		 */
		if (arry[k] == s) {
			flag = 1;
			break;
		}
	}
	return flag;
}

//Format Device name:
char* getFinalDeviceName(char* main, char* substring) {
    int i, j = 0, k = 0;
//char str[100], key[20];
	char str1[10][20];

	for (i = 0; main[i] != '\0'; i++) {
		if (main[i] == ' ') {
			str1[k][j] = '\0';
			k++;
			j = 0;
		} else {
			str1[k][j] = main[i];
			j++;
		}
	}
	str1[k][j] = '\0';

	/* Compares the string with given word */
	for (i = 0; i < k + 1; i++) {
		if (strcmp(str1[i], substring) == 0) {
			for (j = i; j < k + 1; j++)
				strcpy(str1[j], str1[j + 1]);
			k--;
		}
	}

	for (i = 0; i < k + 1; i++) {
		printf("\nRemoveString1 %s ", str1[i]);
		dlog_print(DLOG_INFO, LOG_TAG, "RemoveString1 %s ", str1[i]);
	}

  //last index like : BA-000231
  //dlog_print(DLOG_INFO, LOG_TAG, "Last Index %s", str1[k]);
  //dlog_print(DLOG_INFO, LOG_TAG, "Final Formated1 %.*s", 7, str1[k]);

	char finalStr[10];
	memset(finalStr, '\0', sizeof(finalStr)); //to clear memory location.
	strncpy(finalStr, str1[k], 7);

//dlog_print(DLOG_INFO, LOG_TAG, "Final Formated %s", finalStr);

	return finalStr;
}

static void create_list_view_ble_devices(appdata_s *ad) {

    Evas_Object *circle_genlist;
	Evas_Object *btn;
	Evas_Object *nf = ad->nf;

	//Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
	ad->itc = elm_genlist_item_class_new();
	ad->ptc = elm_genlist_item_class_new();
	ad->ttc = elm_genlist_item_class_new();

	item_data *id;

	ad->index_ble = 0;

	/* Genlist */
	ad->genlist_ble = elm_genlist_add(nf);
	elm_genlist_mode_set(ad->genlist_ble, ELM_LIST_COMPRESS);
	evas_object_smart_callback_add(ad->genlist_ble, "selected", gl_selected_cb,
	NULL);

	circle_genlist = eext_circle_object_genlist_add(ad->genlist_ble,
			ad->circle_surface);
	eext_circle_object_genlist_scroller_policy_set(circle_genlist,
			ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
	eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);

	/* Genlist Title Item style */
	ad->ttc->item_style = "title";
	ad->ttc->func.text_get = _gl_menu_title_text_get_ble;
	ad->ttc->func.del = _gl_menu_del;

	/* Genlist Padding Item style */
	ad->ptc->item_style = "padding";
	ad->ptc->func.del = _gl_menu_del;

	elm_genlist_item_append(ad->genlist_ble, ad->ttc, NULL, NULL,
			ELM_GENLIST_ITEM_NONE, NULL, NULL);

	//static way - works:
	/*int len = sizeof(main_menu_names_ble) / sizeof(main_menu_names_ble[0]);
	 for (int i = 0; i < len; i++) {
	 id = calloc(sizeof(item_data), 1);
	 id->index = ad->index_ble++;
	 id->item = elm_genlist_item_append(ad->genlist_ble, ad->itc, id, NULL,ELM_GENLIST_ITEM_NONE, vibration_cb, ad);
	 }
	 elm_genlist_item_append(ad->genlist_ble, ad->ptc, NULL, NULL,ELM_GENLIST_ITEM_NONE,NULL, NULL);
	 */

	//elm_genlist_item_class_free(ad->itc);
	elm_genlist_item_class_free(ad->ttc);
	//elm_genlist_item_class_free(ad->ptc);

	//add naviframe- genlist after beacon successfully scaned.

	//progress bar call...
	Evas_Object *scroller;
	Elm_Object_Item *nf_it;
	scroller = _create_progressbar(ad);

	//add genlist to
	elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, ad->genlist_ble, "empty");

	//start scanning process
	startScaningBLE(ad);
}

//Set title for create_list_view_ble_devices
static char *
_gl_menu_title_text_get_ble(void *data, Evas_Object *obj, const char *part) {
    char buf[1024];
	snprintf(buf, 1023, "%s", "BLE Devices");
	return strdup(buf);
}

//Array - list items - beacon names. 
static char *
_gl_menu_text_get_ble(void *data, Evas_Object *obj, const char *part) {
    char buf[1024];
	item_data *id = (item_data *) data;
	int index = id->index;

	if (!strcmp(part, "elm.text")) {
		snprintf(buf, 1023, "%s", beacon_name1[index]);
		return strdup(buf);
	}
	return NULL;
}

 

Shaswati Saha

Hi,

For the Problem1 you may try with this line below:
 

evas_object_hide(progressbar);

You may simply hide the progress bar instead of trying to stop once the scanning is done.

For the Problem3, to update the genlist you may use the elm_genlist_item_item_class_update() function. Please follow this link. You'll find a code snippet here containing instructions about updating genlist.

Unfortunately I couldn't understand the second problem. I think, it'll be better if you share some pictures to show the requirements. 

Moreover, you may also go through the UIComponents sample app to get some basic ideas about different types of ui components.