Search in sources :

Example 1 with GlideImageViewFactory

use of com.github.piasy.biv.view.GlideImageViewFactory 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

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