Beispiel #1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.layout_tabacco_list, container, false);

            ListView list    = view.FindViewById <ListView>(Resource.Id.tl_list);
            Spinner  spinner = view.FindViewById <Spinner>(Resource.Id.tl_spinner);
            var      manList = new List <string>();

            manList.Add("All");
            manList.AddRange(TabaccoList.GetManufactorers());
            spinner.Adapter = new ArrayAdapter(Activity, Resource.Layout.sb_listitem, manList);

            spinner.ItemSelected += (sender, e) =>
            {
                list.Adapter = new ArrayAdapter <Tabacco>(Context, Resource.Layout.tl_listitem, TabaccoList.GetFilteredList(spinner.GetItemAtPosition(e.Position).ToString()));
                list.Invalidate();
            };

            list.Adapter           = new ArrayAdapter <Tabacco>(Context, Resource.Layout.tl_listitem, TabaccoList.GetList());
            list.TextFilterEnabled = true;
            list.ItemClick        += (sender, e) =>
            {
                Tabacco tb = TabaccoList.GetItemByString(((TextView)e.View).Text);

                itemClicked(this, new TabaccoListEventArgs(tb));
            };

            return(view);
        }
Beispiel #2
0
        public static bool RemoveTabacco(Tabacco tabacco)
        {
            bool success = list.Remove(tabacco);

            if (success)
            {
                Storage.SetTabaccoList(list);
            }
            return(success);
        }
Beispiel #3
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.layout_tabacco_menu, container, false);

            //Name
            view.FindViewById <EditText>(Resource.Id.tm_name).Text = tabacco.Name;

            //Manufactorer
            view.FindViewById <AutoCompleteTextView>(Resource.Id.tm_manufactorer).Text    = tabacco.Manufactorer;
            view.FindViewById <AutoCompleteTextView>(Resource.Id.tm_manufactorer).Adapter = new ArrayAdapter(Activity, Resource.Layout.sb_listitem, TabaccoList.GetManufactorers());

            //Rating
            view.FindViewById <SeekBar>(Resource.Id.tm_rating).Progress         = tabacco.GetOwnRating();
            view.FindViewById <SeekBar>(Resource.Id.tm_rating).Max              = Rating.MaxRating * Rating.Scaling;
            view.FindViewById <SeekBar>(Resource.Id.tm_rating).Min              = Rating.MinRating * Rating.Scaling;
            view.FindViewById <TextView>(Resource.Id.tm_rating_name).Text       = "Bewertung: " + ((double)view.FindViewById <SeekBar>(Resource.Id.tm_rating).Progress) / Rating.Scaling;
            view.FindViewById <SeekBar>(Resource.Id.tm_rating).ProgressChanged += (sender, e) =>
            {
                view.FindViewById <TextView>(Resource.Id.tm_rating_name).Text = "Bewertung: " + ((double)e.Progress) / Rating.Scaling;
            };

            //AvgRating
            view.FindViewById <TextView>(Resource.Id.tm_avgRating).Text = "Durchschnittliche Bewertung: " + tabacco.GetAverageRating() / Rating.Scaling;

            //Rating List
            ListView listView = view.FindViewById <ListView>(Resource.Id.tm_ratings);

            listView.Adapter = new ArrayAdapter <Rating>(Context, Resource.Layout.tm_listitem, tabacco.GetRatings());

            //Save
            view.FindViewById <Button>(Resource.Id.tm_save).Click += (sender, e) =>
            {
                Tabacco newT = new Tabacco(tabacco);

                newT.Name         = view.FindViewById <EditText>(Resource.Id.tm_name).Text;
                newT.Manufactorer = view.FindViewById <EditText>(Resource.Id.tm_manufactorer).Text;
                int rating = view.FindViewById <SeekBar>(Resource.Id.tm_rating).Progress;

                newT.UpdateRating(new Rating(RaterSaved.GetRater(), rating));

                TabaccoList.RemoveTabacco(tabacco);
                TabaccoList.AddTabacco(newT);
                finished(this, null);
            };

            //Delete
            view.FindViewById <Button>(Resource.Id.tm_delete).Click += (sender, e) =>
            {
                TabaccoList.RemoveTabacco(tabacco);
                finished(this, null);
            };


            return(view);
        }
Beispiel #4
0
        public static bool AddTabacco(Tabacco tabacco)
        {
            foreach (Tabacco tb in list)
            {
                if (tb.Equals(tabacco))
                {
                    return(false);
                }
            }

            list.Add(tabacco);
            SortList();
            Storage.SetTabaccoList(list);

            return(true);
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.layout_tabacco_new, container, false);

            view.FindViewById <AutoCompleteTextView>(Resource.Id.tn_manufactorer).Adapter = new ArrayAdapter(Activity, Resource.Layout.sb_listitem, TabaccoList.GetManufactorers());
            view.FindViewById <Button>(Resource.Id.tn_btn).Click += (sender, e) =>
            {
                Tabacco tb = new Tabacco
                {
                    Name         = view.FindViewById <EditText>(Resource.Id.tn_name).Text.Trim(),
                    Manufactorer = view.FindViewById <AutoCompleteTextView>(Resource.Id.tn_manufactorer).Text.Trim()
                };
                TabaccoList.AddTabacco(tb);
                finished(this, null);
            };

            return(view);
        }
Beispiel #6
0
 public Fragment_Tabacco_menu(Tabacco tabacco)
 {
     this.tabacco = tabacco;
 }
Beispiel #7
0
 public TabaccoListEventArgs(Tabacco tabacco)
 {
     Tabacco = tabacco;
 }