Exemple #1
0
 protected virtual void OnBeforeFragmentChanging(FragmentTransaction ft, Fragment fragment, MvxFragmentPresentationAttribute attribute)
 {
     if (attribute.SharedElements != null)
     {
         foreach (var item in attribute.SharedElements)
         {
             string name = item.Key;
             if (string.IsNullOrEmpty(name))
             {
                 name = ViewCompat.GetTransitionName(item.Value);
             }
             ft.AddSharedElement(item.Value, name);
         }
     }
     if (!attribute.EnterAnimation.Equals(int.MinValue) && !attribute.ExitAnimation.Equals(int.MinValue))
     {
         if (!attribute.PopEnterAnimation.Equals(int.MinValue) && !attribute.PopExitAnimation.Equals(int.MinValue))
         {
             ft.SetCustomAnimations(attribute.EnterAnimation, attribute.ExitAnimation, attribute.PopEnterAnimation, attribute.PopExitAnimation);
         }
         else
         {
             ft.SetCustomAnimations(attribute.EnterAnimation, attribute.ExitAnimation);
         }
     }
     if (attribute.TransitionStyle != int.MinValue)
     {
         ft.SetTransitionStyle(attribute.TransitionStyle);
     }
 }
        protected virtual void OnBeforeFragmentChanging(FragmentTransaction ft, MvxFragmentPresentationAttribute attribute)
        {
            if (attribute.SharedElements != null)
            {
                foreach (var item in attribute.SharedElements)
                {
                    ft.AddSharedElement(item.Value, item.Key);
                }
            }

            if (!attribute.EnterAnimation.Equals(int.MinValue) && !attribute.ExitAnimation.Equals(int.MinValue))
            {
                if (!attribute.PopEnterAnimation.Equals(int.MinValue) && !attribute.PopExitAnimation.Equals(int.MinValue))
                {
                    ft.SetCustomAnimations(attribute.EnterAnimation, attribute.ExitAnimation, attribute.PopEnterAnimation, attribute.PopExitAnimation);
                }
                else
                {
                    ft.SetCustomAnimations(attribute.EnterAnimation, attribute.ExitAnimation);
                }
            }

            if (attribute.TransitionStyle != int.MinValue)
            {
                ft.SetTransitionStyle(attribute.TransitionStyle);
            }
        }
        protected virtual void OnBeforeFragmentChanging(FragmentTransaction ft, Fragment fragment,
                                                        MvxFragmentPresentationAttribute attribute, MvxViewModelRequest request)
        {
            if (CurrentActivity is IMvxAndroidSharedElements sharedElementsActivity)
            {
                var elements = new List <string>();

                foreach (KeyValuePair <string, View> item in sharedElementsActivity.FetchSharedElementsToAnimate(attribute, request))
                {
                    var transitionName = ViewCompat.GetTransitionName(item.Value);
                    if (!string.IsNullOrEmpty(transitionName))
                    {
                        ft.AddSharedElement(item.Value, transitionName);
                        elements.Add($"{item.Key}:{transitionName}");
                    }
                    else
                    {
                        MvxAndroidLog.Instance.Warn("A XML transitionName is required in order to transition a control when navigating.");
                    }
                }

                if (elements.Count > 0)
                {
                    fragment.Arguments.PutString(SharedElementsBundleKey, string.Join("|", elements));
                }
            }

            SetAnimationsOnTransaction(ft, attribute);
        }
        protected virtual void OnBeforeFragmentChanging(FragmentTransaction ft, Fragment fragment, MvxFragmentPresentationAttribute attribute, MvxViewModelRequest request)
        {
            if (CurrentActivity is IMvxAndroidSharedElements sharedElementsActivity)
            {
                var elements = new List <string>();

                foreach (KeyValuePair <string, View> item in sharedElementsActivity.FetchSharedElementsToAnimate(attribute, request))
                {
                    var transitionName = item.Value.GetTransitionNameSupport();
                    if (!string.IsNullOrEmpty(transitionName))
                    {
                        ft.AddSharedElement(item.Value, transitionName);
                        elements.Add($"{item.Key}:{transitionName}");
                    }
                    else
                    {
                        MvxLog.Instance.Warn("A XML transitionName is required in order to transition a control when navigating.");
                    }
                }

                if (elements.Count > 0)
                {
                    fragment.Arguments.PutString(SharedElementsBundleKey, string.Join("|", elements));
                }
            }

            if (!attribute.EnterAnimation.Equals(int.MinValue) && !attribute.ExitAnimation.Equals(int.MinValue))
            {
                if (!attribute.PopEnterAnimation.Equals(int.MinValue) && !attribute.PopExitAnimation.Equals(int.MinValue))
                {
                    ft.SetCustomAnimations(attribute.EnterAnimation, attribute.ExitAnimation, attribute.PopEnterAnimation, attribute.PopExitAnimation);
                }
                else
                {
                    ft.SetCustomAnimations(attribute.EnterAnimation, attribute.ExitAnimation);
                }
            }

            if (attribute.TransitionStyle != int.MinValue)
            {
                ft.SetTransitionStyle(attribute.TransitionStyle);
            }
        }