private void OnThumbnailDownloaded(PhotoHolder holder, Bitmap bitmap) { var drawable = new BitmapDrawable(Resources, bitmap); Log.Info(Tag, "OnThumbnailDownloaded"); holder.BindDrawable(drawable); }
public override MvxRecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) { var itemBindingContext = new MvxAndroidBindingContext(parent.Context, BindingContext.LayoutInflaterHolder); var itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.PhotoHolder, parent, false); var holder = new PhotoHolder(itemView, itemBindingContext); return(holder); }
private void InitailizeAlbum() { // Update origin position & size _originPosition = new Point((double)PhotoHolder.GetValue(Canvas.LeftProperty), (double)PhotoHolder.GetValue(Canvas.TopProperty)); _originSize = new Point(PhotoHolder.Width, PhotoHolder.Height); // Initialize layout manager. _layoutManager = new LayoutManager(PhotoHolder, _photoDataSet, BtnSortCanvas, BtnRandomCanvas, BgCanvas, _sortNavi, _genuineSlice, _tracingIcon, _screenArrowLeft, _screenArrowRight); // Add host resize event listener. BrowserHost.Resize += new EventHandler(BrowserHost_Resize); }
public override void OnViewCreated (View view, Bundle savedInstanceState) { var parentView = view.FindViewById<RelativeLayout> (Resource.Id.layoutview); LinearLayout noficationLayout = parentView.FindViewById<LinearLayout> (Resource.Id.notifcation); notifactionArea = new NotifcationArea (this.Activity, noficationLayout); noficationLayout.Click += (object sender, EventArgs e) => { var i = new Intent(this.Activity, typeof(ChatActivity)); i.PutExtra ("guid", this.notifactionArea.GetGuid()); StartActivity(i); }; var windowwidth = this.Activity.WindowManager.DefaultDisplay.Width; var windowheight = this.Activity.WindowManager.DefaultDisplay.Height; screenCenter = windowwidth / 2; BitmapFactory.Options dimensions = new BitmapFactory.Options(); dimensions.InJustDecodeBounds = true; BitmapFactory.DecodeResource(this.Resources, Resource.Drawable.liked, dimensions); int liked_bmHeight = dimensions.OutHeight; int liked_bmWidth = dimensions.OutWidth; BitmapFactory.DecodeResource(this.Resources, Resource.Drawable.empty_frame, dimensions); int frame_bmHeight = dimensions.OutHeight; int frame_bmWidth = dimensions.OutWidth; int photo_size = frame_bmWidth - toPx(30);//toPx (240); tolerence = toPx (tolerence); pictureX = (windowwidth - frame_bmWidth) / 2; pictureY = toPx(5); // add the 2 photos for (int i = 0; i < NUM_HOLDERS; i++) { photoHolders [i] = new PhotoHolder (); photoHolders [i].Root = this.Activity.LayoutInflater.Inflate (Resource.Layout.Photo, null, false); photoHolders [i].Root.LayoutParameters = new RelativeLayout.LayoutParams(frame_bmWidth,frame_bmHeight); photoHolders [i].Root.SetX (pictureX); photoHolders [i].Root.SetY (pictureY); photoHolders [i].Root.Rotation = 0; parentView.AddView (photoHolders [i].Root); // set up the photo image photoHolders [i].Photo = ((ImageView)(photoHolders [i].Root.FindViewById<ImageView> (Resource.Id.picture))); photoHolders [i].Photo.LayoutParameters.Width = photo_size; photoHolders [i].Photo.LayoutParameters.Height = photo_size; photoHolders [i].Photo.SetX ((frame_bmWidth-photo_size)/2); photoHolders [i].Photo.SetY ((frame_bmWidth-photo_size)/2); photoHolders [i].Photo.SetScaleType (ImageView.ScaleType.FitXy); // setup the nope photoHolders [i].Nope = ((ImageView)(photoHolders [i].Root.FindViewById<ImageView> (Resource.Id.nope))); photoHolders [i].Nope.SetX((frame_bmWidth/2) + (liked_bmWidth/2)); photoHolders [i].Nope.SetY(liked_bmHeight*2); photoHolders [i].Nope.SetAlpha (0); // setup the like photoHolders [i].Liked = ((ImageView)(photoHolders [i].Root.FindViewById<ImageView> (Resource.Id.liked))); photoHolders [i].Liked.SetX((frame_bmWidth/2) - liked_bmWidth - (liked_bmWidth/2)); photoHolders [i].Liked.SetY(liked_bmHeight*2); photoHolders [i].Liked.SetAlpha (0); // setup the block photoHolders [i].Blocked = ((ImageView)(photoHolders [i].Root.FindViewById<ImageView> (Resource.Id.block))); photoHolders [i].Blocked.SetX((frame_bmWidth - liked_bmWidth) / 2); photoHolders [i].Blocked.SetY(frame_bmHeight - liked_bmHeight - toPx(20)); photoHolders [i].Blocked.SetAlpha (0); // container holding the name & status LinearLayout caption = ((LinearLayout)(photoHolders [i].Root.FindViewById<LinearLayout> (Resource.Id.caption))); caption.SetY (frame_bmHeight - toPx(70)); photoHolders [i].Name = ((TextView)(photoHolders [i].Root.FindViewById<TextView> (Resource.Id.name))); photoHolders [i].Status = ((TextView)(photoHolders [i].Root.FindViewById<TextView> (Resource.Id.status))); photoHolders [i].Root.Visibility = ViewStates.Gone; photoHolders [i].ProfileIndex = -1; } this.buttonThumbsUp = view.FindViewById<Button>(Resource.Id.thumbs_up); this.buttonThumbsUp.Click += OnThumbsUp; this.buttonThumbsDown = view.FindViewById<Button>(Resource.Id.thumbs_down); this.buttonThumbsDown.Click += OnThumbsDown; scanningView = new Scanning (parentView, this.Activity); this.aTimer = new System.Timers.Timer (); aTimer.Elapsed += new ElapsedEventHandler (OnTimedEvent); aTimer.Interval = 5000; GetProfiles (); }
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; }
private void UpdateProfile() { activePhotoHolder = this.photoHolders [this.topHolderIndex]; // profilelist is not refreshed when they change Profile profile = this.profileList [activePhotoHolder.ProfileIndex]; // so look them up in the database as we need the latest data profile = Database.Instance ().GetProfileByGuid (profile.Guid); if (profile != null) { // remove the show flag profile.State = Profile.STATE_PROCESSED; switch (this.dragAction) { case eDragAction.LIKE: profile.Match |= Profile.MATCH_LIKED_BY_ME; break; case eDragAction.BLOCK: profile.Match = Profile.MATCH_BLOCKED_BY_ME; Database.Instance ().DeletePicture (profile.Guid); break; case eDragAction.NOPE: profile.Match = Profile.MATCH_NOPE; Database.Instance ().DeletePicture (profile.Guid); break; } if (Profile.MATCH_BOTH == (profile.Match & Profile.MATCH_BOTH)) { profile.State = Profile.STATE_MATCHED; } // save profile Database.Instance ().SaveProfile (profile); // send a match status to the user NetworkManager2.Instance ().RequestHandler.RequestSendMatch (profile.Guid, profile.IPAddress); } }
private void SetPhotoHolderNextProfile(int index) { // set up the new front holder activePhotoHolder = this.photoHolders [index]; if (null != activePhotoHolder) { activePhotoHolder.Root.Visibility = ViewStates.Visible; activePhotoHolder.Root.Rotation = 0; activePhotoHolder.Root.SetX (pictureX); activePhotoHolder.Root.SetY (pictureY); activePhotoHolder.Nope.SetAlpha (0); activePhotoHolder.Liked.SetAlpha (0); activePhotoHolder.Blocked.SetAlpha (0); // bring it to the front var parentView = this.Activity.FindViewById<RelativeLayout> (Resource.Id.layoutview); parentView.RemoveView (activePhotoHolder.Root); parentView.AddView (activePhotoHolder.Root); // set its data Profile profile = this.profileList [this.nextProfileIndex]; activePhotoHolder.ProfileIndex = this.nextProfileIndex; activePhotoHolder.Photo.SetImageBitmap (Utils.BytesToBitmap (Database.Instance () .GetPicture (profile.Guid).Big)); activePhotoHolder.Name.Text = profile.Name; activePhotoHolder.Status.Text = profile.Status; // enable the thumbs up & down buttons this.buttonThumbsUp.Enabled = true; this.buttonThumbsDown.Enabled = true; // move to next profile this.nextProfileIndex++; } }