listmgr: focus to recently played content when viewer view is popped 49/43749/3
authorJehun Lim <jehun.lim@samsung.com>
Mon, 13 Jul 2015 12:58:55 +0000 (21:58 +0900)
committerJehun Lim <jehun.lim@samsung.com>
Tue, 14 Jul 2015 02:10:46 +0000 (11:10 +0900)
Change-Id: I07ce24107e97c7415d608e8892d662d306788669
Signed-off-by: Jehun Lim <jehun.lim@samsung.com>
include/util/listmgr.h
src/layout/gallery.c
src/layout/movie.c
src/util/listmgr.c
src/view/base.c

index 121c97e..7272023 100644 (file)
@@ -50,4 +50,6 @@ bool listmgr_draw_list_area(struct listmgr *lmgr);
 bool listmgr_update_content_list(struct listmgr *lmgr, Eina_List *list);
 bool listmgr_update_play_info(struct listmgr *lmgr, app_media_info *info);
 
+bool listmgr_update_focus_item(struct listmgr *lmgr, int index);
+
 #endif /* __AIR_MEDIAHUB_LISTMGR_H__ */
index 673a280..ed45631 100644 (file)
@@ -315,6 +315,7 @@ static void _hide(void *layout_data)
 static void _update(void *layout_data, int update_type, void *data)
 {
        struct _priv *priv;
+       int index;
 
        if (!layout_data) {
                _ERR("failed to get layout data");
@@ -323,7 +324,23 @@ static void _update(void *layout_data, int update_type, void *data)
 
        priv = layout_data;
 
-       _update_list_area(priv);
+       switch (update_type) {
+       case UPDATE_CONTENT:
+               _update_list_area(priv);
+               break;
+       case UPDATE_FOCUS:
+               if (!data) {
+                       _ERR("invalid argument");
+                       return;
+               }
+
+               index = *(int *)data;
+               listmgr_update_focus_item(priv->listmgr, index);
+
+               break;
+       default:
+               break;
+       }
 }
 
 static layout_class _lclass = {
index 31b18ca..1944c65 100644 (file)
@@ -478,6 +478,7 @@ static void _hide(void *layout_data)
 static void _update(void *layout_data, int update_type, void *data)
 {
        struct _priv *priv;
+       int index;
 
        if (!layout_data) {
                _ERR("failed to get layout data");
@@ -486,7 +487,23 @@ static void _update(void *layout_data, int update_type, void *data)
 
        priv = layout_data;
 
-       _update_content_list(priv);
+       switch (update_type) {
+       case UPDATE_CONTENT:
+               _update_content_list(priv);
+               break;
+       case UPDATE_FOCUS:
+               if (!data) {
+                       _ERR("invalid argument");
+                       return;
+               }
+
+               index = *(int *)data;
+               listmgr_update_focus_item(priv->listmgr, index);
+
+               break;
+       default:
+               break;
+       }
 }
 
 static layout_class _lclass = {
index 652e00c..b2f0511 100644 (file)
@@ -197,6 +197,49 @@ static Evas_Object *_draw_list_item(struct listmgr *lmgr, struct group_info *gi)
        return ly;
 }
 
+bool listmgr_update_focus_item(struct listmgr *lmgr, int index)
+{
+       Eina_List *item, *l;
+       Evas_Object *ly, *grid;
+       Elm_Object_Item *it;
+       int count;
+
+       item = elm_box_children_get(lmgr->box);
+       if (lmgr->show_play_info)
+               item = eina_list_next(item);
+
+       grid = NULL;
+       EINA_LIST_FOREACH(item, l, ly) {
+               grid = elm_object_part_content_get(ly, PART_ITEM_CONTENT);
+               if (!grid) {
+                       _ERR("failed to get grid object");
+                       return false;
+               }
+
+               count = elm_gengrid_items_count(grid);
+
+               if (index < count)
+                       break;
+
+               index -= count;
+       }
+
+       it = elm_gengrid_first_item_get(grid);
+       while (index--)
+               it = elm_gengrid_item_next_get(it);
+
+       if (!it) {
+               _ERR("failed to get current grid item");
+               return false;
+       }
+
+       elm_gengrid_item_bring_in(it, ELM_GENGRID_ITEM_SCROLLTO_MIDDLE);
+       elm_object_focus_set(grid, EINA_TRUE);
+       elm_object_item_focus_set(it, EINA_TRUE);
+
+       return true;
+}
+
 bool listmgr_update_content_list(struct listmgr *lmgr, Eina_List *list)
 {
        Evas_Object *ly;
index 7185c77..8e92b44 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "define.h"
 #include "layout.h"
+#include "view.h"
 
 #define TITLE_TEXT "Media Hub"
 
@@ -92,7 +93,8 @@ static void _focused_cb(int id, void *data, Evas_Object *obj,
        layoutmgr_hide_layout(priv->lmgr,
                        g_menu_item[priv->current_layout].layout_id);
        layoutmgr_show_layout(priv->lmgr, g_menu_item[i].layout_id);
-       layoutmgr_update_layout(priv->lmgr, g_menu_item[i].layout_id, 0, NULL);
+       layoutmgr_update_layout(priv->lmgr, g_menu_item[i].layout_id,
+                       UPDATE_CONTENT, NULL);
 
        priv->focused_btn = obj;
        priv->current_layout = i;
@@ -257,6 +259,29 @@ static void _hide(void *view_data)
        evas_object_hide(priv->base);
 }
 
+static void _update(void *view_data, int update_type, void *data)
+{
+       struct _priv *priv;
+       struct view_update_data *vdata;
+
+       if (!view_data) {
+               _ERR("failed to get view data");
+               return;
+       }
+
+       if (!data) {
+               _ERR("invalid argument");
+               return;
+       }
+
+       priv = view_data;
+       vdata = data;
+
+       layoutmgr_update_layout(priv->lmgr,
+                       g_menu_item[priv->current_layout].layout_id,
+                       UPDATE_FOCUS, (void *)&vdata->index);
+}
+
 static void _destroy(void *view_data)
 {
        struct _priv *priv;
@@ -288,6 +313,7 @@ static view_class _vclass = {
        .create = _create,
        .show = _show,
        .hide = _hide,
+       .update = _update,
        .destroy = _destroy,
 };