public void BlockCheck() { AlertDialog.Builder builder; builder = new AlertDialog.Builder(this.Activity); builder.SetTitle(GetString(Resource.String.block_title)); builder.SetMessage(GetString(Resource.String.block_check_message)); builder.SetCancelable(false); builder.SetPositiveButton(GetString(Resource.String.yes), delegate { this.dragAction = eDragAction.BLOCK; this.SlideOffY ((int)this.activePhotoHolder.Root.GetY (), -800, 500); }); builder.SetNegativeButton(GetString(Resource.String.no), delegate { MovePhotoBack(); }); builder.Show(); }
public bool OnTouch(View sender, MotionEvent e) { //activePhoto = (RelativeLayout)sender; RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)((RelativeLayout)sender).LayoutParameters; int x_cord = (int)e.RawX; int y_cord = (int)e.RawY; int photo_y; switch (e.Action) { case MotionEventActions.Down: touchX = x_cord - (int)((RelativeLayout)sender).GetX (); touchY = y_cord - (int)((RelativeLayout)sender).GetY (); alphaStartX = x_cord; break; case MotionEventActions.Move: this.activePhotoHolder.Root.SetX (x_cord - touchX); this.activePhotoHolder.Root.SetY (y_cord - touchY); photo_y = (int)this.activePhotoHolder.Root.GetY (); if (x_cord > (this.screenCenter - tolerence) && x_cord < (this.screenCenter + tolerence) && photo_y < -toPx(100)) { float diff = (photo_y - -toPx(100)); float amount = Math.Abs (diff / 10); if (amount > 10) { amount = 10; } this.activePhotoHolder.Blocked.SetAlpha ((int)(255 * (amount / 10))); diff = (alphaStartX - x_cord); this.activePhotoHolder.Root.Rotation = -((float)((diff) * (Math.PI / 32))); } else { this.activePhotoHolder.Blocked.SetAlpha (0); float diff = (alphaStartX - x_cord); this.activePhotoHolder.Root.Rotation = -((float)((diff) * (Math.PI / 32))); float amount = Math.Abs (diff / 10); if (amount > 10) { amount = 10; } // nope if (x_cord < this.alphaStartX) { this.activePhotoHolder.Nope.SetAlpha ((int)(255 * (amount / 10))); // like } else { this.activePhotoHolder.Liked.SetAlpha ((int)(255 * (amount / 10))); } } break; case MotionEventActions.Up: photo_y = (int)this.activePhotoHolder.Root.GetY (); if (x_cord > (this.screenCenter - tolerence) && x_cord < (this.screenCenter + tolerence) && photo_y < -toPx(100)) { this.BlockCheck (); } else { int dif = (int)Math.Abs (alphaStartX - x_cord); if (dif > toPx(100) && x_cord < this.screenCenter - tolerence) { this.dragAction = eDragAction.NOPE; this.SlideOffX ((int)this.activePhotoHolder.Root.GetX (), -500, 200); } else if (dif > toPx(100) && x_cord > this.screenCenter + tolerence) { this.dragAction = eDragAction.LIKE; this.SlideOffX ((int)this.activePhotoHolder.Root.GetX (), this.Activity.WindowManager.DefaultDisplay.Width + 500, 200); } else { this.dragAction = eDragAction.NONE; MovePhotoBack (); } } break; default: this.dragAction = eDragAction.NONE; MovePhotoBack (); break; } return true; }
private void OnThumbsUp(object sender, System.EventArgs e) { if (this.activePhotoHolder != null) { this.SlideOffX ((int)activePhotoHolder.Root.GetX (), this.Activity.WindowManager.DefaultDisplay.Width, 400); this.Rotate((int)activePhotoHolder.Root.Rotation, 32, 400); this.activePhotoHolder.Liked.SetAlpha(255); this.buttonThumbsUp.Enabled = false; this.buttonThumbsDown.Enabled = false; this.dragAction = eDragAction.LIKE; } }
private void OnThumbsDown(object sender, System.EventArgs e) { if (this.activePhotoHolder != null) { this.SlideOffX ((int)activePhotoHolder.Root.GetX (), -500, 500); this.Rotate((int)activePhotoHolder.Root.Rotation, -32, 400); activePhotoHolder.Nope.SetAlpha(255); this.buttonThumbsUp.Enabled = false; this.buttonThumbsDown.Enabled = false; this.dragAction = eDragAction.NOPE; } }
private void SetNextMatch() { UpdateProfile(); // deactivate the top one PhotoHolder holder = this.photoHolders [this.topHolderIndex]; holder.Root.SetOnTouchListener(null); holder.Root.Rotation = 0; holder.Root.SetX(pictureX); holder.Root.SetY(pictureY); holder.Nope.SetAlpha(0); holder.Liked.SetAlpha(0); holder.Blocked.SetAlpha(0); holder.ProfileIndex = -1; holder.Root.Visibility = ViewStates.Gone; activePhotoHolder = null; // is there anymore to show replace this holder with the data if (this.nextProfileIndex < this.profileList.Count) { SetPhotoHolderNextProfile (this.topHolderIndex); } // move to the next holder int next = this.topHolderIndex + 1; if (next >= NUM_HOLDERS) { next = 0; } // should it become the new top holder = this.photoHolders [next]; if (holder.ProfileIndex != -1) { this.activePhotoHolder = holder; this.topHolderIndex = next; // bring it to the front var parentView = this.Activity.FindViewById<RelativeLayout> (Resource.Id.layoutview); parentView.RemoveView (holder.Root); parentView.AddView (holder.Root); } if (this.activePhotoHolder != null) { // enable the thumbs up & down buttons this.buttonThumbsUp.Enabled = true; this.buttonThumbsDown.Enabled = true; // activate the on touch this.activePhotoHolder.Root.SetOnTouchListener (this); } else { aTimer.Interval = 500; this.SetScanningMode (); } dragAction = eDragAction.NONE; }