Java 类android.databinding.ObservableBoolean 实例源码

项目:Cinder    文件:CinderBooleanUnitTest.java   
@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());
}
项目:Cinder    文件:CinderBooleanUnitTest.java   
@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());
}
项目:devfest-2016-realm    文件:PasswordReadViewModel.java   
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);
}
项目:rx-property-android    文件:RxCommand.java   
/**
 * 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();
                    }
                });
    }
}
项目:Anago    文件:SignInActivityViewModel.java   
@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);
}
项目:RxDataBinding    文件:ObservableBooleanObservable.java   
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());
          }
        }
      };
}
项目:Twitter_Client    文件:FollowersViewModel.java   
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);
}
项目:SimpleFTP    文件:ExplorerViewModel.java   
/**
 * 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("/");
}
项目:SimpleFTP    文件:ListServerViewModel.java   
/**
 * 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();
}
项目:Architecture-Demo    文件:PostListComponentViewModel.java   
@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);
}
项目:Cinder    文件:ObservableEventUnitTest.java   
@Test
public void fireNotifiesChange() throws Exception {
    ObservableEvent event = new ObservableEvent();
    ObservableBoolean fired = Cinder.computeBoolean(()->true, event);
    event.fire();

    assertTrue(fired.get());
}
项目:Cinder    文件:CinderUnitTest.java   
@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);
}
项目:Cinder    文件:CinderBooleanUnitTest.java   
@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());
}
项目:Cinder    文件:CinderBooleanUnitTest.java   
@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());
}
项目:Cinder    文件:CinderBooleanUnitTest.java   
@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());
}
项目:Cinder    文件:CinderBooleanUnitTest.java   
@Test
public void skipWhileSkipsWhileTrue() throws Exception {
    String badString = "BAD STRING";
    String goodString = "GOOD STRING";
    ObservableField<String> observed = new ObservableField<>("");
    ObservableBoolean observing = Cinder.computeBoolean(()->
        observed.get().equals(goodString)
        , observed).skipWhile(()->observed.get().startsWith("BAD"));

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

    observed.set(goodString);
    assertTrue(observing.get());
}
项目:Cinder    文件:CinderBooleanUnitTest.java   
@Test
public void withDefaultAssignsDefault() throws Exception {
    ObservableBoolean observing = Cinder.computeBoolean(()->false
    ).withDefault(true);

    assertTrue(observing.get());
}
项目:Cinder    文件:RxCinderUnitTest.java   
@Test
public void convertsObservableBooleanToRx() throws Exception {
    ObservableBoolean observableBoolean = new ObservableBoolean();
    Observable<Boolean> rxBoolean = RxCinder.convert(observableBoolean);

    final String TEST_KEY = "TEST_KEY";
    final ArrayMap<String, Boolean> testMap = new ArrayMap<>();
    rxBoolean.subscribe((b)->{
        testMap.put(TEST_KEY, b);});

    observableBoolean.set(true);
    assertTrue(testMap.get(TEST_KEY));
}
项目:devfest-2016-realm    文件:LoginViewModel.java   
public LoginViewModel(LoginInteractor interactor, ProNavigator navigator) {
  this.interactor = interactor;
  this.navigator = navigator;

  email = new ObservableField<>();
  password = new ObservableField<>();
  passwordRepeat = new ObservableField<>();
  inProgress = new ObservableBoolean();
}
项目:DataBindingFormValidation    文件:MainViewModel.java   
/**
 * I would like to use this in the layout expressions, but there seems to be an issue related to this.
 * See https://code.google.com/p/android/issues/detail?id=230115
 */
