コード例 #1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            try
            {
                var view = inflater.Inflate(Resource.Layout.fragment_report, container, false);

                Activity.FindViewById <TabLayout>(Resource.Id.tabs).Visibility = ViewStates.Gone;
                Activity.FindViewById <FloatingActionButton>(Resource.Id.fab_list).Visibility = ViewStates.Gone;
                advertisement = view.FindViewById <LinearLayout>(Resource.Id.advertisement);
                Task.Run(() =>
                {
                    Task.Delay(50).Wait();
                    Platform.RunSafeOnUIThread("ReportFragment.OnCreateView", () =>
                    {
                        items = view.FindViewById <LinearLayout>(Resource.Id.reportitems);
                        int z = 0;
                        foreach (Property p in UserSettings.Current.SelectedProperties)
                        {
                            var chart         = inflater.Inflate(Resource.Layout.item_chart, container, false);
                            var titleTextView = chart.FindViewById <TextView>(Resource.Id.chart_title);

                            var propertyView = chart.FindViewById <WeekGraph>(Resource.Id.chart1);
                            p.Color          = AndroidUI.GetPropertyColor(Activity, z, p);
                            titleTextView.SetTextColor(p.Color);
                            titleTextView.Text     = p.TextOnly;
                            propertyView.property  = p;
                            propertyView.BarClick += (sender, e) =>
                            {
                                var date = e;
                                Intent i = new Intent(Activity, typeof(FoodJournal.Android15.Activities.ViewDayActivity));
                                i.PutExtra("date", date.ToStorageStringDate());
                                i.PutExtra("dateText", (date == DateTime.Now.Date) ? AppResources.Today : date.ToString("dddd"));
                                i.PutExtra("period", (int)Period.Breakfast);
                                StartActivity(i);
                            };

                            items.AddView(chart);

                            z++;
                        }
                        SessionLog.EndPerformance("Navigate");
                    });
                });


                return(view);
            }
            catch (Exception ex)
            {
                LittleWatson.ReportException(ex);
                return(null);
            }
        }
コード例 #2
0
        public void UpdateEmptyVisibility()
        {
            bool HasEntries = vm.EntriesVisibility == FoodJournal.AppModel.UI.Visibility.Visible;

            recycler.Visibility         = HasEntries ? ViewStates.Visible : ViewStates.Gone;
            emptyScreenImage.Visibility = HasEntries ? ViewStates.Gone : ViewStates.Visible;
            getStarted.Visibility       = HasEntries ? ViewStates.Gone : ViewStates.Visible;
            getStartedText.Visibility   = HasEntries ? ViewStates.Gone : ViewStates.Visible;


            if (UserSettings.Current.ShowTotal)
            {
                Property p = UserSettings.Current.SelectedTotal;
                int      i = UserSettings.Current.SelectedProperties.IndexOf(p);
                text_totalCalories2.SetTextColor(AndroidUI.GetPropertyColor(Activity, i, p));
            }
        }
コード例 #3
0
        public SpannableStringBuilder MakeColoredText(Entry entry)
        {
            SpannableStringBuilder spannable = new SpannableStringBuilder();

            int i = 0;

            foreach (Property p in UserSettings.Current.SelectedProperties)
            {
                try {
                    Amount a     = entry.GetPropertyValue(p);
                    string value = a.ValueString();

                    if (!string.IsNullOrEmpty(value))
                    {
                        if (i > 0)
                        {
                            spannable.Append(", ");
                        }

                        spannable.Append(p.TextOnly);

                        spannable.Append(" - ");

                        var span = new ForegroundColorSpan(AndroidUI.GetPropertyColor(context, i, p));
                        spannable.Append(value);

                        spannable.SetSpan(span, spannable.Length() - value.Length, spannable.Length(), SpanTypes.ExclusiveExclusive);
                    }

                    i++;
                } catch (Exception ex) {
                    LittleWatson.ReportException(ex);
                }
            }

            return(spannable);
        }