本文整理匯總了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());
}
示例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());
}
示例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);
}
示例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();
}
});
}
}
示例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);
}
示例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());
}
}
};
}
示例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);
}
示例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("/");
}
示例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();
}
示例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);
}
示例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());
}
示例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);
}
示例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());
}
示例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());
}
示例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());
}