Exemple #1
0
        private void ConfigureSwipe(ConnectionManager connectionManager)
        {
            _swipeLayout = FindViewById <SwipeLayout>(Resource.Id.swipeLayout);

            _swipeLayout.SetShowMode(SwipeLayout.ShowMode.PullOut);

            var addFavoriteView = FindViewById(Resource.Id.leftBottomWrapper);

            _swipeLayout.AddDrag(SwipeLayout.DragEdge.Left, addFavoriteView);

            var removeFavoriteView = FindViewById(Resource.Id.rightBottomWrapper);

            _swipeLayout.AddDrag(SwipeLayout.DragEdge.Right, removeFavoriteView);

            View backgroundView = FindViewById <Button>(Resource.Id.addToFavorite);

            _swipeLayout.Opened += (sender, e) => {
                if (_swipeLayout.CurrentBottomView.FindViewById <Button>(Resource.Id.addToFavorite) != null)
                {
                    _favoriteView.SetImageResource(Resource.Drawable.Star);
                    backgroundView = FindViewById <Button>(Resource.Id.addToFavorite);
                    connectionManager.MarkFavorite(true, _article.ID);
                    _article.Favorite = true;
                }
                else
                {
                    _favoriteView.SetImageResource(Resource.Drawable.EmptyStar);
                    backgroundView = FindViewById <Button>(Resource.Id.removeFromFavorite);
                    connectionManager.MarkFavorite(false, _article.ID);
                    _article.Favorite = false;
                }

                backgroundView.SetBackgroundColor(Color.Green);

                _swipeLayout.Close();
            };

            _swipeLayout.Closed += (sender, e) =>
            {
                backgroundView.SetBackgroundColor(Color.Transparent);
            };

            _swipeLayout.Hover += (sender, e) =>
            {
                _swipeLayout.Close();
            };

            _swipeLayout.Click += delegate {
                string swipeStatus = _swipeLayout.OpenStatus.ToString();
                if (!swipeStatus.Equals("Open") && !swipeStatus.Equals("Middle"))
                {
                    Intent intent = new Intent(Context, typeof(ArticleActivity));
                    intent.PutExtra("sourceUri", _article.Link);
                    _activity.StartActivity(intent);
                }
                _swipeLayout.Close();
            };
        }
Exemple #2
0
		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);
			SetContentView (Resource.Layout.main);

			//sample1

			sample1 = FindViewById<SwipeLayout> (Resource.Id.sample1);
			sample1.SetShowMode (SwipeLayout.ShowMode.PullOut);
			sample1.AddDrag (SwipeLayout.DragEdge.Left, sample1.FindViewById (Resource.Id.bottom_wrapper));
			sample1.AddDrag (SwipeLayout.DragEdge.Right, sample1.FindViewById (Resource.Id.bottom_wrapper_2));
			sample1.AddDrag (SwipeLayout.DragEdge.Top, sample1.FindViewById (Resource.Id.starbott));
			sample1.AddDrag (SwipeLayout.DragEdge.Bottom, sample1.FindViewById (Resource.Id.starbott));
			sample1.AddRevealListener (Resource.Id.delete, (sender, e) => {
			});
			sample1.SurfaceView.Click += (sender, e) => {
				Toast.MakeText (this, "Click on surface", ToastLength.Short).Show ();
			};
			sample1.SurfaceView.LongClick += (sender, e) => {
				Toast.MakeText (this, "longClick on surface", ToastLength.Short).Show ();
				e.Handled = true;
			};
			sample1.FindViewById (Resource.Id.star2).Click += (sender, e) => {
				Toast.MakeText (this, "Star", ToastLength.Short).Show ();
			};
			sample1.FindViewById (Resource.Id.trash2).Click += (sender, e) => {
				Toast.MakeText (this, "Trash Bin", ToastLength.Short).Show ();
			};
			sample1.FindViewById (Resource.Id.magnifier2).Click += (sender, e) => {
				Toast.MakeText (this, "Magnifier", ToastLength.Short).Show ();
			};
			sample1.AddRevealListener (Resource.Id.starbott, (sender, e) => {
				View star = e.Child.FindViewById (Resource.Id.star);
				float d = e.Child.Height / 2 - star.Height / 2;
				ViewHelper.SetTranslationY (star, d * e.Fraction);
				ViewHelper.SetScaleX (star, e.Fraction + 0.6f);
				ViewHelper.SetScaleY (star, e.Fraction + 0.6f);
			});

			//sample2

			sample2 = FindViewById<SwipeLayout> (Resource.Id.sample2);
			sample2.SetShowMode (SwipeLayout.ShowMode.LayDown);
			sample2.AddDrag (SwipeLayout.DragEdge.Right, sample2.FindViewWithTag ("Bottom2"));
			sample2.FindViewById (Resource.Id.star).Click += (sender, e) => {
				Toast.MakeText (this, "Star", ToastLength.Short).Show ();
			};
			sample2.FindViewById (Resource.Id.trash).Click += (sender, e) => {
				Toast.MakeText (this, "Trash Bin", ToastLength.Short).Show ();
			};
			sample2.FindViewById (Resource.Id.magnifier).Click += (sender, e) => {
				Toast.MakeText (this, "Magnifier", ToastLength.Short).Show ();
			};
			sample2.FindViewById (Resource.Id.click).Click += (sender, e) => {
				Toast.MakeText (this, "Yo!", ToastLength.Short).Show ();
			};
			sample2.SurfaceView.Click += (sender, e) => {
				Toast.MakeText (this, "Click on surface", ToastLength.Short).Show ();
			};

			//sample3

			sample3 = FindViewById<SwipeLayout> (Resource.Id.sample3);
			sample3.AddDrag (SwipeLayout.DragEdge.Top, sample3.FindViewWithTag ("Bottom3"));
			sample3.AddRevealListener (Resource.Id.bottom_wrapper_child1, (sender, e) => {
				View star = e.Child.FindViewById (Resource.Id.star);
				float d = e.Child.Height / 2 - star.Height / 2;
				ViewHelper.SetTranslationY (star, d * e.Fraction);
				ViewHelper.SetScaleX (star, e.Fraction + 0.6f);
				ViewHelper.SetScaleY (star, e.Fraction + 0.6f);
				Color c = Evaluate (e.Fraction, Color.ParseColor ("#dddddd"), Color.ParseColor ("#4C535B"));
				e.Child.SetBackgroundColor (c);
			});
			sample3.FindViewById (Resource.Id.bottom_wrapper_child1).Click += (sender, e) => {
				Toast.MakeText (this, "Yo!", ToastLength.Short).Show ();
			};
			sample3.SurfaceView.Click += (sender, e) => {
				Toast.MakeText (this, "Click on surface", ToastLength.Short).Show ();
			};
		}
