public override Java.Lang.ICharSequence GetPageTitleFormatted(int position)
        {
            var title = position == today ? AppResources.Today : GetItemFromId(position).ToShortDateString();

            SessionLog.Debug(string.Format("Page Title: {0}", title));
            return(new Java.Lang.String(title));
        }
Exemple #2
0
        private void MakeSureVM()
        {
            if (vm == null)
            {
                DateTime date = DateTime.Parse(Arguments.GetString("date"));

                SessionLog.Debug(string.Format("New Journal: {0}", date));

                jvm = new JournalVM();
                vm  = new JournalDayVM(jvm, date);
                //vm.Sync (vm.Date);
                //vm.StartRequery();
            }
        }
Exemple #3
0
        private void MakeSureVM()
        {
            if (vm == null)
            {
                DateTime date = Arguments.GetString("date").ToDateTime();

                SessionLog.Debug(string.Format("New Journal: {0}", date));

                jvm = new JournalVM();
                vm  = new JournalDayVM(jvm, date);
                jvm.SelectedProperty = property;
                jvm.SelectedDay      = vm;
            }
        }
Exemple #4
0
        public void StartRequery()
        {
            SessionLog.Debug(string.Format("*** StartRequery: {0}", period));

            //App.PeriodVM = this;
            Navigate.selectedDate = date;
                        #if WINDOWS_PHONE
            Navigate.selectedPeriod = period;
                        #endif

            var syncID = new System.Random().NextDouble().ToString();
            querySyncID = syncID;

            try
            {
                SyncPeriod();

                if (NewStyleWithoutItems)
                {
                    return;
                }

                Requery(syncID, false);
            }
            catch (Exception ex) { LittleWatson.ReportException(ex); }

            var bw = new System.ComponentModel.BackgroundWorker();
            bw.DoWork += (s, a) =>
            {
                System.Threading.Thread.Sleep(300);
                try
                {
                    if (querySyncID == syncID)
                    {
#if DEBUG && WINDOWS_PHONE
                        FoodJournal.WinPhone.App.SetThreadCulture(); // only needed for screenshots
#endif
                        Requery(syncID, true);
                    }
                }
                catch (Exception ex) { LittleWatson.ReportException(ex); }
            };
            bw.RunWorkerAsync();
        }
Exemple #5
0
        public override void OnResume()
        {
            base.OnResume();

            if (vm == null)
            {
                return;
            }

            SessionLog.Debug(string.Format("* OnResume: {0}", vm.Period));
            vm.StartRequery();

            //if (daypivot != null && vm != null)
            pda.daypivot = daypivot;
            //	daypivot.SetAd (vm.Period, pda.Ad);

            //pda.NotifyDataSetChanged ();
            //entryListView.Adapter = new EntryListAdapter(this, vm.EntryList); // todo, handle ItemList ref changes
            //itemListView.Adapter = new SearchResultListAdapter(this, vm.ItemList); // todo, handle ItemList ref changes
        }
Exemple #6
0
        public override Fragment GetItem(int position)
        {
            Period period = list [position];

            if (fragments.ContainsKey(period))
            {
                return(fragments [period]);
            }

            SessionLog.Debug(string.Format("New Fragment: {0}", list [position]));
            // getItem is called to instantiate the fragment for the given page.
            // Return a DummySectionFragment (defined as a static inner class
            // below) with the page number as its lone argument.
            PeriodFragment fragment = PeriodFragment.newInstance(date, list [position]);

            fragments.Add(period, fragment);

            //Bundle args = new Bundle();
            //args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, position + 1);
            //fragment.setArguments(args);
            return(fragment);
        }
Exemple #7
0
        public PeriodListAdapter(Context context, PeriodVM vm)
        {
            this.vm  = vm;
            _context = context;

            vm.EntryList.CollectionChanged += ItemList_CollectionChanged;
            entrylist = vm.EntryList;

            vm.ItemList.CollectionChanged += ItemList_CollectionChanged;
            itemlist = vm.ItemList;

            vm.PropertyChanged += (sender, e) => {
                if (e.PropertyName == "EntryList")
                {
                    if (entrylist != null)
                    {
                        entrylist.CollectionChanged -= ItemList_CollectionChanged;
                    }
                    entrylist = vm.EntryList;
                    entrylist.CollectionChanged += ItemList_CollectionChanged;
                }


                if (e.PropertyName == "ItemList")
                {
                    if (itemlist != null)
                    {
                        itemlist.CollectionChanged -= ItemList_CollectionChanged;
                    }
                    itemlist = vm.ItemList;
                    itemlist.CollectionChanged += ItemList_CollectionChanged;
                }

                SessionLog.Debug(string.Format("PropertyChanged: {0} - {1}", vm.Period, e.PropertyName));
                this.NotifyDataSetChanged();
            };
        }
