public async void OnGlobalLayout()
        {
            productImage.ViewTreeObserver.RemoveGlobalOnLayoutListener(this);

            const int DeltaX = 100;

            var img1 = Images.FromUrl(Product.ImageForSize(images [0], Images.ScreenWidth));
            var img2 = Images.FromUrl(Product.ImageForSize(images [1], Images.ScreenWidth));

            productDrawable              = new KenBurnsDrawable(Color.DarkBlue);
            productDrawable.FirstBitmap  = await img1;
            productDrawable.SecondBitmap = await img2;
            productImage.SetImageDrawable(productDrawable);
            currentIndex++;

            var evaluator   = new MatrixEvaluator();
            var finalMatrix = new Matrix();

            finalMatrix.SetTranslate(-DeltaX, -(float)productDrawable.FirstBitmap.Height / 1.3f + (float)productImage.Height);
            finalMatrix.PostScale(1.27f, 1.27f);
            kenBurnsMovement         = ValueAnimator.OfObject(evaluator, new Matrix(), finalMatrix);
            kenBurnsMovement.Update += (sender, e) => productDrawable.SetMatrix((Matrix)e.Animation.AnimatedValue);
            kenBurnsMovement.SetDuration(14000);
            kenBurnsMovement.RepeatMode  = ValueAnimatorRepeatMode.Reverse;
            kenBurnsMovement.RepeatCount = ValueAnimator.Infinite;
            kenBurnsMovement.Start();

            kenBurnsAlpha = ObjectAnimator.OfInt(productDrawable, "alpha", 0, 0, 0, 255, 255, 255);
            kenBurnsAlpha.SetDuration(kenBurnsMovement.Duration);
            kenBurnsAlpha.RepeatMode       = ValueAnimatorRepeatMode.Reverse;
            kenBurnsAlpha.RepeatCount      = ValueAnimator.Infinite;
            kenBurnsAlpha.AnimationRepeat += (sender, e) => NextImage();
            kenBurnsAlpha.Start();
        }
        async void NextImage()
        {
            currentIndex = (currentIndex + 1) % images.Length;
            var image = images [currentIndex];
            await Images.SetImageFromUrlAsync(productDrawable, Product.ImageForSize(image, Images.ScreenWidth));

            PrecacheNextImage();
        }
Ejemplo n.º 3
0
            async void LoadProductImage(View mainView, ProgressBar progressView, ImageView imageView, Product product)
            {
                var currentId = mainView.Id;

                progressView.Visibility = ViewStates.Visible;
                imageView.SetImageResource(Android.Resource.Color.Transparent);
                await Images.SetImageFromUrlAsync(imageView, product.ImageForSize(Images.ScreenWidth));

                progressView.Visibility = ViewStates.Invisible;
            }
Ejemplo n.º 4
0
 public async Task PreloadImages(float imageWidth)
 {
     if (hasPreloadedImages)
     {
         return;
     }
     hasPreloadedImages = true;
     //Lets precach the countries too
                 #pragma warning disable 4014
     GetCountries();
                 #pragma warning restore 4014
     await Task.Factory.StartNew(() => {
         var imagUrls = products.SelectMany(x => x.ImageUrls.Select(y => Product.ImageForSize(y, imageWidth))).ToList();
         imagUrls.ForEach(async(x) => await FileCache.Download(x));
     });
 }
Ejemplo n.º 5
0
                public async Task Update(Product product)
                {
                    NameLabel.Text  = product.Name;
                    SizeLabel.Text  = product.Size.Description;
                    ColorLabel.Text = product.Color.Name;
                    PriceLabel.Text = product.PriceDescription;
                    var imageTask = FileCache.Download(product.ImageForSize(320));

                    if (!imageTask.IsCompleted)
                    {
                        //Put default before doing the web request;
                        ImageView.Image = Image.Value;
                    }
                    var image = await imageTask;

                    ImageView.Image = UIImage.FromFile(image);
                }
        void AnimateImages()
        {
            if (images.Length < 1)
            {
                return;
            }
            if (images.Length == 1)
            {
                //No need to await the change
                                #pragma warning disable 4014
                Images.SetImageFromUrlAsync(productImage, Product.ImageForSize(images [0], Images.ScreenWidth));
                                #pragma warning restore 4014
                return;
            }

            productImage.ViewTreeObserver.AddOnGlobalLayoutListener(this);
        }
        void PrecacheNextImage()
        {
            if (currentIndex + 1 >= images.Length)
            {
                cached = true;
            }
            if (cached)
            {
                return;
            }
            var next  = currentIndex + 1;
            var image = images [next];

            //No need to await the precache to finish
                        #pragma warning disable 4014
            FileCache.Download(Product.ImageForSize(image, Images.ScreenWidth));
                        #pragma warning restore 4014
        }
