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


Java ObservableArrayMap.put方法代码示例

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


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

示例1: computableMapElementsAreComputable

import android.databinding.ObservableArrayMap; //导入方法依赖的package包/类
@Test
public void computableMapElementsAreComputable() throws Exception {
    String key = "KEY";
    String string1 = "STRING 1";
    String string2 = "STRING 2";
    StringClass stringClass = new StringClass(string1);

    ObservableArrayMap<String, StringClass> strings = new ObservableArrayMap<>();
    strings.put(key, stringClass);
    ObservableField<String> computedString = Cinder.computeField(()->strings.get(key).element.get(),
            Cinder.observable(strings, StringClass.class, "element")).immediate();
    assertEquals(computedString.get(), string1);

    strings.get(key).element.set(string2);
    assertEquals(computedString.get(), string2);
}
 
开发者ID:akiraspeirs,项目名称:Cinder,代码行数:17,代码来源:CinderUnitTest.java

示例2: simpleObservesObservableMaps

import android.databinding.ObservableArrayMap; //导入方法依赖的package包/类
@Test
public void simpleObservesObservableMaps() throws Exception {
    String key1 = "KEY 1";
    String string1 = "STRING 1";
    String string2 = "STRING 2";
    String stringMissing = "MISSING";
    StringClass stringClass1 = new StringClass(string1);
    StringClass stringClass2 = new StringClass(string2);
    ObservableArrayMap<String, StringClass> observableMap = new ObservableArrayMap<>();

    ObservableField<String> observingString = new ObservableField<>("");
    Cinder.observe(()->
                    observingString.set((observableMap.get(key1) != null) ?
                    observableMap.get(key1).element.get() : stringMissing),
                    observableMap);
    observableMap.put(key1, stringClass1);
    assertEquals(observingString.get(), string1);

    observableMap.put(key1, stringClass2);
    assertEquals(observingString.get(), string2);

    observableMap.remove(key1);
    assertEquals(observingString.get(), stringMissing);
}
 
开发者ID:akiraspeirs,项目名称:Cinder,代码行数:25,代码来源:CinderUnitTest.java

示例3: stopArrayMapStops

import android.databinding.ObservableArrayMap; //导入方法依赖的package包/类
@Test
public void stopArrayMapStops() throws Exception {
    String string1 = "STRING 1";
    String string2 = "STRING 2";
    int TEST = 43;
    ObservableArrayMap<String, TestClass> observed = new ObservableArrayMap<>();
    TestClass testClass = new TestClass();
    testClass.number.set(TEST);
    observed.put(string1, testClass);
    CinderComputable computing = Cinder.observable(observed, TestClass.class, "number").immediate();
    CinderInt observing = Cinder.computeInt(()->
        observed.get(string1).number.get(), computing).immediate();
    assertEquals(TEST, observing.get());

    computing.stop();

    observed.get(string1).number.set(23);
    assertEquals(TEST, observing.get());

    observed.put(string2, new TestClass());
    assertEquals(TEST, observing.get());
}
 
开发者ID:akiraspeirs,项目名称:Cinder,代码行数:23,代码来源:CinderComputableUnitTest.java

示例4: main

import android.databinding.ObservableArrayMap; //导入方法依赖的package包/类
public static void main(String[] args) {
    ObservableModel user1 = new ObservableModel();
    user1.firstName.set("Google");
    int age = user1.age.get();

    ObservableArrayMap<String, Object> user2 = new ObservableArrayMap<>();
    user2.put("firstName", "Google");
    user2.put("lastName", "Inc.");
    user2.put("age", 17);


    ObservableArrayList<Object> user3 = new ObservableArrayList<>();
    user3.add("Google");
    user3.add("Inc.");
    user3.add(17);

}
 
开发者ID:yunair,项目名称:MVVMDemo,代码行数:18,代码来源:ObservableModel.java

示例5: mapChange

