private void UpdateDrinkListView(List <DrinkMultiple> drinkMultiple, List <String> drinkNames) { if (drinkMultiple == null || drinkMultiple.Count < 1) { return; } int drinkOrder_MustContaianAtLeastIngridients = 2; List <DrinkMultiple> availableDrinksMixFiltered = CocktailDBService.FilterMixableDrinks(drinkMultiple, drinkNames, drinkOrder_MustContaianAtLeastIngridients); ListView listView = FindViewById <ListView>(Resource.Id.cocktailListView); List <Drink> allDrinks = new List <Drink>(); // Clean and Empty the list int childCount = listView.ChildCount; if (childCount > 0) { List <Drink> emptyList = new List <Drink>(); listAdapterDrink adapterTemp = new listAdapterDrink(this, emptyList); listView.SetAdapter(adapterTemp); } // Add to list foreach (var item in availableDrinksMixFiltered) { allDrinks.AddRange(item.Drinks); } // Order by all pictures first allDrinks = allDrinks.OrderByDescending(o => o.strDrinkThumb).ToList(); listAdapterDrink adapter = new listAdapterDrink(this, allDrinks); listView.Adapter = adapter; }
private void listView_ItemClick(object sender, AdapterView.ItemClickEventArgs e) { ListView listView = sender as Android.Widget.ListView; if (listView == null) { return; } listAdapterDrink listAdapterDrink = listView.Adapter as listAdapterDrink; if (listAdapterDrink == null) { return; } Drink drink = listAdapterDrink.listDrink[e.Position]; // TODO: DEV ONLY : Remove this? Or you can have this left? Drink detailDrink = CocktailDBService.HttpGet(drink.idDrink.ToString(), HttpGetRequests.CocktailByID).Drinks[0]; ChangePage(detailDrink); }
private void PopulateData() { Drink drink = TransporterClass.SelectedDrink; // Set picture listAdapterDrink listAdapter = new listAdapterDrink(null, null); if (drink.strDrinkThumb != null) { Bitmap picture = listAdapter.GetImageBitmapFromUrl(drink.strDrinkThumb); Bitmap pictureRound = listAdapter.GetRoundedShape(picture, 650, 650); FindViewById <ImageView>(Resource.Id.imageView4).SetImageBitmap(pictureRound); } else { Stream picStream = this.Resources.OpenRawResource(Resource.Drawable.placeholder2); var bitmapPicture = new BitmapDrawable(picStream); FindViewById <ImageView>(Resource.Id.imageView4).SetImageBitmap(listAdapter.GetRoundedShape(bitmapPicture.Bitmap, 650, 650)); } // Set text FindViewById <TextView>(Resource.Id.strDrink).Text = drink.strDrink.ToUpper(); LinearLayout drinkOrderLinearView = FindViewById <LinearLayout>(Resource.Id.linearLayoutDrinkOrder); if (!string.IsNullOrEmpty(drink.strIngredient1) && drink.strIngredient1.Length > 2) { RunOnUiThread(() => drinkOrderLinearView.AddView(Factory.ProduceDetailIngridientsForLinview(this, drink.strIngredient1, drink.strMeasure1))); } if (!string.IsNullOrEmpty(drink.strIngredient2) && drink.strIngredient2.Length > 2) { RunOnUiThread(() => drinkOrderLinearView.AddView(Factory.ProduceDetailIngridientsForLinview(this, drink.strIngredient2, drink.strMeasure2))); } if (!string.IsNullOrEmpty(drink.strIngredient3) && drink.strIngredient3.Length > 2) { RunOnUiThread(() => drinkOrderLinearView.AddView(Factory.ProduceDetailIngridientsForLinview(this, drink.strIngredient3, drink.strMeasure3))); } if (!string.IsNullOrEmpty(drink.strIngredient4) && drink.strIngredient4.Length > 2) { RunOnUiThread(() => drinkOrderLinearView.AddView(Factory.ProduceDetailIngridientsForLinview(this, drink.strIngredient4, drink.strMeasure4))); } if (!string.IsNullOrEmpty(drink.strIngredient5) && drink.strIngredient5.Length > 2) { RunOnUiThread(() => drinkOrderLinearView.AddView(Factory.ProduceDetailIngridientsForLinview(this, drink.strIngredient5, drink.strMeasure5))); } if (!string.IsNullOrEmpty(drink.strIngredient6) && drink.strIngredient6.Length > 2) { RunOnUiThread(() => drinkOrderLinearView.AddView(Factory.ProduceDetailIngridientsForLinview(this, drink.strIngredient6, drink.strMeasure6))); } if (!string.IsNullOrEmpty(drink.strIngredient7) && drink.strIngredient7.Length > 2) { RunOnUiThread(() => drinkOrderLinearView.AddView(Factory.ProduceDetailIngridientsForLinview(this, drink.strIngredient7, drink.strMeasure7))); } if (!string.IsNullOrEmpty(drink.strIngredient8) && drink.strIngredient8.Length > 2) { RunOnUiThread(() => drinkOrderLinearView.AddView(Factory.ProduceDetailIngridientsForLinview(this, drink.strIngredient8, drink.strMeasure8))); } if (!string.IsNullOrEmpty(drink.strIngredient9) && drink.strIngredient9.Length > 2) { RunOnUiThread(() => drinkOrderLinearView.AddView(Factory.ProduceDetailIngridientsForLinview(this, drink.strIngredient9, drink.strMeasure9))); } if (!string.IsNullOrEmpty(drink.strIngredient10) && drink.strIngredient10.Length > 2) { RunOnUiThread(() => drinkOrderLinearView.AddView(Factory.ProduceDetailIngridientsForLinview(this, drink.strIngredient10, drink.strMeasure10))); } if (!string.IsNullOrEmpty(drink.strIngredient11) && drink.strIngredient11.Length > 2) { RunOnUiThread(() => drinkOrderLinearView.AddView(Factory.ProduceDetailIngridientsForLinview(this, drink.strIngredient11, drink.strMeasure11))); } if (!string.IsNullOrEmpty(drink.strIngredient12) && drink.strIngredient12.Length > 2) { RunOnUiThread(() => drinkOrderLinearView.AddView(Factory.ProduceDetailIngridientsForLinview(this, drink.strIngredient12, drink.strMeasure12))); } if (!string.IsNullOrEmpty(drink.strIngredient13) && drink.strIngredient13.Length > 2) { RunOnUiThread(() => drinkOrderLinearView.AddView(Factory.ProduceDetailIngridientsForLinview(this, drink.strIngredient13, drink.strMeasure13))); } if (!string.IsNullOrEmpty(drink.strIngredient14) && drink.strIngredient14.Length > 2) { RunOnUiThread(() => drinkOrderLinearView.AddView(Factory.ProduceDetailIngridientsForLinview(this, drink.strIngredient14, drink.strMeasure14))); } if (!string.IsNullOrEmpty(drink.strIngredient15) && drink.strIngredient15.Length > 2) { RunOnUiThread(() => drinkOrderLinearView.AddView(Factory.ProduceDetailIngridientsForLinview(this, drink.strIngredient15, drink.strMeasure15))); } // TODO: Create a Factory for creating Textview with ingridients and populate the ListView FindViewById <TextView>(Resource.Id.strdescription).Text = drink.strInstructions; // ----- Remove this way of getting the data --------------------------------------------- // }