public <T> void onFieldChanged(ObservableField<T> field, ObservableBoolean errorIndicator,
                               boolean hasFocus, Validator<T> validator) {
    if (hasFocus) {
        errorIndicator.set(false);
    } else {
        T value = field.get();
        errorIndicator.set(!validator.validate(value));
        Log.d(TAG, "Field is invalid: " + errorIndicator.get());
        dataValid.set(validateForm());
    }
}
项目:rx-property-android    文件:RxCommandTest.java   
private static TestObserver<Boolean> observableBooleanTestObserver(RxCommand command) {
    return Observe.allPropertiesOf(command.getEnabled())
            .map(new Function<ObservableBoolean, Boolean>() {
                @Override
                public Boolean apply(ObservableBoolean value) throws Exception {
                    return value.get();
                }
            })
            .test();
}
项目:rx-property-android    文件:RxPropertyTest.java   
private static <T> TestObserver<Boolean> hasErrorObserver(final RxProperty<T> property) {
    return Observe.propertyOf(property.getHasError(), 0,
            new Function<ObservableBoolean, Boolean>() {
                @Override
                public Boolean apply(ObservableBoolean value) throws Exception {
                    return value.get();
                }
            })
            .test();
}
项目:Anago    文件:StarredRepoListFragmentViewModel.java   
@Inject
public StarredRepoListFragmentViewModel(BaseFragment fragment, GetStarredReposUseCase getStarredReposUseCase,
                                        EventBus eventBus) {
    super(fragment);

    this.getStarredReposUseCase = getStarredReposUseCase;
    this.eventBus = eventBus;

    repos = new ObservableArrayList<>();
    isConnecting = new ObservableBoolean(true);
    isRefreshing = new ObservableBoolean(false);
}
项目:Anago    文件:RepoListItemViewModel.java   
@Inject
public RepoListItemViewModel(BaseFragment fragment,
                             StarUseCase starUseCase,
                             UnstarUseCase unstarUseCase,
                             EventBus eventBus) {
    super(fragment);
    this.starUseCase = starUseCase;
    this.unstarUseCase = unstarUseCase;
    this.eventBus = eventBus;

    this.repo = new ObservableField<>();
    this.starred = new ObservableBoolean(false);
}
项目:Anago    文件:RepoInfoFragmentViewModel.java   
@Inject
public RepoInfoFragmentViewModel(BaseFragment fragment, GetRepoUseCase getRepoUseCase,
                                 CheckStarUseCase checkStarUseCase, StarUseCase starUseCase,
                                 UnstarUseCase unstarUseCase, EventBus eventBus) {
    super(fragment);
    this.getRepoUseCase = getRepoUseCase;
    this.checkStarUseCase = checkStarUseCase;
    this.starUseCase = starUseCase;
    this.unstarUseCase = unstarUseCase;
    this.eventBus = eventBus;

    this.repo = new ObservableField<>();
    this.isConnecting = new ObservableBoolean(true);
    this.starred = new ObservableBoolean(false);
}
项目:Anago    文件:UserActivityViewModel.java   
@Inject
public UserActivityViewModel(BaseActivity activity, GetUserUseCase getUserUseCase, EventBus eventBus) {
    super(activity);
    this.getUserUseCase = getUserUseCase;
    this.eventBus = eventBus;

    this.user = new ObservableField<>();
    this.isConnecting = new ObservableBoolean(true);
}
项目:Anago    文件:MyRepoListFragmentViewModel.java   
@Inject
public MyRepoListFragmentViewModel(BaseFragment fragment, GetUserReposUseCase getUserReposUseCase, EventBus eventBus) {
    super(fragment);

    this.getUserReposUseCase = getUserReposUseCase;
    this.eventBus = eventBus;

    repos = new ObservableArrayList<>();
    isConnecting = new ObservableBoolean(true);
    isRefreshing = new ObservableBoolean(false);
}
项目:Android-Code-Demos    文件:Employee.java   
public ObservableBoolean getIsFired() {
    return isFired;
}
项目:Android-Code-Demos    文件:Employee.java   
public void setIsFired(ObservableBoolean isFired) {
    this.isFired = isFired;
    notifyChange();
}
项目:Flubber    文件:RadioElementModel.java   
public ObservableBoolean getChecked() {
    return checked;
}
项目:Flubber    文件:RadioElementModel.java   
public void setChecked(ObservableBoolean checked) {
    this.checked = checked;
}
项目:android-mvvm-architecture    文件:BaseViewModel.java   
public ObservableBoolean getIsLoading() {
    return mIsLoading;
}
项目:Android-HTTPS-based-on-MVVM    文件:MainViewModel.java   
public MainViewModel(Context context) {
    this.context = context;
    this.user = new UserBean();
    this.agree = new ObservableBoolean();
}
项目:Android-HTTPS-based-on-MVVM    文件:MainViewModel.java   
public ObservableBoolean getAgree() {
    return agree;
}
项目:RxDataBinding    文件:ObservableBooleanObservable.java   
ObservableBooleanObservable(ObservableBoolean observableBoolean) {
  this.observableBoolean = observableBoolean;
}
项目:AndroidAgeraTutorial    文件:VehicleInfo.java   
public VehicleInfo(ObservableBoolean isSelected, String logoUrl, String brand, String description) {
    this.isSelected = isSelected;
    this.logoUrl = logoUrl;
    this.brand = brand;
    this.description = description;
}
项目:SimpleFTP    文件:FileViewModel.java   
/**
 * Default constructor.
 * @param mainViewModel The parent view model.
 */
public FileViewModel(ExplorerViewModel mainViewModel) {
    this.mainViewModel = mainViewModel;
    this.isSelected = new ObservableBoolean(false);
}
项目:AndroidDataBindingTutorial    文件:VehicleInfo.java   
public VehicleInfo(ObservableBoolean isSelected, String logoUrl, String brand, String description) {
    this.isSelected = isSelected;
    this.logoUrl = logoUrl;
    this.brand = brand;
    this.description = description;
}
项目:Architecture-Demo    文件:PostListComponentViewModel.java   
public ObservableBoolean getIsBusy() {
    return isBusy;
}
项目:Architecture-Demo    文件:Command.java   
public Command(boolean canExecute, boolean isVisible, Action0 execute) {
    this.canExecute = new ObservableBoolean(canExecute);
    this.isVisible = new ObservableBoolean(isVisible);
    this.execute = execute;
}