public override void OnBackPressed() { if (categoryFab == null) { base.OnBackPressed(); return; } else if (FindViewById(Resource.Id.task_view) != null) { Intent.AddFlags(ActivityFlags.ClearTop); StartActivity(Intent); } var listener = new AnimatorListener(this); listener.AnimationEnd += (sender, e) => { if (IsFinishing || IsDestroyed) { return; } base.OnBackPressed(); }; categoryFab.Animate() .ScaleX(0f) .ScaleY(0f) .SetInterpolator(interpolator) .SetStartDelay(100) .SetListener(listener) .Start(); }
public override void OnBackPressed() { if (icon == null || quizFab == null) { base.OnBackPressed(); return; } icon.Animate() .ScaleX(.7f) .ScaleY(.7f) .Alpha(0f) .SetInterpolator(interpolator) .Start(); var listener = new AnimatorListener(this); listener.AnimationEnd += (sender, e) => { if (IsFinishing || IsDestroyed) { return; } base.OnBackPressed(); }; quizFab.Animate() .ScaleX(0f) .ScaleY(0f) .SetInterpolator(interpolator) .SetStartDelay(100) .SetListener(listener) .Start(); }
public ExpandHelper(Context context, Callback callback, int small, int large) { this.smallSize = small; this.maximumStretch = Math.Max(smallSize, 1) * StretchInterval; this.largeSize = large; this.context = context; this.callback = callback; this.scaler = new ViewScaler(); this.gravity = GravityFlags.Top; //this.scaleAnimation = ObjectAnimator.OfFloat (scaler, "Height", 0f); this.scaleAnimation = ValueAnimator.OfFloat(0f); this.scaleAnimation.Update += (sender, e) => scaler.Height = (float)e.Animation.AnimatedValue; this.scaleAnimation.SetDuration(ExpandDuration); AnimatorListenerAdapter glowVisibilityController = new AnimatorListener(); glowTopAnimation = ObjectAnimator.OfFloat(null, "alpha", 0f); glowTopAnimation.AddListener(glowVisibilityController); glowBottomAnimation = ObjectAnimator.OfFloat(null, "alpha", 0f); glowBottomAnimation.AddListener(glowVisibilityController); glowAnimationSet = new AnimatorSet(); glowAnimationSet.Play(glowTopAnimation).With(glowBottomAnimation); glowAnimationSet.SetDuration(GlowDuration); detector = new DoubleSwipeDetector(context, new GestureDetector(this)); }
private void Initialize() { Use3D = false; ScaleValueX = 0.7f; ScaleValueY = 0.95f; viewActivityOnClickListener = new OnClickListener(this); animationListener = new AnimatorListener(this); InitViews(Context, -1, -1); }
protected override void OnElementChanged(ElementChangedEventArgs <AnimationView> e) { base.OnElementChanged(e); if (Control == null) { _animationView = new LottieAnimationView(Context); _animatorListener = new AnimatorListener(PlaybackFinished); _animationView.AddAnimatorListener(_animatorListener); SetNativeControl(_animationView); } if (e.OldElement != null) { e.OldElement.OnPlay -= OnPlay; e.OldElement.OnPause -= OnPause; e.OldElement.OnPlayProgressSegment -= OnPlayProgressSegment; e.OldElement.OnPlayFrameSegment -= OnPlayFrameSegment; _animationView.SetOnClickListener(null); } if (e.NewElement != null) { e.NewElement.OnPlay += OnPlay; e.NewElement.OnPause += OnPause; e.NewElement.OnPlayProgressSegment += OnPlayProgressSegment; e.NewElement.OnPlayFrameSegment += OnPlayFrameSegment; _animationView.SetRenderMode(e.NewElement.HardwareAcceleration ? RenderMode.Hardware : RenderMode.Software); _animationView.Speed = e.NewElement.Speed; _animationView.Loop(e.NewElement.Loop); _animationView.ImageAssetsFolder = e.NewElement.ImageAssetsFolder; _animationView.SetOnClickListener(new Lottie.Forms.Droid.AnimationViewRenderer.ClickListener(e.NewElement)); if (!string.IsNullOrEmpty(e.NewElement.Animation)) { _animationView.SetAnimation(e.NewElement.Animation); Element.Duration = TimeSpan.FromMilliseconds(_animationView.Duration); } if (e.NewElement.AutoPlay || e.NewElement.IsPlaying) { _animationView.PlayAnimation(); } } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); this.OverridePendingTransition(Resource.Animation.slide_right,Resource.Animation.slide_left); PostRootView = this.BindingInflate(Resource.Layout.PostView, null); SetContentView (PostRootView); PostRootView.ViewTreeObserver.AddOnGlobalLayoutListener (this); txtName = (EditText)PostRootView.FindViewById (Resource.Id.post_view_comments_editText_name); txtEmail = (EditText)PostRootView.FindViewById (Resource.Id.post_view_comments_editText_email); if (Settings.wpLoggedIn) { txtName.Visibility = ViewStates.Gone; txtEmail.Visibility = ViewStates.Gone; } ObservableWebview web = (ObservableWebview)this.FindViewById (Resource.Id.post_view_webview); WebSettings settings = web.Settings; settings.DefaultTextEncodingName = "utf-8"; PostViewModel.PropertyChanged += (sender, e) => { if(e.PropertyName == "Html") { web.LoadData (((PostViewModel)base.ViewModel).Html,"text/html; charset=utf-8","utf-8"); } }; CommentsView = PostRootView.FindViewById (Resource.Id.post_view_comments_layout); InputCommentEditText = PostRootView.FindViewById (Resource.Id.post_view_comments_editText); PostViewModel.CommentPressed += (sender, e) => { if (IsCommentsViewAnimating) return; if(CommentsView.Visibility == ViewStates.Visible){ //hide softkeyboard HideSoftkeyboard (); //hide IsCommentsViewAnimating = true; var al = new AnimatorListener(); al.OnAnimationEndAction = (Animator animation) => { CommentsView.Visibility = ViewStates.Gone; IsCommentsViewAnimating = false; }; CommentsView.Animate().TranslationX(CommentsView.Width).SetListener(al).SetDuration(200); } else { //show IsCommentsViewAnimating = true; var al = new AnimatorListener(); al.OnAnimationEndAction = (Animator animation) => { IsCommentsViewAnimating = false; }; if (CommentsView.TranslationX < PostRootView.Width){ //width of the view is zero before layout CommentsView.TranslationX = PostRootView.Width; //set to right } CommentsView.Visibility = ViewStates.Visible; CommentsView.Animate().TranslationX(0).SetListener(al).SetDuration(200); } }; PostViewModel.PostCommentPressed += (sender, e) => { HideSoftkeyboard (); ((EditText)InputCommentEditText).Text = string.Empty;//using binding }; PostViewModel.ErrorHandler += (sender, e) => { ErrorEventArgs ee = (ErrorEventArgs)e; var dispatcher = Mvx.Resolve<IMvxMainThreadDispatcher> (); dispatcher.RequestMainThreadAction (() => { AlertDialog.Builder builder = new AlertDialog.Builder (this); builder.SetTitle (ee.Title); builder.SetMessage (ee.Message); builder.SetNegativeButton (ee.CloseTitle, (EventHandler<DialogClickEventArgs>)null); builder.Show (); }); }; View BottomView = PostRootView.FindViewById (Resource.Id.post_view_bottom_layout); web.BottomReached += (sender, e) => { if (IsBottomViewAnimating) return; if(BottomView.Visibility == ViewStates.Gone) { //show IsBottomViewAnimating = true; var al = new AnimatorListener(); al.OnAnimationEndAction = (Animator animation) => { IsBottomViewAnimating = false; }; if (BottomView.TranslationY < PostRootView.Height){ //width of the view is zero before layout BottomView.TranslationY = PostRootView.Height; //set to right } BottomView.Visibility = ViewStates.Visible; BottomView.Animate().TranslationY(0).SetListener(al).SetDuration(500); } }; web.UnBottomReached += (sender, e) => { if (IsBottomViewAnimating) return; if(BottomView.Visibility == ViewStates.Visible){ //hide IsBottomViewAnimating = true; var al = new AnimatorListener(); al.OnAnimationEndAction = (Animator animation) => { BottomView.Visibility = ViewStates.Gone; IsBottomViewAnimating = false; }; BottomView.Animate().TranslationY(BottomView.Height).SetListener(al).SetDuration(500); } }; this.StartCalled += (sender, e) => PostViewModel.LoadPost(); //this.OnBackPressed }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); this.OverridePendingTransition(Resource.Animation.slide_right, Resource.Animation.slide_left); PostRootView = this.BindingInflate(Resource.Layout.PostView, null); SetContentView(PostRootView); PostRootView.ViewTreeObserver.AddOnGlobalLayoutListener(this); txtName = (EditText)PostRootView.FindViewById(Resource.Id.post_view_comments_editText_name); txtEmail = (EditText)PostRootView.FindViewById(Resource.Id.post_view_comments_editText_email); if (Settings.wpLoggedIn) { txtName.Visibility = ViewStates.Gone; txtEmail.Visibility = ViewStates.Gone; } ObservableWebview web = (ObservableWebview)this.FindViewById(Resource.Id.post_view_webview); WebSettings settings = web.Settings; settings.DefaultTextEncodingName = "utf-8"; PostViewModel.PropertyChanged += (sender, e) => { if (e.PropertyName == "Html") { web.LoadData(((PostViewModel)base.ViewModel).Html, "text/html; charset=utf-8", "utf-8"); } }; CommentsView = PostRootView.FindViewById(Resource.Id.post_view_comments_layout); InputCommentEditText = PostRootView.FindViewById(Resource.Id.post_view_comments_editText); PostViewModel.CommentPressed += (sender, e) => { if (IsCommentsViewAnimating) { return; } if (CommentsView.Visibility == ViewStates.Visible) { //hide softkeyboard HideSoftkeyboard(); //hide IsCommentsViewAnimating = true; var al = new AnimatorListener(); al.OnAnimationEndAction = (Animator animation) => { CommentsView.Visibility = ViewStates.Gone; IsCommentsViewAnimating = false; }; CommentsView.Animate().TranslationX(CommentsView.Width).SetListener(al).SetDuration(200); } else { //show IsCommentsViewAnimating = true; var al = new AnimatorListener(); al.OnAnimationEndAction = (Animator animation) => { IsCommentsViewAnimating = false; }; if (CommentsView.TranslationX < PostRootView.Width) { //width of the view is zero before layout CommentsView.TranslationX = PostRootView.Width; //set to right } CommentsView.Visibility = ViewStates.Visible; CommentsView.Animate().TranslationX(0).SetListener(al).SetDuration(200); } }; PostViewModel.PostCommentPressed += (sender, e) => { HideSoftkeyboard(); ((EditText)InputCommentEditText).Text = string.Empty; //using binding }; PostViewModel.ErrorHandler += (sender, e) => { ErrorEventArgs ee = (ErrorEventArgs)e; var dispatcher = Mvx.Resolve <IMvxMainThreadDispatcher> (); dispatcher.RequestMainThreadAction(() => { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle(ee.Title); builder.SetMessage(ee.Message); builder.SetNegativeButton(ee.CloseTitle, (EventHandler <DialogClickEventArgs>)null); builder.Show(); }); }; View BottomView = PostRootView.FindViewById(Resource.Id.post_view_bottom_layout); web.BottomReached += (sender, e) => { if (IsBottomViewAnimating) { return; } if (BottomView.Visibility == ViewStates.Gone) { //show IsBottomViewAnimating = true; var al = new AnimatorListener(); al.OnAnimationEndAction = (Animator animation) => { IsBottomViewAnimating = false; }; if (BottomView.TranslationY < PostRootView.Height) { //width of the view is zero before layout BottomView.TranslationY = PostRootView.Height; //set to right } BottomView.Visibility = ViewStates.Visible; BottomView.Animate().TranslationY(0).SetListener(al).SetDuration(500); } }; web.UnBottomReached += (sender, e) => { if (IsBottomViewAnimating) { return; } if (BottomView.Visibility == ViewStates.Visible) { //hide IsBottomViewAnimating = true; var al = new AnimatorListener(); al.OnAnimationEndAction = (Animator animation) => { BottomView.Visibility = ViewStates.Gone; IsBottomViewAnimating = false; }; BottomView.Animate().TranslationY(BottomView.Height).SetListener(al).SetDuration(500); } }; this.StartCalled += (sender, e) => PostViewModel.LoadPost(); //this.OnBackPressed }
public ExpandHelper(Context context, Callback callback, int small, int large) { this.smallSize = small; this.maximumStretch = Math.Max (smallSize, 1) * StretchInterval; this.largeSize = large; this.context = context; this.callback = callback; this.scaler = new ViewScaler(); this.gravity = GravityFlags.Top; //this.scaleAnimation = ObjectAnimator.OfFloat (scaler, "Height", 0f); this.scaleAnimation = ValueAnimator.OfFloat (0f); this.scaleAnimation.Update += (sender, e) => scaler.Height = (float)e.Animation.AnimatedValue; this.scaleAnimation.SetDuration (ExpandDuration); AnimatorListenerAdapter glowVisibilityController = new AnimatorListener (); glowTopAnimation = ObjectAnimator.OfFloat (null, "alpha", 0f); glowTopAnimation.AddListener (glowVisibilityController); glowBottomAnimation = ObjectAnimator.OfFloat (null, "alpha", 0f); glowBottomAnimation.AddListener (glowVisibilityController); glowAnimationSet = new AnimatorSet(); glowAnimationSet.Play (glowTopAnimation).With(glowBottomAnimation); glowAnimationSet.SetDuration(GlowDuration); detector = new DoubleSwipeDetector(context, new GestureDetector (this)); }