Search in sources :

Example 26 with SwitchCompat

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);
    });
}
Also used : PreviewMorphAnimator(com.github.rubensousa.previewseekbar.animator.PreviewMorphAnimator) RadioGroup(android.widget.RadioGroup) Button(android.widget.Button) PreviewFadeAnimator(com.github.rubensousa.previewseekbar.animator.PreviewFadeAnimator) SwitchCompat(androidx.appcompat.widget.SwitchCompat)

Example 27 with SwitchCompat

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();
        }
    }
}
Also used : Checkable(android.widget.Checkable) View(android.view.View) InvocationTargetException(java.lang.reflect.InvocationTargetException) SwitchCompat(androidx.appcompat.widget.SwitchCompat)

Example 28 with SwitchCompat

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);
}
Also used : SwitchCompat(androidx.appcompat.widget.SwitchCompat)

Example 29 with SwitchCompat

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);
    }
}
Also used : BluetoothDevice(android.bluetooth.BluetoothDevice) Button(android.widget.Button) TextView(android.widget.TextView) SwitchCompat(androidx.appcompat.widget.SwitchCompat)

Example 30 with SwitchCompat

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);
}
Also used : SwitchCompat(androidx.appcompat.widget.SwitchCompat)

Aggregations

SwitchCompat (androidx.appcompat.widget.SwitchCompat)43 TextView (android.widget.TextView)23 View (android.view.View)20 CompoundButton (android.widget.CompoundButton)17 RelativeLayout (android.widget.RelativeLayout)8 LayoutInflater (android.view.LayoutInflater)7 AlertDialog (androidx.appcompat.app.AlertDialog)6 PopupMenu (androidx.appcompat.widget.PopupMenu)6 Toolbar (androidx.appcompat.widget.Toolbar)5 CheckerBoardDrawable (com.facebook.fresco.samples.showcase.misc.CheckerBoardDrawable)5 ArrayList (java.util.ArrayList)5 Activity (android.app.Activity)4 DialogInterface (android.content.DialogInterface)4 Intent (android.content.Intent)4 Uri (android.net.Uri)4 ViewGroup (android.view.ViewGroup)4 ContextCompat (androidx.core.content.ContextCompat)4 SimpleDraweeView (com.facebook.drawee.view.SimpleDraweeView)4 Dialog (android.app.Dialog)3 Drawable (android.graphics.drawable.Drawable)3