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


Java ObservableBoolean类代码示例

本文整理汇总了Java中android.databinding.ObservableBoolean的典型用法代码示例。如果您正苦于以下问题:Java ObservableBoolean类的具体用法?Java ObservableBoolean怎么用?Java ObservableBoolean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ObservableBoolean类属于android.databinding包,在下文中一共展示了ObservableBoolean类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: takeTakesCorrectTimes

import android.databinding.ObservableBoolean; //导入依赖的package包/类
@Test
public void takeTakesCorrectTimes() throws Exception {
    String string1 = "STRING 1";
    String string2 = "STRING 2";
    ObservableField<String> observed = new ObservableField<>(string1);
    ObservableBoolean observing = Cinder.computeBoolean(()->
        observed.get().equals(string1)
        , observed).take(2).immediate();
    assertTrue(observing.get());

    observed.set(string2);
    assertFalse(observing.get());

    observed.set(string1);
    assertFalse(observing.get());
}
 
开发者ID:akiraspeirs,项目名称:Cinder,代码行数:17,代码来源:CinderBooleanUnitTest.java

示例2: skipSkipsCorrectTimes

import android.databinding.ObservableBoolean; //导入依赖的package包/类
@Test
public void skipSkipsCorrectTimes() throws Exception {
    String string1 = "STRING 1";
    String string2 = "STRING 2";
    ObservableField<String> observed = new ObservableField<>(string1);
    ObservableBoolean observing = Cinder.computeBoolean(()->
        observed.get().equals(string1)
        , observed).skip(1);

    observed.set(string1);
    assertFalse(observing.get());

    observed.set(string2);
    assertFalse(observing.get());

    observed.set(string1);
    assertTrue(observing.get());
}
 
开发者ID:akiraspeirs,项目名称:Cinder,代码行数:19,代码来源:CinderBooleanUnitTest.java

示例3: PasswordReadViewModel

import android.databinding.ObservableBoolean; //导入依赖的package包/类
public PasswordReadViewModel(Navigator navigator, PasswordInteractor interactor, int id) {
  this.navigator = navigator;
  this.interactor = interactor;
  this.id = id;

  this.title = new ObservableField<>();
  this.icon = new ObservableField<>();
  this.username = new ObservableField<>();
  this.password = new ObservableField<>();
  this.displayPassword = new ObservableBoolean(false);
  this.customFields = new ObservableArrayList<>();

  realmPassword = interactor.readPassword(id);
  realmPassword.addChangeListener(this::updateView);

  updateView(realmPassword);
}
 
开发者ID:a11n,项目名称:devfest-2016-realm,代码行数:18,代码来源:PasswordReadViewModel.java

示例4: RxCommand

import android.databinding.ObservableBoolean; //导入依赖的package包/类
/**
 * Creates {@code RxCommand} to execute the specified command from the specified {@link
 * Observable} with the specified initial state.
 *
 * @param canExecuteSource an {@link Observable} to emit whether this {@code RxCommand} can
 *                         execute
 * @param canExecute       whether this {@code RxCommand} can execute initially
 */
public RxCommand(@Nullable final Observable<Boolean> canExecuteSource, boolean canExecute) {
    canExecuteFlag = new ObservableBoolean(canExecute);

    if (canExecuteSource != null) {
        canExecuteSourceDisposable = canExecuteSource.distinctUntilChanged()
                .subscribeWith(new DisposableObserver<Boolean>() {
                    @Override
                    public void onNext(Boolean value) {
                        canExecuteFlag.set(value);
                    }

                    @Override
                    public void onError(Throwable e) {
                        kicker.onError(e);
                        RxCommand.this.dispose();
                    }

                    @Override
                    public void onComplete() {
                        kicker.onComplete();
                        RxCommand.this.dispose();
                    }
                });
    }
}
 
开发者ID:k-kagurazaka,项目名称:rx-property-android,代码行数:34,代码来源:RxCommand.java

示例5: SignInActivityViewModel

import android.databinding.ObservableBoolean; //导入依赖的package包/类
@Inject
public SignInActivityViewModel(BaseActivity activity, SignInUseCase signInUseCase,
                               CheckSessionUseCase checkSessionUseCase) {
    super(activity);

    this.signInUseCase = signInUseCase;
    this.checkSessionUseCase = checkSessionUseCase;

    name = new ObservableField<>();
    password = new ObservableField<>();
    buttonEnabled = new ObservableBoolean(false);

    checkSessionUseCase.run()
            .compose(bindToLifecycle().forSingle())
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(authToken -> {
                Timber.v("Check session: " + authToken.token);
                Toast.makeText(getContext(), "Already signed in", Toast.LENGTH_SHORT).show();
                goToNext();
            }, Timber::e);
}
 
开发者ID:kobakei,项目名称:Anago,代码行数:23,代码来源:SignInActivityViewModel.java

示例6: Listener

import android.databinding.ObservableBoolean; //导入依赖的package包/类
Listener(final ObservableBoolean observableBoolean, final Observer<? super Boolean> observer) {
  this.observableBoolean = observableBoolean;
  this.onPropertyChangedCallback =
      new android.databinding.Observable.OnPropertyChangedCallback() {
        @Override
        public void onPropertyChanged(android.databinding.Observable observable,
            int ignoredPropertyId) {
          if (!isDisposed()) {
            ObservableBoolean observableBoolean = (ObservableBoolean) observable;
            observer.onNext(observableBoolean.get());
          }
        }
      };
}
 
开发者ID:oldergod,项目名称:RxDataBinding,代码行数:15,代码来源:ObservableBooleanObservable.java

示例7: FollowersViewModel

