protected override void ShowActivity(Type view,
                                             MvxActivityPresentationAttribute attribute,
                                             MvxViewModelRequest request)
        {
            var intent = CreateIntentForRequest(request);

            if (attribute.Extras != null)
            {
                intent.PutExtras(attribute.Extras);
            }

            var activity = CurrentActivity;

            if (activity == null)
            {
                MvxTrace.Warning("Cannot Resolve current top activity");
                return;
            }

            if (attribute.SharedElements != null)
            {
                IList <Pair> sharedElements = new List <Pair>();
                foreach (var item in attribute.SharedElements)
                {
                    intent.PutExtra(item.Key, ViewCompat.GetTransitionName(item.Value));
                    sharedElements.Add(Pair.Create(item.Value, item.Key));
                }
                ActivityOptionsCompat options = ActivityOptionsCompat.MakeSceneTransitionAnimation(CurrentActivity, sharedElements.ToArray());
                activity.StartActivity(intent, options.ToBundle());
            }
            else
            {
                activity.StartActivity(intent);
            }
        }
예제 #2
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, 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 override void ShowDialogFragment(Type view,
                                                   MvxDialogFragmentPresentationAttribute attribute,
                                                   MvxViewModelRequest request)
        {
            var fragmentName = FragmentJavaName(attribute.ViewType);
            IMvxFragmentView mvxFragmentView = CreateFragment(attribute, fragmentName);
            var dialog = (DialogFragment)mvxFragmentView;

            // MvxNavigationService provides an already instantiated ViewModel here,
            // therefore just assign it
            if (request is MvxViewModelInstanceRequest instanceRequest)
            {
                mvxFragmentView.ViewModel = instanceRequest.ViewModelInstance;
            }
            else
            {
                mvxFragmentView.LoadViewModelFrom(request, null);
            }

            dialog.Cancelable = attribute.Cancelable;

            Dialogs.Add(mvxFragmentView.ViewModel, dialog);

            var ft = CurrentFragmentManager.BeginTransaction();

            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);
            }

            if (attribute.AddToBackStack == true)
            {
                ft.AddToBackStack(fragmentName);
            }

            dialog.Show(ft, fragmentName);
        }
예제 #5
0
        private void ProfileImageView_Click(object sender, EventArgs e)
        {
            var intent = new Intent(this, typeof(FullscreenImageActivity));
            var pp     = new ProfileParcelable();

            pp.UserProfile = user;
            intent.PutExtra(Constants.TRANSITION_NAME, ViewCompat.GetTransitionName(profileImageView));
            intent.PutExtra(Constants.PROFILE_DATA_EXTRA, pp);
            intent.PutExtra(Constants.PARCEL_TYPE, 1);
            var options = ActivityOptionsCompat.MakeSceneTransitionAnimation(this, profileImageView,
                                                                             ViewCompat.GetTransitionName(profileImageView));

            StartActivity(intent, options.ToBundle());
        }
예제 #6
0
        protected virtual ActivityOptionsCompat CreateActivityTransitionOptions(Android.Content.Intent intent, MvxActivityPresentationAttribute attribute)
        {
            ActivityOptionsCompat options = null;

            if (attribute.SharedElements != null)
            {
                IList <Pair> sharedElements = new List <Pair>();
                foreach (var item in attribute.SharedElements)
                {
                    intent.PutExtra(item.Key, ViewCompat.GetTransitionName(item.Value));
                    sharedElements.Add(Pair.Create(item.Value, item.Key));
                }
                options = ActivityOptionsCompat.MakeSceneTransitionAnimation(CurrentActivity, sharedElements.ToArray());
            }

            return(options);
        }
        protected virtual void PerformShowFragmentTransaction(
            FragmentManager fragmentManager,
            MvxFragmentPresentationAttribute attribute,
            MvxViewModelRequest request)
        {
            var fragmentName = FragmentJavaName(attribute.ViewType);
            var fragment     = CreateFragment(attribute, fragmentName);

            // MvxNavigationService provides an already instantiated ViewModel here,
            // therefore just assign it
            if (request is MvxViewModelInstanceRequest instanceRequest)
            {
                fragment.ViewModel = instanceRequest.ViewModelInstance;
            }
            else
            {
                var bundle            = new Bundle();
                var serializedRequest = NavigationSerializer.Serializer.SerializeObject(request);
                bundle.PutString(ViewModelRequestBundleKey, serializedRequest);

                var fragmentView = fragment.ToFragment();
                if (fragmentView != null)
                {
                    fragmentView.Arguments = bundle;
                }
            }

            var ft = fragmentManager.BeginTransaction();

            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);
            }

            if (attribute.AddToBackStack == true)
            {
                ft.AddToBackStack(fragmentName);
            }

            ft.Replace(attribute.FragmentContentId, (Fragment)fragment, fragmentName);
            ft.CommitAllowingStateLoss();
        }
        private async Task NextActivity()
        {
            await Task.Delay(interval).ConfigureAwait(true);

            Intent          intent  = new Intent(this, typeof(SignInActivity));
            ActivityOptions options = ActivityOptions.MakeSceneTransitionAnimation(this, logoAnim, ViewCompat.GetTransitionName(logoAnim));

            StartActivity(intent, options.ToBundle());
            Finish();
        }
