Java Code Examples for android.widget.CompoundButton

The following examples show how to use android.widget.CompoundButton. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: scalpel   Source File: SampleActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  setContentView(R.layout.sample_activity);
  ButterKnife.inject(this);

  pagerView.setAdapter(new SamplePagerAdapter(this));

  Switch enabledSwitch = new Switch(this);
  enabledSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
    @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
      if (first) {
        first = false;
        Toast.makeText(SampleActivity.this, R.string.first_run, LENGTH_LONG).show();
      }

      scalpelView.setLayerInteractionEnabled(isChecked);
      invalidateOptionsMenu();
    }
  });

  ActionBar actionBar = getActionBar();
  actionBar.setCustomView(enabledSwitch);
  actionBar.setDisplayOptions(DISPLAY_SHOW_TITLE | DISPLAY_SHOW_CUSTOM);
}
 
Example 2
Source Project: Rumble   Source File: StatisticActivity.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings_statistic);
    setTitle(R.string.settings_statistic);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayUseLogoEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);

    CheckBox checkBox = (CheckBox)findViewById(R.id.stat_check_box);
    checkBox.setChecked(RumblePreferences.UserOkWithSharingAnonymousData(this));
    checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            RumblePreferences.setUserPreferenceWithSharingData(StatisticActivity.this, isChecked);
        }
    });
}
 
Example 3
Source Project: views-widgets-samples   Source File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mRadioGroup = (RadioGroup) findViewById(R.id.radioGroup);
    mPredictiveCB = (CheckBox) findViewById(R.id.predictiveCB);
    mCustomCB = (CheckBox) findViewById(R.id.customCB);

    mRecyclerView = (RecyclerView) findViewById(R.id.recyclerview);
    mRecyclerView.setLayoutManager(new MyLinearLayoutManager(this));
    mRecyclerView.setAdapter(new RVAdapter());

    mCustomCB.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mRecyclerView.setItemAnimator(isChecked ? mChangeAnimator : mDefaultItemAnimator);
        }
    });
}
 
Example 4
Source Project: VideoRecorder   Source File: VideoRecorderFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mSurfaceView = view.findViewById(R.id.SurfaceView);
    mBtnRecord = view.findViewById(R.id.cbRecord);
    mTvFps = view.findViewById(R.id.tvFps);
    mBtnRecord.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (mRecorder != null) {
                if (mRecorder.isRecordEnable()) {
                    mRecorder.stopRecord();
                } else {
                    mRecorder.startRecord();
                }
            }
        }
    });
    mSurfaceView.getHolder().addCallback(this);
}
 
Example 5
@Override
	public void populateView(Displayable displayable) {
//        final AdultRowViewHolder holder = (AdultRowViewHolder) viewHolder;
		adultSwitch.setOnCheckedChangeListener(null);
		adultSwitch.setChecked(PreferenceManager.getDefaultSharedPreferences(Aptoide.getContext()).getBoolean(Constants.MATURE_CHECK_BOX, false));
		adultSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
			@Override
			public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

				if (isChecked) {
					new AdultDialog().show(fragmentManager, "adultDialog");
				} else {
					BusProvider.getInstance().post(new OttoEvents.MatureEvent(false));
				}
			}
		});
	}
 
Example 6
Source Project: sa-sdk-android   Source File: ViewUtil.java    License: Apache License 2.0 6 votes vote down vote up
static boolean isTrackEvent(View view, boolean isFromUser) {
    if (view instanceof CheckBox) {
        if (!isFromUser) {
            return false;
        }
    } else if (view instanceof RadioButton) {
        if (!isFromUser) {
            return false;
        }
    } else if (view instanceof ToggleButton) {
        if (!isFromUser) {
            return false;
        }
    } else if (view instanceof CompoundButton) {
        if (!isFromUser) {
            return false;
        }
    }
    if (view instanceof RatingBar) {
        if (!isFromUser) {
            return false;
        }
    }
    return true;
}
 
