예제 #1
0
        async Task ResetPinApiCall(string dsrPhone)
        {
            _apiCallRunning = false;
            try
            {
                if (string.IsNullOrEmpty(dsrPhone))
                {
                    dsrPhone = DsrPhone;
                }

                ShowFragment(progressFragment);

                ActionBar.SetHomeButtonEnabled(false);

                _apiCallRunning = true;
                ServerResponseDto serverResponse =
                    await new PinResetOperations
                    (

                    ).ResetPinAsync(dsrPhone);

                _apiCallRunning = false;
                ActionBar.SetHomeButtonEnabled(true);


                resetPinResultInfoFragment.SetContent(serverResponse.Title, serverResponse.Message);

                // if the response is empty, we consider it not correct
                if (String.IsNullOrEmpty(serverResponse.Message))
                {
                    serverResponse.RequestException = new Exception("No valid response from server.");
                }

                if (serverResponse.RequestException == null)
                {
                    resetPinResultInfoFragment.SetContent(serverResponse.Title, serverResponse.Message, GetString(Resource.String.back_to_login), null);
                    ShowFragment(resetPinResultInfoFragment);
                }
                else
                {
                    ShowFragment(resetPinFailedFragment);
                }
            }
            catch (Exception ex)
            {
                Log.Error("ResetPinActivity", ex.Message + "\n\n" + ex.StackTrace);
                ShowFragment(resetPinFailedFragment);
            }
            finally
            {
                _apiCallRunning = false;
            }
        }
예제 #2
0
        private void ShowFragment(ErrorDescriber describer, string story)
        {
            ActivityBase activityBase = this._context as ActivityBase;

            if (activityBase == null)
            {
                return;
            }

            var custInfoFragment =
                activityBase.SupportFragmentManager.FindFragmentByTag(new CustomInfoFragment().FragmentTag);

            if (custInfoFragment != null)
            {
                activityBase.SupportFragmentManager.BeginTransaction().Remove(custInfoFragment).Commit();
            }

            if (!activityBase.ErrorFragmentContainerExists)
            {
                Logger.Error("Container for error displaying fragment has not been set or could not be found. Error will be displayed in a dialog");
                describer.UiNotifierType = typeof(Dialog);
                Notify(describer, story);
                describer.UiNotifierType = typeof(FullOverlay);
                return;
            }

            CustomInfoFragment customInfoFragment = new CustomInfoFragment();

            customInfoFragment.PositiveAction += () =>
            {
                activityBase.SupportFragmentManager.BeginTransaction()
                .Remove(
                    activityBase.SupportFragmentManager.FindFragmentByTag(customInfoFragment.FragmentTag))
                .CommitAllowingStateLoss();
            };
            if (describer.RetrySupported)
            {
                customInfoFragment.NegativeAction += () => describer.RetryAction(describer.SuccessCallback);
            }

            activityBase.SupportFragmentManager.BeginTransaction()
            .Add(activityBase.ErrorFragmentContainerId, customInfoFragment, customInfoFragment.FragmentTag)
            .CommitAllowingStateLoss();
            customInfoFragment.SetContent("", story, activityBase.GetString(Resource.String.api_errors_ok), describer.RetrySupported ? activityBase.GetString(Resource.String.api_errors_retry) : "");
        }