use of com.facebook.fresco.samples.showcase.common.SimpleScaleTypeAdapter 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 Spinner scaleType = (Spinner) 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(mDraweeFancy, scaleType, spinnerEntry.focusPoint);
if (BITMAP_ONLY_SCALETYPES.contains(scaleType) && !BITMAP_ONLY_SCALETYPES.contains(mPreviousScaleType)) {
Toast.makeText(getContext(), R.string.drawee_rounded_corners_bitmap_only_toast, Toast.LENGTH_SHORT).show();
} else if (!BITMAP_ONLY_SCALETYPES.contains(scaleType) && BITMAP_ONLY_SCALETYPES.contains(mPreviousScaleType)) {
Toast.makeText(getContext(), R.string.drawee_rounded_corners_overlay_color_toast, Toast.LENGTH_SHORT).show();
}
mPreviousScaleType = scaleType;
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
final CheckBox borders = (CheckBox) view.findViewById(R.id.borders);
borders.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
setShowBorder(mDraweeRound, isChecked);
setShowBorder(mDraweeRadius, isChecked);
setShowBorder(mDraweeSome, isChecked);
setShowBorder(mDraweeFancy, isChecked);
}
});
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);
}
use of com.facebook.fresco.samples.showcase.common.SimpleScaleTypeAdapter 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);
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(URI_1);
mDraweeTop1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
changeMainDraweeUri(URI_1);
}
});
mDraweeTop2.setImageURI(URI_2);
mDraweeTop2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
changeMainDraweeUri(URI_2);
}
});
changeMainDraweeUri(URI_1);
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;
}
Aggregations