private void updateUsername() { Rater user = RaterSaved.GetRater(); if (user != null && FindViewById <AppCompatTextView>(Resource.Id.userName) != null) { FindViewById <AppCompatTextView>(Resource.Id.userName).SetText(user.Name.ToCharArray(), 0, user.Name.Length); } }
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); }
public void AddRatings(List <Rating> ratings) { foreach (Rating rating in ratings) { if (rating.rater.Equals(RaterSaved.GetRater())) { continue; } UpdateRating(rating); } }
public int GetOwnRating() { Rater me = RaterSaved.GetRater(); foreach (Rating rat in ratings) { if (rat.rater.Equals(me)) { return(rat.Value); } } return(-1); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var view = inflater.Inflate(Resource.Layout.layout_rater_change, container, false); view.FindViewById <EditText>(Resource.Id.rc_text).Text = RaterSaved.GetRater().Name; view.FindViewById <Button>(Resource.Id.rc_btn).Click += (sender, e) => { RaterSaved.SetRater(new Rater(view.FindViewById <EditText>(Resource.Id.rc_text).Text)); finished(this, null); }; return(view); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); AndroidX.AppCompat.Widget.Toolbar toolbar = FindViewById <AndroidX.AppCompat.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); DrawerLayout drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close); drawer.AddDrawerListener(toggle); drawer.DrawerOpened += (sender, e) => { updateUsername(); }; toggle.SyncState(); NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view); navigationView.SetNavigationItemSelectedListener(this); BluetoothHelper.getPermission(BaseContext, this); ActivityCompat.RequestPermissions(this, new string[] { Manifest.Permission.ReadExternalStorage }, 1); ActivityCompat.RequestPermissions(this, new string[] { Manifest.Permission.WriteExternalStorage }, 1); TabaccoList.Init(() => { RaterSaved.Init(() => { if (RaterSaved.GetRater().Name == Rater.DefaultName) { ShowRaterChange(); } else { updateUsername(); ShowTabaccoHome(); } finishedInit = true; }); }); }