Example 7
Source Project: umeng_community_android   Source File: PushSettingFragment.java    License: MIT License 6 votes vote down vote up
@Override
protected void initWidgets() {
    int switchButtonResId = ResFinder.getId(
            "umeng_common_switch_button");
    mSwitchButton = (SwitchButton) mRootView
            .findViewById(switchButtonResId);
    mSwitchButton.setChecked(mSDKConfig.isPushEnable(getActivity()));
    mSwitchButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // 保存配置
            CommConfig.getConfig().setSDKPushable(getActivity(), isChecked);
        }
    });
}
 
Example 8
Source Project: ViewInspector   Source File: SettingsMenu.java    License: Apache License 2.0 6 votes vote down vote up
public SettingsMenu(final Context context) {
  super(context);
  ViewInspector.runtimeComponentMap.get(context).inject(this);

  inflate(context, R.layout.view_inspector_settings_menu, this);

  Switch logViewEventsSwitch = (Switch) findViewById(R.id.log_view_events_switch);
  logViewEventsSwitch.setChecked(logViewEvents.get());
  logViewEventsSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
    @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
      logViewEvents.set(isChecked);
    }
  });

  View viewFilter = findViewById(R.id.view_filter);
  viewFilter.setOnClickListener(new OnClickListener() {
    @Override public void onClick(View v) {
      new SetViewFilterDialog(
          new ContextThemeWrapper(context, BaseDialog.getDialogTheme(context))).show();
    }
  });
}
 
Example 9
Source Project: AndroidProject   Source File: RadioButtonGroupHelper.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * {@link CompoundButton.OnCheckedChangeListener}
 */
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    if (isChecked && !mTag) {
        mTag = true;
        for (CompoundButton view : mViewSet) {
            if (view != buttonView && view.isChecked()) {
                // 这个 API 会触发监听事件
                view.setChecked(false);
            }
        }
        if (mListener != null) {
            mListener.onCheckedChanged((RadioButton) buttonView, buttonView.getId());
        }
        mTag = false;
    }
}
 
Example 10
Source Project: FuAgoraDemoDroid   Source File: CheckGroup.java    License: MIT License 6 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    // prevents from infinite recursion
    if (mProtectFromCheckedChange) {
        return;
    }

    int id = buttonView.getId();
    mProtectFromCheckedChange = true;
    if (mCheckedId != View.NO_ID && mCheckedId != id) {
        setCheckedStateForView(mCheckedId, false);
    }
    mProtectFromCheckedChange = false;

    setCheckedId(isChecked ? id : View.NO_ID);
}
 
Example 11
Source Project: Noyze   Source File: ConfigurationActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);

    LinearLayout root = (LinearLayout)findViewById(android.R.id.list).getParent().getParent().getParent();
    bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.settings_toolbar, root, false);
    bar.setTitle(getTitle());
    bar.inflateMenu(R.menu.toggle_switch);
    final MenuItem toggle = bar.getMenu().findItem(R.id.action_switch);
    if (null != toggle) {
        switchView = (CompoundButton) toggle.getActionView().findViewById(R.id.switch_view);
        if (null != switchView) {
            switchView.setChecked(VolumeAccessibilityService.isEnabled(this));
            switchView.setOnCheckedChangeListener(this);
        }
    }
    if (isTaskRoot()) bar.setNavigationIcon(null);
    root.addView(bar, 0);
    bar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });
}
 
Example 12
Source Project: SSForms   Source File: TokensChipAdapter.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public View createSearchView(Context context, boolean is_checked, final int pos) {
    View view = View.inflate(context, R.layout.tokens_search,null);
    CheckBox cbCheck = view.findViewById(R.id.cbCheck);
    cbCheck.setText((String)search_data.get(pos).getValue());
    cbCheck.setChecked(is_checked);
    cbCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if(b){
                tokens.add(search_data.get(pos));
                //refresh();
            }else{
                tokens.remove(search_data.get(pos));
                //refresh();
            }
        }
    });
    return view;
}
 
