From f98f5066036b133bfa7d2d5f96a28c8581404d70 Mon Sep 17 00:00:00 2001 From: "bhutani.92" Date: Fri, 6 Jan 2017 20:18:55 +0530 Subject: [PATCH] [TSAM-12421] Checkbox auto uncheck on language change Change-Id: I3e010011f41a927bcfc62f29d9253fe2aceb78f1 Signed-off-by: bhutani.92 --- src/widget/mp-album-detail-list.c | 47 ++++++++++++++++++++++++++------------ src/widget/mp-artist-detail-list.c | 41 ++++++++++++++++++++++++--------- src/widget/mp-artist-list.c | 2 -- src/widget/mp-list.c | 2 +- 4 files changed, 64 insertions(+), 28 deletions(-) diff --git a/src/widget/mp-album-detail-list.c b/src/widget/mp-album-detail-list.c index 8b1ccfc..5ef4410 100644 --- a/src/widget/mp-album-detail-list.c +++ b/src/widget/mp-album-detail-list.c @@ -239,9 +239,17 @@ static void _mp_album_detail_list_append_item(MpAlbumDetailList_t * list, int index = 0; for (index = 0; index < count; index++) { mp_media_info_h item = NULL; - item = mp_media_info_list_nth_item(svc_handle, index); + char *title = NULL; mp_list_item_data_t *item_data; + item = mp_media_info_list_nth_item(svc_handle, index); + if (!item) { + DEBUG_TRACE + ("Fail to mp_media_info_group_list_nth_item, index[%d]", index); + goto END; + } + mp_media_info_get_file_path(item, &title); + #ifdef MP_FEATURE_PERSONAL_PAGE char *path = NULL; mp_media_info_get_file_path(item, &path); @@ -258,24 +266,29 @@ static void _mp_album_detail_list_append_item(MpAlbumDetailList_t * list, continue; } } - append_album_items: +append_album_items: #endif - item_data = calloc(1, sizeof(mp_list_item_data_t)); - MP_CHECK(item_data); - item_data->handle = item; - item_data->index = index; - item_data->group_type = MP_GROUP_NONE; - - item_data->it = - elm_genlist_item_append(list->genlist, list->itc, item_data, - NULL, ELM_GENLIST_ITEM_NONE, - _mp_album_detail_genlist_sel_cb, list); - elm_object_item_data_set(item_data->it, item_data); + item_data = calloc(1, sizeof(mp_list_item_data_t)); + MP_CHECK(item_data); + item_data->handle = item; + item_data->index = index; + item_data->group_type = MP_GROUP_NONE; + if (list->edit_mode) { + item_data->checked = + mp_list_is_in_checked_path_list(list->checked_path_list, + title); } - endfunc; + item_data->it = + elm_genlist_item_append(list->genlist, list->itc, item_data, + NULL, ELM_GENLIST_ITEM_NONE, + _mp_album_detail_genlist_sel_cb, list); + elm_object_item_data_set(item_data->it, item_data); + } + END: + endfunc; } static char *_mp_album_detail_list_album_text_get(void *data, @@ -668,6 +681,8 @@ static void _mp_album_detail_list_destory_cb(void *thiz) list->itc_shuffle = NULL; } + mp_list_free_checked_path_list(list->checked_path_list); + IF_FREE(list->type_str); IF_FREE(list->type_str2); IF_FREE(list->filter_str); @@ -731,6 +746,10 @@ static void _mp_album_detail_list_update(void *thiz) MP_CHECK(res == 0); list->track_count = count; + mp_list_free_checked_path_list(list->checked_path_list); + list->checked_path_list = + mp_list_get_checked_path_list((MpList_t *) list); + mp_evas_object_del(list->no_content); mp_evas_object_del(list->genlist); diff --git a/src/widget/mp-artist-detail-list.c b/src/widget/mp-artist-detail-list.c index 50a9e77..91df586 100644 --- a/src/widget/mp-artist-detail-list.c +++ b/src/widget/mp-artist-detail-list.c @@ -26,6 +26,8 @@ #include "mp-minicontroller.h" #include "mp-common.h" +int selected_tracks_count; + static char *_mp_artist_detail_list_album_label_get(void *data, Evas_Object * obj, const char *part) @@ -438,14 +440,6 @@ static int _mp_artist_detail_list_append_album_tracks(void *thiz, mp_media_list_h svc_handle; /*clear genlist */ - /* - Elm_Object_Item *item = elm_genlist_first_item_get(list->genlist); - if (item) - { - elm_genlist_item_bring_in(item, ELM_GENLIST_ITEM_SCROLLTO_IN); - elm_genlist_clear(list->genlist); - } - */ /*get data from DB */ int ret = 0; int count = 0; @@ -502,6 +496,14 @@ static int _mp_artist_detail_list_append_album_tracks(void *thiz, MP_CHECK_VAL(item_data, real_count); item_data->handle = item; item_data->index = index; + if (list->edit_mode) { + item_data->checked = + mp_list_is_in_checked_path_list(list->checked_path_list, + path); + if (item_data->checked) { + selected_tracks_count++; + } + } item_data->it = elm_genlist_item_append(list->genlist, list->itc_track, @@ -727,7 +729,7 @@ static void _mp_artist_detail_list_load_list(void *thiz, int count) 0, count); if (ret != 0) { - DEBUG_TRACE("Fail to get items"); + ERROR_TRACE("Fail to get items"); goto END; } @@ -740,6 +742,8 @@ static void _mp_artist_detail_list_load_list(void *thiz, int count) mp_media_info_h item = NULL; Elm_Object_Item *list_item = NULL; char *title = NULL; + char *full_path = NULL; + Elm_Object_Item *item_track; item = mp_media_info_group_list_nth_item(svc_handle, index); if (!item) { @@ -749,6 +753,7 @@ static void _mp_artist_detail_list_load_list(void *thiz, int count) goto END; } mp_media_info_group_get_main_info(item, &title); + mp_list_item_data_t *item_data; item_data = mp_list_item_data_create @@ -770,12 +775,19 @@ static void _mp_artist_detail_list_load_list(void *thiz, int count) } /* append tracks of the album */ + selected_tracks_count = 0; // Getting the number of tracks selected within an album int appended_track_num = _mp_artist_detail_list_append_album_tracks(list, title, list_item); if (!appended_track_num) { elm_object_item_del(list_item); list->count_album--; + } else { + if (list->edit_mode && (appended_track_num == selected_tracks_count)) { + item_data->checked = true; + } else { + item_data->checked = false; + } } } @@ -808,6 +820,8 @@ void _mp_artist_detail_list_destory_cb(void *thiz) list->itc_shuffle = NULL; } + mp_list_free_checked_path_list(list->checked_path_list); + IF_FREE(list->type_str); IF_FREE(list->filter_str); @@ -918,8 +932,13 @@ void _mp_artist_detail_list_update(void *thiz) DEBUG_TRACE("count is %d", count_album); list->count_album = count_album; - mp_evas_object_del(list->genlist); + mp_list_free_checked_path_list(list->checked_path_list); + list->checked_path_list = + mp_list_get_checked_path_list((MpList_t *) list); + mp_evas_object_del(list->no_content); + mp_evas_object_del(list->genlist); + if (count_album) { /*create new genlist */ @@ -1078,7 +1097,7 @@ _mp_artist_detail_list_selected_item_data_get(void *thiz, item = mp_list_item_next_get(item); } END: - if (selected) { + if (selected || sel_list) { *selected = sel_list; } } diff --git a/src/widget/mp-artist-list.c b/src/widget/mp-artist-list.c index ae92e5b..390b244 100644 --- a/src/widget/mp-artist-list.c +++ b/src/widget/mp-artist-list.c @@ -609,8 +609,6 @@ static void _mp_artist_list_gengrid_create(MpArtistList_t * list) MP_CHECK(list); /*create new genlist */ - mp_evas_object_del(list->genlist); - list->genlist = elm_gengrid_add(list->box); MP_CHECK(list->genlist); evas_object_size_hint_weight_set(list->genlist, EVAS_HINT_EXPAND, diff --git a/src/widget/mp-list.c b/src/widget/mp-list.c index e9abe90..a8c3992 100644 --- a/src/widget/mp-list.c +++ b/src/widget/mp-list.c @@ -436,7 +436,7 @@ static void _mp_list_selected_item_data_get(void *thiz, GList ** selected) item = mp_list_item_next_get(item); } END: - if (selected) { + if (selected || sel_list) { *selected = sel_list; } } -- 2.7.4