import android.databinding.ObservableArrayMap; //导入方法依赖的package包/类
@Test @UiThreadTest public void mapChange() {
  final ObservableArrayMap<String, String> observableArrayMap = new ObservableArrayMap<>();
  String key = "key";
  String value = "value";
  ObservableArrayMapOnMapChangeEvent<String, String> next;

  RecordingObserver<ObservableArrayMapOnMapChangeEvent<String, String>> o =
      new RecordingObserver<>();
  RxObservableArrayMap.mapChanges(observableArrayMap).subscribe(o);
  o.assertNoMoreEvents();

  observableArrayMap.put(key, value);
  next = o.takeNext();
  assertEquals(observableArrayMap, next.observableArrayMap());
  assertEquals(key, next.key());

  value = "corrupted";
  observableArrayMap.put(key, value);
  next = o.takeNext();
  assertEquals(observableArrayMap, next.observableArrayMap());
  assertEquals(key, next.key());

  observableArrayMap.put(key + "2", value + "2");
  o.takeNext();
  observableArrayMap.remove(key);
  next = o.takeNext();
  assertEquals(observableArrayMap, next.observableArrayMap());
  assertEquals(key, next.key());

  observableArrayMap.clear();
  next = o.takeNext();
  assertEquals(observableArrayMap, next.observableArrayMap());
  assertNull(next.key());

  o.dispose();

  observableArrayMap.put(key, value);
  o.assertNoMoreEvents();
}
 
开发者ID:oldergod,项目名称:RxDataBinding,代码行数:40,代码来源:RxObservableArrayMapTest.java

示例6: computableMapsAreComputable

import android.databinding.ObservableArrayMap; //导入方法依赖的package包/类
@Test
public void computableMapsAreComputable() throws Exception {
    String key1 = "KEY 1";
    String key2 = "KEY 2";
    String value1 = "VALUE 1";
    String value2 = "VALUE 2";
    ObservableArrayMap<String, String> strings = new ObservableArrayMap<>();
    strings.put(key1, value1);
    ObservableInt computedCount = Cinder.computeInt(()->strings.size(),
            Cinder.observable(strings)).immediate();
    assertEquals(computedCount.get(), 1);

    strings.put(key2, value2);
    assertEquals(computedCount.get(), 2);
}
 
开发者ID:akiraspeirs,项目名称:Cinder,代码行数:16,代码来源:CinderUnitTest.java

示例7: observesObservableMaps

import android.databinding.ObservableArrayMap; //导入方法依赖的package包/类
@Test
public void observesObservableMaps() throws Exception {
    String key1 = "KEY 1";
    String string1 = "STRING 1";
    String string2 = "STRING 2";
    String string3 = "STRING 3";
    String stringMissing = "MISSING";
    StringClass stringClass1 = new StringClass(string1);
    StringClass stringClass2 = new StringClass(string2);
    ObservableArrayMap<String, StringClass> observableMap = new ObservableArrayMap<>();

    ObservableField<String> observingString = new ObservableField<>("");
    Cinder.observe(()->
                    observingString.set((observableMap.get(key1) != null) ?
                            observableMap.get(key1).element.get() : stringMissing),
            observableMap, StringClass.class, "element");
    observableMap.put(key1, stringClass1);
    assertEquals(observingString.get(), string1);

    observableMap.put(key1, stringClass2);
    assertEquals(observingString.get(), string2);

    stringClass2.element.set(string3);
    assertEquals(observingString.get(), string3);

    observableMap.remove(key1);
    assertEquals(observingString.get(), stringMissing);
}
 
开发者ID:akiraspeirs,项目名称:Cinder,代码行数:29,代码来源:CinderUnitTest.java

示例8: convertsObservableArrayMapToRx

import android.databinding.ObservableArrayMap; //导入方法依赖的package包/类
@Test
public void convertsObservableArrayMapToRx() throws Exception {
    ObservableArrayMap<String, String> observableStringMap = new ObservableArrayMap<>();
    Observable<ArrayMap<String, String>> rxStringMap = RxCinder.convert(observableStringMap);
    final String TEST_KEY = "TEST_KEY";

    final ArrayMap<String, String> testStringMap = new ArrayMap<>();
    rxStringMap.subscribe((stringMap)->{
        testStringMap.put(TEST_KEY, stringMap.get(TEST_KEY));});

    final String TEST_VALUE = "TEST_VALUE";
    observableStringMap.put(TEST_KEY, TEST_VALUE);
    assertTrue(testStringMap.get(TEST_KEY).equals(TEST_VALUE));
}
 
开发者ID:akiraspeirs,项目名称:Cinder,代码行数:15,代码来源:RxCinderUnitTest.java


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