Exemple #1
0
        public void CreateRecyclerView(View view)
        {
            recyclerView = view.FindViewById <Android.Support.V7.Widget.RecyclerView>(Resource.Id.addressRecyclerView);

            Android.Support.V7.Widget.DividerItemDecoration dividerItemDecoration = new
                                                                                    Android.Support.V7.Widget.DividerItemDecoration(recyclerView.Context, Android.Support.V7.Widget.LinearLayoutManager.Vertical);

            List <AddressBook> addressBookList = new List <AddressBook>();

            addressBookAdapter = new AddressBookAdapter(addressBookList);

            recyclerView.SetLayoutManager(new Android.Support.V7.Widget.LinearLayoutManager(Context));
            recyclerView.SetAdapter(addressBookAdapter);
            recyclerView.AddItemDecoration(dividerItemDecoration);
            recyclerView.AddOnItemTouchListener(new RecyclerViewOnItemTouchListener(Context, recyclerView, new ClickListener(Context, searchEditView)));

            addressBookList.Add(new AddressBook("Steven Howchenhowser", "*****@*****.**", "1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L"));
            addressBookList.Add(new AddressBook("Taun Olson", "*****@*****.**", "1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L"));
            addressBookList.Add(new AddressBook("Todd Hoffman", "*****@*****.**", "PKM90iag9jJgTHD1VXjvLCEnZuQ3rTCF0Q"));
            addressBookList.Add(new AddressBook("Todd Swasinger", "*****@*****.**", "20M90iag9jJgTHD1VXjvLCEnZuQ3rTCF0Q"));
            addressBookList.Add(new AddressBook("Ramin Zahraie", "*****@*****.**", "58M90iag9jJgTHD1VXjvLCEnZuQ3rTCH1X"));
            addressBookList.Add(new AddressBook("Steve Smith", "*****@*****.**", "58M90iag9jJgTHD1VXjvLCEnZuQ3rTCH2H"));
            addressBookList.Add(new AddressBook("William Johnson", "*****@*****.**", "58M90iag9jJgTHD1VXjvLCEnZuQ3rTCH27T"));

            addressBookAdapter.NotifyDataSetChanged();
        }
        private void ShowSendDialog()
        {
            var builder = new Android.Support.V7.App.AlertDialog.Builder(Context);

            builder.SetTitle("Send");

            LayoutInflater layoutInflater = Activity.LayoutInflater;

            View view = layoutInflater.Inflate(Resource.Layout.sendlayout, null, false);

            mainLayout = view.FindViewById <LinearLayout>(Resource.Id.mainSendLayout);

            List <AddressBook> addressBookList = new List <AddressBook>();

            btcAddressLayout = view.FindViewById <Android.Support.Design.Widget.TextInputLayout>(
                Resource.Id.username_layout);
            labelLayout = view.FindViewById <Android.Support.Design.Widget.TextInputLayout>(
                Resource.Id.labelLayout);
            amountLayout = view.FindViewById <Android.Support.Design.Widget.TextInputLayout>(
                Resource.Id.amountLayout);
            recyclerView = view.FindViewById <Android.Support.V7.Widget.RecyclerView>(Resource.Id.recyclerView);

            addressBookAdapter = new AddressBookAdapter(addressBookList);

            bitCoinAddressView = view.FindViewById <AutoCompleteTextView>(Resource.Id.autoComplete);
            labelTextView      = view.FindViewById <TextInputEditText>(Resource.Id.labelEdit);
            amountTextView     = view.FindViewById <TextInputEditText>(Resource.Id.amountEdit);

            buttonLayout = view.FindViewById <LinearLayout>(Resource.Id.buttonLayout);

            addressBookButton = view.FindViewById <Button>(Resource.Id.addressBook);
            qrCodeButton      = view.FindViewById <Button>(Resource.Id.qrCode);
            clearButton       = view.FindViewById <Button>(Resource.Id.clear);

            Android.Support.V7.Widget.DividerItemDecoration dividerItemDecoration = new
                                                                                    Android.Support.V7.Widget.DividerItemDecoration(recyclerView.Context, Android.Support.V7.Widget.LinearLayoutManager.Vertical);

            recyclerView.SetLayoutManager(new Android.Support.V7.Widget.LinearLayoutManager(builder.Context));
            recyclerView.SetAdapter(addressBookAdapter);
            recyclerView.AddItemDecoration(dividerItemDecoration);
            //recyclerView.AddOnItemTouchListener(new RecyclerViewOnItemTouchListener(Context, recyclerView, new ClickListener(Context)));

            addressBookList.Add(new AddressBook("Steven Howchenhowser", "*****@*****.**", "1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L"));
            addressBookList.Add(new AddressBook("Taun Olson", "*****@*****.**", "1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L"));
            addressBookList.Add(new AddressBook("Todd Hoffman", "*****@*****.**", "PKM90iag9jJgTHD1VXjvLCEnZuQ3rTCF0Q"));
            addressBookList.Add(new AddressBook("Todd Swasinger", "*****@*****.**", "20M90iag9jJgTHD1VXjvLCEnZuQ3rTCF0Q"));
            addressBookList.Add(new AddressBook("Ramin Zahraie", "*****@*****.**", "58M90iag9jJgTHD1VXjvLCEnZuQ3rTCH1X"));
            addressBookList.Add(new AddressBook("Steve Smith", "*****@*****.**", "58M90iag9jJgTHD1VXjvLCEnZuQ3rTCH2H"));
            addressBookList.Add(new AddressBook("William Johnson", "*****@*****.**", "58M90iag9jJgTHD1VXjvLCEnZuQ3rTCH27T"));


            addressBookAdapter.NotifyDataSetChanged();

            //@@address book


            addressBookButton.Click += AddressBookButton_Click;
            clearButton.Click       += ClearButton_Click;

            List <string> addressList = new List <string>()
            {
                "1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L",
                "1NU19iag9jJgTHD1VXjvLCEnZuQ3rKDE9L",
                "PKM90iag9jJgTHD1VXjvLCEnZuQ3rTCF0Q",
                "20M90iag9jJgTHD1VXjvLCEnZuQ3rTCF0Q",
                "58M90iag9jJgTHD1VXjvLCEnZuQ3rTCH1X"
            };

            ArrayAdapter <String> addressListDataAdapters = new ArrayAdapter <String>(Context,
                                                                                      Android.Resource.Layout.SimpleListItem1, addressList);

            //bitCoinAddressView.Adapter = addressListDataAdapters;


            bitCoinAddressView.FocusChange += BitCoinAddressView_FocusChange;
            //bitCoinAddressView.AddTextChangedListener(new TextWatcher(ref addressBookAdapter));
            bitCoinAddressView.AfterTextChanged += BitCoinAddressView_AfterTextChanged;
            bitCoinAddressView.TextChanged      += BitCoinAddressView_TextChanged;
            labelTextView.FocusChange           += LabelTextView_FocusChange;
            amountTextView.FocusChange          += AmountTextView_FocusChange;

            builder.SetView(view);

            builder.SetPositiveButton(Resource.String.send, (senderAlert, args) =>
            {
                if ((bitCoinAddressView.Text.Length != 0) && (labelTextView.Text.Length != 0) &&
                    (amountTextView.Text.Length != 0))
                {
                    dataRepository.AddTransactionData(DateTime.Now, bitCoinAddressView.Text, labelTextView.Text, Convert.ToDecimal(amountTextView.Text),
                                                      GetValue(amountTextView.Text), "Sent to");

                    Snackbar s = Snackbar.Make(mainView, "Request sent. Add " + bitCoinAddressView.Text + " to address book?", Snackbar.LengthLong).SetAction("Yes", (v) =>
                    {
                        ShowAddressBookAddEntry();
                    });

                    s.Show();
                }
            });

            builder.SetNegativeButton(Resource.String.cancel, (senderAlert, args) => { });

            builder.Show();
        }