Search in sources :

Example 31 with SwitchCompat

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

Example 32 with SwitchCompat

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);
        }
    });
}
Also used : CheckerBoardDrawable(com.facebook.fresco.samples.showcase.misc.CheckerBoardDrawable) DraweeController(com.facebook.drawee.interfaces.DraweeController) CompoundButton(android.widget.CompoundButton) SwitchCompat(androidx.appcompat.widget.SwitchCompat)

Example 33 with SwitchCompat

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());
}
Also used : SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) CheckerBoardDrawable(com.facebook.fresco.samples.showcase.misc.CheckerBoardDrawable) TextView(android.widget.TextView) CompoundButton(android.widget.CompoundButton) SwitchCompat(androidx.appcompat.widget.SwitchCompat)

Example 34 with SwitchCompat

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);
        }
    });
}
Also used : CheckerBoardDrawable(com.facebook.fresco.samples.showcase.misc.CheckerBoardDrawable) CompoundButton(android.widget.CompoundButton) SwitchCompat(androidx.appcompat.widget.SwitchCompat)

Example 35 with SwitchCompat

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);
}
Also used : ProgressBarDrawable(com.facebook.drawee.drawable.ProgressBarDrawable) Spinner(android.widget.Spinner) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) AdapterView(android.widget.AdapterView) CompoundButton(android.widget.CompoundButton) 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