update noti badge dinamically from notification changed callback 07/44207/1
authorSoohye Shin <soohye.shin@samsung.com>
Sun, 19 Jul 2015 05:47:26 +0000 (14:47 +0900)
committerSoohye Shin <soohye.shin@samsung.com>
Sun, 19 Jul 2015 05:47:26 +0000 (14:47 +0900)
Change-Id: I7ef435ed8c63215fbe82f38289c1426ee9f23775
Signed-off-by: Soohye Shin <soohye.shin@samsung.com>
include/view.h
src/data/data_home.c
src/view/view_home.c

index 58f2a07..a981f18 100644 (file)
@@ -19,7 +19,8 @@
 
 enum update_type {
        UPDATE_TYPE_EDIT,
-       UPDATE_TYPE_PHOTO
+       UPDATE_TYPE_PHOTO,
+       UPDATE_TYPE_NOTI
 };
 
 view_class *view_home_get_vclass(void);
index f2a8b20..c03c143 100644 (file)
@@ -27,6 +27,7 @@
 #include "datamgr.h"
 #include "utils.h"
 #include "view.h"
+#include "defs.h"
 
 #define STR_SELECT_ACTION_PUSH "push"
 #define STR_SELECT_ACTION_LAUNCH "launch"
@@ -265,7 +266,25 @@ static Eina_List *_get_items(struct datamgr *dm)
 
 static void _notification_cb(void *data, notification_type_e type)
 {
-       /* It should be implemented later for loading a count of notification */
+       char *noti = NULL;
+       Eina_List *l;
+       struct datamgr *dm;
+       struct datamgr_item *di;
+
+       if (!data) {
+               _ERR("Invalid argument");
+               return;
+       }
+
+       dm = data;
+
+       _get_notification(&noti);
+       viewmgr_update_view(VIEW_HOME, UPDATE_TYPE_NOTI, noti);
+
+       EINA_LIST_FOREACH(dm->list, l, di) {
+               if (di->noti)
+                       di->subtitle = noti;
+       }
 }
 
 static void _fini(struct datamgr *dm)
index 1580e1f..703d8fd 100644 (file)
@@ -407,12 +407,52 @@ static void _destroy(void *data)
        free(priv);
 }
 
+static void _update(void *view_data, int update_type, void *data)
+{
+       struct _priv *priv;
+       struct bar_item *bi;
+       Eina_List *list;
+       Evas_Object *badge;
+
+       if (!view_data) {
+               _ERR("Invalid argument");
+               return;
+       }
+
+       priv = view_data;
+
+       switch (update_type) {
+       case UPDATE_TYPE_NOTI:
+               if (!priv->list)
+                       return;
+
+               EINA_LIST_FOREACH(priv->list, list, bi) {
+                       if (!bi->di->noti)
+                               continue;
+
+                       badge = _add_notification_badge(bi->eo, data);
+                       if (!badge && bi->badge) {
+                               evas_object_del(bi->badge);
+                               elm_object_part_text_set(bi->eo,
+                                               PART_BAR_ITEM_BADGE_COUNT, "");
+                       }
+                       evas_object_show(bi->eo);
+                       bi->badge = badge;
+               }
+               break;
+       default:
+               _ERR("Invalid type");
+               return;
+       }
+}
+
 static view_class vclass = {
        .view_id = VIEW_HOME,
        .create = _create,
        .show = _show,
        .hide = _hide,
-       .destroy = _destroy
+       .destroy = _destroy,
+       .update = _update
 };
 
 view_class *view_home_get_vclass(void)