Search in sources :

Example 1 with ImageUriProvider

use of com.facebook.fresco.samples.showcase.misc.ImageUriProvider in project fresco by facebook.

the class SimpleListSectionSpec method generateData.

private static List<Data> generateData(final SectionContext c, int count) {
    ImageUriProvider uris = ShowcaseApplication.Companion.getImageUriProvider();
    ArrayList<Data> data = new ArrayList<>(count);
    for (int i = 1; i <= count; i++) {
        data.add(new Data(uris.createSampleUri(ImageUriProvider.ImageSize.S), uris.createSampleUri(ImageUriProvider.ImageSize.M), "Photo " + i));
    }
    return data;
}
Also used : ArrayList(java.util.ArrayList) ImageUriProvider(com.facebook.fresco.samples.showcase.misc.ImageUriProvider)

Example 2 with ImageUriProvider

use of com.facebook.fresco.samples.showcase.misc.ImageUriProvider in project fresco by facebook.

the class DraweeScaleTypeFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_drawee_scale_type, container, false);
    final ImageUriProvider imageUriProvider = sampleUris();
    final Uri uri1 = imageUriProvider.createSampleUri(ImageUriProvider.ImageSize.M, ImageUriProvider.Orientation.LANDSCAPE);
    final Uri uri2 = imageUriProvider.createSampleUri(ImageUriProvider.ImageSize.M, ImageUriProvider.Orientation.PORTRAIT);
    mDraweeTop1 = (SimpleDraweeView) view.findViewById(R.id.drawee_view_top_1);
    mDraweeTop2 = (SimpleDraweeView) view.findViewById(R.id.drawee_view_top_2);
    mDraweeMain = (SimpleDraweeView) view.findViewById(R.id.drawee_view);
    mSpinner = (Spinner) view.findViewById(R.id.spinner);
    mDraweeTop1.setImageURI(uri1);
    mDraweeTop1.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            changeMainDraweeUri(uri1);
        }
    });
    mDraweeTop2.setImageURI(uri2);
    mDraweeTop2.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            changeMainDraweeUri(uri2);
        }
    });
    changeMainDraweeUri(uri1);
    final SimpleScaleTypeAdapter adapter = SimpleScaleTypeAdapter.createForAllScaleTypes();
    mSpinner.setAdapter(adapter);
    mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            final SimpleScaleTypeAdapter.Entry spinnerEntry = (SimpleScaleTypeAdapter.Entry) adapter.getItem(position);
            changeMainDraweeScaleType(spinnerEntry.scaleType, spinnerEntry.focusPoint);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    mSpinner.setSelection(0);
    return view;
}
Also used : SimpleScaleTypeAdapter(com.facebook.fresco.samples.showcase.common.SimpleScaleTypeAdapter) AdapterView(android.widget.AdapterView) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) AdapterView(android.widget.AdapterView) ImageUriProvider(com.facebook.fresco.samples.showcase.misc.ImageUriProvider) Uri(android.net.Uri) Nullable(androidx.annotation.Nullable)

Example 3 with ImageUriProvider

use of com.facebook.fresco.samples.showcase.misc.ImageUriProvider in project fresco by facebook.

the class DraweeRoundedCornersFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    findDrawees(view);
    initColors();
    final ImageUriProvider imageUriProvider = sampleUris();
    mDraweeRound.setImageURI(imageUriProvider.createSampleUri(ImageSize.L));
    mDraweeRadius.setImageURI(imageUriProvider.createSampleUri(ImageSize.L));
    mDraweeSome.setImageURI(imageUriProvider.createSampleUri(ImageSize.L));
    mDraweeSomeRtl.setImageURI(imageUriProvider.createSampleUri(ImageSize.L));
    mDraweeFancy.setImageURI(imageUriProvider.createSampleUri(ImageSize.L));
    final Spinner scaleType = view.findViewById(R.id.scaleType);
    final SimpleScaleTypeAdapter scaleTypeAdapter = SimpleScaleTypeAdapter.createForAllScaleTypes();
    scaleType.setAdapter(scaleTypeAdapter);
    scaleType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            final SimpleScaleTypeAdapter.Entry spinnerEntry = (SimpleScaleTypeAdapter.Entry) scaleTypeAdapter.getItem(position);
            final ScaleType scaleType = spinnerEntry.scaleType;
            changeDraweeViewScaleType(mDraweeRound, scaleType, spinnerEntry.focusPoint);
            changeDraweeViewScaleType(mDraweeRadius, scaleType, spinnerEntry.focusPoint);
            changeDraweeViewScaleType(mDraweeSome, scaleType, spinnerEntry.focusPoint);
            changeDraweeViewScaleType(mDraweeSomeRtl, scaleType, spinnerEntry.focusPoint);
            changeDraweeViewScaleType(mDraweeFancy, scaleType, spinnerEntry.focusPoint);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    mShowBordersCheck = view.findViewById(R.id.borders);
    mShowBordersCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            updateRounding();
        }
    });
    mScaleInsideBordersCheck = view.findViewById(R.id.scaleInside);
    mScaleInsideBordersCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            updateRounding();
        }
    });
    mColorOverlayCheck = view.findViewById(R.id.color_overlay);
    mColorOverlayCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            updateRounding();
        }
    });
    mFixRepeatedEdgesCheck = view.findViewById(R.id.fix_repeated_edges);
    mFixRepeatedEdgesCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            updateRounding();
        }
    });
    final Resources res = getResources();
    final RoundingParams fancyRoundingParams = RoundingParams.fromCornersRadii(res.getDimensionPixelSize(R.dimen.drawee_rounded_corners_fancy_top_left), res.getDimensionPixelSize(R.dimen.drawee_rounded_corners_fancy_top_right), res.getDimensionPixelSize(R.dimen.drawee_rounded_corners_fancy_bottom_right), res.getDimensionPixelSize(R.dimen.drawee_rounded_corners_fancy_bottom_left));
    mDraweeFancy.getHierarchy().setRoundingParams(fancyRoundingParams);
}
Also used : Spinner(android.widget.Spinner) ScaleType(com.facebook.drawee.drawable.ScalingUtils.ScaleType) SimpleScaleTypeAdapter(com.facebook.fresco.samples.showcase.common.SimpleScaleTypeAdapter) ImageUriProvider(com.facebook.fresco.samples.showcase.misc.ImageUriProvider) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) AdapterView(android.widget.AdapterView) AdapterView(android.widget.AdapterView) Resources(android.content.res.Resources) CompoundButton(android.widget.CompoundButton) RoundingParams(com.facebook.drawee.generic.RoundingParams)

Aggregations

ImageUriProvider (com.facebook.fresco.samples.showcase.misc.ImageUriProvider)3 View (android.view.View)2 AdapterView (android.widget.AdapterView)2 SimpleDraweeView (com.facebook.drawee.view.SimpleDraweeView)2 SimpleScaleTypeAdapter (com.facebook.fresco.samples.showcase.common.SimpleScaleTypeAdapter)2 Resources (android.content.res.Resources)1 Uri (android.net.Uri)1 CompoundButton (android.widget.CompoundButton)1 Spinner (android.widget.Spinner)1 Nullable (androidx.annotation.Nullable)1 ScaleType (com.facebook.drawee.drawable.ScalingUtils.ScaleType)1 RoundingParams (com.facebook.drawee.generic.RoundingParams)1 ArrayList (java.util.ArrayList)1