本文整理汇总了Java中com.jakewharton.rxbinding.widget.RxCompoundButton类的典型用法代码示例。如果您正苦于以下问题:Java RxCompoundButton类的具体用法?Java RxCompoundButton怎么用?Java RxCompoundButton使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RxCompoundButton类属于com.jakewharton.rxbinding.widget包,在下文中一共展示了RxCompoundButton类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.jakewharton.rxbinding.widget.RxCompoundButton; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
button = (Button) findViewById( R.id.login_bt );
checkBox = (CheckBox) findViewById( R.id.checkbox );
RxCompoundButton.checkedChanges( checkBox )
.subscribe(new Action1<Boolean>() {
@Override
public void call(Boolean aBoolean) {
button.setEnabled( aBoolean );
button.setBackgroundResource( aBoolean ? R.color.button_yes : R.color.button_no );
}
}) ;
}
示例2: onCreate
import com.jakewharton.rxbinding.widget.RxCompoundButton; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
signInOutButton = (Button) findViewById(R.id.signinout_button);
signoutProgress = (ProgressBar) findViewById(R.id.signout_progress);
datasaverCheck = (CheckBox) findViewById(R.id.datasaver_check);
metricunitsCheck = (CheckBox) findViewById(R.id.metricunits_check);
setupDefaultUpButton();
// Settings persistence
datasaverCheck.setChecked(Session.get().inDataSaverMode());
RxCompoundButton.checkedChanges(datasaverCheck).skip(1)
.subscribe(checked -> Session.get().setDataSaverMode(checked));
metricunitsCheck.setChecked(Session.get().useMetricUnits());
RxCompoundButton.checkedChanges(metricunitsCheck).skip(1)
.subscribe(checked -> Session.get().setUseMetricUnits(checked));
}
示例3: addSharedFolders
import com.jakewharton.rxbinding.widget.RxCompoundButton; //导入依赖的package包/类
@BindingAdapter("addShareFolders")
public static void addSharedFolders(LinearLayout shareFoldersContainer, EditDevicePresenter presenter) {
if (presenter == null) return;
shareFoldersContainer.removeAllViews();
for (Map.Entry<String, Boolean> e : presenter.sharedFolders.entrySet()) {
final String id = e.getKey();
CheckBox checkBox = new CheckBox(shareFoldersContainer.getContext());
checkBox.setText(id);
checkBox.setChecked(e.getValue());
shareFoldersContainer.addView(checkBox);
presenter.bindingSubscriptions().add(RxCompoundButton.checkedChanges(checkBox)
.subscribe(checked -> {
presenter.setFolderShared(id, checked);
}));
}
}
示例4: addShareDevices
import com.jakewharton.rxbinding.widget.RxCompoundButton; //导入依赖的package包/类
@BindingAdapter("addShareDevices")
public static void addShareDevices(LinearLayout shareDevicesContainer, EditFolderPresenter presenter) {
if (presenter == null) return;
shareDevicesContainer.removeAllViews();
for (Map.Entry<String, Boolean> e : presenter.sharedDevices.entrySet()) {
final String id = e.getKey();
CheckBox checkBox = new CheckBox(shareDevicesContainer.getContext());
DeviceConfig device = presenter.controller.getDevice(id);
if (device == null) {
device = new DeviceConfig();
device.deviceID = id;
}
checkBox.setText(SyncthingUtils.getDisplayName(device));
checkBox.setChecked(e.getValue());
shareDevicesContainer.addView(checkBox);
presenter.bindingSubscriptions().add(RxCompoundButton.checkedChanges(checkBox)
.subscribe(b -> {
presenter.setDeviceShared(id, b);
}));
}
}
示例5: init
import com.jakewharton.rxbinding.widget.RxCompoundButton; //导入依赖的package包/类
@Override
protected void init() {
super.init();
btn_submit.setText("查看变量");
editText=new EditText(getActivity());
checkBox=new CheckBox(getActivity());
checkBox.setText("是否为男性");
container.addView(checkBox);
container.addView(editText);
//创建实例
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
RxSharedPreferences rxPreferences = RxSharedPreferences.create(preferences);
//创建个人
pre_username = rxPreferences.getString("username");
pre_sex= rxPreferences.getBoolean("sex", true);
//绑定
RxCompoundButton.checkedChanges(checkBox)
.subscribe(pre_sex.asAction());
RxTextView.textChanges(editText)
.flatMap(new Func1<CharSequence, Observable<String>>() {
@Override
public Observable<String> call(final CharSequence charSequence) {
return Observable.create(new Observable.OnSubscribe<String>() {
@Override
public void call(Subscriber<? super String> subscriber) {
subscriber.onNext(charSequence.toString());
subscriber.onCompleted();
}
});
}
})
.subscribe(pre_username.asAction());
}
示例6: onResume
import com.jakewharton.rxbinding.widget.RxCompoundButton; //导入依赖的package包/类
@Override
protected void onResume() {
super.onResume();
ToggleButton btnLight = (ToggleButton) findViewById(R.id.btnLight);
ToggleButton btnAcc = (ToggleButton) findViewById(R.id.btnAcc);
shield.addActionEvent(RxCompoundButton.checkedChanges(btnLight).map(aBoolean -> {
if (aBoolean) return new Pair<>(LightOn,btnLight.getContext());
else return new Pair<>(LightOff,btnLight.getContext());
}));
shield.addActionEvent(RxCompoundButton.checkedChanges(btnAcc).map(aBoolean -> {
if (aBoolean) return new Pair<>(AccOn,btnAcc.getContext());
else return new Pair<>(AccOff,btnAcc.getContext());
}));
}
示例7: onAttached
import com.jakewharton.rxbinding.widget.RxCompoundButton; //导入依赖的package包/类
@Override
public void onAttached() {
position.onAttached();
scrollingItemDelegate.onAttached();
scrollingItemDelegate.subscribe(
RxCompoundButton.checkedChanges(checkBox)
.map(isChecked -> TagItemHolder.this)
.compose(Transformers.channel(stateChanges))
.subscribe()
);
}
示例8: bindPreference
import com.jakewharton.rxbinding.widget.RxCompoundButton; //导入依赖的package包/类
void bindPreference(CheckBox checkBox, Preference<Boolean> preference) {
subscriptions.add(preference.asObservable()
.observeOn(AndroidSchedulers.mainThread())
.subscribe(RxCompoundButton.checked(checkBox)));
subscriptions.add(RxCompoundButton.checkedChanges(checkBox)
.skip(1)
.subscribe(preference.asAction()));
}
示例9: check_update1
import com.jakewharton.rxbinding.widget.RxCompoundButton; //导入依赖的package包/类
/**
* 同步SharedPreferences
*/
private void check_update1() {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
RxSharedPreferences rxPreferences = RxSharedPreferences.create(preferences);
Preference<Boolean> xxFunction = rxPreferences.getBoolean("xxFunction", false);
checkBox1.setChecked(xxFunction.get());
RxCompoundButton.checkedChanges(checkBox1)
.subscribe(xxFunction.asAction());
}
示例10: check_update2
import com.jakewharton.rxbinding.widget.RxCompoundButton; //导入依赖的package包/类
/**
* 同步UI
*/
private void check_update2() {
RxCompoundButton.checkedChanges(checkBox2)
.subscribe(new Action1<Boolean>() {
@Override
public void call(Boolean aBoolean) {
btn_login.setClickable(aBoolean);
btn_login.setBackgroundResource(aBoolean ? R.color.can_login : R.color.not_login);
}
});
}
示例11: bindPreference
import com.jakewharton.rxbinding.widget.RxCompoundButton; //导入依赖的package包/类
void bindPreference(final CheckBox checkBox, Preference<Boolean> preference) {
// Bind the preference to the checkbox.
disposables.add(preference.asObservable()
.observeOn(AndroidSchedulers.mainThread())
.subscribe(checkBox::setChecked));
// Bind the checkbox to the preference.
disposables.add(RxJavaInterop.toV2Observable(RxCompoundButton.checkedChanges(checkBox))
.skip(1) // First emission is the original state.
.subscribe(preference.asConsumer()));
}
示例12: onCreate
import com.jakewharton.rxbinding.widget.RxCompoundButton; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final XLMaterialCalendarView calendarView = (XLMaterialCalendarView) findViewById(R.id.calendarView);
final CheckBox checkBox = (CheckBox) findViewById(R.id.checkbox);
if (calendarView.getMinimumLocalDate() != null) {
Toast.makeText(MainActivity.this, "There shouldn't be a minimum date yet", Toast.LENGTH_SHORT).show();
}
if (calendarView.getMaximumLocalDate() != null) {
Toast.makeText(MainActivity.this, "There shouldn't be a maximum date yet", Toast.LENGTH_SHORT).show();
}
calendarView.newState()
.setFirstDayOfWeek(1)
.setMinimumDate(LocalDate.of(2016, 6, 12))
.setMaximumDate(LocalDate.of(2016, 12, 9))
.commit();
if (calendarView.getSelectedLocalDate() != null) {
Toast.makeText(MainActivity.this, "There shouldn't be a selected date yet", Toast.LENGTH_SHORT).show();
}
if (!calendarView.getSelectedLocalDates().isEmpty()) {
Toast.makeText(MainActivity.this, "There selected dates range should be empty", Toast.LENGTH_SHORT).show();
}
calendarView.setClock(mockedClock());
calendarView.selectRange(LocalDate.of(2016, 9, 17), LocalDate.of(2016, 9, 29)); // We could select a range.
calendarView.setSelectedDate(LocalDate.of(2016, 11, 14)); // But we will select a particular date.
calendarView.setDateSelected(LocalDate.of(2016, 11, 14), true); // We can use this method to (un)select too.
RxCalendarView.dateChanges(calendarView)
.subscribe(new Action1<LocalDate>() {
@Override
public void call(LocalDate localDate) {
Toast.makeText(MainActivity.this, String.format("Selected date: %s", localDate), Toast.LENGTH_SHORT).show();
}
});
RxCalendarView.monthChanges(calendarView)
.subscribe(new Action1<YearMonth>() {
@Override
public void call(YearMonth yearMonth) {
Toast.makeText(MainActivity.this, String.format("Month changed: %s", yearMonth), Toast.LENGTH_SHORT).show();
}
});
RxCalendarView.rangeSelected(calendarView)
.subscribe(new Action1<List<LocalDate>>() {
@Override
public void call(List<LocalDate> localDates) {
Toast.makeText(MainActivity.this, "Selected dates: " + formattedLocalDates(localDates), Toast.LENGTH_SHORT)
.show();
}
});
RxCompoundButton.checkedChanges(checkBox)
.subscribe(new Action1<Boolean>() {
@Override
public void call(Boolean isChecked) {
calendarView.setSelectionMode(isChecked
? MaterialCalendarView.SELECTION_MODE_RANGE
: MaterialCalendarView.SELECTION_MODE_SINGLE
);
}
});
}
示例13: showFilterBottomSheetDialog
import com.jakewharton.rxbinding.widget.RxCompoundButton; //导入依赖的package包/类
private void showFilterBottomSheetDialog() {
mIsFiltered = false;
BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(mContext);
View dialogView = LayoutInflater.from(mContext).inflate(R.layout.dialog_bottom_sheet_filter, null);
FilterViews bottomViews = new FilterViews();
ButterKnife.bind(bottomViews, dialogView);
mCurrentFilterTitle = bottomViews.filterTitle;
updateCurrentFilterTitle();
bottomViews.redeAtendimentoSpinner.setAdapter(getRedeAtendimentoAdapter());
bottomViews.categoriaSpinner.setAdapter(getCategoriaSpinner());
RxAdapterView.itemSelections(bottomViews.redeAtendimentoSpinner).subscribe(integer -> {
doFilter(bottomViews);
});
RxAdapterView.itemSelections(bottomViews.categoriaSpinner).subscribe(integer -> {
doFilter(bottomViews);
});
RxCompoundButton.checkedChanges(bottomViews.vinculoSusCheckbox).subscribe(isChecked -> {
doFilter(bottomViews);
});
RxCompoundButton.checkedChanges(bottomViews.atendimentoUrgencialCheckbox).subscribe(isChecked -> {
doFilter(bottomViews);
});
RxCompoundButton.checkedChanges(bottomViews.atendimentoAmbulatorialCheckbox).subscribe(isChecked -> {
doFilter(bottomViews);
});
RxCompoundButton.checkedChanges(bottomViews.centroCirurgicoCheckbox).subscribe(isChecked -> {
doFilter(bottomViews);
});
RxCompoundButton.checkedChanges(bottomViews.obstetraCheckbox).subscribe(isChecked -> {
doFilter(bottomViews);
});
RxCompoundButton.checkedChanges(bottomViews.neoNatalCheckbox).subscribe(isChecked -> {
doFilter(bottomViews);
});
RxCompoundButton.checkedChanges(bottomViews.dialiseCheckbox).subscribe(isChecked -> {
doFilter(bottomViews);
});
bottomViews.filterButton.setOnClickListener(view -> {
mIsFiltered = true;
mInteractor.clearMarkers(mMap);
showMapPins(mFilteredEstablishmentList);
mInteractor.animateCameraToAllEstablishments(mMap);
bottomSheetDialog.dismiss();
});
bottomSheetDialog.setContentView(dialogView);
bottomSheetDialog.getWindow().findViewById(R.id.design_bottom_sheet)
.setBackgroundResource(R.color.default_dialog_background);
dialogView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
BottomSheetBehavior mBehavior = BottomSheetBehavior.from((View) dialogView.getParent());
mBehavior.setPeekHeight((int) (mView.getMapContainerHeight() + 400));
bottomSheetDialog.setOnDismissListener(dialogInterface -> {
if (!mIsFiltered) {
mFilteredEstablishmentList.clear();
mFilteredEstablishmentList.addAll(mEstablishmentList);
}
});
bottomSheetDialog.show();
}
示例14: subscribeCheckedChanges
import com.jakewharton.rxbinding.widget.RxCompoundButton; //导入依赖的package包/类
@BindingAdapter("checkedChanges")
public static void subscribeCheckedChanges(BindingSubscriptionsHolder bsh, CompoundButton button, Action1<Boolean> onNext) {
bsh.bindingSubscriptions().add(RxCompoundButton.checkedChanges(button).skip(1).subscribe(onNext));
}