Exemplo n.º 1
0
        public void ShowAddDialog()
        {
            View dialogContent = View.Inflate(this, Resource.Layout.dialog_copy_from_similar, null);

            AlertDialog.Builder builder = new AlertDialog.Builder(SupportActionBar.ThemedContext, Resource.Style.Dialog);
            builder.SetView(dialogContent);
            var dialogList = dialogContent.FindViewById <Android.Support.V7.Widget.RecyclerView>(Resource.Id.recycler_dialog_copy_from_similar);

            dialogList.HasFixedSize = false;
            LinearLayoutManager mLayoutManager = new LinearLayoutManager(this);

            dialogList.SetLayoutManager(mLayoutManager);

#if DEBUG1
            SearchVM vm = new SearchVM(Values.Period.Dinner);
            //vm.Query="Banana";
#endif

            var addInputDialog = dialogContent.FindViewById <Android.Widget.EditText>(Resource.Id.addInputDialog);
            addInputDialog.TextChanged += (sender, e) =>
            {
                vm.Query = addInputDialog.Text;
            };

            // create an empty cardsAdapter and add it to the recycler view
            var cardsAdapter = new SearchResultRecyclerAdapter(this, vm, SearchResultRecyclerAdapter.SRCType.ServingSizes);
            dialogList.SetAdapter(cardsAdapter);
            var dialog = builder.Create();
            cardsAdapter.Click = (svm) =>
            {
                dialog.Dismiss();
            };
            dialog.Show();
        }
Exemplo n.º 2
0
        public void ShowNewDialog()
        {
            View dialogContent = View.Inflate(Activity, Resource.Layout.dialog, null);

            Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(Activity, Resource.Style.Dialog);
            builder.SetView(dialogContent);

            var dialogList = dialogContent.FindViewById <Android.Support.V7.Widget.RecyclerView>(Resource.Id.recyclerDialog);

            dialogList.HasFixedSize = false;

            LinearLayoutManager mLayoutManager = new LinearLayoutManager(Activity);

            dialogList.SetLayoutManager(mLayoutManager);

            SearchVM vm = new SearchVM(Navigate.selectedPeriod);

            var addItemDialog = dialogContent.FindViewById <Android.Widget.ImageView>(Resource.Id.addItemDialog);

            var addInputDialog = dialogContent.FindViewById <Android.Widget.EditText>(Resource.Id.addInputDialog);

            addInputDialog.TextChanged += (sender, e) =>
            {
                vm.Query = addInputDialog.Text;
            };


            builder.SetPositiveButton(GetString(Resource.String.Add_New), (a, b) =>
            {
                var svm = new SearchResultNewVM("", "");
                Navigate.selectedDate = Date.Date;
                vm.OnItemTap(svm);
                //bannerView();
            });
            var notes = Cache.GetPeriodNote(Navigate.selectedDate, Navigate.selectedPeriod);

            builder.SetNeutralButton(GetString(Resource.String.Add_Note), (a, b) =>
            {
                Navigate.selectedDate = Date.Date;
                Cache.SetPeriodNote(Date.Date, Navigate.selectedPeriod, notes ?? "");
                mainPagerAdapter.RefreshPeriod(Navigate.selectedPeriod, true);
            });

            var cardsAdapter = new SearchResultRecyclerAdapter(Activity, vm, SearchResultRecyclerAdapter.SRCType.Search);

            dialogList.SetAdapter(cardsAdapter);
            dialogList.GetItemAnimator().RemoveDuration = 120;

            var dialog = builder.Create();

            cardsAdapter.Click = (svm) =>
            {
                Navigate.selectedDate = Date.Date;
                if (!svm.IsLocked)
                {
                    dialog.Dismiss();
                }
                vm.OnItemTap(svm);
                mainPagerAdapter.RefreshPeriod(Navigate.selectedPeriod, false);
            };

            dialog.Show();
        }