import android.databinding.ObservableBoolean; //导入依赖的package包/类
public FollowersViewModel(@NonNull DataListener dataListener, @NonNull Context context,
                          TwitterSession session, Long userId) {
    this.dataListener = dataListener;
    this.context = context;
    this.session = session;
    this.userId = userId;
    activityFollowerProgressBar = new ObservableInt(View.VISIBLE);
    activityFollowerSwipeRefreshLayout = new ObservableInt(View.GONE);
    activityFollowerRecyclerView = new ObservableInt(View.GONE);
    activityFollowerIsPullToRefresh = new ObservableBoolean(false);
    initializeViews();
    fetchFollowersList(false, false, cursor);
}
 
开发者ID:ahmed-adel-said,项目名称:Twitter_Client,代码行数:14,代码来源:FollowersViewModel.java

示例8: ExplorerViewModel

import android.databinding.ObservableBoolean; //导入依赖的package包/类
/**
 * Default constructor.
 * @param context The context of the current activity.
 */
public ExplorerViewModel(Context context) {
    this.context = context;
    this.isLoading = new ObservableBoolean(false);
    this.isRefreshing = new ObservableBoolean(false);
    this.files = new ObservableArrayList<FileViewModel>();
    this.isSelectionMode = new ObservableBoolean(false);
    this.numberSelectedItems = new ObservableInt(0);
    this.changeDirectory("/");
}
 
开发者ID:Paul-DS,项目名称:SimpleFTP,代码行数:14,代码来源:ExplorerViewModel.java

示例9: ListServerViewModel

import android.databinding.ObservableBoolean; //导入依赖的package包/类
/**
 * Default constructor.
 * @param context The context of the current activity.
 */
public ListServerViewModel(Activity context) {
    this.context = context;
    this.servers = new ObservableArrayList<FtpServerViewModel>();
    this.selectedServer = new ObservableField<FtpServerViewModel>();
    this.selectedServerVisible = new ObservableBoolean();
}
 
开发者ID:Paul-DS,项目名称:SimpleFTP,代码行数:11,代码来源:ListServerViewModel.java

示例10: PostListComponentViewModel

import android.databinding.ObservableBoolean; //导入依赖的package包/类
@Inject
public PostListComponentViewModel(Bus bus, IRepository repository, INavigator navigator, ILocalization localization) {
    super(bus);

    this.repository = repository;
    this.navigator = navigator;
    this.localization = localization;

    this.posts = new ObservableArrayList<>();

    this.isBusy = new ObservableBoolean();
    this.loadCommand = new Command(this::loadPosts);
}
 
开发者ID:0nko,项目名称:Architecture-Demo,代码行数:14,代码来源:PostListComponentViewModel.java

示例11: fireNotifiesChange

import android.databinding.ObservableBoolean; //导入依赖的package包/类
@Test
public void fireNotifiesChange() throws Exception {
    ObservableEvent event = new ObservableEvent();
    ObservableBoolean fired = Cinder.computeBoolean(()->true, event);
    event.fire();

    assertTrue(fired.get());
}
 
开发者ID:akiraspeirs,项目名称:Cinder,代码行数:9,代码来源:ObservableEventUnitTest.java

示例12: computesBoolean

import android.databinding.ObservableBoolean; //导入依赖的package包/类
@Test
public void computesBoolean() throws Exception {
    boolean bool1 = true;
    boolean bool2 = false;
    ObservableBoolean truth = new ObservableBoolean(bool1);
    ObservableBoolean computedTruth = Cinder.computeBoolean(()->truth.get(), truth).immediate();
    assertEquals(computedTruth.get(), bool1);

    truth.set(bool2);
    assertEquals(computedTruth.get(), bool2);
}
 
开发者ID:akiraspeirs,项目名称:Cinder,代码行数:12,代码来源:CinderUnitTest.java

示例13: onceTakesOnce

import android.databinding.ObservableBoolean; //导入依赖的package包/类
@Test
public void onceTakesOnce() throws Exception {
    String string1 = "STRING 1";
    String string2 = "STRING 2";
    ObservableField<String> observed = new ObservableField<>(string1);
    ObservableBoolean observing = Cinder.computeBoolean(()->
        observed.get().equals(string1), observed).once().immediate();
    assertTrue(observing.get());

    observed.set(string2);
    assertTrue(observing.get());
}
 
开发者ID:akiraspeirs,项目名称:Cinder,代码行数:13,代码来源:CinderBooleanUnitTest.java

示例14: filterFilters

import android.databinding.ObservableBoolean; //导入依赖的package包/类
@Test
public void filterFilters() throws Exception {
    String badString = "BAD STRING";
    String goodString = "GOOD STRING";
    ObservableField<String> observed = new ObservableField<>("");
    ObservableBoolean observing = Cinder.computeBoolean(()->
        observed.get().equals(goodString)
        , observed).filter(()->observed.get().startsWith("GOOD"));

    observed.set(badString);
    assertFalse(observing.get());

    observed.set(goodString);
    assertTrue(observing.get());
}
 
开发者ID:akiraspeirs,项目名称:Cinder,代码行数:16,代码来源:CinderBooleanUnitTest.java

示例15: takeWhileTakesWhileTrue

import android.databinding.ObservableBoolean; //导入依赖的package包/类
@Test
public void takeWhileTakesWhileTrue() throws Exception {
    String badString = "BAD STRING";
    String goodString = "GOOD STRING";
    ObservableField<String> observed = new ObservableField<>("");
    ObservableBoolean observing = Cinder.computeBoolean(()->
        observed.get().equals(goodString)
        , observed).takeWhile(()->observed.get().startsWith("GOOD"));

    observed.set(goodString);
    assertTrue(observing.get());

    observed.set(badString);
    assertTrue(observing.get());
}
 
开发者ID:akiraspeirs,项目名称:Cinder,代码行数:16,代码来源:CinderBooleanUnitTest.java


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