Example 13
Source Project: YImagePicker   Source File: WXBottomBar.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void initView(View view) {
    mDirButton = view.findViewById(R.id.mDirButton);
    mPreview = view.findViewById(R.id.mPreview);
    mCheckBox = view.findViewById(R.id.mCheckBox);
    setCheckBoxDrawable(R.mipmap.picker_wechat_unselect, R.mipmap.picker_wechat_select);
    setBottomBarColor(Color.parseColor("#303030"));
    mCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            ImagePicker.isOriginalImage = isChecked;
        }
    });
    previewText = getContext().getString(R.string.picker_str_bottom_preview);
    mPreview.setText(previewText);
    mCheckBox.setText(getContext().getString(R.string.picker_str_bottom_original));
}
 
Example 14
Source Project: NestedRadioButton   Source File: NestedRadioGroupManager.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    // prevents from infinite recursion
    if (protectFromCheckedChange) {
        return;
    }
    int id = buttonView.getId();

    protectFromCheckedChange = true;
    if (checkedId != -1 && checkedId != id) {
        setCheckedStateForView(checkedId, false);
    }
    protectFromCheckedChange = false;

    setCheckedId(id);
}
 
Example 15
/**
 * Sync value of "can edit" {@link Switch} according to a change in one of its subordinate checkboxes.
 *
 * If all the subordinates are disabled, "can edit" has to be disabled.
 *
 * If any subordinate is enabled, "can edit" has to be enabled.
 *
 * @param subordinateCheckBoxView   Subordinate {@link CheckBox} that was changed.
 * @param isChecked                 'true' iif subordinateCheckBoxView was checked.
 */
private void syncCanEditSwitch(View subordinateCheckBoxView, boolean isChecked) {
    CompoundButton canEditCompound = (CompoundButton) getView().findViewById(R.id.canEditSwitch);
    if (isChecked) {
        if (!canEditCompound.isChecked()) {
            toggleDisablingListener(canEditCompound);
        }
    } else {
        boolean allDisabled = true;
        for (int i=0; allDisabled && i<sSubordinateCheckBoxIds.length; i++) {
            allDisabled &=
                    sSubordinateCheckBoxIds[i] == subordinateCheckBoxView.getId() ||
                            !((CheckBox) getView().findViewById(sSubordinateCheckBoxIds[i])).isChecked()
            ;
        }
        if (canEditCompound.isChecked() && allDisabled) {
            toggleDisablingListener(canEditCompound);
            for (int i=0; i<sSubordinateCheckBoxIds.length; i++) {
                getView().findViewById(sSubordinateCheckBoxIds[i]).setVisibility(View.GONE);
            }
        }
    }
}
 
Example 16
Source Project: ImagePicker   Source File: ImagePagerActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
    if (isChecked)
    {
        if (ImageDataModel.getInstance().getResultNum() == mOptions.getMaxNum())
        {
            showShortToast(getString(R.string.warning_imagepicker_max_num, String.valueOf(mOptions.getMaxNum())));
            mCkSelected.setOnCheckedChangeListener(null);//取消监听,以免冲突
            mCkSelected.setChecked(false);
            mCkSelected.setOnCheckedChangeListener(mCkChangeListener);
        } else
        {
            ImageDataModel.getInstance().addDataToResult(mDataList.get(mCurPosition));
            onSelectNumChanged();
        }
    } else
    {
        ImageDataModel.getInstance().delDataFromResult(mDataList.get(mCurPosition));
        onSelectNumChanged();
    }
}
 
