use of com.facebook.animated.giflite.GifDecoder in project fresco by facebook.
the class ImageFormatGifFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
mSpinnerEntries = new Entry[] { new Entry(R.string.format_gif_label_small, sampleUris().createGifUri(ImageUriProvider.ImageSize.S)), new Entry(R.string.format_gif_label_medium, sampleUris().createGifUri(ImageUriProvider.ImageSize.M)), new Entry(R.string.format_gif_label_large, sampleUris().createGifUri(ImageUriProvider.ImageSize.L)) };
mSimpleDraweeView = view.findViewById(R.id.drawee_view);
final SwitchCompat switchBackground = view.findViewById(R.id.switch_background);
switchBackground.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mSimpleDraweeView.getHierarchy().setBackgroundImage(isChecked ? new CheckerBoardDrawable(getResources()) : null);
}
});
final SwitchCompat switchAutoPlay = view.findViewById(R.id.switch_autoplay);
switchAutoPlay.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mAutoPlayEnabled = isChecked;
refreshAnimation();
}
});
mAutoPlayEnabled = switchAutoPlay.isEnabled();
final SwitchCompat switchAspect = view.findViewById(R.id.switch_aspect_ratio);
switchAspect.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
ViewGroup.LayoutParams layoutParams = mSimpleDraweeView.getLayoutParams();
layoutParams.height = layoutParams.width * (isChecked ? 2 : 1);
mSimpleDraweeView.setLayoutParams(layoutParams);
}
});
mSpinner = (Spinner) view.findViewById(R.id.spinner);
mSpinner.setAdapter(new SimpleUriListAdapter());
mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
refreshAnimation();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
mSpinner.setSelection(0);
final Spinner decoderSpinner = view.findViewById(R.id.spinner_select_decoder);
decoderSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
switch(position) {
case 0:
mGifDecoder = null;
break;
case 1:
mGifDecoder = new GifDecoder();
break;
default:
throw new IllegalArgumentException("Unknown decoder selected");
}
refreshAnimation();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
decoderSpinner.setSelection(0);
}
Aggregations