當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。