Search in sources :

Example 56 with SimpleDraweeView

use of com.facebook.drawee.view.SimpleDraweeView in project fresco by facebook.

the class ImageFormatProgressiveJpegFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    mSpinnerEntries = new Entry[] { new Entry(R.string.format_pjpeg_label_small, sampleUris().createSampleUri(ImageUriProvider.ImageSize.L)), new Entry(R.string.format_pjpeg_label_medium, sampleUris().createSampleUri(ImageUriProvider.ImageSize.M)), new Entry(R.string.format_pjpeg_label_large, sampleUris().createSampleUri(ImageUriProvider.ImageSize.S)), new Entry(R.string.format_pjpeg_label_slow, sampleUris().createPJPEGSlow()) };
    ProgressBarDrawable progressBarDrawable = new ProgressBarDrawable();
    progressBarDrawable.setColor(getResources().getColor(R.color.progress_bar_color));
    progressBarDrawable.setBackgroundColor(getResources().getColor(R.color.progress_bar_background));
    mSimpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.drawee_view);
    mSimpleDraweeView.getHierarchy().setProgressBarImage(progressBarDrawable);
    mDebugOutput = (TextView) view.findViewById(R.id.debug_output);
    mDebugOutputScrollView = (ScrollView) view.findViewById(R.id.debug_output_scroll_view);
    final SwitchCompat switchProgressiveRenderingEnabled = (SwitchCompat) view.findViewById(R.id.switch_progressive_enabled);
    switchProgressiveRenderingEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mProgressiveRenderingEnabled = isChecked;
        }
    });
    mProgressiveRenderingEnabled = switchProgressiveRenderingEnabled.isChecked();
    final Spinner spinner = (Spinner) view.findViewById(R.id.spinner);
    spinner.setAdapter(new SimpleUriListAdapter());
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            final Entry spinnerEntry = mSpinnerEntries[spinner.getSelectedItemPosition()];
            setImageUri(spinnerEntry.uri);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    spinner.setSelection(0);
}
Also used : ProgressBarDrawable(com.facebook.drawee.drawable.ProgressBarDrawable) Spinner(android.widget.Spinner) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) AdapterView(android.widget.AdapterView) CompoundButton(android.widget.CompoundButton) SwitchCompat(androidx.appcompat.widget.SwitchCompat)

Example 57 with SimpleDraweeView

use of com.facebook.drawee.view.SimpleDraweeView in project fresco by facebook.

the class ImagePipelinePrefetchFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mUris = new Uri[] { sampleUris().createSampleUri(ImageSize.L, Orientation.LANDSCAPE), sampleUris().createSampleUri(ImageSize.L, Orientation.PORTRAIT) };
    final Button clearCacheButton = (Button) view.findViewById(R.id.clear_cache);
    clearCacheButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            for (Uri uri : mUris) {
                Fresco.getImagePipeline().evictFromCache(uri);
            }
        }
    });
    mPrefetchStatus = (TextView) view.findViewById(R.id.prefetch_status);
    mPrefetchDiskButton = (Button) view.findViewById(R.id.prefetch_disk_now);
    mPrefetchDiskButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mPrefetchDiskButton.setEnabled(false);
            final PrefetchSubscriber subscriber = new PrefetchSubscriber();
            for (Uri uri : mUris) {
                final DataSource<Void> ds = Fresco.getImagePipeline().prefetchToDiskCache(ImageRequest.fromUri(uri), null);
                ds.subscribe(subscriber, UiThreadImmediateExecutorService.getInstance());
            }
        }
    });
    mPrefetchEncodedButton = (Button) view.findViewById(R.id.prefetch_encoded_now);
    mPrefetchEncodedButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mPrefetchEncodedButton.setEnabled(false);
            final PrefetchSubscriber subscriber = new PrefetchSubscriber();
            for (Uri uri : mUris) {
                final DataSource<Void> ds = Fresco.getImagePipeline().prefetchToEncodedCache(ImageRequest.fromUri(uri), null);
                ds.subscribe(subscriber, UiThreadImmediateExecutorService.getInstance());
            }
        }
    });
    mPrefetchBitmapButton = (Button) view.findViewById(R.id.prefetch_bitmap_now);
    mPrefetchBitmapButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mPrefetchBitmapButton.setEnabled(false);
            final PrefetchSubscriber subscriber = new PrefetchSubscriber();
            for (Uri uri : mUris) {
                final DataSource<Void> ds = Fresco.getImagePipeline().prefetchToBitmapCache(ImageRequest.fromUri(uri), null);
                ds.subscribe(subscriber, UiThreadImmediateExecutorService.getInstance());
            }
        }
    });
    mDraweesHolder = (ViewGroup) view.findViewById(R.id.drawees);
    Button toggleImages = (Button) view.findViewById(R.id.toggle_images);
    toggleImages.setOnClickListener(new View.OnClickListener() {

        private boolean mShowing = false;

        @Override
        public void onClick(View v) {
            if (!mShowing) {
                for (int i = 0; i < mDraweesHolder.getChildCount(); i++) {
                    SimpleDraweeView draweeView = (SimpleDraweeView) mDraweesHolder.getChildAt(i);
                    draweeView.setController(Fresco.newDraweeControllerBuilder().setOldController(draweeView.getController()).setImageOriginListener(mImageOriginListener).setUri(mUris[i]).build());
                }
            } else {
                for (int i = 0; i < mDraweesHolder.getChildCount(); i++) {
                    ((SimpleDraweeView) mDraweesHolder.getChildAt(i)).setController(null);
                }
            }
            mShowing = !mShowing;
        }
    });
}
Also used : SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) Button(android.widget.Button) TextView(android.widget.TextView) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) Uri(android.net.Uri) DataSource(com.facebook.datasource.DataSource)

Example 58 with SimpleDraweeView

use of com.facebook.drawee.view.SimpleDraweeView in project fresco by facebook.

the class PartialRequestFragment method onViewCreated.

@Override
public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final SimpleDraweeView partialDrawee = (SimpleDraweeView) view.findViewById(R.id.drawee_partial_img);
    final SimpleDraweeView fullDrawee = (SimpleDraweeView) view.findViewById(R.id.drawee_full_img);
    final Button clearCacheButton = (Button) view.findViewById(R.id.clear_cache);
    clearCacheButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            partialDrawee.setController(null);
            fullDrawee.setController(null);
            Fresco.getImagePipeline().clearDiskCaches();
            Fresco.getImagePipeline().clearMemoryCaches();
        }
    });
    final Button prefetchButton = (Button) view.findViewById(R.id.prefetch_now);
    prefetchButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            loadImageIntoDrawee(partialDrawee, BytesRange.toMax(30000));
        }
    });
    Button loadFull = (Button) view.findViewById(R.id.load_full);
    loadFull.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            loadImageIntoDrawee(fullDrawee, null);
        }
    });
}
Also used : SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) Button(android.widget.Button) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View)

Aggregations

SimpleDraweeView (com.facebook.drawee.view.SimpleDraweeView)58 View (android.view.View)30 TextView (android.widget.TextView)20 Uri (android.net.Uri)8 DraweeController (com.facebook.drawee.interfaces.DraweeController)8 Intent (android.content.Intent)6 ImageView (android.widget.ImageView)5 RecyclerView (android.support.v7.widget.RecyclerView)4 Button (android.widget.Button)4 TintImageView (com.bilibili.magicasakura.widgets.TintImageView)4 RoundingParams (com.facebook.drawee.generic.RoundingParams)4 Animatable (android.graphics.drawable.Animatable)3 ViewGroup (android.view.ViewGroup)3 AdapterView (android.widget.AdapterView)3 CompoundButton (android.widget.CompoundButton)3 LinearLayout (android.widget.LinearLayout)3 SwitchCompat (androidx.appcompat.widget.SwitchCompat)3 BaseControllerListener (com.facebook.drawee.controller.BaseControllerListener)3 ControllerListener (com.facebook.drawee.controller.ControllerListener)3 ProgressBarDrawable (com.facebook.drawee.drawable.ProgressBarDrawable)3