use of androidx.appcompat.widget.SwitchCompat in project sexytopo by richsmith.
the class DeviceActivity method setupSwitchListeners.
private void setupSwitchListeners() {
SwitchCompat bluetoothSwitch = findViewById(R.id.bluetoothSwitch);
bluetoothSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> toggleBluetooth(buttonView));
SwitchCompat connectionSwitch = findViewById(R.id.connectionSwitch);
connectionSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> toggleConnection(buttonView));
}
use of androidx.appcompat.widget.SwitchCompat in project fresco by facebook.
the class ImageFormatKeyframesFragment method initAnimation.
private void initAnimation(View view) {
mSimpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.drawee_view);
mSimpleDraweeView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
DraweeController controller = Fresco.newDraweeControllerBuilder().setOldController(mSimpleDraweeView.getController()).setUri(sampleUris().createKeyframesUri()).setAutoPlayAnimations(true).build();
mSimpleDraweeView.setController(controller);
final SwitchCompat switchBackground = (SwitchCompat) 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);
}
});
}
use of androidx.appcompat.widget.SwitchCompat in project fresco by facebook.
the class ImageFormatWebpFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
final SimpleDraweeView draweeWebpStatic = view.findViewById(R.id.drawee_view_webp_static);
draweeWebpStatic.setImageURI(sampleUris().createWebpStaticUri());
final SimpleDraweeView draweeWebpTranslucent = view.findViewById(R.id.drawee_view_webp_translucent);
draweeWebpTranslucent.setImageURI(sampleUris().createWebpTranslucentUri());
final SwitchCompat switchBackground = view.findViewById(R.id.switch_background);
switchBackground.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
draweeWebpTranslucent.getHierarchy().setBackgroundImage(isChecked ? new CheckerBoardDrawable(getResources()) : null);
}
});
final SimpleDraweeView draweeWebpAnimated = view.findViewById(R.id.drawee_view_webp_animated);
draweeWebpAnimated.setController(Fresco.newDraweeControllerBuilder().setAutoPlayAnimations(true).setOldController(draweeWebpAnimated.getController()).setUri(sampleUris().createWebpAnimatedUri()).build());
final TextView supportStatusTextView = view.findViewById(R.id.text_webp_support_status);
final StringBuilder sb = new StringBuilder();
sb.append("WebpSupportStatus.sIsSimpleWebpSupported = ").append(WebpSupportStatus.sIsSimpleWebpSupported).append('\n');
sb.append("WebpSupportStatus.sIsExtendedWebpSupported = ").append(WebpSupportStatus.sIsExtendedWebpSupported).append('\n');
sb.append("WebpSupportStatus.sIsWebpSupportRequired = ").append(WebpSupportStatus.sIsWebpSupportRequired).append('\n');
supportStatusTextView.setText(sb.toString());
}
use of androidx.appcompat.widget.SwitchCompat in project fresco by facebook.
the class ImageFormatColorFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
mSimpleDraweeView1 = (SimpleDraweeView) view.findViewById(R.id.drawee1);
mSimpleDraweeView2 = (SimpleDraweeView) view.findViewById(R.id.drawee2);
// Set a simple custom color resource as the image.
// The format of custom_color1 is <color>#rrggbb</color>
mSimpleDraweeView1.setImageURI(UriUtil.getUriForResourceId(R.raw.custom_color1));
mSimpleDraweeView2.setImageURI(UriUtil.getUriForResourceId(R.raw.custom_color2));
final SwitchCompat switchBackground = (SwitchCompat) view.findViewById(R.id.switch_background);
switchBackground.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mSimpleDraweeView1.getHierarchy().setBackgroundImage(isChecked ? new CheckerBoardDrawable(getResources()) : null);
mSimpleDraweeView2.getHierarchy().setBackgroundImage(isChecked ? new CheckerBoardDrawable(getResources()) : null);
}
});
SwitchCompat switchCompat = (SwitchCompat) view.findViewById(R.id.decoder_switch);
switchCompat.setChecked(CustomImageFormatConfigurator.isGlobalColorDecoderEnabled(getContext()));
switchCompat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
CustomImageFormatConfigurator.setGlobalColorDecoderEnabled(getContext(), isChecked);
}
});
}
use of androidx.appcompat.widget.SwitchCompat 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);
}
Aggregations