Search in sources :

Example 1 with CheckBox

use of carbon.widget.CheckBox in project Carbon by ZieIony.

the class Samples method initToolbar.

public static void initToolbar(final Activity activity, String title) {
    final DebugOverlay overlay = new DebugOverlay(activity);
    Toolbar toolbar = (Toolbar) activity.findViewById(R.id.toolbar);
    toolbar.setTitle(title);
    final ImageView debug = (ImageView) activity.findViewById(R.id.debug);
    if (debug != null) {
        debug.setTint(Carbon.getThemeColor(activity, R.attr.carbon_colorDisabled));
        debug.setOnClickListener(new View.OnClickListener() {

            boolean debugEnabled = false;

            @Override
            public void onClick(View view) {
                if (!debugEnabled) {
                    debug.setTint(Carbon.getThemeColor(activity, R.attr.carbon_iconColor));
                    overlay.show();
                    debugEnabled = true;
                } else {
                    debug.setTint(Carbon.getThemeColor(activity, R.attr.carbon_colorDisabled));
                    overlay.dismiss();
                    debugEnabled = false;
                }
            }
        });
    }
    CheckBox checkBox = (CheckBox) activity.findViewById(R.id.enabled);
    if (checkBox != null)
        checkBox.setOnCheckedChangeListener((compoundButton, checked) -> {
            List<View> views = findViewsWithTag((ViewGroup) activity.getWindow().getDecorView().getRootView(), "enable");
            for (View v : views) v.setEnabled(checked);
        });
}
Also used : CheckBox(carbon.widget.CheckBox) Context(android.content.Context) List(java.util.List) Carbon(carbon.Carbon) SharedPreferences(android.content.SharedPreferences) Toolbar(carbon.widget.Toolbar) DebugOverlay(carbon.internal.DebugOverlay) View(android.view.View) ImageView(carbon.widget.ImageView) Activity(android.app.Activity) ViewGroup(android.view.ViewGroup) ArrayList(java.util.ArrayList) CheckBox(carbon.widget.CheckBox) ViewGroup(android.view.ViewGroup) DebugOverlay(carbon.internal.DebugOverlay) List(java.util.List) ArrayList(java.util.ArrayList) ImageView(carbon.widget.ImageView) View(android.view.View) ImageView(carbon.widget.ImageView) Toolbar(carbon.widget.Toolbar)

Example 2 with CheckBox

use of carbon.widget.CheckBox in project Carbon by ZieIony.

the class SnackbarActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_snackbar);
    final CheckBox tapCheckBox = (CheckBox) findViewById(R.id.tap);
    final CheckBox swipeCheckBox = (CheckBox) findViewById(R.id.swipe);
    final CheckBox floatingCheckBox = (CheckBox) findViewById(R.id.floating);
    final CheckBox infiniteCheckBox = (CheckBox) findViewById(R.id.infinite);
    final CheckBox pushCheckBox = (CheckBox) findViewById(R.id.push);
    final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    findViewById(R.id.button).setOnClickListener(view -> {
        final Snackbar snackbar = new Snackbar(SnackbarActivity.this, "Hello world!", "dismiss", infiniteCheckBox.isChecked() ? Snackbar.INFINITE : getResources().getInteger(R.integer.carbon_snackbarDuration));
        snackbar.setOnClickListener(v -> snackbar.dismiss());
        snackbar.setStyle(floatingCheckBox.isChecked() ? Snackbar.Style.Floating : Snackbar.Style.Docked);
        snackbar.setTapOutsideToDismissEnabled(tapCheckBox.isChecked());
        snackbar.setSwipeToDismissEnabled(swipeCheckBox.isChecked());
        if (pushCheckBox.isChecked())
            snackbar.addPushedView(fab);
        snackbar.show((ViewGroup) getWindow().getDecorView().getRootView());
        snackbar.setOnDismissListener(() -> {
        });
    });
    Snackbar.clearQueue();
}
Also used : CheckBox(carbon.widget.CheckBox) FloatingActionButton(carbon.widget.FloatingActionButton) Snackbar(carbon.widget.Snackbar)

Aggregations

CheckBox (carbon.widget.CheckBox)2 Activity (android.app.Activity)1 Context (android.content.Context)1 SharedPreferences (android.content.SharedPreferences)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 Carbon (carbon.Carbon)1 DebugOverlay (carbon.internal.DebugOverlay)1 FloatingActionButton (carbon.widget.FloatingActionButton)1 ImageView (carbon.widget.ImageView)1 Snackbar (carbon.widget.Snackbar)1 Toolbar (carbon.widget.Toolbar)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1