Ejemplo n.º 8
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            Product product = items [position];

            View view = convertView;        // re-use an existing view, if one is available

            if (view == null)               // otherwise create a new one
            {
                view = LayoutInflater.From(context).Inflate(Resource.Layout.BasketItem, parent, false);
                var swipper = ((SwipableListItem)view).SwipeListener;
                swipper.SwipeGestureBegin += (sender, e) => ((ListView)parent).RequestDisallowInterceptTouchEvent(true);
                swipper.SwipeGestureEnd   += (sender, e) => ((ListView)parent).RequestDisallowInterceptTouchEvent(false);
                swipper.ItemSwipped       += (sender, e) => {
                    // If view has already been processed, do nothing
                    if (view.Parent == null)
                    {
                        return;
                    }
                    var p     = ((ListView)parent).GetPositionForView(view);
                    var order = WebService.Shared.CurrentOrder;
                    order.Remove(order.Products [p]);
                    NotifyDataSetChanged();
                };
            }

            view.FindViewById <TextView> (Resource.Id.productTitle).Text = product.Name;
            view.FindViewById <TextView> (Resource.Id.productPrice).Text = product.PriceDescription;
            view.FindViewById <TextView> (Resource.Id.productColor).Text = product.Color.ToString();
            view.FindViewById <TextView> (Resource.Id.productSize).Text  = product.Size.Description;

            var orderImage = view.FindViewById <ImageView> (Resource.Id.productImage);

            orderImage.SetImageResource(Resource.Drawable.blue_shirt);
            //No need to wait for the async download to return the view
                        #pragma warning disable 4014
            orderImage.SetImageFromUrlAsync(product.ImageForSize(Images.ScreenWidth));
                        #pragma warning restore 4014
            return(view);
        }
				public async Task Update (Product product)
				{
					NameLabel.Text = product.Name;
					SizeLabel.Text = product.Size.Description;
					ColorLabel.Text = product.Color.Name;
					PriceLabel.Text = product.PriceDescription;
					var imageTask = FileCache.Download (product.ImageForSize (320));
					if(!imageTask.IsCompleted)
						//Put default before doing the web request;
						ImageView.Image = Image.Value;
					var image = await imageTask;
					ImageView.Image = UIImage.FromFile (image);
				}
				public async Task Update (Product product)
				{
					var isSurprise = product.GetType () == typeof(SurpriseProduct);

					NameLabel.Text = isSurprise ? SurpriseProduct.SurpriseProductName : product.Name;
					SizeLabel.Text = isSurprise ? "???" : product.Size.Description;
					ColorLabel.Text = isSurprise ? "???" : product.Color.Name;
					PriceLabel.Text = product.PriceDescription;

					if (!isSurprise) 
					{
						var imageTask = FileCache.Download (product.ImageForSize (320));
						if (!imageTask.IsCompleted)
							//Put default before doing the web request;
							ImageView.Image = Image.Value;
						var image = await imageTask;
						ImageView.Image = UIImage.FromFile (image);
					}
				}
			async void LoadProductImage (View mainView, ProgressBar progressView, ImageView imageView, Product product)
			{
				var currentId = mainView.Id;
				progressView.Visibility = ViewStates.Visible;
				imageView.SetImageResource (Android.Resource.Color.Transparent);
				await Images.SetImageFromUrlAsync (imageView,product.ImageForSize (Images.ScreenWidth));
				progressView.Visibility = ViewStates.Invisible;
			}