Beispiel #1
0
            public override Java.Lang.Object InstantiateItem(ViewGroup container, int position)
            {
                PhotoView photoView = new PhotoView(true, curentContext);

                photoView.SetScaleType(ImageView.ScaleType.CenterCrop);
                photoView.Tag = position;
                string path = mPathList[position];

                if (path != null)
                {
                    if (mCache.Get(path) is Android.Graphics.Bitmap bitmap)
                    {
                        photoView.SetImageBitmap(bitmap);
                    }
                    else
                    {
                        if (System.IO.File.Exists(path))
                        {
                            bitmap = BitmapLoader.GetBitmapFromFile(path, mWidth, mHeight);
                            if (bitmap != null)
                            {
                                photoView.SetImageBitmap(bitmap);
                                mCache.Put(path, bitmap);
                            }
                            else
                            {
                                photoView.SetImageResource(Resource.Drawable.aurora_picture_not_found);
                            }
                        }
                        else
                        {
                            photoView.SetImageResource(Resource.Drawable.aurora_picture_not_found);
                        }
                    }
                }
                else
                {
                    photoView.SetImageResource(Resource.Drawable.aurora_picture_not_found);
                }
                container.AddView(photoView, ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
                return(photoView);
            }
Beispiel #2
0
        private void InitCurrentItem()
        {
            PhotoView photoView = new PhotoView(true, this);
            string    msgId     = Intent.GetStringExtra("msgId");
            int       position  = mMsgIdList.IndexOf(msgId);
            string    path      = mPathList[position];

            if (path != null)
            {
                if (mCache.Get(path) is Android.Graphics.Bitmap bitmap)
                {
                    photoView.SetImageBitmap(bitmap);
                }
                else
                {
                    if (System.IO.File.Exists(path))
                    {
                        bitmap = BitmapLoader.GetBitmapFromFile(path, mWidth, mHeight);
                        if (bitmap != null)
                        {
                            photoView.SetImageBitmap(bitmap);
                            mCache.Put(path, bitmap);
                        }
                        else
                        {
                            photoView.SetImageResource(Resource.Drawable.aurora_picture_not_found);
                        }
                    }
                    else
                    {
                        photoView.SetImageResource(Resource.Drawable.aurora_picture_not_found);
                    }
                }
            }
            else
            {
                photoView.SetImageResource(Resource.Drawable.aurora_picture_not_found);
            }
            mViewPager.CurrentItem = position;
        }