本文整理汇总了Java中android.databinding.ObservableField.set方法的典型用法代码示例。如果您正苦于以下问题:Java ObservableField.set方法的具体用法?Java ObservableField.set怎么用?Java ObservableField.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.databinding.ObservableField
的用法示例。
在下文中一共展示了ObservableField.set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: propertyChangeEvents_String
import android.databinding.ObservableField; //导入方法依赖的package包/类
@Test @UiThreadTest public void propertyChangeEvents_String() {
final ObservableField<String> observableField = new ObservableField<>();
String value = "databinding";
RecordingObserver<String> o = new RecordingObserver<>();
RxObservableField.propertyChanges(observableField).subscribe(o);
o.assertNoMoreEvents();
observableField.set(value);
assertEquals(value, o.takeNext());
value += " is cool.";
observableField.set(value);
assertEquals(value, o.takeNext());
o.dispose();
value += " Yeah?";
observableField.set(value);
o.assertNoMoreEvents();
}
示例2: propertyChangeEvents_Object
import android.databinding.ObservableField; //导入方法依赖的package包/类
@Test @UiThreadTest public void propertyChangeEvents_Object() {
final ObservableField<Object> observableField = new ObservableField<>();
Object value;
RecordingObserver<Object> o = new RecordingObserver<>();
RxObservableField.propertyChanges(observableField).subscribe(o);
o.assertNoMoreEvents();
value = new Object();
observableField.set(value);
assertEquals(value, o.takeNext());
value = new Object();
observableField.set(value);
assertEquals(value, o.takeNext());
o.dispose();
value = new Object();
observableField.set(value);
o.assertNoMoreEvents();
}
示例3: takeWhileTakesWhileTrue
import android.databinding.ObservableField; //导入方法依赖的package包/类
@Test
public void takeWhileTakesWhileTrue() throws Exception {
String badString = "BAD STRING";
String goodString = "GOOD STRING";
String gooderString = "GOODER STRING";
ObservableField<String> observed = new ObservableField<>("");
ObservableArrayMap<String, String> observing = Cinder.<String, String>computeArrayMap((list)->{
list.put(key1, observed.get());
}, observed).takeWhile(()->observed.get().startsWith("GOOD"));
observed.set(goodString);
assertEquals(goodString, observing.get(key1));
observed.set(badString);
assertEquals(goodString, observing.get(key1));
observed.set(gooderString);
assertEquals(goodString, observing.get(key1));
}
示例4: skipWhileSkipsWhileTrue
import android.databinding.ObservableField; //导入方法依赖的package包/类
@Test
public void skipWhileSkipsWhileTrue() throws Exception {
String badString = "BAD STRING";
String goodString = "GOOD STRING";
String gooderString = "GOODER STRING";
ObservableField<String> observed = new ObservableField<>("");
ObservableArrayMap<String, String> observing = Cinder.<String, String>computeArrayMap((list)->{
list.put(key1, observed.get());
}, observed).skipWhile(()->observed.get().startsWith("BAD"));
observed.set(badString);
assertEquals(0, observing.size());
observed.set(goodString);
assertEquals(goodString, observing.get(key1));
observed.set(gooderString);
assertEquals(gooderString, observing.get(key1));
}
示例5: skipSkipsCorrectTimes
import android.databinding.ObservableField; //导入方法依赖的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());
}
示例6: takeWhileTakesWhileTrue
import android.databinding.ObservableField; //导入方法依赖的package包/类
@Test
public void takeWhileTakesWhileTrue() throws Exception {
String badString = "BAD STRING";
String goodString = "GOOD STRING";
String gooderString = "GOODER STRING";
ObservableField<String> observed = new ObservableField<>("");
ObservableArrayList<String> observing = Cinder.<String>computeArrayList((list)->{
list.add(0, observed.get());
}, observed).takeWhile(()->observed.get().startsWith("GOOD"));
observed.set(goodString);
assertEquals(goodString, observing.get(0));
observed.set(badString);
assertEquals(goodString, observing.get(0));
observed.set(gooderString);
assertEquals(goodString, observing.get(0));
}
示例7: takeTakesCorrectTimes
import android.databinding.ObservableField; //导入方法依赖的package包/类
@Test
public void takeTakesCorrectTimes() throws Exception {
String string1 = "123";
String string2 = "32";
ObservableField<String> observed = new ObservableField<>(string1);
ObservableField<String> observing = Cinder.<String>computeField(()->
observed.get()
, observed).take(2).immediate();
assertTrue(observing.get() == string1);
observed.set(string2);
assertTrue(observing.get() == string2);
observed.set(string1);
assertTrue(observing.get() == string2);
}
示例8: skipSkipsCorrectTimes
import android.databinding.ObservableField; //导入方法依赖的package包/类
@Test
public void skipSkipsCorrectTimes() throws Exception {
String string1 = "123";
String string2 = "32";
ObservableField<String> observed = new ObservableField<>();
ObservableField<String> observing = Cinder.<String>computeField(()->
observed.get()
, observed).skip(1);
observed.set(string1);
assertTrue(observing.get() == null);
observed.set(string2);
assertTrue(observing.get() == string2);
observed.set(string1);
assertTrue(observing.get() == string1);
}
示例9: computesField
import android.databinding.ObservableField; //导入方法依赖的package包/类
@Test
public void computesField() throws Exception {
String string1 = "STRING 1";
String string2 = "STRING 2";
ObservableField<String> obsString = new ObservableField<>(string1);
ObservableField<String> computedString = Cinder.computeField(()->obsString.get(), obsString).immediate();
assertEquals(computedString.get(), string1);
obsString.set(string2);
assertEquals(computedString.get(), string2);
}
示例10: onceTakesOnce
import android.databinding.ObservableField; //导入方法依赖的package包/类
@Test
public void onceTakesOnce() throws Exception {
String string1 = "STRING 1";
String string2 = "STRING 2";
ObservableField<String> observed = new ObservableField<>(string1);
ObservableArrayMap<String, String> observing = Cinder.<String, String>computeArrayMap((list)->
list.put(key1, observed.get()), observed).once().immediate();
assertEquals(string1, observing.get(key1));
observed.set(string2);
assertEquals(string1, observing.get(key1));
}
示例11: stopStops
import android.databinding.ObservableField; //导入方法依赖的package包/类
@Test
public void stopStops() throws Exception {
String string1 = "STRING 1";
String string2 = "STRING 2";
ObservableField<String> observed = new ObservableField<>(string1);
CinderBoolean observing = Cinder.computeBoolean(()->
observed.get().equals(string1), observed).immediate();
assertTrue(observing.get());
observing.stop();
observed.set(string2);
assertTrue(observing.get());
}
示例12: skipSkipsCorrectTimes
import android.databinding.ObservableField; //导入方法依赖的package包/类
@Test
public void skipSkipsCorrectTimes() throws Exception {
String string1 = "STRING 1";
String string2 = "STRING 2";
ObservableField<String> observed = new ObservableField<>();
ObservableArrayMap<String, String> observing = Cinder.<String, String>computeArrayMap((list)->{
list.put(key1, observed.get());
}, observed).skip(1);
observed.set(string1);
assertEquals(0, observing.size());
observed.set(string2);
assertEquals(string2, observing.get(key1));
}
示例13: filterFilters
import android.databinding.ObservableField; //导入方法依赖的package包/类
@Test
public void filterFilters() throws Exception {
String badString = "BAD STRING";
String goodString = "GOOD STRING";
ObservableField<String> observed = new ObservableField<>("");
ObservableArrayMap<String, String> observing = Cinder.<String, String>computeArrayMap((list)->{
list.put(key1, observed.get());
}, observed).filter(()->observed.get().startsWith("GOOD"));
observed.set(badString);
assertEquals(0, observing.size());
observed.set(goodString);
assertEquals(goodString, observing.get(key1));
}
示例14: skipWhileSkipsWhileTrue
import android.databinding.ObservableField; //导入方法依赖的package包/类
@Test
public void skipWhileSkipsWhileTrue() throws Exception {
String string1 = "123";
String string2 = "32";
ObservableField<String> observed = new ObservableField<>();
ObservableField<String> observing = Cinder.<String>computeField(()->
observed.get()
, observed).skipWhile(()->observed.get() == string1);
observed.set(string1);
assertTrue(observing.get() == null);
observed.set(string2);
assertTrue(observing.get() == string2);
}
示例15: skipWhileSkipsWhileTrue
import android.databinding.ObservableField; //导入方法依赖的package包/类
@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());
}