Exemple #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.main);

            //sample1

            sample1 = FindViewById <SwipeLayout> (Resource.Id.sample1);
            sample1.SetShowMode(SwipeLayout.ShowMode.PullOut);
            sample1.AddDrag(SwipeLayout.DragEdge.Left, sample1.FindViewById(Resource.Id.bottom_wrapper));
            sample1.AddDrag(SwipeLayout.DragEdge.Right, sample1.FindViewById(Resource.Id.bottom_wrapper_2));
            sample1.AddDrag(SwipeLayout.DragEdge.Top, sample1.FindViewById(Resource.Id.starbott));
            sample1.AddDrag(SwipeLayout.DragEdge.Bottom, sample1.FindViewById(Resource.Id.starbott));
            sample1.AddRevealListener(Resource.Id.delete, (sender, e) => {
            });
            sample1.SurfaceView.Click += (sender, e) => {
                Toast.MakeText(this, "Click on surface", ToastLength.Short).Show();
            };
            sample1.SurfaceView.LongClick += (sender, e) => {
                Toast.MakeText(this, "longClick on surface", ToastLength.Short).Show();
                e.Handled = true;
            };
            sample1.FindViewById(Resource.Id.star2).Click += (sender, e) => {
                Toast.MakeText(this, "Star", ToastLength.Short).Show();
            };
            sample1.FindViewById(Resource.Id.trash2).Click += (sender, e) => {
                Toast.MakeText(this, "Trash Bin", ToastLength.Short).Show();
            };
            sample1.FindViewById(Resource.Id.magnifier2).Click += (sender, e) => {
                Toast.MakeText(this, "Magnifier", ToastLength.Short).Show();
            };
            sample1.AddRevealListener(Resource.Id.starbott, (sender, e) => {
                View star = e.Child.FindViewById(Resource.Id.star);
                float d   = e.Child.Height / 2 - star.Height / 2;
                ViewHelper.SetTranslationY(star, d * e.Fraction);
                ViewHelper.SetScaleX(star, e.Fraction + 0.6f);
                ViewHelper.SetScaleY(star, e.Fraction + 0.6f);
            });

            //sample2

            sample2 = FindViewById <SwipeLayout> (Resource.Id.sample2);
            sample2.SetShowMode(SwipeLayout.ShowMode.LayDown);
            sample2.AddDrag(SwipeLayout.DragEdge.Right, sample2.FindViewWithTag("Bottom2"));
            sample2.FindViewById(Resource.Id.star).Click += (sender, e) => {
                Toast.MakeText(this, "Star", ToastLength.Short).Show();
            };
            sample2.FindViewById(Resource.Id.trash).Click += (sender, e) => {
                Toast.MakeText(this, "Trash Bin", ToastLength.Short).Show();
            };
            sample2.FindViewById(Resource.Id.magnifier).Click += (sender, e) => {
                Toast.MakeText(this, "Magnifier", ToastLength.Short).Show();
            };
            sample2.FindViewById(Resource.Id.click).Click += (sender, e) => {
                Toast.MakeText(this, "Yo!", ToastLength.Short).Show();
            };
            sample2.SurfaceView.Click += (sender, e) => {
                Toast.MakeText(this, "Click on surface", ToastLength.Short).Show();
            };

            //sample3

            sample3 = FindViewById <SwipeLayout> (Resource.Id.sample3);
            sample3.AddDrag(SwipeLayout.DragEdge.Top, sample3.FindViewWithTag("Bottom3"));
            sample3.AddRevealListener(Resource.Id.bottom_wrapper_child1, (sender, e) => {
                View star = e.Child.FindViewById(Resource.Id.star);
                float d   = e.Child.Height / 2 - star.Height / 2;
                ViewHelper.SetTranslationY(star, d * e.Fraction);
                ViewHelper.SetScaleX(star, e.Fraction + 0.6f);
                ViewHelper.SetScaleY(star, e.Fraction + 0.6f);
                Color c = Evaluate(e.Fraction, Color.ParseColor("#dddddd"), Color.ParseColor("#4C535B"));
                e.Child.SetBackgroundColor(c);
            });
            sample3.FindViewById(Resource.Id.bottom_wrapper_child1).Click += (sender, e) => {
                Toast.MakeText(this, "Yo!", ToastLength.Short).Show();
            };
            sample3.SurfaceView.Click += (sender, e) => {
                Toast.MakeText(this, "Click on surface", ToastLength.Short).Show();
            };
        }