コード例 #1
0
        /// <summary>
        /// Updates the values on the view
        /// </summary>
        protected void updateValues()
        {
            List <Ingredient> placeholderL            = ItemParser.IdCSVToIngredientList(recipe.Ingredients, BrowseIngredientFragment.ViewModel);
            ObservableCollection <Ingredient> ingList = new ObservableCollection <Ingredient>();
            List <float> qList = ItemParser.QuantityValuesToFloatList(recipe.Quantities);
            double       price = ItemParser.GetEstimatedPrice(recipe, BrowseIngredientFragment.ViewModel);

            ratingSeekBar.Progress = recipe.Rating;

            placeholderL.ForEach(i => ingList.Add(i));
            ingredientList.SetAdapter(adapter = new RecipeIngredientsAdapter(this, ingList, qList));

            recipeDetails.Text     = recipe.Instructions;
            recipeAllergen.Text    = GetString(Resource.String.no);
            recipePrice.Text       = Utils.ParsePrice(price);
            SupportActionBar.Title = recipe.Name;
        }
コード例 #2
0
        /// <summary>
        /// Handles the actions to do when this activity is created
        /// </summary>
        /// <param name="savedInstanceState">Saved instance state.</param>
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            toastAlert = true;
            editRecipe = null;
            editMode   = false;

            IngViewModel     = BrowseIngredientFragment.ViewModel;
            RecViewModel     = BrowseRecipeFragment.ViewModel;
            ingredientNames  = IngViewModel.Ingredients.Select(ingredient => ingredient.Name).ToArray();
            addedIngredients = new ObservableCollection <Ingredient>();

            SetContentView(Resource.Layout.activity_add_recipe);
            saveButton             = FindViewById <FloatingActionButton>(Resource.Id.save_button_addRecipe);
            nameField              = FindViewById <EditText>(Resource.Id.nameField_addRecipe);
            instructionsField      = FindViewById <EditText>(Resource.Id.instructionsField_addRecipe);
            addIngredientButton    = FindViewById <Button>(Resource.Id.addIngredientToRecipe_addRecipe);
            ingredientRecyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerviewAddIngredients_addRecipe);
            ingredientSpinner      = FindViewById <Spinner>(Resource.Id.ingredientSpinner_addRecipe);
            swipeRefreshLayout     = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout_addRecipe);

            ingredientRecyclerView.SetAdapter(adapter = new RecipeIngredientsAdapter(this, addedIngredients, quantityStore));
            ingredientSpinner.Adapter = new ArrayAdapter(this.ApplicationContext, Android.Resource.Layout.SimpleListItem1, ingredientNames);

            quantityStore = new List <float>();

            var data = Intent.GetStringExtra("recipe") ?? null;

            if (data != null)
            {
                editMode   = true;
                editRecipe = Newtonsoft.Json.JsonConvert.DeserializeObject <Recipe>(data);
                fillForm();
            }
            addIngredientButton.Click  += AddIngredientButton_Click;
            saveButton.Click           += SaveButton_Click;
            adapter.ItemLongClick      += IngredientRecyclerView_ItemLongClick;
            swipeRefreshLayout.Refresh += SwipeRefreshLayout_Refresh;
        }