Example 17
private void ininEvent() {
	btnNext.setOnClickListener(this);
	imgWiFiList.setOnClickListener(this);

	cbLaws.setOnCheckedChangeListener(new OnCheckedChangeListener() {
		@Override
		public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
			String psw = etPsw.getText().toString();

			if (isChecked) {
				etPsw.setInputType(0x90);
			} else {
				etPsw.setInputType(0x81);
			}
			etPsw.setSelection(psw.length());
		}
	});
	cbLaws.setChecked(true);
}
 
Example 18
Source Project: TestChat   Source File: BasePreViewActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void initView() {
        back = (ImageView) findViewById(R.id.iv_picture_top_bar_back);
        description = (TextView) findViewById(R.id.tv_picture_top_bar_description);
        finish = (Button) findViewById(R.id.btn_picture_top_bar_finish);
        delete = (ImageView) findViewById(R.id.iv_picture_top_bar_delete);
        topBar = (RelativeLayout) findViewById(R.id.picture_top_bar);
        bottomView = (RelativeLayout) findViewById(R.id.rl_base_preview_bottom);
        origin = (CheckBox) findViewById(R.id.cb_base_preview_origin);
        select = (CheckBox) findViewById(R.id.cb_base_preview_select);
        display = (PreviewViewPager) findViewById(R.id.vp_base_preview_display);
        back.setOnClickListener(this);
        delete.setOnClickListener(this);
        select.setOnClickListener(this);
        finish.setOnClickListener(this);
        origin.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                        if (isChecked) {
                                origin.setText(getString(R.string.origin_size, previewList.get(currentPosition).getSize()));
                        } else {
                                origin.setText(getString(R.string.origin_text));
                        }
                }
        });
}
 
Example 19
Source Project: AcDisplay   Source File: Option.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    if (mBroadcasting) {
        return;
    }

    getValue(mAppConfig)[0] = isChecked;

    // Clone current state cause it can be changed after.
    mBlacklist.saveAppConfig(mContext, mAppConfig, this);
}
 
Example 20
@NonNull
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.skill_operation__ringer_mode, container, false);

    rb_normal = view.findViewById(R.id.radioButton_normal);
    rb_vibrate = view.findViewById(R.id.radioButton_vibrate);
    rb_silent_dnd = view.findViewById(R.id.radioButton_silent_dnd);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        container_dnd = view.findViewById(R.id.container_dnd);
        rb_silent_dnd.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                container_dnd.setVisibility(b ? View.VISIBLE : View.GONE);
            }
        });
        rb_dnd_all = view.findViewById(R.id.radioButton_dnd_all);
        rb_dnd_priority = view.findViewById(R.id.radioButton_dnd_priority);
        rb_dnd_none = view.findViewById(R.id.radioButton_dnd_none);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            rb_dnd_alarms = view.findViewById(R.id.radioButton_dnd_alarms);
        }
    }

    return view;
}
 
Example 21
public static SwitcherFragment newInstance(String title, String summary, boolean checked,
                                           CompoundButton.OnCheckedChangeListener onCheckedChangeListener) {
    Bundle args = new Bundle();
    args.putString(INTENT_TITLE, title);
    args.putString(INTENT_SUMMARY, summary);
    args.putBoolean(INTENT_CHECKED, checked);
    SwitcherFragment fragment = new SwitcherFragment();
    fragment.setArguments(args);
    fragment.mOnCheckedChangeListener = onCheckedChangeListener;
    return fragment;
}
 
Example 22
@Override
public void configViews() {
    cbAgreement.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b) {
                if (verifyInfo()) {
                    btnLoadWallet.setEnabled(true);
                }
            } else {
                btnLoadWallet.setEnabled(false);
            }
        }
    });
}
 