예제 #9
0
        private void SetUpRecycler()
        {
            postAdapter = new PostAdapter(this, posts);
            mainRecycler.SetAdapter(postAdapter);
            emptyObserver = new RecyclerViewEmptyObserver(mainRecycler, emptyRoot);
            postAdapter.RegisterAdapterDataObserver(emptyObserver);
            postAdapter.ItemLongClick += (s1, e1) =>
            {
                string postID  = posts[e1.Position].ID;
                string ownerID = posts[e1.Position].OwnerId;

                if (SessionManager.GetFirebaseAuth().CurrentUser.Uid != ownerID)
                {
                    return;
                }

                var sweetDialog = new SweetAlertDialog(this, SweetAlertDialog.WarningType);
                sweetDialog.SetTitleText("Post Options");
                sweetDialog.SetContentText("Do you want to edit or delete selected post?");
                sweetDialog.SetCancelText("Delete");
                sweetDialog.SetConfirmText("Edit");
                sweetDialog.SetConfirmClickListener(new SweetConfirmClick(
                                                        onClick: d1 =>
                {
                    d1.ChangeAlertType(SweetAlertDialog.SuccessType);
                    d1.SetTitleText("Done");
                    d1.SetContentText("");
                    d1.ShowCancelButton(false);
                    d1.SetConfirmText("OK");
                    d1.SetConfirmClickListener(null);
                    d1.Show();
                }));
                sweetDialog.SetCancelClickListener(new SweetConfirmClick(
                                                       onClick: d2 =>
                {
                    SessionManager.GetFireDB().GetReference("posts").Child(postID).RemoveValue()
                    .AddOnCompleteListener(new OncompleteListener((onComplete) =>
                    {
                        switch (onComplete.IsSuccessful)
                        {
                        case false:
                            break;

                        default:
                            StorageReference storageReference = FirebaseStorage.Instance.GetReference("postImages/" + postID);
                            storageReference.DeleteAsync();
                            postAdapter.NotifyItemRemoved(e1.Position);
                            postAdapter.NotifyItemRangeChanged(e1.Position, posts.Count);
                            break;
                        }
                    }));
                    d2.ChangeAlertType(SweetAlertDialog.SuccessType);
                    d2.SetTitleText("Deleted");
                    d2.SetContentText("");
                    d2.ShowCancelButton(false);
                    d2.SetConfirmText("OK");
                    d2.SetConfirmClickListener(null);
                    d2.Show();
                }));
                sweetDialog.Show();
            };

            postAdapter.ItemClick += (s2, e2) =>
            {
                var intent = new Intent(this, typeof(FullscreenImageActivity));

                PostParcelable postParcelable = new PostParcelable();
                postParcelable.PostItem = posts[e2.Position];

                intent.PutExtra(Constants.TRANSITION_NAME, ViewCompat.GetTransitionName(e2.ImageView));
                intent.PutExtra(Constants.POST_DATA_EXTRA, postParcelable);
                intent.PutExtra(Constants.PARCEL_TYPE, 0);
                var options = ActivityOptionsCompat.MakeSceneTransitionAnimation(this, e2.ImageView,
                                                                                 ViewCompat.GetTransitionName(e2.ImageView));
                StartActivity(intent, options.ToBundle());
            };
        }