protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); _persoon = Gegevens.GetPerson(); _groep = Gegevens.CurrentGroup(); SetContentView(Resource.Layout.Betaalscherm); _toolbar = FindViewById<Toolbar>(Resource.Id.toolbar); ImageView Avatar = _toolbar.FindViewById<ImageView>(Resource.Id.Avatar); TextView Title = _toolbar.FindViewById<TextView>(Resource.Id.Title); Title.Text = _groep.groepsnaam; foreach (var lid in _persoon.KrijgSchuldGroep(_groep)) { deelnemers.Add(new ListItem(lid.Key, Resource.Drawable.iconn, lid.Value, _groep)); } _adapter = new ListItemAdapter(ListItem.Session, deelnemers); _adapter.ItemClick += OnItemClick; _adapter.ItemLongClick += (sender, e) => {}; _recyclerView = FindViewById<RecyclerView>(Resource.Id.recyclerview); _recyclerView.SetMinimumHeight(ConvertDptoPx(listItemHeight*deelnemers.Count)); _recyclerView.SetLayoutManager(new LinearLayoutManager(this)); _recyclerView.SetScrollContainer(true); _recyclerView.NestedScrollingEnabled = false; _recyclerView.SetAdapter(_adapter); SetSupportActionBar(_toolbar); SupportActionBar.Title = ""; SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetDisplayShowHomeEnabled(true); }
public override void CreateEnvironment() { p = Gegevens.GetPerson(); ListItems = p.Contacten.Select(contact => new ListItem(contact, Resource.Drawable.iconn)).ToList(); ListItems = ListItems.OrderBy(x => x.Name).ToList(); Adapter = new ListItemAdapter(ListItem.Contact, ListItems); Adapter.ItemClick += (sender, args) => { ShowPopupMenu(sender, args, RecyclerView, this); }; Adapter.ItemLongClick += (sender, args) => { ShowPopupMenu(sender, args, RecyclerView, this); }; RecyclerView.SetAdapter(Adapter); }
public override void CreateEnvironment() { p = Gegevens.GetPerson(); ListItems = new List<ListItem>(); foreach (Groep groep in p.Groepen) { ListItems.Add(new ListItem(groep.groepsnaam, Resource.Drawable.iconn, p.TotaalSchuldGroep(groep), groep)); } ListItems = ListItems.OrderBy(x => x.Name).ToList(); Adapter = new ListItemAdapter(ListItem.Session, ListItems); Adapter.ItemClick += (sender, args) => { Gegevens.ChangeCurrentGroup((((ListItemAdapter) sender).Items[args.Position].Groep)); var activity = new Intent(this.Activity, typeof(Groepscherm)); StartActivity(activity); }; Adapter.ItemLongClick += (sender, args) => { //doe niks }; RecyclerView.SetAdapter(Adapter); }
private void CreateParticipantsEnvironment() { List<ListItem> participants = new List<ListItem>(); foreach (var naam in _persoon.KrijgSchuldGroep(_groep)) { participants.Add(new ListItem(naam.Key, Resource.Drawable.iconn, naam.Value, _groep)); } _participantsAdapter = new ListItemAdapter(ListItem.Session, participants); _participantsAdapter.ItemClick += (sender, args) => { ShowPopupMenu(args.Position); }; _participantsAdapter.ItemLongClick += (sender, args) => { ShowPopupMenu(args.Position); }; _participantsRecyclerView.LayoutParameters.Height = ConvertDptoPx(listItemHeight * _participantsAdapter.Items.Count); _participantsRecyclerView.SetAdapter(_participantsAdapter); }
private void CreateParticipantsEnvironment() { _participants = new List<ListItem>(); _participantsAdapter = new ListItemAdapter(ListItem.SampleContact, _participants); _participantsAdapter.ItemClick += (sender, args) => { Toast.MakeText(this, "Removed " + ((ListItemAdapter) sender).Items[args.Position].Name, ToastLength.Short).Show(); ((ListItemAdapter) sender).Items.RemoveAt(args.Position); ((ListItemAdapter) sender).NotifyDataSetChanged(); _participantsRecyclerView.LayoutParameters.Height = ConvertDptoPx(listItemHeight * _participantsAdapter.Items.Count); }; _participantsRecyclerView = FindViewById<RecyclerView>(Resource.Id.participantsrecyclerview); _participantsRecyclerView.LayoutParameters.Height = ConvertDptoPx(listItemHeight * _participantsAdapter.Items.Count); _participantsRecyclerView.SetLayoutManager(new LinearLayoutManager(this)); _participantsRecyclerView.SetScrollContainer(false); _participantsRecyclerView.NestedScrollingEnabled = false; _participantsRecyclerView.SetAdapter(_participantsAdapter); }
private void ShowDialog(ListItemAdapter adapter, int itemPosition, string dialogTitle, bool isPayment, bool isHistory) { AlertDialog.Builder builder = new AlertDialog.Builder(this.Activity, Resource.Style.AlertDialogStyle); var debtItem = adapter.Items[itemPosition]; builder.SetTitle(dialogTitle); View dialogView; if (isPayment) { dialogView = this.Activity.LayoutInflater.Inflate(Resource.Layout.PaymentDialog, null); builder.SetView(dialogView); } else { if (isHistory) { dialogView = this.Activity.LayoutInflater.Inflate(Resource.Layout.HistoryDialog, null); builder.SetView(dialogView); dialogView.FindViewById<TextView>(Resource.Id.dialogItemDate).Text = debtItem.StringValue; } else { dialogView = this.Activity.LayoutInflater.Inflate(Resource.Layout.DebtDialog, null); builder.SetView(dialogView); } List<string> tempList = debtItem.FullDescription.Split('-').ToList(); tempList.RemoveAt(0); if (tempList.Count != 0) // check of er producten zijn toegevoegd { tempList.RemoveAt(tempList.Count - 1); } List<ListItem> productList = new List<ListItem>(); for (int i = 0; i < tempList.Count; i += 2) { productList.Add(new ListItem(tempList[i], double.Parse(tempList[i + 1]) / 100)); } ListItemAdapter dialogAdapter = new ListItemAdapter(ListItem.DialogItem, productList); RecyclerView dialogRecyclerView = dialogView.FindViewById<RecyclerView>(Resource.Id.dialogrecyclerview); dialogRecyclerView.SetLayoutManager(new LinearLayoutManager(this.Activity)); dialogRecyclerView.SetAdapter(dialogAdapter); dialogView.FindViewById<TextView>(Resource.Id.dialogItemDescription).Text = debtItem.Description; } dialogView.FindViewById<TextView>(Resource.Id.dialogItemName).Text = debtItem.Name; dialogView.FindViewById<TextView>(Resource.Id.dialogItemValue).Text = debtItem.Value.ToString("N"); dialogView.FindViewById<ImageView>(Resource.Id.dialogItemImage).SetImageResource(debtItem.ImageId); builder.SetCancelable(true); builder.Show(); }
private void CreateContactList(List<ListItem> list) { _adapter = new ListItemAdapter (ListItem.Contact, list); _adapter.Filter.InvokeFilter("zxcvbnmasdfghjklqwertyuiopmnbvcxzlkjhgfdsapoiuytrewq"); _adapter.ItemClick += (sender, args) => { ShowPopupMenu(sender, args, _recyclerView, this); }; _recyclerView = FindViewById<RecyclerView> (Resource.Id.recyclerview); _recyclerView.SetLayoutManager (new LinearLayoutManager (this)); _recyclerView.SetAdapter (_adapter); }
public void CreateProductEnvironment() { //foreach (string participant in new List<string> {"Kekker Ino", "Lol Rofl", "Oane Ite", "Test"}) { foreach (string participant in Gegevens.CurrentGroup ().Deelnemers) { if (participant != Gegevens.GetPerson ().Id) { Participant person = new Participant (participant); person.debt = 0.00; enabledParticipants.Add (person); } } try // just to be sure { foreach (Tuple<string, double, bool> product in Gegevens.GetBonnetje()) { productList.Add (new ListItem(product.Item1, product.Item2, product.Item3, enabledParticipants, Enumerable.Repeat(true, enabledParticipants.Count).ToList())); } } catch { Toast.MakeText(this, "No products have been found", ToastLength.Long).Show(); Finish(); } /*double d = 4.20; //heheheh for (int i = 0; i < 5; i++) { productList.Add(new ListItem("testproduct", d, i % 2 == 1, enabledParticipants, Enumerable.Repeat(true, enabledParticipants.Count).ToList())); }*/ productAdapter = new ListItemAdapter (ListItem.ProcessedListItem, productList); _processedListRecyclerView.SetAdapter (productAdapter); productAdapter.ItemClick += (sender, args) => { if (args.ButtonPressed == -3) { //EDIT/BACK } else if (args.ButtonPressed == -2) { //DROPDOWN } else if (args.ButtonPressed == -1) { //HANDLE DELETION productList.RemoveAt(args.Position); productAdapter.NotifyItemRemoved(args.Position); productAdapter.NotifyItemRangeChanged(args.Position, productList.Count); } else if (args.ButtonPressed >= 0) { //HANDLE PARTICIPATION productList[args.Position].Deelnames[args.ButtonPressed] = !productList[args.Position].Deelnames[args.ButtonPressed]; productAdapter.NotifyItemChanged(args.Position); } }; }
private void CreatePendingDebtEnvironment() { _pendingDebtListItems = new List<ListItem>(); foreach (Debt debt in _persoon.KrijgRequestVanGroep(_groep)) { string realDebtReason = debt.Reason.Replace("%20", " "); string[] debtReasonList = realDebtReason.Split('-'); _pendingDebtListItems.Add(new ListItem("Payer: " + debt.Payer, debt.Amount, debtReasonList[0], realDebtReason, debt.DebtID, Debt.RedStatusColor)); } _pendingDebtAdapter = new ListItemAdapter(ListItem.DebtItem, _pendingDebtListItems); _pendingDebtAdapter.ItemClick += (sender, args) => { ShowDialog(_pendingDebtAdapter, args.Position, "Owing waiting for acception", false, false); }; _pendingDebtAdapter.ItemLongClick += (sender, args) => { //niks doen }; }
private void CreateActiveDebtEnvironment() { // testlijst _activeDebtListItems = new List<ListItem>(); foreach (Debt schuld in _persoon.KrijgDebtsVanGroep(_groep)) { string realDebtReason = schuld.Reason.Replace("%20", " "); string[] debtReasonList = realDebtReason.Split('-'); _activeDebtListItems.Add(new ListItem("Payer: " + schuld.Payer, schuld.Amount, debtReasonList[0], realDebtReason, schuld.DebtID, Debt.OrangeStatusColor)); } _activeDebtAdapter = new ListItemAdapter(ListItem.DebtItem, _activeDebtListItems); _activeDebtAdapter.ItemClick += (sender, args) => { ShowDialog(_activeDebtAdapter, args.Position, "Active owing", false, false); }; _activeDebtAdapter.ItemLongClick += (sender, args) => { //niks doen }; }
private void ShowDialog(ListItemAdapter adapter, int itemPosition, string dialogTitle, bool isPendingDialog, bool isPayment, bool isHistory) { AlertDialog.Builder builder = new AlertDialog.Builder(this.Activity, Resource.Style.AlertDialogStyle); var debtItem = adapter.Items[itemPosition]; builder.SetTitle(dialogTitle); if (isPendingDialog) { builder.SetPositiveButton("Accept", (senderAlert, e) => { if (dialogTitle.ToLower().Contains("debt")) { DatabaseInterface.AcceptDebt(debtItem.Id, _persoon.Id, _persoon.Password); Toast.MakeText(this.Activity, "Debt accepted: " + debtItem.Description, ToastLength.Short).Show(); SwipeRefreshLayout.Refreshing = true; this.Refresh(); } else if (dialogTitle.ToLower().Contains("payment")) { string[] user = debtItem.Name.Split(' '); foreach(int debt in _persoon.KrijgPaymentsVanGebruiker(user[1])) DatabaseInterface.AcceptPayment(debt, _persoon.Id, _persoon.Password); Toast.MakeText(this.Activity, "Payment accepted from: " + debtItem.Name, ToastLength.Short).Show(); SwipeRefreshLayout.Refreshing = true; this.Refresh(); } CreateEnvironments(); }); builder.SetNegativeButton("Decline", (s, e) => { if (dialogTitle.ToLower().Contains("debt")) { DatabaseInterface.DeclineDebt(debtItem.Id, _persoon.Id, _persoon.Password); Toast.MakeText(this.Activity, "Debt declined: " + debtItem.Description, ToastLength.Short).Show(); Gegevens.GetServerData(_persoon.Id, _persoon.Password); ((Payscherm)this.Activity).Restart(); } else if (dialogTitle.ToLower().Contains("payment")) { string[] user = debtItem.Name.Split(' '); foreach(int debt in _persoon.KrijgPaymentsVanGebruiker(user[1])) DatabaseInterface.DeclinePayment(debt, _persoon.Id, _persoon.Password); Toast.MakeText(this.Activity, "Payment declined from: " + debtItem.Name, ToastLength.Short).Show(); Gegevens.GetServerData(_persoon.Id, _persoon.Password); ((Payscherm)this.Activity).Restart(); } CreateEnvironments(); }); builder.SetNeutralButton("Cancel", (s, e) => { // dialog cancelt automatisch }); } View dialogView; if (isPayment) { dialogView = this.Activity.LayoutInflater.Inflate(Resource.Layout.PaymentDialog, null); builder.SetView(dialogView); } else { if (isHistory) { dialogView = this.Activity.LayoutInflater.Inflate(Resource.Layout.HistoryDialog, null); builder.SetView(dialogView); dialogView.FindViewById<TextView>(Resource.Id.dialogItemDate).Text = debtItem.StringValue; } else { dialogView = this.Activity.LayoutInflater.Inflate(Resource.Layout.DebtDialog, null); builder.SetView(dialogView); } List<string> tempList = debtItem.FullDescription.Split('-').ToList(); tempList.RemoveAt(0); if (tempList.Count != 0) // check of er producten zijn toegevoegd { tempList.RemoveAt(tempList.Count - 1); } // maak producten aan op basis van een stringlist List<ListItem> productList = new List<ListItem>(); for(int i = 0; i < tempList.Count; i += 2) { productList.Add(new ListItem(tempList[i], double.Parse(tempList[i+1]) / 100)); } ListItemAdapter dialogAdapter = new ListItemAdapter(ListItem.DialogItem, productList); RecyclerView dialogRecyclerView = dialogView.FindViewById<RecyclerView>(Resource.Id.dialogrecyclerview); dialogRecyclerView.SetLayoutManager(new LinearLayoutManager(this.Activity)); dialogRecyclerView.SetAdapter(dialogAdapter); dialogView.FindViewById<TextView>(Resource.Id.dialogItemDescription).Text = debtItem.Description; } dialogView.FindViewById<TextView>(Resource.Id.dialogItemName).Text = debtItem.Name; dialogView.FindViewById<TextView>(Resource.Id.dialogItemValue).Text = debtItem.Value.ToString("N"); dialogView.FindViewById<ImageView>(Resource.Id.dialogItemImage).SetImageResource(debtItem.ImageId); builder.SetCancelable(true); builder.Show(); }
private void CreateActiveDebtEnvironment() { _activeDebtListItems = new List<ListItem>(); foreach (Debt debt in _persoon.KrijgDebtsBijGroep(_groep)) { string realDebtReason = debt.Reason.Replace("%20", " "); string[] debtReasonList = realDebtReason.Split('-'); _activeDebtListItems.Add(new ListItem("Collector: " + debt.Collector, debt.Amount, debtReasonList[0], realDebtReason, debt.DebtID, Debt.OrangeStatusColor)); } _activeDebtAdapter = new ListItemAdapter(ListItem.DebtItem, _activeDebtListItems); _activeDebtAdapter.ItemClick += (sender, args) => { ShowDialog(_activeDebtAdapter, args.Position, "Active debt", false, false, false); }; _activeDebtAdapter.ItemLongClick += (sender, args) => { //niks doen }; }
private void MakeView(List<ListItem> _list, int state) { _adapter = new ListItemAdapter(state, _list); _recyclerView = FindViewById<RecyclerView>(Resource.Id.recyclerview); _recyclerView.SetMinimumHeight(ConvertDptoPx(listItemHeight*_list.Count)); _recyclerView.SetLayoutManager(new LinearLayoutManager(this)); _recyclerView.SetScrollContainer(true); _recyclerView.NestedScrollingEnabled = false; _recyclerView.SetAdapter(_adapter); SetSupportActionBar(_toolbar); SupportActionBar.Title = ""; SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetDisplayShowHomeEnabled(true); }
private void CreateEnvironment() { List<ListItem> listItems = new List<ListItem>(); List<PaidDebt> paidDebts = _persoon.KrijgHistorieVanGroep(_groep); foreach (PaidDebt debt in paidDebts) { string realDebtReason = debt.Reason.Replace("%20", " "); string[] debtReasonList = realDebtReason.Split('-'); listItems.Add(new ListItem("Payer: " + debt.Payer, debt.Amount, debtReasonList[0], realDebtReason, debt.Date, Resource.Drawable.ic_debt_up)); } paidDebts = _persoon.KrijgHistorieBijGroep(_groep); foreach (PaidDebt debt in paidDebts) { string realDebtReason = debt.Reason.Replace("%20", " "); string[] debtReasonList = realDebtReason.Split('-'); listItems.Add(new ListItem("Collector: " + debt.Collector, debt.Amount, debtReasonList[0], realDebtReason, debt.Date, Resource.Drawable.ic_debt_down)); } _adapter = new ListItemAdapter(ListItem.HistoryItem, listItems); _adapter.ItemClick += (sender, args) => { ShowDialog(args.Position); }; _adapter.ItemLongClick += (sender, args) => { ShowDialog(args.Position); }; _recyclerView.SetAdapter(_adapter); }
private void CreatePendingPaymentEnvironment() { //testlijst _pendingPaymentListItems = new List<ListItem>(); foreach (var debt in _persoon.PaymentsBij(_groep)) { _pendingPaymentListItems.Add(new ListItem("To: " + debt.Key, debt.Value, 0, Debt.YellowStatusColor)); } _pendingPaymentAdapter = new ListItemAdapter(ListItem.PaymentItem, _pendingPaymentListItems); _pendingPaymentAdapter.ItemClick += (sender, args) => { ShowDialog(_pendingPaymentAdapter, args.Position, "Payment waiting for acception", true, false); }; _pendingPaymentAdapter.ItemLongClick += (sender, args) => { //niks doen }; }
public ListItemFilter(ListItemAdapter adapter) { _adapter = adapter; }
private void RefreshRecyclerView(RecyclerView rv, ListItemAdapter adapter, TextView tv) { tv.Text = adapter.Items.Count.ToString(); rv.LayoutParameters.Height = ConvertDptoPx(ListItemHeight * adapter.Items.Count); rv.SetAdapter(adapter); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.AddParticipantsScherm); List<ListItem> contactList = new List<ListItem>(); contactList.Add(new ListItem("MacDonalds", Resource.Drawable.iconn)); contactList.Add(new ListItem("Burger King", Resource.Drawable.iconn)); contactList.Add(new ListItem("Kentucky Fried Chicken", Resource.Drawable.iconn)); contactList.Add(new ListItem("Appel", Resource.Drawable.iconn)); contactList.Add(new ListItem("Sinasappel", Resource.Drawable.iconn)); contactList.Add(new ListItem("Banaan", Resource.Drawable.iconn)); contactList.Add(new ListItem("Mango", Resource.Drawable.iconn)); contactList.Add(new ListItem("Luipaard", Resource.Drawable.iconn)); contactList.Add(new ListItem("Laptop", Resource.Drawable.iconn)); contactList.Add(new ListItem("Tafel", Resource.Drawable.iconn)); contactList.Add(new ListItem("Peer", Resource.Drawable.iconn)); contactList.Add(new ListItem("Auto", Resource.Drawable.iconn)); contactList.Add(new ListItem("Wafel", Resource.Drawable.iconn)); contactList = contactList.OrderBy(x => x.Name).ToList(); _adapter = new ListItemAdapter(ListItem.Contact, contactList); _adapter.ItemClick += (sender, args) => { string intentString = Intent.GetStringExtra("Current sessions"); if (intentString != string.Empty) { string[] contactStrings = intentString.Split('|'); for (int i = 0; i < contactStrings.Length; i++) { if (contactStrings[i] == _adapter.Items[args.Position].Name) { // Er is al session open met contact, dus // zet current groep naar de groep met naam: _adapter._items[args.Position].Name // en dan: Toast.MakeText(this, "Session bestaat al: " + _adapter.Items[args.Position].Name, ToastLength.Short).Show(); var intent = new Intent(this, typeof(Groepscherm)); StartActivity(intent); Finish(); } } // Maak nieuw groep aan met participants: user, gekozen contact, // zet current groep naar de net aangemaakte groep // en dan: Toast.MakeText(this, "Session bestaat nog niet: " + _adapter.Items[args.Position].Name, ToastLength.Short).Show(); var myIntent = new Intent(this, typeof(Groepscherm)); StartActivity(myIntent); Finish(); } }; _recyclerView = FindViewById<RecyclerView>(Resource.Id.recyclerview); _recyclerView.SetLayoutManager(new LinearLayoutManager(this)); _recyclerView.SetAdapter(_adapter); Toolbar _toolbar = FindViewById<Toolbar>(Resource.Id.toolbar); SetSupportActionBar(_toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetDisplayShowHomeEnabled(true); SupportActionBar.Title = "New DEBT Single Session"; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.AddParticipantsScherm); _persoon = Gegevens.GetPerson(); _groep = Gegevens.CurrentGroup(); // haal contectenlijst uit database en stop ze in ListItem lijst List<ListItem> contactList = DatabaseInterface.GetContacts(_persoon.Id, _persoon.Password).Select(contact => new ListItem(contact, Resource.Drawable.iconn)).ToList(); contactList = contactList.OrderBy(x => x.Name).ToList(); _adapter = new ListItemAdapter(ListItem.CheckBoxContact, contactList); _adapter.ItemClick += (sender, args) => { Toast.MakeText(this, _adapter.Items[args.Position].Name, ToastLength.Short).Show(); }; _recyclerView = FindViewById<RecyclerView>(Resource.Id.recyclerview); _recyclerView.SetLayoutManager(new LinearLayoutManager(this)); _recyclerView.SetAdapter(_adapter); string intentString = Intent.GetStringExtra("Current participants"); if (intentString != string.Empty) { string[] contactStrings = intentString.Split('|'); if (contactStrings[0] == "New Group") { for (int i = 1; i < contactStrings.Length; i++) { string[] contactAttr = contactStrings[i].Split(','); foreach (var item in _adapter.Items) { if (contactAttr[0] == item.Name) { item.State = true; } } } } else if (contactStrings[0] == "Existing Group") { for (int i = 1; i < contactStrings.Length; i++) { string[] contactAttr = contactStrings[i].Split(','); for (int j = 0; j < _adapter.Items.Count; j++) { if (contactAttr[0] == _adapter.Items[j].Name) { _adapter.Items.RemoveAt(j); break; } } } } _adapter.NotifyDataSetChanged(); } Toolbar toolbar = FindViewById<Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetDisplayShowHomeEnabled(true); SupportActionBar.Title = "Add participants"; }