Search in sources :

Example 21 with SwitchCompat

use of android.support.v7.widget.SwitchCompat in project fresco by facebook.

the class ImageFormatKeyframesFragment method initAnimation.

@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
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(URI_KEYFRAMES_ANIMATION).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(android.support.v7.widget.SwitchCompat) RequiresApi(android.support.annotation.RequiresApi)

Example 22 with SwitchCompat

use of android.support.v7.widget.SwitchCompat in project fresco by facebook.

the class ImageFormatProgressiveJpegFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    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 = SPINNER_ENTRIES[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(android.support.v7.widget.SwitchCompat)

Example 23 with SwitchCompat

use of android.support.v7.widget.SwitchCompat in project MusicDNA by harjot-oberai.

the class SettingsFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    backBtn = (ImageView) view.findViewById(R.id.settings_back_btn);
    backBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            getActivity().onBackPressed();
        }
    });
    fragTitle = (TextView) view.findViewById(R.id.settings_fragment_title);
    if (SplashActivity.tf4 != null)
        fragTitle.setTypeface(SplashActivity.tf4);
    bottomMarginLayout = view.findViewById(R.id.bottom_margin_layout);
    if (HomeActivity.isReloaded)
        bottomMarginLayout.getLayoutParams().height = 0;
    else
        bottomMarginLayout.getLayoutParams().height = CommonUtils.dpTopx(65, getContext());
    resetSettings = (RelativeLayout) view.findViewById(R.id.reset_settings_card);
    resetSettings.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            final android.app.AlertDialog alertDialog = new android.app.AlertDialog.Builder(view.getContext()).create();
            alertDialog.setTitle("Reset settings?");
            alertDialog.setMessage("This operation will reset all settings but playlist and other content will remain unchanged.");
            alertDialog.setButton(android.app.AlertDialog.BUTTON_POSITIVE, "Reset", new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    resetAllSettings();
                    Toast.makeText(getContext(), "Settings have been reset", Toast.LENGTH_LONG).show();
                }
            });
            alertDialog.setButton(android.app.AlertDialog.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
            alertDialog.create();
            alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {

                @Override
                public void onShow(DialogInterface arg0) {
                    alertDialog.getButton(android.app.AlertDialog.BUTTON_POSITIVE).setTextColor(HomeActivity.themeColor);
                    alertDialog.getButton(android.app.AlertDialog.BUTTON_NEGATIVE).setTextColor(HomeActivity.themeColor);
                }
            });
            alertDialog.show();
        }
    });
    densitycard = (RelativeLayout) view.findViewById(R.id.density_card);
    densityText = (TextView) view.findViewById(R.id.density_value);
    densityText.setText(String.valueOf(100 - (int) (homeActivity.minAudioStrength * 100)));
    densitycard.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Dialog dialog = new Dialog(getContext());
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setContentView(R.layout.density_dialog);
            densitySeekbar = (SeekBar) dialog.findViewById(R.id.density_dialog_seekbar);
            densitySeekbar.getProgressDrawable().setColorFilter(new PorterDuffColorFilter(homeActivity.themeColor, PorterDuff.Mode.SRC_IN));
            densityTextDialog = (TextView) dialog.findViewById(R.id.density_dialog_value);
            densitySeekbar.setMax(100);
            densitySeekbar.setProgress(Integer.parseInt(densityText.getText().toString()));
            densityTextDialog.setText(String.valueOf(densitySeekbar.getProgress()));
            densitySeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

                @Override
                public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                    setHomeActivityDNADensity(progress);
                    densityTextDialog.setText(String.valueOf(progress));
                    densityText.setText(String.valueOf(progress));
                }

                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {
                }

                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {
                }
            });
            dialog.show();
        }
    });
    themeCard = (RelativeLayout) view.findViewById(R.id.theme_card);
    themeColorImg = (ImageView) view.findViewById(R.id.theme_color_img);
    themeColorImg.setBackgroundColor(homeActivity.themeColor);
    themeCard.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final AlertDialog dialog = ColorPickerDialogBuilder.with(getContext()).setTitle("Choose color").initialColor(HomeActivity.themeColor).wheelType(ColorPickerView.WHEEL_TYPE.FLOWER).density(9).showColorPreview(true).lightnessSliderOnly().setOnColorSelectedListener(new OnColorSelectedListener() {

                @Override
                public void onColorSelected(int color) {
                }
            }).setPositiveButton("ok", new ColorPickerClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int color, Integer[] allColors) {
                    setHomeActivityColor(color);
                }
            }).setNegativeButton("cancel", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).build();
            dialog.setOnShowListener(new DialogInterface.OnShowListener() {

                @Override
                public void onShow(DialogInterface dialogInterface) {
                    dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(HomeActivity.themeColor);
                    dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(HomeActivity.themeColor);
                }
            });
            dialog.show();
        }
    });
    albumArtCard = (RelativeLayout) view.findViewById(R.id.album_art_card);
    albumArtToggle = (SwitchCompat) view.findViewById(R.id.album_art_toggle);
    albumArtToggle.setChecked(homeActivity.settings.isAlbumArtBackgroundEnabled());
    albumArtCard.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            albumArtToggle.toggle();
        }
    });
    albumArtToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            setHomeActivityAlbumBg(isChecked);
        }
    });
    wifiCard = (RelativeLayout) view.findViewById(R.id.wifi_card);
    wifiToggle = (SwitchCompat) view.findViewById(R.id.wifi_stream_toggle);
    wifiToggle.setChecked(homeActivity.settings.isStreamOnlyOnWifiEnabled());
    wifiCard.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            wifiToggle.toggle();
        }
    });
    wifiToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            setHomeActivityStreamingOnWifi(isChecked);
        }
    });
    aboutCard = (RelativeLayout) view.findViewById(R.id.about_card);
    aboutCard.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mCallback.onAboutClicked();
        }
    });
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) SeekBar(android.widget.SeekBar) DialogInterface(android.content.DialogInterface) ColorPickerDialogBuilder(com.flask.colorpicker.builder.ColorPickerDialogBuilder) ColorPickerClickListener(com.flask.colorpicker.builder.ColorPickerClickListener) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) ImageView(android.widget.ImageView) ColorPickerView(com.flask.colorpicker.ColorPickerView) View(android.view.View) TextView(android.widget.TextView) OnColorSelectedListener(com.flask.colorpicker.OnColorSelectedListener) Dialog(android.app.Dialog) AlertDialog(android.support.v7.app.AlertDialog) TextView(android.widget.TextView) CompoundButton(android.widget.CompoundButton)