Exemple #8
0
 void ItemList_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     SessionLog.Debug(string.Format("CollectionChanged: {0}", vm.Period));
     this.NotifyDataSetChanged();
 }
Exemple #9
0
        public override View GetChildView(int groupPosition, int childPosition, bool isLastChild, View convertView, ViewGroup parent)
        {
            try {
                var inflater = _context.GetSystemService(Context.LayoutInflaterService) as LayoutInflater;

                switch (groupPosition)
                {
                case 0:

                    if (vm.EntryList.Count == 0)
                    {
                        try {
                            var view4 = inflater.Inflate(Resource.Layout.NothingSelected, parent, false);
                            return(view4);
                        } catch (Exception ex) {
                            var m = ex.Message;
                        }
                    }

                    var result = vm.EntryList [childPosition];

                    bool isexisting = convertView is LinearLayout;
                    if (isexisting && (convertView as LinearLayout).FindViewById <TextView> (Resource.Id.itemText) == null)
                    {
                        isexisting = false;
                    }

                    LinearLayout view = (isexisting ? convertView :
                                         inflater.Inflate(Resource.Layout.EntryListItem, parent, false)) as LinearLayout;

                    var itemText = view.FindViewById <TextView> (Resource.Id.itemText);
                    var summary  = view.FindViewById <TextView> (Resource.Id.summary);

                    SessionLog.Debug(string.Format("ItemText: {0} = {1} ({2})", vm.Period, itemText, isexisting));

                    itemText.SetText(result.ItemText, TextView.BufferType.Normal);
                    summary.SetText(result.Summary, TextView.BufferType.Normal);

                    return(view);

                case 1:

                    try {
                        bool isexisting2 = convertView is LinearLayout;
                        if (isexisting2 && (convertView as LinearLayout).FindViewById <Button> (Resource.Id.hidead) == null)
                        {
                            isexisting2 = false;
                        }

                        LinearLayout view3 = isexisting2 ? (LinearLayout)convertView : (LinearLayout)inflater.Inflate(Resource.Layout.Ad, parent, false);

                        if (!isexisting2)
                        {
                            view3.FindViewById <Button> (Resource.Id.hidead).Click += (object sender, EventArgs e) => {
                                FoodJournal.Runtime.Navigate.ToBuyNowPage();
                            };
                        }


                        // show moved to DayPivot

//						if (ad.Parent != null)
//							(ad.Parent as LinearLayout).RemoveView (ad);
//
//						(view3 as LinearLayout).AddView (ad);

                        AllAds.Add(view3);


                        if (daypivot == null)
                        {
                            daypivot = FoodJournal.Runtime.Navigate.navigationContext as DayPivot;
                        }

                        daypivot.SetAd(vm.Period, view3);


//						} else {
//						var requestbuilder = new AdRequest.Builder ();
//							ad.LoadAd (requestbuilder.Build ());
//						}
//
//						//var layout = FindViewById<LinearLayout>(Resource.Id.mainlayout);
//						//layout.AddView(ad);
//
//						//AdRequest re;
//
//						//AdRequest re = new AdRequest();
//						//re.
//						//view3.FindViewById<AdView>(Resource.Id.ad).LoadAd(re);
                        return(view3);
                    } catch (Exception ex) {
                        var m = ex.Message;
                    }

                    return(new Button(parent.Context));

                case 2:

                    var item = vm.ItemList [childPosition];
                    if (convertView != null && convertView.Tag != null)
                    {
                        convertView = null;
                    }
                    // Try to reuse convertView if it's not  null, otherwise inflate it from our item layout
                    FrameLayout view2 = (convertView is FrameLayout ? convertView :
                                         inflater.Inflate(Resource.Layout.ItemListItem, parent, false)) as FrameLayout;

                    var captionA = item.CaptionAccent;
                    if (captionA != null)
                    {
                        captionA = captionA.ToUpper();
                    }

                    if (captionA != null)
                    {
                        view2     = inflater.Inflate(Resource.Layout.ItemListSection, parent, false) as FrameLayout;
                        view2.Tag = "this";
                    }

                    var captionAccent = view2.FindViewById <TextView> (Resource.Id.captionAccent);
                    var text          = view2.FindViewById <TextView> (Resource.Id.text);

//					if (childPosition % 2 == 0)
//					{
//						var d = _context.Resources.GetDrawable(Resource.Drawable.divider);
//						view2.SetBackgroundDrawable(d);
//					}

                    captionAccent.SetText(captionA, TextView.BufferType.Normal);
                    text.SetText(item.Text, TextView.BufferType.Normal);

                    return(view2);
                }
            } catch (Exception ex) {
                var ex2 = ex.Message;
            }
            return(convertView);
        }
Exemple #10
0
 public override Java.Lang.ICharSequence GetPageTitleFormatted(int position)
 {
     SessionLog.Debug(string.Format("Page Title: {0}", list [position]));
     return(new Java.Lang.String(Strings.FromEnum(list [position])));
 }