protected override void OnCreate(Bundle savedInstanceState) { // Xamarin.Insights.Initialize (XamarinInsights.ApiKey, this); base.OnCreate(savedInstanceState); Stripe.StripeClient.DefaultPublishableKey = TempStorage.PublishableKey; TempStorage.SetupDb(); TempStorage.GetMilks(); TempStorage.GetSizes(); SetContentView(Resource.Layout.Main); SetupUi(); //might move to else statement if (NetworkAvailable()) { SetupFacebook(); if (Profile.CurrentProfile != null) { TempStorage.ProfileId = string.Concat("facebook:", Profile.CurrentProfile.Id); StartLogin(); } } else { SetupNetworkPrompt(); networkDialog.Show(); } }
public void LoadEverything() { TempStorage.GetOrders(); TempStorage.GetCafes(); TempStorage.GetFavourites(); TempStorage.GetCoffees(); }
public void SendOrder() { Intent activeOrders; string fullName = Profile.CurrentProfile.Name; string facebookId = string.Concat("facebook:", Profile.CurrentProfile.Id); string orderTime = ((Int32)(DateTime.UtcNow.AddSeconds(5).Subtract(new DateTime(1970, 1, 1))).TotalSeconds).ToString(); loadingBar.Visibility = ViewStates.Visible; //Add pricing to the mix... new Thread(new ThreadStart(new ThreadStart(() => { TempStorage.CafeId = TempStorage.GetCafeId(TempStorage.Cafe); TempStorage.Price = TempStorage.GetPrice(TempStorage.Coffee); TempStorage.Orders.Insert(0, new Order { CafeId = TempStorage.CafeId, Coffee = TempStorage.Coffee, OrderStatus = "red", OrderTime = TempStorage.GetDate(orderTime), Size = TempStorage.Size, Price = TempStorage.Price }); JObject order = JObject.Parse(@"{ 'cafe_id' : '" + TempStorage.CafeId + "', 'coffee' : '" + TempStorage.Coffee + "', 'order_status' : 'red', 'order_time' : '" + orderTime + "', 'price' : '" + TempStorage.Price + "', 'size' : '" + TempStorage.Size + "', 'user_fullName' : '" + Profile.CurrentProfile.Name + "', 'user_id' : '" + string.Concat("facebook:", Profile.CurrentProfile.Id) + "', 'milk' : '" + TempStorage.Milk + "' }"); FirebaseResponse orderSend = TempStorage.FbClient.Push("orders/", order); if (favChecked) { JObject favouritesSend = JObject.Parse(@"{ 'cafe_id' : '" + TempStorage.CafeId + "', 'coffee' : '" + TempStorage.Coffee + "', 'price' : '" + TempStorage.Price + "', 'size' : '" + TempStorage.Size + "', 'milk' : '" + TempStorage.Milk + "'}"); orderSend = TempStorage.FbClient.Push(string.Concat("users/", facebookId, "/favourites"), favouritesSend); favouritesSend = orderSend.ResultAs <JObject> (); TempStorage.Favourites.Add(new Favourite { Coffee = TempStorage.Coffee, Milk = TempStorage.Milk, Size = TempStorage.Size, Price = TempStorage.Price }); } activeOrders = new Intent(this, typeof(ActivePastActivity)); activeOrders.PutExtra("Past", "pay"); activeOrders.PutExtra("Query", "not"); RunOnUiThread(() => { StartActivity(activeOrders); }); }))).Start(); }
public override View GetView(int position, View convertView, ViewGroup parent) { View view = convertView; // re-use an existing view, if one is available if (view == null) // otherwise create a new one { view = context.LayoutInflater.Inflate(Resource.Layout.ListItem, null); } LinearLayout lin = view.FindViewById <LinearLayout> (Resource.Id.list_item); LinearLayout colour = view.FindViewById <LinearLayout> (Resource.Id.order_colour); TextView coffee, cafe, orderDate; coffee = lin.FindViewById <TextView> (Resource.Id.txtItemCoffee); cafe = lin.FindViewById <TextView> (Resource.Id.txtItemCafe); orderDate = lin.FindViewById <TextView> (Resource.Id.txtItemOrder); if (items [position].OrderStatus != "black") { if (items [position].OrderStatus == "red") { colour.SetBackgroundColor(Android.Graphics.Color.Red); orderDate.Text = string.Concat("Expected delivery time: ", items[position].OrderTime.AddMinutes(TempStorage.GetPrepTime(items [position].CafeId)).ToShortTimeString()); } else if (items [position].OrderStatus == "yellow") { colour.SetBackgroundColor(Android.Graphics.Color.Yellow); orderDate.Text = string.Concat("Expected delivery time: ", items[position].OrderTime.AddMinutes(TempStorage.GetPrepTime(items [position].CafeId)).ToShortTimeString()); } else if (items [position].OrderStatus == "green") { colour.SetBackgroundColor(Android.Graphics.Color.Green); orderDate.Text = string.Concat("Expected delivery time: ", items[position].OrderTime.AddMinutes(TempStorage.GetPrepTime(items [position].CafeId)).ToShortTimeString()); } } else { colour.SetBackgroundColor(Android.Graphics.Color.ParseColor("#FFFFFF")); orderDate.Text = items [position].OrderTime.ToString("F"); } coffee.Text = string.Concat(items[position].Size, " ", items [position].Coffee, " ($", items[position].Price, ")"); cafe.Text = items [position].CafeName; return(view); }