Exemplo n.º 1
0
        protected override void OnHandleIntent(Intent intent)
        {
            var password = intent.GetStringExtra(EXTR_PASSWORD);
            var email    = intent.GetStringExtra(EXTR_EMAIL);
            var status   = string.Empty;

            switch (intent.Action)
            {
            case REG_ACTION:
                var username = intent.GetStringExtra(EXTR_USERNAME);
                status = PWAPI.LoginCreate(username, password, email).Result;
                break;

            case LOGIN_ACTION:
                status = PWAPI.Login(email, password).Result;
                break;

            default:
                break;
            }
            Intent loginResponce = new Intent(RESPONSE_BROADCAST_FILTER);

            loginResponce.PutExtra(EXTR_STATUS, status);
            SendBroadcast(loginResponce);
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            username       = FindViewById <TextView>(Resource.Id.userName);
            email          = FindViewById <TextView>(Resource.Id.email);
            balance        = FindViewById <TextView>(Resource.Id.balance);
            titleContainer = FindViewById <LinearLayout>(Resource.Id.main_linearlayout_title);
            appBar         = FindViewById <AppBarLayout>(Resource.Id.app_bar);
            toolbar        = FindViewById <Toolbar>(Resource.Id.toolbar);
            toolbarLable   = FindViewById <TextView>(Resource.Id.toolbarLable);
            SetSupportActionBar(toolbar);
            SupportActionBar.SetDisplayShowTitleEnabled(false);

            appBar.AddOnOffsetChangedListener(this);
            startAlphaAnimation(toolbarLable, 0, ViewStates.Invisible);

            historylist = FindViewById <RecyclerView>(Resource.Id.histotyList);
            adapter     = new HistoryAdapter(new List <Transaction>());
            historylist.SetAdapter(adapter);
            adapter.ItemClick += (sender, item) =>
            {
                var editText = new EditText(this);
                editText.InputType = Android.Text.InputTypes.ClassNumber;
                int sum = 0;
                if (int.TryParse(item.amount, out sum))
                {
                    sum = Math.Abs(sum);
                }
                editText.Text = sum.ToString();
                AlertDialog.Builder alert = new AlertDialog.Builder(this, Resource.Style.Dialog);
                alert.SetTitle(Resource.String.repeat_dialog_title)
                .SetView(editText)
                .SetMessage(GetString(Resource.String.repeat_msg_format, item.username))
                .SetPositiveButton(Resource.String.btn_send, (s, e) =>
                {
                    PWAPI.PayTransaction(item.username, editText.Text, TransacrionComplete);
                })
                .SetNegativeButton(Resource.String.btn_cancel, (s, e) => { });

                alert.Show();
            };
            buttonSend        = FindViewById <FloatingActionButton>(Resource.Id.fab);
            buttonSend.Click += (sender, e) =>
            {
                StartPay();
            };
        }
Exemplo n.º 3
0
        private void CreatePayDialog(string name)
        {
            var editText = new EditText(this);

            editText.InputType = Android.Text.InputTypes.ClassNumber;
            AlertDialog.Builder alert = new AlertDialog.Builder(this, Resource.Style.Dialog);
            alert.SetTitle(Resource.String.pay_dialog_title)
            .SetView(editText)
            .SetPositiveButton(Resource.String.btn_send, (s, e) =>
            {
                PWAPI.PayTransaction(name, editText.Text, TransacrionComplete);
            })
            .SetNegativeButton(Resource.String.btn_cancel, (s, e) => { });
            alert.Show();
        }
Exemplo n.º 4
0
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            MenuInflater.Inflate(Resource.Menu.menu_search, menu);
            var searchItem = menu.FindItem(Resource.Id.action_search);

            searchView              = searchItem.ActionView as SearchView;
            searchView.FocusChange += (sender, e) =>
            {
                if (e.HasFocus)
                {
                    appBar.SetExpanded(false);
                }
            };
            searchView.QueryTextSubmit += (sender, args) =>
            {
                userList.ShowLoading(EmptyView.StyleEmptyView.TEXT_AND_PROGRESS, Resource.String.str_search);
                PWAPI.GetFilteredUserList(args.Query, FillList);
            };
            return(true);
        }
Exemplo n.º 5
0
 private void TransacrionComplete(Transaction t, string erroorMessage)
 {
     if (string.IsNullOrEmpty(erroorMessage))
     {
         balance.Text = GetString(Resource.String.balance_format, t.balance);
         PWAPI.GetListTransaction(FillHistoryList);
         balance.Text = GetString(Resource.String.balance_format, t.balance);
         AlertDialog.Builder alert = new AlertDialog.Builder(this, Resource.Style.Dialog)
                                     .SetTitle(Resource.String.pay_success)
                                     .SetMessage(GetString(Resource.String.pay_success_format, t.username, t.amount, t.balance))
                                     .SetPositiveButton(Resource.String.btn_ok, (sender, e) => { });
         alert.Show();
     }
     else
     {
         AlertDialog.Builder alert = new AlertDialog.Builder(this, Resource.Style.Dialog);
         alert.SetTitle(Resource.String.str_error).SetMessage(erroorMessage)
         .SetPositiveButton(Resource.String.btn_ok, (s, e) => { });
         alert.Show();
     }
 }
Exemplo n.º 6
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_pay);
            userList = FindViewById <EmptyRecyclerView>(Resource.Id.userList);
            userList.SetEmptView(FindViewById <EmptyView>(Resource.Id.empty_view));
            userList.ShowLoading(EmptyView.StyleEmptyView.ONLY_TEXT, Resource.String.str_default_search);
            toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            appBar  = FindViewById <AppBarLayout>(Resource.Id.app_bar);
            balance = FindViewById <TextView>(Resource.Id.balance);
            SetSupportActionBar(toolbar);
            SupportActionBar.SetTitle(Resource.String.pay_activity_title);
            adapter            = new UserListAdapter(new List <Users>());
            adapter.ItemClick += (sender, pos) =>
                                 CreatePayDialog(adapter.UsersList[pos].name);
            userList.SetAdapter(adapter);
            DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(userList.Context, LinearLayoutManager.Vertical);

            dividerItemDecoration.SetDrawable(GetDrawable(Resource.Drawable.divider));
            userList.AddItemDecoration(dividerItemDecoration);
            PWAPI.GetUserInfo(FillHeader);
        }
Exemplo n.º 7
0
 protected override void OnResume()
 {
     base.OnResume();
     PWAPI.GetUserInfo(FillHeader);
     PWAPI.GetListTransaction(FillHistoryList);
 }