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); }
public static async void SendTo(BluetoothSocket socket) { var list = TabaccoList.GetList(); string listString = JsonConvert.SerializeObject(list, Formatting.Indented); byte[] array = Encoding.ASCII.GetBytes(listString); await socket.OutputStream.WriteAsync(array, 0, array.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 override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var view = inflater.Inflate(Resource.Layout.layout_sync_file, container, false); view.FindViewById <Button>(Resource.Id.sf_export).Click += async(sender, e) => { ActivityCompat.RequestPermissions(Activity, new string[] { Manifest.Permission.WriteExternalStorage }, 1); string filename = "ShishaBacon_List_" + DateTime.Now.ToString("dd-MM-yyyy_HH:mm") + ".json"; string filePath = Path.Combine(Context.GetExternalFilesDir("").AbsolutePath, filename); if (File.Exists(filePath)) { File.Delete(filePath); } File.WriteAllText(filePath, JsonConvert.SerializeObject(TabaccoList.GetList(), Formatting.Indented)); await Share.RequestAsync(new ShareFileRequest { Title = "ShishaBacon-Liste", File = new ShareFile(filePath) }); finished(this, null); }; view.FindViewById <Button>(Resource.Id.sf_import).Click += async(sender, e) => { try { var result = await FilePicker.PickAsync(); if (result != null) { ActivityCompat.RequestPermissions(Activity, new string[] { Manifest.Permission.ReadExternalStorage }, 1); string resString = File.ReadAllText(result.FullPath); TabaccoList.ImportList(new List <Tabacco>(JsonConvert.DeserializeObject <Tabacco[]>(resString))); view.FindViewById <TextView>(Resource.Id.sf_text).Text = "Imported File: " + result.FileName; } } catch (Exception ex) { Console.WriteLine(ex.Message); // The user canceled or something went wrong } }; return(view); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); try { Stream stream = ContentResolver.OpenInputStream(Intent.Data); string res = new StreamReader(stream).ReadToEnd(); if (!string.IsNullOrWhiteSpace(res)) { TabaccoList.ImportList(new List <Tabacco>(JsonConvert.DeserializeObject <Tabacco[]>(res))); } } catch (Exception) { } StartActivity(typeof(MainActivity)); }
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); }
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; }); }); }