use of androidx.appcompat.widget.SwitchCompat in project PreviewSeekBar by rubensousa.
the class MainActivity method setupOptions.
private void setupOptions() {
// Enable or disable the previews
SwitchCompat previewSwitch = findViewById(R.id.previewEnabledSwitch);
previewSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
previewTimeBar.setPreviewEnabled(isChecked);
previewSeekBar.setPreviewEnabled(isChecked);
});
// Enable or disable auto-hide mode of previews
SwitchCompat previewAutoHideSwitch = findViewById(R.id.previewAutoHideSwitch);
previewAutoHideSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
exoPlayerManager.setResumeVideoOnPreviewStop(isChecked);
previewTimeBar.setAutoHidePreview(isChecked);
previewSeekBar.setAutoHidePreview(isChecked);
});
// Change the animations
RadioGroup animationRadioGroup = findViewById(R.id.previewAnimationRadioGroup);
animationRadioGroup.setOnCheckedChangeListener((group, checkedId) -> {
if (checkedId == R.id.noAnimationRadioButton) {
previewTimeBar.setPreviewAnimationEnabled(false);
previewSeekBar.setPreviewAnimationEnabled(false);
} else {
previewTimeBar.setPreviewAnimationEnabled(true);
previewSeekBar.setPreviewAnimationEnabled(true);
if (checkedId == R.id.fadeAnimationRadioButton) {
previewTimeBar.setPreviewAnimator(new PreviewFadeAnimator());
previewSeekBar.setPreviewAnimator(new PreviewFadeAnimator());
} else if (Build.VERSION.SDK_INT >= 21) {
previewTimeBar.setPreviewAnimator(new PreviewMorphAnimator());
previewSeekBar.setPreviewAnimator(new PreviewMorphAnimator());
}
}
});
// Toggle previews
Button toggleButton = findViewById(R.id.previewToggleButton);
toggleButton.setOnClickListener(v -> {
if (previewTimeBar.isShowingPreview()) {
previewTimeBar.hidePreview();
} else {
previewTimeBar.showPreview();
exoPlayerManager.loadPreview(previewTimeBar.getProgress(), previewTimeBar.getMax());
}
if (previewSeekBar.isShowingPreview()) {
previewSeekBar.hidePreview();
} else {
previewSeekBar.showPreview();
}
});
// Change colors
Button changeColorsButton = findViewById(R.id.previewToggleColors);
changeColorsButton.setOnClickListener(v -> {
final int seekBarColor = previewSeekBar.getScrubberColor();
final int timeBarColor = previewTimeBar.getScrubberColor();
previewSeekBar.setPreviewThumbTint(timeBarColor);
previewSeekBar.setProgressTint(timeBarColor);
previewTimeBar.setPreviewThumbTint(seekBarColor);
previewTimeBar.setPlayedColor(seekBarColor);
});
}
use of androidx.appcompat.widget.SwitchCompat in project EhViewer by seven332.
the class SwitchPreference method onBindView.
@SuppressWarnings("TryWithIdenticalCatches")
@Override
protected void onBindView(View view) {
super.onBindView(view);
View checkableView = view.findViewById(R.id.switchWidget);
if (checkableView != null && checkableView instanceof Checkable) {
if (checkableView instanceof SwitchCompat) {
final SwitchCompat switchView = (SwitchCompat) checkableView;
switchView.setOnCheckedChangeListener(null);
}
((Checkable) checkableView).setChecked(isChecked());
if (checkableView instanceof SwitchCompat) {
final SwitchCompat switchView = (SwitchCompat) checkableView;
switchView.setTextOn(mSwitchOn);
switchView.setTextOff(mSwitchOff);
switchView.setOnCheckedChangeListener(mListener);
}
}
if (sSyncSummaryViewMethod != null) {
try {
sSyncSummaryViewMethod.invoke(this, view);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
use of androidx.appcompat.widget.SwitchCompat in project syncthing-android by syncthing.
the class FolderActivity method addDeviceViewAndSetListener.
private void addDeviceViewAndSetListener(Device device, LayoutInflater inflater) {
inflater.inflate(R.layout.item_device_form, mDevicesContainer);
SwitchCompat deviceView = (SwitchCompat) mDevicesContainer.getChildAt(mDevicesContainer.getChildCount() - 1);
deviceView.setOnCheckedChangeListener(null);
deviceView.setChecked(mFolder.getDevice(device.deviceID) != null);
deviceView.setText(device.getDisplayName());
deviceView.setTag(device);
deviceView.setOnCheckedChangeListener(mCheckedListener);
}
use of androidx.appcompat.widget.SwitchCompat in project sexytopo by richsmith.
the class DeviceActivity method updatePairedStatus.
private void updatePairedStatus() {
BluetoothDevice device = getPairedDevice();
boolean isPaired = (device != null);
SwitchCompat bluetoothSwitch = findViewById(R.id.bluetoothSwitch);
Button pairButton = findViewById(R.id.pairButton);
Button unpairButton = findViewById(R.id.unpairButton);
TextView deviceList = findViewById(R.id.deviceList);
deviceList.setTextColor(device == null ? Color.BLACK : Color.RED);
if (isPaired) {
pairButton.setEnabled(false);
unpairButton.setEnabled(true);
deviceList.setTextColor(Color.BLACK);
deviceList.setText(device.getName());
} else {
pairButton.setEnabled(true);
unpairButton.setEnabled(false);
deviceList.setTextColor(Color.RED);
deviceList.setText(R.string.no_device);
}
// Allow connections iff we have one connected DistoX
SwitchCompat connectionSwitch = findViewById(R.id.connectionSwitch);
if (isPaired && bluetoothSwitch.isChecked()) {
connectionSwitch.setEnabled(true);
} else {
connectionSwitch.setChecked(false);
connectionSwitch.setEnabled(false);
}
}
use of androidx.appcompat.widget.SwitchCompat in project sexytopo by richsmith.
the class DeviceActivity method updateConnectionStatus.
public void updateConnectionStatus() {
SwitchCompat connectionSwitch = findViewById(R.id.connectionSwitch);
connectionSwitch.setChecked(isConnectionStartingOrStarted);
}
Aggregations