예제 #1
0
        /// <summary>
        /// Will convert a diary element to a standard item in order to display it in
        /// the detail activity.
        /// </summary>
        public Item ConvertToItem(DiaryElement de)
        {
            de.DiaryShortItem.Description.producer = string.Format(Localization.Localization.Static.Raw("AddedOn"),
                                                                   de.DateInTime.ToString("dd.MM.yyyy"));
            de.DiaryShortItem.Description.group = Localization.Localization.Static.Raw("InDiary");

            Item i = new Item
            {
                id          = de.id,
                Data        = de.DiaryShortItem.Data,
                Description = de.DiaryShortItem.Description,
            };

            try
            {
                i.thumbsrc      = PersistenceManager.Static.GetFirst(string.Format("{0}-img", de.DiaryShortItem.id)).Value;
                i.thumbsrclarge = i.thumbsrc;
            }
            catch
            {
                i.Description.group = Localization.Localization.Static.Raw("FromExternal");
            }

            return(i);
        }
예제 #2
0
        protected override GeneralViewHolder populateHolder(GeneralViewHolder _holder)
        {
            DiaryElement        item   = (DiaryElement)items[itemPosition];
            DiaryItemViewHolder holder = (DiaryItemViewHolder)_holder;

            if (item != null)
            {
                holder.ApplyData(item, activity);
            }

            return(holder);
        }
        /// <summary>
        /// Will apply the passed meal data to the UI elements.
        /// </summary>
        public void ApplyData(DiaryElement diaryElement, Activity a)
        {
            ThreadPool.QueueUserWorkItem(o => loadThumbnail(diaryElement, a));

            Name.Text     = shortenName(diaryElement.DiaryShortItem.Description.name, 25);
            Producer.Text = string.Format(Localization.Static.Raw("DiaryItemProduct"),
                                          diaryElement.DiaryShortItem.Data.diary_serving_amount,
                                          diaryElement.DiaryShortItem.Data.GetMeasureUnit(),
                                          diaryElement.DateInTime.ToString("HH:mm"));

            Kcal.Text          = string.Format("{0}", diaryElement.DiaryShortItem.Data.kcal_diary);
            Proteins.Text      = string.Format("{0}g", diaryElement.DiaryShortItem.Data.protein_gram);
            Carbohydrates.Text = string.Format("{0}g", diaryElement.DiaryShortItem.Data.kh_gram);
            Sugar.Text         = string.Format("{0}g", diaryElement.DiaryShortItem.Data.sugar_gram);
            Fat.Text           = string.Format("{0}g", diaryElement.DiaryShortItem.Data.fat_diary);
        }
 /// <summary>
 /// Will load the thumbnail into the ImageView UI.
 /// </summary>
 private void loadThumbnail(DiaryElement item, Activity a)
 {
     try
     {
         a.RunOnUiThread(() =>
         {
             try
             {
                 string url = PersistenceManager.Static.GetFirst(string.Format("{0}-img", item.DiaryShortItem.id)).Value;
                 ImageLoader.Instance.DisplayImage(url, Thumbnail);
             }
             catch (Exception ex)
             {
                 MetricsManager.TrackEvent(string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
             }
         });
     }
     catch (Exception ex)
     {
         MetricsManager.TrackEvent(string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
     }
 }