Search in sources :

Example 1 with BigImageView

use of com.github.piasy.biv.view.BigImageView in project BBS-Android by bdpqchen.

the class BigPhotoActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    super.onCreate(savedInstanceState);
    url = getIntent().getStringExtra(IMG_URL);
    BigImageView bigImageView = (BigImageView) findViewById(R.id.image);
    bigImageView.setImageSaveCallback(new ImageSaveCallback() {

        @Override
        public void onSuccess(String uri) {
            SnackBarUtil.normal(BigPhotoActivity.this, "已保存至Pictures");
        }

        @Override
        public void onFail(Throwable t) {
            SnackBarUtil.error(BigPhotoActivity.this, "保存失败,请检查相关权限设置", true);
        }
    });
    mIvSave.setOnClickListener(v -> {
        if (ActivityCompat.checkSelfPermission(BigPhotoActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(BigPhotoActivity.this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, 0);
        }
        bigImageView.saveImageIntoGallery();
    });
    bigImageView.setProgressIndicator(new ProgressPieIndicator());
    bigImageView.showImage(Uri.parse(url));
// Glide.with(this).load(url).placeholder(R.drawable.vista_title).crossFade().into(imageView);
}
Also used : ImageSaveCallback(com.github.piasy.biv.view.ImageSaveCallback) BigImageView(com.github.piasy.biv.view.BigImageView) ProgressPieIndicator(com.github.piasy.biv.indicator.progresspie.ProgressPieIndicator)

Example 2 with BigImageView

use of com.github.piasy.biv.view.BigImageView in project BigImageViewer by Piasy.

the class GlideImageLoader method showThumbnail.

@Override
public View showThumbnail(BigImageView parent, Uri thumbnail, int scaleType) {
    ImageView thumbnailView = (ImageView) LayoutInflater.from(parent.getContext()).inflate(R.layout.ui_glide_thumbnail, parent, false);
    switch(scaleType) {
        case BigImageView.INIT_SCALE_TYPE_CENTER_CROP:
            thumbnailView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            break;
        case BigImageView.INIT_SCALE_TYPE_CENTER_INSIDE:
            thumbnailView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        default:
            break;
    }
    mRequestManager.load(thumbnail).into(thumbnailView);
    return thumbnailView;
}
Also used : BigImageView(com.github.piasy.biv.view.BigImageView) ImageView(android.widget.ImageView)

Example 3 with BigImageView

use of com.github.piasy.biv.view.BigImageView in project BigImageViewer by Piasy.

the class ImageTypesActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_image_type);
    mRootLayout = findViewById(R.id.rootLayout);
    Spinner spLoader = findViewById(R.id.spLoader);
    spLoader.setAdapter(getArrayAdapter(IMAGE_LOADERS));
    spLoader.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(final AdapterView<?> parent, final View view, final int position, final long id) {
            mImageLoader = IMAGE_LOADERS.get(position).value;
        }

        @Override
        public void onNothingSelected(final AdapterView<?> parent) {
        }
    });
    Spinner spType = findViewById(R.id.spType);
    spType.setAdapter(getArrayAdapter(IMAGE_TYPES));
    spType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(final AdapterView<?> parent, final View view, final int position, final long id) {
            mImageType = IMAGE_TYPES.get(position).value;
        }

        @Override
        public void onNothingSelected(final AdapterView<?> parent) {
        }
    });
    findViewById(R.id.load).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(final View v) {
            if (mBiv != null) {
                mRootLayout.removeView(mBiv);
            }
            ImageViewFactory imageViewFactory;
            switch(mImageLoader) {
                case IMAGE_LOADER_FRESCO:
                    BigImageViewer.initialize(FrescoImageLoader.with(getApplicationContext()));
                    imageViewFactory = new FrescoImageViewFactory();
                    break;
                case IMAGE_LOADER_GLIDE:
                    BigImageViewer.initialize(GlideImageLoader.with(getApplicationContext()));
                    imageViewFactory = new GlideImageViewFactory();
                    break;
                default:
                    return;
            }
            mBiv = new BigImageView(ImageTypesActivity.this);
            mBiv.setImageViewFactory(imageViewFactory);
            mBiv.setProgressIndicator(new ProgressPieIndicator());
            mRootLayout.addView(mBiv, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
            mBiv.showImage(Uri.parse(IMAGE_URLS.get(mImageType)));
        }
    });
}
Also used : BigImageView(com.github.piasy.biv.view.BigImageView) Spinner(android.widget.Spinner) ProgressPieIndicator(com.github.piasy.biv.indicator.progresspie.ProgressPieIndicator) BigImageView(com.github.piasy.biv.view.BigImageView) View(android.view.View) AdapterView(android.widget.AdapterView) FrescoImageViewFactory(com.github.piasy.biv.view.FrescoImageViewFactory) ImageViewFactory(com.github.piasy.biv.view.ImageViewFactory) FrescoImageViewFactory(com.github.piasy.biv.view.FrescoImageViewFactory) GlideImageViewFactory(com.github.piasy.biv.view.GlideImageViewFactory) AdapterView(android.widget.AdapterView) GlideImageViewFactory(com.github.piasy.biv.view.GlideImageViewFactory)

Aggregations

BigImageView (com.github.piasy.biv.view.BigImageView)3 ProgressPieIndicator (com.github.piasy.biv.indicator.progresspie.ProgressPieIndicator)2 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 Spinner (android.widget.Spinner)1 FrescoImageViewFactory (com.github.piasy.biv.view.FrescoImageViewFactory)1 GlideImageViewFactory (com.github.piasy.biv.view.GlideImageViewFactory)1 ImageSaveCallback (com.github.piasy.biv.view.ImageSaveCallback)1 ImageViewFactory (com.github.piasy.biv.view.ImageViewFactory)1