use of androidx.appcompat.widget.SwitchCompat 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);
}
use of androidx.appcompat.widget.SwitchCompat in project fresco by facebook.
the class DraweeHierarchyFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
final Uri uriSuccess = sampleUris().createSampleUri(ImageUriProvider.ImageSize.XL, ImageUriProvider.Orientation.ANY, ImageUriProvider.UriModification.CACHE_BREAKER);
final Uri uriFailure = sampleUris().getNonExistingUri();
final SimpleDraweeView draweeView = view.findViewById(R.id.drawee);
final SwitchCompat retrySwitch = view.findViewById(R.id.retry_enabled);
// noinspection deprecation
final Drawable failureDrawable = getResources().getDrawable(R.drawable.ic_error_black_96dp);
DrawableCompat.setTint(failureDrawable, Color.RED);
final ProgressBarDrawable progressBarDrawable = new ProgressBarDrawable();
progressBarDrawable.setColor(getResources().getColor(R.color.accent));
progressBarDrawable.setBackgroundColor(getResources().getColor(R.color.primary));
progressBarDrawable.setRadius(getResources().getDimensionPixelSize(R.dimen.drawee_hierarchy_progress_radius));
draweeView.getHierarchy().setProgressBarImage(progressBarDrawable);
draweeView.getHierarchy().setFailureImage(failureDrawable, ScaleType.CENTER_INSIDE);
view.findViewById(R.id.load_success).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setUri(draweeView, uriSuccess, retrySwitch.isChecked());
}
});
view.findViewById(R.id.load_fail).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setUri(draweeView, uriFailure, retrySwitch.isChecked());
}
});
view.findViewById(R.id.clear).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
draweeView.setController(null);
Fresco.getImagePipeline().evictFromCache(uriSuccess);
}
});
final SwitchCompat roundCorners = view.findViewById(R.id.switch_rounded);
roundCorners.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
RoundingParams roundingParams = new RoundingParams().setCornersRadius(isChecked ? buttonView.getResources().getDimensionPixelSize(R.dimen.drawee_hierarchy_corner_radius) : 0);
draweeView.getHierarchy().setRoundingParams(roundingParams);
}
});
final SwitchCompat useNinePatch = view.findViewById(R.id.switch_ninepatch);
useNinePatch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
draweeView.getHierarchy().setPlaceholderImage(isChecked ? R.drawable.ninepatch : R.drawable.logo, isChecked ? ScaleType.FIT_XY : ScaleType.CENTER_INSIDE);
}
});
}
use of androidx.appcompat.widget.SwitchCompat in project fresco by facebook.
the class ImageFormatSvgFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
mSimpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.drawee_view);
mSimpleDraweeView.setImageURI(sampleUris().createSvgUri());
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);
}
});
SwitchCompat switchCompat = (SwitchCompat) view.findViewById(R.id.decoder_switch);
switchCompat.setChecked(CustomImageFormatConfigurator.isSvgEnabled(getContext()));
switchCompat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
CustomImageFormatConfigurator.setSvgEnabled(getContext(), isChecked);
getShowRestartMessageDialog().show(getChildFragmentManager(), null);
}
});
}
use of androidx.appcompat.widget.SwitchCompat in project K6nele by Kaljurand.
the class RewritesActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.rewrites, menu);
// TODO: review (seems like a detour)
MenuItem menuItem = menu.findItem(R.id.menuRewritesToggle);
menuItem.setActionView(R.layout.ab_switch);
SwitchCompat abSwitch = menuItem.getActionView().findViewById(R.id.abSwitch);
abSwitch.setChecked(mRewrites.isSelected());
abSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
mRewrites.setSelected(isChecked);
if (isChecked) {
toast(String.format(getString(R.string.toastActivated), mRewrites.getId()));
} else {
toast(String.format(getString(R.string.toastDeactivated), mRewrites.getId()));
}
});
/*
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
MenuItem searchMenuItem = menu.findItem(R.id.search);
SearchView searchView = (SearchView) searchMenuItem.getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setSubmitButtonEnabled(false);
searchView.setOnQueryTextListener(mFragment);
*/
return true;
}
use of androidx.appcompat.widget.SwitchCompat in project sexytopo by richsmith.
the class DeviceActivity method toggleConnection.
public void toggleConnection(View view) {
SwitchCompat connectionSwitch = (SwitchCompat) view;
if (connectionSwitch.isChecked()) {
Log.device(getString(R.string.device_log_connection_requested));
isConnectionStartingOrStarted = true;
startConnection();
} else {
Log.device(getString(R.string.device_log_connection_stop_requested));
isConnectionStartingOrStarted = false;
stopConnection();
}
}
Aggregations