Example 23
Source Project: JKeyboardPanelSwitch   Source File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    setTitle(R.string.activity_main_title);

    assignViews();

    mThemeRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            if (checkedId == R.id.full_screen_rb) {
                // full screen theme.
                mHandleByPlaceholderResolvedBtn.
                        setText(R.string.activity_chatting_fullscreen_resolved_title);
            } else {
                // translucent status with fitSystemWindows=false theme.
                mHandleByPlaceholderResolvedBtn.setText(R.string
                        .activity_chatting_translucent_status_false_resolved_title);
            }
        }
    });

    mTranslucentStatusTrueCb
            .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    if (isChecked) {
                        // translucent status with fitSystemWindows=true theme.
                        mHandleByDelayResolvedBtn.setText(R.string
                                .activity_chatting_translucent_status_true_resolved_title);
                    } else {
                        // normal theme.
                        mHandleByDelayResolvedBtn.setText(R.string
                                .activity_chatting_resolved_title);
                    }
                }
            });
}
 
Example 24
Source Project: weex   Source File: WXSwitch.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void addEvent(String type) {
  super.addEvent(type);
  if (type != null && type.equals(WXEventType.CHANGE) && getView() != null) {
    getView().setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
      @Override
      public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        Map<String, Object> params = new HashMap<>(2);
        params.put("value", isChecked);
        WXSDKManager.getInstance().fireEvent(mInstanceId, mDomObj.ref, WXEventType.CHANGE, params);
      }
    });
  }
}
 
Example 25
Source Project: progressbutton   Source File: ProgressButtonTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test public void onCheckedChangeListenerIsNotifiedOnToggle() {
  button.setPinned(true);
  CompoundButton.OnCheckedChangeListener publisher =
      mock(CompoundButton.OnCheckedChangeListener.class);
  button.setOnCheckedChangeListener(publisher);
  button.toggle();
  verify(publisher).onCheckedChanged(button, false);
}
 
Example 26
Source Project: mobikul-standalone-pos   Source File: PaymentMethodActivity.java    License: MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ActivityPaymentMethodBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_payment_method);
    setSupportActionBar(binding.toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    binding.enableCash.setChecked(AppSharedPref.isCashEnabled(PaymentMethodActivity.this, true));
    binding.enableCash.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            AppSharedPref.setCashEnabled(PaymentMethodActivity.this, isChecked);
        }
    });
}
 
Example 27
Source Project: TraceByAmap   Source File: Animate_CameraActivity.java    License: MIT License 5 votes vote down vote up
/**
 * 根据动画按钮状态,调用函数animateCamera或moveCamera来改变可视区域
 */
private void changeCamera(CameraUpdate update, CancelableCallback callback) {
	boolean animated = ((CompoundButton) findViewById(R.id.animate))
			.isChecked();
	if (animated) {
		aMap.animateCamera(update, 1000, callback);
	} else {
		aMap.moveCamera(update);
	}
}
 
Example 28
Source Project: AcDisplay   Source File: NonClearableOption.java    License: GNU General Public License v2.0 5 votes vote down vote up
public NonClearableOption(Context context, CompoundButton cb,
                          Blacklist blacklist, String packageName) {
    super(context, cb, blacklist, packageName,
            ResUtils.getDrawable(context, R.drawable.ic_settings_non_clearable_notifies),
            context.getResources().getString(R.string.blacklist_app_non_clearable_title),
            context.getResources().getString(R.string.blacklist_app_non_clearable_summary));
}
 
Example 29
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    switch (buttonView.getId()) {
        case R.id.checkbox_force_use_compat_mode:
            setForceCompatMode(isChecked);
            break;
    }
}
 
Example 30
Source Project: Theogony   Source File: ChampionListActivity.java    License: MIT License 5 votes vote down vote up
private void initNavigationView() {
    mNavigationView.setNavigationItemSelectedListener(this);
    MenuItem dayNightMenuItem = mNavigationView.getMenu().findItem(R.id.menu_item_dayNight);
    View view = MenuItemCompat.getActionView(dayNightMenuItem);
    mSwitchCompat = ButterKnife.findById(view, R.id.switch_view);
    mSwitchCompat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            setNightMode(isChecked);
        }
    });
    mSwitchCompat.setChecked(ThemeUtils.isNightMode(this));
}