Example 24 with SwitchCompat

use of android.support.v7.widget.SwitchCompat in project Notes by lguipeng.

the class SwitchPreference method onBindView.

@Override
protected void onBindView(View view) {
    super.onBindView(view);
    SwitchCompat switchCompat = (SwitchCompat) view.findViewById(R.id.switch_compat);
    switchCompat.setChecked(isChecked());
    syncSummaryView(view);
}
Also used : SwitchCompat(android.support.v7.widget.SwitchCompat)

Example 25 with SwitchCompat

use of android.support.v7.widget.SwitchCompat in project XposedInstaller by rovo89.

the class StatusInstallerFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.status_installer, container, false);
    // Available ZIPs
    final SwipeRefreshLayout refreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swiperefreshlayout);
    refreshLayout.setColorSchemeColors(getResources().getColor(R.color.colorPrimary));
    ONLINE_ZIP_LOADER.setSwipeRefreshLayout(refreshLayout);
    ONLINE_ZIP_LOADER.addListener(mOnlineZipListener);
    ONLINE_ZIP_LOADER.triggerFirstLoadIfNecessary();
    LOCAL_ZIP_LOADER.addListener(mLocalZipListener);
    LOCAL_ZIP_LOADER.triggerFirstLoadIfNecessary();
    refreshZipViews(v);
    // Disable switch
    final SwitchCompat disableSwitch = (SwitchCompat) v.findViewById(R.id.disableSwitch);
    disableSwitch.setChecked(!DISABLE_FILE.exists());
    disableSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (DISABLE_FILE.exists()) {
                DISABLE_FILE.delete();
                Snackbar.make(disableSwitch, R.string.xposed_on_next_reboot, Snackbar.LENGTH_LONG).show();
            } else {
                try {
                    DISABLE_FILE.createNewFile();
                    Snackbar.make(disableSwitch, R.string.xposed_off_next_reboot, Snackbar.LENGTH_LONG).show();
                } catch (IOException e) {
                    Log.e(XposedApp.TAG, "Could not create " + DISABLE_FILE, e);
                }
            }
        }
    });
    // Device info
    TextView androidSdk = (TextView) v.findViewById(R.id.android_version);
    TextView manufacturer = (TextView) v.findViewById(R.id.ic_manufacturer);
    TextView cpu = (TextView) v.findViewById(R.id.cpu);
    androidSdk.setText(getString(R.string.android_sdk, Build.VERSION.RELEASE, getAndroidVersion(), Build.VERSION.SDK_INT));
    manufacturer.setText(getUIFramework());
    cpu.setText(FrameworkZips.ARCH);
    // Known issues
    refreshKnownIssue(v);
    // Display warning dialog to new users
    if (!XposedApp.getPreferences().getBoolean("hide_install_warning", false)) {
        new MaterialDialog.Builder(getActivity()).title(R.string.install_warning_title).content(R.string.install_warning).positiveText(android.R.string.ok).onPositive(new MaterialDialog.SingleButtonCallback() {

            @Override
            public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                if (dialog.isPromptCheckBoxChecked()) {
                    XposedApp.getPreferences().edit().putBoolean("hide_install_warning", true).apply();
                }
            }
        }).checkBoxPromptRes(R.string.dont_show_again, false, null).cancelable(false).show();
    }
    return v;
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) IOException(java.io.IOException) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) DialogAction(com.afollestad.materialdialogs.DialogAction) NonNull(android.support.annotation.NonNull) TextView(android.widget.TextView) CompoundButton(android.widget.CompoundButton) SwitchCompat(android.support.v7.widget.SwitchCompat)

Aggregations

SwitchCompat (android.support.v7.widget.SwitchCompat)33 TextView (android.widget.TextView)25 View (android.view.View)24 CompoundButton (android.widget.CompoundButton)20 Intent (android.content.Intent)10 AlertDialog (android.support.v7.app.AlertDialog)8 ImageView (android.widget.ImageView)8 DialogInterface (android.content.DialogInterface)7 CardView (android.support.v7.widget.CardView)6 MenuItem (android.view.MenuItem)6 ScrollView (android.widget.ScrollView)6 AdapterView (android.widget.AdapterView)5 LinearLayout (android.widget.LinearLayout)5 SeekBar (android.widget.SeekBar)5 SearchView (android.support.v7.widget.SearchView)4 Button (android.widget.Button)4 CheckerBoardDrawable (com.facebook.fresco.samples.showcase.misc.CheckerBoardDrawable)4 ArrayList (java.util.ArrayList)4 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)3 Uri (android.net.Uri)3