Example #1
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            string menuURL = "http://54.191.98.63/menu.php";
            JsonValue json = await JsonParsing<Task<JsonValue>>.FetchDataAsync(menuURL);
            List<EMItemList> parsedData = JsonParsing<EMItemList>.ParseAndDisplay(json);
            AP_EM_ItemList.mBuiltInCards = parsedData.ToArray();

            //Create Menu List
            mItemList = new AP_EM_ItemList();
            
            //Set View
            SetContentView(Resource.Layout.APEditMenu);
            Button logout = FindViewById<Button>(Resource.Id.LogOut_Edit_Menu_Button);
            logout.Click += delegate
            {
                Android.Widget.Toast.MakeText(this, "Logged Out Successfully", Android.Widget.ToastLength.Short).Show();
                StartActivity(typeof(LoginScreen));
            };

            //Set up layout manager to view all cards on recycler view
            mRecyclerView = FindViewById<RecyclerView>(Resource.Id.recyclerView);
            mLayoutManager = new LinearLayoutManager(this);
            mRecyclerView.SetLayoutManager(mLayoutManager);
            //Menu List Adapter
            mAdapter = new CVBFItemListAdapter(mItemList);
            //Put adapter into RecyclerView
            mRecyclerView.SetAdapter(mAdapter);
            //Item Click
            mAdapter.ItemClick += OnItemClick;

            mView = FindViewById(Resource.Id.fullAPEMAdd);

            //FAB
            var fab = FindViewById<FloatingActionButton>(Resource.Id.APEMfab);
            fab.AttachToRecyclerView(mRecyclerView);
            FindViewById<FloatingActionButton>(Resource.Id.APEMfab).Click += (sender, e) =>
            {
                StartActivity(typeof(AP_EM_Add));
                OverridePendingTransition(Resource.Animation.right_in, Resource.Animation.right_out);
            };
        }
Example #2
0
 //start method to load adapter
 public CVMItemListAdapter(AP_EM_ItemList itemitem)
 {
     mItemList = itemitem;
 }
Example #3
0
 public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
 {
     var view = inflater.Inflate(Resource.Layout.CV_Menu, container, false);
     //Create Menu List
     mItemList = new AP_EM_ItemList();
     //Set up layout manager to view all cards on recycler view
     mRecyclerView = view.FindViewById<RecyclerView>(Resource.Id.cv_menurecyclerView);
     mRecyclerView.HasFixedSize = true;
     mLayoutManager = new StaggeredGridLayoutManager(2, 1);
     mRecyclerView.SetLayoutManager(mLayoutManager);
     //Menu List Adapter
     mAdapter = new CVMItemListAdapter(mItemList);
     //Put adapter into RecyclerView
     mRecyclerView.SetAdapter(mAdapter);
     mRecyclerView.SetItemAnimator(new DefaultItemAnimator());
     //Item Click
     mAdapter.ItemClick += OnItemClick;
     return view;
 }
