当前位置: 首页>>代码示例>>Java>>正文


Java RxCompoundButton类代码示例

本文整理汇总了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 );
                }
            }) ;

}
 
开发者ID:zyj1609wz,项目名称:RxJava_RxAndroid,代码行数:19,代码来源:LoginActivity.java

示例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));

}
 
开发者ID:erickok,项目名称:ratebeer,代码行数:22,代码来源:HelpActivity.java

示例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);
                }));
    }
}
 
开发者ID:OpenSilk,项目名称:SyncthingAndroid,代码行数:17,代码来源:EditDevicePresenter.java

示例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);
                }));
    }
}
 
开发者ID:OpenSilk,项目名称:SyncthingAndroid,代码行数:22,代码来源:EditFolderPresenter.java

示例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());
}
 
开发者ID:Aiushtha,项目名称:Go-RxJava,代码行数:37,代码来源:RxPreferences_Demo.java

示例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());
    }));
}
 
开发者ID:apptik,项目名称:RHub,代码行数:16,代码来源:MainActivity.java

示例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()
    );
}
 
开发者ID:st1hy,项目名称:Red-Calorie,代码行数:12,代码来源:TagItemHolder.java

示例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()));
}
 
开发者ID:hotchemi,项目名称:tiamat,代码行数:9,代码来源:BaseActivity.java

示例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());
}
 
开发者ID:cowthan,项目名称:AyoSunny,代码行数:14,代码来源:CheckBoxUpdateFragment.java

示例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);
                }
            });
}
 
开发者ID:cowthan,项目名称:AyoSunny,代码行数:14,代码来源:CheckBoxUpdateFragment.java

示例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()));
}
 
开发者ID:f2prateek,项目名称:rx-preferences,代码行数:11,代码来源:SampleActivity.java

示例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
          );
        }
      });
}
 
开发者ID:xmartlabs,项目名称:XLMaterialCalendarView,代码行数:73,代码来源:MainActivity.java

示例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();
}
 
开发者ID:matbrandao,项目名称:Saude-no-Mapa,代码行数:76,代码来源:EstablishmentPresenterImpl.java

示例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));
}
 
开发者ID:OpenSilk,项目名称:SyncthingAndroid,代码行数:5,代码来源:CompoundButtonEventBinding.java


注:本文中的com.jakewharton.rxbinding.widget.RxCompoundButton类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。