Exemplo n.º 1
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) : "");
        }
Exemplo n.º 2
0
        private void ShowMessageFragment(int actionBarTitle, int title, int message, int positiveButton, int negativeButton, string dynamicValues)
        {
            string btnNegative = "";

            if (negativeButton > 0)
            {
                btnNegative = GetText(negativeButton).ToTitleCase();
            }
            string msg = GetText(message);

            if (dynamicValues.IsBlank() == false)
            {
                object[] vals = JsonConvert.DeserializeObject <object[]>(dynamicValues);
                msg = msg.GetFormated(vals);
            }

            CustomInfoFragment.Info info = new CustomInfoFragment.Info()
            {
                ActionBarTitle        = GetText(actionBarTitle),
                Title                 = GetText(title),
                Content               = msg,
                PositiveButtonCaption = GetText(positiveButton).ToTitleCase(),
                NegativeButtonCaption = btnNegative
            };

            CustomInfoFragment customInfoFragment = new CustomInfoFragment();

            customInfoFragment.SetArgument(CustomInfoFragment.InfoKey, info);

            GetFragmentManager()
            .BeginTransaction()
            .Replace
            (
                Resource.Id.modalContent
                , customInfoFragment
            )
            .Commit();
            customInfoFragment.PositiveAction += customInfoFragment_PositiveAction;
            customInfoFragment.NegativeAction += customInfoFragment_NegativeAction;
        }
Exemplo n.º 3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.layout_resetpin);

            var trans = GetFragmentManager().BeginTransaction();

            // TODO check why this exists
            alertinfo = new CustomDialogFragment(
                string.Empty,
                this.GetString(Resource.String.pin_reset_no_internet),
                this.GetString(Resource.String.go_back), null, null);

            string dealerSupportLine = Settings.Instance.DealerSupportLine;

            CustomInfoFragment.Info info = new CustomInfoFragment.Info
            {
                ActionBarTitle        = Resources.GetString(Resource.String.pin_reset_fail_title),
                Title                 = Resources.GetString(Resource.String.pin_reset_fail_title),
                Content               = string.Format(Resources.GetString(Resource.String.pin_reset_fail_msg), dealerSupportLine),
                PositiveButtonCaption = Resources.GetString(Resource.String.try_again),
                NegativeButtonCaption = Resources.GetString(Resource.String.cancel_reset)
            };

            resetPinFailedFragment = new CustomInfoFragment();
            resetPinFailedFragment.SetArgument(CustomInfoFragment.InfoKey, info);

            // set event handlers for failed pin
            resetPinFailedFragment.PositiveAction += new CustomInfoFragment.BtnClick(go);
            resetPinFailedFragment.NegativeAction += new CustomInfoFragment.BtnClick(GoBackToLogin);

            // register fragment
            trans.Add(Resource.Id.reset_pin_placeholder, resetPinFailedFragment, RESETPINFAILED_FRAGMENT_TAG);
            trans.AddToBackStack(null);
            trans.Hide(resetPinFailedFragment);

            CustomInfoFragment.Info infoSuccess = new CustomInfoFragment.Info()
            {
                ActionBarTitle        = Resources.GetString(Resource.String.pin_reset_done),
                Title                 = Resources.GetString(Resource.String.pin_reset_done),
                Content               = Resources.GetString(Resource.String.pin_reset_success_msg),
                PositiveButtonCaption = Resources.GetString(Resource.String.back_to_login)
            };

            resetPinResultInfoFragment = new CustomInfoFragment();
            resetPinResultInfoFragment.SetArgument(CustomInfoFragment.InfoKey, infoSuccess);

            resetPinResultInfoFragment.PositiveAction += new CustomInfoFragment.BtnClick(GoBackToLogin);

            trans.Add(Resource.Id.reset_pin_placeholder, resetPinResultInfoFragment, RESETPINRESULT_FRAGMENT_TAG);
            trans.AddToBackStack(null);
            trans.Hide(resetPinResultInfoFragment);

            fragmentResetPin = new ResetPinFragment();
            fragmentResetPin.ButtonNextClicked += fragmentResetPin_ButtonNextClicked;
            trans.Add(Resource.Id.reset_pin_placeholder, fragmentResetPin, RESETPIN_FRAGMENT_TAG);
            trans.AddToBackStack(null);
            trans.Hide(fragmentResetPin);

            progressFragment = new ProgressFragment();
            Bundle arguments = new Bundle();

            arguments.PutString(ProgressFragment.TitleKey, GetString(Resource.String.reset_pin_title));
            arguments.PutString(ProgressFragment.MessageKey, GetString(Resource.String.resetting_pin));
            progressFragment.Arguments = arguments;
            trans.Add(Resource.Id.reset_pin_placeholder, progressFragment, RESETPINPROGRESS_FRAGMENT_TAG);
            trans.AddToBackStack(null);

            trans.Commit();
            go();
            // TODO check why we are adding all the fragments to start with and not only when needed
        }