Example #4
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.CV_Menu);

            #region "logout"
            //logout button
            Button logout = FindViewById<Button>(Resource.Id.menuLogOut);
            logout.Click += (sender, e) => {

                EditText input = new EditText(this);
                RunOnUiThread(() =>
                {
                    AlertDialog.Builder builder;
                    builder = new AlertDialog.Builder(this);
                    builder.SetTitle("Logout?");
                    builder.SetMessage("Enter the password associated with " + LoginScreen.loginUsername + " to logout");
                    builder.SetCancelable(false);
                    builder.SetView(input);
                    builder.SetPositiveButton("OK", delegate {

                        if (input.Text == ("lmo"))
                        {
                            var webClient = new WebClient();
                            Console.WriteLine();
                            webClient.DownloadString("http://54.191.98.63/logout.php?id=" + LoginScreen.loginUsername);
                            this.Finish();
                            SetContentView(Resource.Layout.LoginScreen);
                            Android.Widget.Toast.MakeText(this, "Logged Out Successfully", Android.Widget.ToastLength.Short).Show();
                            StartActivity(typeof(LoginScreen));
                        }
                        else
                        {
                            Android.Widget.Toast.MakeText(this, "Incorrect Password", Android.Widget.ToastLength.Short).Show();
                        }


                    });
                    builder.Show();
                }
                );




                /*
                var webClient = new WebClient();
                Console.WriteLine();
                webClient.DownloadString("http://54.191.98.63/logout.php?id=" + LoginScreen.loginUsername);
                this.Finish();
                SetContentView(Resource.Layout.LoginScreen);
                Android.Widget.Toast.MakeText(this, "Logged Out Successfully", Android.Widget.ToastLength.Short).Show();
                StartActivity(typeof(LoginScreen));
                */
            };
            #endregion

            JsonValue json = await JsonParsing<Task<JsonValue>>.FetchDataAsync(menuURL);
            List<EMItemList> parsedData = JsonParsing<EMItemList>.ParseAndDisplay(json);
            AP_EM_ItemList.mBuiltInCards = parsedData.ToArray();

            //Associations
            mView = FindViewById(Resource.Id.customerspalsh);
            fView = FindViewById(Resource.Id.CV2Menufab);
            headerView = FindViewById(Resource.Id.cv_menuhead);
            frameView = FindViewById(Resource.Id.cv_framerv);

            //FAB
            var fab = FindViewById<FloatingActionButton>(Resource.Id.CV2Menufab);
            FindViewById<FloatingActionButton>(Resource.Id.CV2Menufab).Click += (sender, e) =>
            {
                Hide();
                fab.Visibility = ViewStates.Gone;
            };

            //Create Menu List
            mItemList = new AP_EM_ItemList();
            //Set up layout manager to view all cards on recycler view
            mRecyclerView = FindViewById<RecyclerView>(Resource.Id.cv_menurecyclerView);
            mRecyclerView.HasFixedSize = true;
            mLayoutManager = new StaggeredGridLayoutManager(2, 1);
            mRecyclerView.SetLayoutManager(mLayoutManager);
            //Menu List Adapter
            mAdapter = new CVMItemListAdapter(mItemList);
            //Put adapter into RecyclerView
            mRecyclerView.SetAdapter(mAdapter);
            mRecyclerView.SetItemAnimator(new DefaultItemAnimator());
            //Item Click
            mAdapter.ItemClick += OnItemClick;

            mAdapter.NotifyDataSetChanged();

            Button orderbtn = FindViewById<Button>(Resource.Id.menuorderBtn);
            Button callbtn = FindViewById<Button>(Resource.Id.menuCallWaiter);
            Button pay = FindViewById<Button>(Resource.Id.menupayButton);
            pay.Click += (s, o) =>
            {
                RunOnUiThread(() =>
                {
                    AlertDialog.Builder builder;
                    builder = new AlertDialog.Builder(this);
                    builder.SetTitle("How would you like to pay?");
                    builder.SetMessage("Choose from the 3 options below:\n• Single Check: One check with everything ordered.\n• Split Evenly: Splits the check evenly.\n• Split by Dish: Pick who pays for what dish.");
                    builder.SetCancelable(true);
                    
                    builder.SetPositiveButton("Split by Dish", delegate {
                        StartActivity(typeof(SplitPayment));
                    });
                    builder.SetNeutralButton("Split Evenly", delegate
                    {
                        
                        StartActivity(typeof(EvenPayment));

                    });
                    builder.SetNegativeButton("Single Check", delegate
                    {
                        double subtotal = 0;

                        //Getting subtotal of items ordered
                        foreach (CustomerOrderItem x in CustomerPortal.CustomerOrderList)
                        {
                            int numQty = Int32.Parse(x.Quantity);
                            while (numQty > 0)
                            {
                                double price = Convert.ToDouble(x.Dish.iPrice);
                                subtotal += price;
                                numQty--;
                            }
                        }
                        //Adding tax to subtotal
                        Double TotalCost = Math.Round(((subtotal * .08875) + subtotal), 2);
                        String TotalCostString = Convert.ToString(TotalCost);

                        pubnub.Publish<string>(LoginScreen.loginUsername, "Here's their single check total: $" + TotalCostString, DisplayReturnMessage, DisplayErrorMessage);

                    });
                    builder.Show();
                }
               );






                
                //Android.Widget.Toast.MakeText(this, "Your waiter has been notified that you are ready to pay!", Android.Widget.ToastLength.Long).Show();
                //pubnub.Publish<string>(LoginScreen.loginUsername, LoginScreen.loginUsername + ": Requires Assistance, " + LoginScreen.loginUsername + " Ready To Pay", DisplayReturnMessage, DisplayErrorMessage);
            };
            orderbtn.Click += (s, o) => StartActivity(typeof(CV2_YourOrder));
            callbtn.Click += (s, o) => {
                //Sends a message to the table's channel with the help message. 
                Android.Widget.Toast.MakeText(this, "Your waiter has been notified that you need help!", Android.Widget.ToastLength.Long).Show();
                pubnub.Publish<string>(LoginScreen.loginUsername, LoginScreen.loginUsername + ": Requires Assistance, " + LoginScreen.loginUsername + " requires your assistance", DisplayReturnMessage, DisplayErrorMessage);
            };


        }