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


Java ObservableArrayList类代码示例

本文整理汇总了Java中android.databinding.ObservableArrayList的典型用法代码示例。如果您正苦于以下问题:Java ObservableArrayList类的具体用法?Java ObservableArrayList怎么用?Java ObservableArrayList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

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

示例1: getTwirledDownLayersForGroup

import android.databinding.ObservableArrayList; //导入依赖的package包/类
public ObservableList<Layer> getTwirledDownLayersForGroup(LayerGroup root) {
    ObservableList<Layer> twirledDownLayers = new ObservableArrayList<>();

    for (Layer l : root.getLayers()) {
        twirledDownLayers.add(l);
        if (l instanceof LayerGroup) {
            LayerGroup group = (LayerGroup) l;
            if (group.isTwirledDown()) {
                int i = twirledDownLayers.indexOf(l);
                List<Layer> childLayers = getTwirledDownLayersForGroup(group);
                twirledDownLayers.addAll(i + 1, childLayers);
            }
        }
    }

    return twirledDownLayers;
}
 
开发者ID:google,项目名称:spline,代码行数:18,代码来源:LayerListAdapter.java


示例2: SongVM

import android.databinding.ObservableArrayList; //导入依赖的package包/类
public SongVM(BaseActivity mContext, Song song) {
    super(mContext);
    song.name = song.name.replace("\\n", "\n");
    songJacketUrl.set(String.format(SStaticR.SERVER_URL_RES + "/jacket/%s.png", song.music_id));
    switch (song.type){
        case 1:
            songIcon.set(R.drawable.ic_song_cute);
            break;
        case 2:
            songIcon.set(R.drawable.ic_song_cool);
            break;
        case 3:
            songIcon.set(R.drawable.ic_song_passion);
            break;
        case 4:
            songIcon.set(R.drawable.ic_song_all);
            break;
    }
    if (mContext instanceof SongDetailActivity){
        song.discription = song.discription.replace("\\n", "\n");
        itemViewModel = new ObservableArrayList<>();
        itemView = ItemView.of(com.lazyeraser.imas.derehelper.BR.viewModel, R.layout.item_list_live);
        loadLiveDetail(String.valueOf(song.music_id));
    }
    this.song.set(song);
}
 
开发者ID:Lazyeraser,项目名称:DereHelper,代码行数:27,代码来源:SongVM.java


示例3: computableListElementsAreComputable

import android.databinding.ObservableArrayList; //导入依赖的package包/类
@Test
public void computableListElementsAreComputable() throws Exception {

    String string1 = "STRING 1";
    String string2 = "STRING 2";
    StringClass stringClass = new StringClass(string1);

    ObservableList<StringClass> strings = new ObservableArrayList<>();
    strings.add(0, stringClass);
    ObservableField<String> computedString = Cinder.computeField(()->strings.get(0).element.get(),
            Cinder.observable(strings, StringClass.class, "element")).immediate();
    assertEquals(computedString.get(), string1);

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


示例4: observesObservableLists

import android.databinding.ObservableArrayList; //导入依赖的package包/类
@Test
public void observesObservableLists() throws Exception {
    String string1 = "STRING 1";
    String string2 = "STRING 2";
    String string3 = "STRING 3";
    StringClass stringClass1 = new StringClass(string1);
    StringClass stringClass2 = new StringClass(string2);
    ObservableArrayList<StringClass> observableList = new ObservableArrayList<>();

    ObservableField<String> observingString = new ObservableField<>("");
    Cinder.observe(
            ()->observingString.set(observableList.get(0).element.get()),
            observableList, StringClass.class, "element");

    observableList.add(0, stringClass1);
    assertEquals(observingString.get(), string1);

    observableList.add(0, stringClass2);
    assertEquals(observingString.get(), string2);

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

    observableList.remove(0);
    assertEquals(observingString.get(), string1);
}
 
开发者ID:akiraspeirs,项目名称:Cinder,代码行数:27,代码来源:CinderUnitTest.java


示例5: simpleObservesObservableLists

import android.databinding.ObservableArrayList; //导入依赖的package包/类
@Test
public void simpleObservesObservableLists() throws Exception {
    String string1 = "STRING 1";
    String string2 = "STRING 2";
    StringClass stringClass1 = new StringClass(string1);
    StringClass stringClass2 = new StringClass(string2);
    ObservableArrayList<StringClass> observableList = new ObservableArrayList<>();

    ObservableField<String> observingString = new ObservableField<>("");
    Cinder.observe(
            ()->observingString.set(observableList.get(0).element.get()),
            observableList);

    observableList.add(0, stringClass1);
    assertEquals(observingString.get(), string1);

    observableList.add(0, stringClass2);
    assertEquals(observingString.get(), string2);

    observableList.remove(0);
    assertEquals(observingString.get(), string1);
}
 
开发者ID:akiraspeirs,项目名称:Cinder,代码行数:23,代码来源:CinderUnitTest.java


示例6: takeTakesCorrectTimes

import android.databinding.ObservableArrayList; //导入依赖的package包/类
@Test
public void takeTakesCorrectTimes() throws Exception {
    String string1 = "STRING 1";
    String string2 = "STRING 2";
    String string3 = "STRING 3";
    ObservableArrayList<String> observed = new ObservableArrayList<>();
    observed.add(string1);
    CinderComputable computing = Cinder.observable(observed).take(2).immediate();
    ObservableField<String> observing = Cinder.<String>computeField(()-> {
        return observed.get(0);
    }, computing).immediate();
    assertEquals(string1, observing.get());

    observed.add(0, string2);
    assertEquals(string2, observing.get());

    observed.add(0, string3);
    assertEquals(string2, observing.get());
}
 
开发者ID:akiraspeirs,项目名称:Cinder,代码行数:20,代码来源:CinderComputableUnitTest.java


示例7: skipSkipsCorrectTimes

import android.databinding.ObservableArrayList; //导入依赖的package包/类
@Test
public void skipSkipsCorrectTimes() throws Exception {
    String string1 = "STRING 1";
    String string2 = "STRING 2";
    ObservableArrayList<String> observed = new ObservableArrayList<>();
    observed.add(string1);
    CinderComputable computing = Cinder.observable(observed).skip(1);
    ObservableField<String> observing = Cinder.<String>computeField(()-> {
        return observed.size() > 0 ?  observed.get(0) : "";
    }, computing);

    observed.add(0, string1);
    assertEquals(null, observing.get());

    observed.add(0, string2);
    assertEquals(string2, observing.get());
}
 
开发者ID:akiraspeirs,项目名称:Cinder,代码行数:18,代码来源:CinderComputableUnitTest.java


示例8: filterFilters

import android.databinding.ObservableArrayList; //导入依赖的package包/类
@Test
public void filterFilters() throws Exception {
    String badString = "BAD STRING";
    String goodString = "GOOD STRING";
    ObservableArrayList<String> observed = new ObservableArrayList<>();
    observed.add(goodString);
    CinderComputable computing = Cinder.observable(observed).filter(()->observed.get(0).startsWith("GOOD"));
    ObservableField<String> observing = Cinder.<String>computeField(()-> {
        return observed.get(0);
    }, computing).immediate();
    assertEquals(goodString, observing.get());

    observed.add(0, badString);
    assertEquals(goodString, observing.get());

}
 
开发者ID:akiraspeirs,项目名称:Cinder,代码行数:17,代码来源:CinderComputableUnitTest.java


示例9: takeWhileTakesWhileTrue

import android.databinding.ObservableArrayList; //导入依赖的package包/类
@Test
public void takeWhileTakesWhileTrue() throws Exception {
    String badString = "BAD STRING";
    String goodString = "GOOD STRING";
    String gooderString = "GOODER STRING";
    ObservableArrayList<String> observed = new ObservableArrayList<>();
    observed.add(goodString);
    CinderComputable computing = Cinder.observable(observed).takeWhile(()->observed.get(0).startsWith("GOOD"));
    ObservableField<String> observing = Cinder.<String>computeField(()-> {
        return observed.get(0);
    }, computing).immediate();

    observed.add(0, goodString);
    assertEquals(goodString, observing.get());

    observed.add(0, badString);
    assertEquals(goodString, observing.get());

    observed.add(0, gooderString);
    assertEquals(goodString, observing.get());
}
 
开发者ID:akiraspeirs,项目名称:Cinder,代码行数:22,代码来源:CinderComputableUnitTest.java


示例10: skipWhileSkipsWhileTrue

import android.databinding.ObservableArrayList; //导入依赖的package包/类
@Test
public void skipWhileSkipsWhileTrue() throws Exception {
    String badString = "BAD STRING";
    String goodString = "GOOD STRING";
    String gooderString = "GOODER STRING";
    ObservableArrayList<String> observed = new ObservableArrayList<>();
    observed.add(goodString);
    CinderComputable computing = Cinder.observable(observed).takeWhile(()->observed.get(0).startsWith("GOOD"));
    ObservableField<String> observing = Cinder.<String>computeField(()-> {
        return observed.get(0);
    }, computing).immediate();

    observed.add(0, goodString);
    assertEquals(goodString, observing.get());

    observed.add(0, badString);
    assertEquals(goodString, observing.get());

    observed.add(0, gooderString);
    assertEquals(goodString, observing.get());
}
 
开发者ID:akiraspeirs,项目名称:Cinder,代码行数:22,代码来源:CinderComputableUnitTest.java


示例11: stopArrayListStops

import android.databinding.ObservableArrayList; //导入依赖的package包/类
@Test
public void stopArrayListStops() throws Exception {
    int TEST = 43;
    ObservableArrayList<TestClass> observed = new ObservableArrayList<>();
    TestClass testClass = new TestClass();
    testClass.number.set(TEST);
    observed.add(testClass);
    CinderComputable computing = Cinder.observable(observed, TestClass.class, "number").immediate();
    CinderInt observing = Cinder.computeInt(()->
            observed.get(0).number.get(), computing).immediate();
    assertEquals(TEST, observing.get());

    computing.stop();

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

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


示例12: takeTakesCorrectTimes

import android.databinding.ObservableArrayList; //导入依赖的package包/类
@Test
public void takeTakesCorrectTimes() throws Exception {
    String string1 = "STRING 1";
    String string2 = "STRING 2";
    String string3 = "STRING 3";
    ObservableField<String> observed = new ObservableField<>(string1);
    ObservableArrayList<String> observing = Cinder.<String>computeArrayList((list)->{
        list.add(0, observed.get());
    }, observed).take(2).immediate();
    assertEquals(string1, observing.get(0));

    observed.set(string2);
    assertEquals(string2, observing.get(0));

    observed.set(string3);
    assertEquals(string2, observing.get(0));
}
 
开发者ID:akiraspeirs,项目名称:Cinder,代码行数:18,代码来源:CinderArrayListUnitTest.java


示例13: takeWhileTakesWhileTrue

import android.databinding.ObservableArrayList; //导入依赖的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));
}
 
开发者ID:akiraspeirs,项目名称:Cinder,代码行数:20,代码来源:CinderArrayListUnitTest.java


示例14: skipWhileSkipsWhileTrue

import android.databinding.ObservableArrayList; //导入依赖的package包/类
@Test
public void skipWhileSkipsWhileTrue() 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));
}
 
开发者ID:akiraspeirs,项目名称:Cinder,代码行数:20,代码来源:CinderArrayListUnitTest.java


示例15: onCreate

import android.databinding.ObservableArrayList; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    try {
        mRecipes = new ObservableArrayList<>();
        mRecipes.addAll(App.getAccessor().loadAllRecipes(App.getDisplayLimit()));

    } catch (SQLException e) {
        new AlertDialog.Builder(getActivity())
                .setTitle(R.string.message_failed_to_load)
                .setMessage(e.getLocalizedMessage())
                .show();
        Log.e(TAG, "Failed to load recipes", e);
    }
}
 
开发者ID:Cook-E-team,项目名称:Cook-E,代码行数:17,代码来源:RecipeList.java


示例16: onCreate

import android.databinding.ObservableArrayList; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mMeals = new ObservableArrayList<>();
    mVisibleMeals = new ObservableArrayList<>();
    try {
        mMeals.addAll(App.getAccessor().loadAllBunches(App.getDisplayLimit()));
        mVisibleMeals.addAll(mMeals);
    } catch (SQLException e) {
        new AlertDialog.Builder(getActivity())
                .setTitle("Failed to load Meals")
                .setMessage(e.getLocalizedMessage())
                .show();
        Log.e(TAG, "Failed to load Meals", e);
    }
}
 
开发者ID:Cook-E-team,项目名称:Cook-E,代码行数:18,代码来源:MealList.java


示例17: testRemoveWithIterator

import android.databinding.ObservableArrayList; //导入依赖的package包/类
/**
     * Checks whether the ObservableArrayList notifies its callbacks when an iterator is used
     * to remove items
     *
     * This test is temporarily disabled because of an Android bug.
     * A bug report has been filed: https://code.google.com/p/android/issues/detail?id=201481
     */
//    @Test
    public void testRemoveWithIterator() {
        final ObservableList<String> items = new ObservableArrayList<>();

        final ListChangeMock<String> mock = new ListChangeMock<>();
        items.addOnListChangedCallback(mock);

        // Add items to list
        items.addAll(Arrays.asList("Cake", "Pie", "Galette", "Pudding"));
        // Change listener reflects the added items
        assertEquals(items, mock.getCurrentList());

        // Remove all items from the list using an iterator
        for (Iterator<String> iter = items.iterator(); iter.hasNext(); ) {
            iter.next();
            iter.remove();
        }
        // List is now empty
        assertTrue(items.isEmpty());
        // Change listener should reflect this
        assertEquals(items, mock.getCurrentList());
    }
 
开发者ID:Cook-E-team,项目名称:Cook-E,代码行数:30,代码来源:ObservableArrayListTest.java


示例18: PasswordReadViewModel

import android.databinding.ObservableArrayList; //导入依赖的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


示例19: expandItem

import android.databinding.ObservableArrayList; //导入依赖的package包/类
/**
 * expand item
 *
 * @param parentIndex                       will be expand item index
 * @param baseExpandableObservable          the item Observable
 * @param expansionTriggeredByListItemClick
 */
public void expandItem(int parentIndex, BaseExpandableObservable baseExpandableObservable, boolean expansionTriggeredByListItemClick) {
    if (parentIndex >= 0 && parentIndex < mDataList.size() && !baseExpandableObservable.isExpand.get()) {

        ObservableArrayList<Object> childList = baseExpandableObservable.getChildList();
        final int childSize = childList.size();
        for (int i = 0; i < childSize; i++) {
            Object o = childList.get(i);
            int newIndex = parentIndex + i + 1;
            mDataList.add(newIndex, o);
        }
        notifyItemRangeInserted(parentIndex + 1, childSize);
        int positionStart = parentIndex + childSize;
        if (parentIndex != mDataList.size() - 1)
            notifyItemRangeChanged(positionStart, mDataList.size() - positionStart);
        baseExpandableObservable.setIsExpand(true);
        if (!mRecyclerViews.isEmpty()) {
            BindingViewHolder viewHolderForAdapterPosition = (BindingViewHolder) mRecyclerViews.get(0).findViewHolderForAdapterPosition(parentIndex);
            baseExpandableObservable.onExpansionToggled(viewHolderForAdapterPosition, parentIndex, true);
        }
        if (expansionTriggeredByListItemClick && mExpandCollapseListener != null) {
            mExpandCollapseListener.onListItemExpanded(parentIndex);
        }
    }
}
 
开发者ID:zaihuishou,项目名称:ExpandableRecyclerview-Databinding,代码行数:32,代码来源:BaseExpandableAdapter.java


示例20: main

import android.databinding.ObservableArrayList; //导入依赖的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


示例21: getCategoriesList

import android.databinding.ObservableArrayList; //导入依赖的package包/类
public static ObservableArrayList<Category> getCategoriesList() {
    ObservableArrayList<Category> categories = new ObservableArrayList<>();

    categories.add(getCategoryAll());
    categories.add(new Category(1, R.string.art, R.color.art, R.drawable.art));
    categories.add(new Category(3, R.string.comics, R.color.comics, R.drawable.comics));
    categories.add(new Category(26, R.string.crafts, R.color.crafts, R.drawable.crafts));
    categories.add(new Category(6, R.string.dance, R.color.dance, R.drawable.dance));
    categories.add(new Category(7, R.string.design, R.color.design, R.drawable.design));
    categories.add(new Category(9, R.string.fashion, R.color.fashion, R.drawable.fashion));
    categories.add(new Category(11, R.string.film_video, R.color.film_video, R.drawable.film_video));
    categories.add(new Category(10, R.string.food, R.color.food, R.drawable.food));
    categories.add(new Category(12, R.string.games, R.color.games, R.drawable.games));
    categories.add(new Category(13, R.string.journalism, R.color.journalism, R.drawable.journalism));
    categories.add(new Category(14, R.string.music, R.color.music, R.drawable.music));
    categories.add(new Category(15, R.string.photography, R.color.photography, R.drawable.photography));
    categories.add(new Category(18, R.string.publishing, R.color.publishing, R.drawable.publishing));
    categories.add(new Category(16, R.string.technology, R.color.technology, R.drawable.technology));
    categories.add(new Category(17, R.string.theater, R.color.theater, R.drawable.theater));

    return categories;
}
 
开发者ID:byoutline,项目名称:kickmaterial,代码行数:23,代码来源:DataManager.java


示例22: adapterDoesntChangeForSameItemBindingInListView

import android.databinding.ObservableArrayList; //导入依赖的package包/类
@Test
@UiThreadTest
public void adapterDoesntChangeForSameItemBindingInListView() {
    ObservableList<String> items = new ObservableArrayList<>();
    items.addAll(Arrays.asList("one", "two", "three"));
    TestHelpers.ViewModel viewModel = new TestHelpers.ViewModel.Builder(items, ItemBinding.<String>of(BR.item, item)).build();

    ViewDataBinding binding = DataBindingUtil.inflate(inflater, R.layout.list_view, null, false);
    binding.setVariable(BR.viewModel, viewModel);
    binding.executePendingBindings();

    ListView listView1 = (ListView) binding.getRoot();
    BindingCollectionAdapter<String> adapter1 = (BindingCollectionAdapter<String>) listView1.getAdapter();

    items.add("four");

    ListView listView2 = (ListView) binding.getRoot();
    @SuppressWarnings("unchecked")
    BindingCollectionAdapter<String> adapter2 = (BindingCollectionAdapter<String>) listView2.getAdapter();

    assertThat(adapter1).isSameAs(adapter2);
}
 
开发者ID:evant,项目名称:binding-collection-adapter,代码行数:23,代码来源:DynamicItemViewTest.java


示例23: insertingItemAndListContainsItemThenList

import android.databinding.ObservableArrayList; //导入依赖的package包/类
@Test
public void insertingItemAndListContainsItemThenList() {
    MergeObservableList<String> list = new MergeObservableList<>();
    ObservableList.OnListChangedCallback callback = mock(ObservableList.OnListChangedCallback.class);
    list.addOnListChangedCallback(callback);
    list.insertItem("test1");
    ObservableList<String> items = new ObservableArrayList<>();
    items.add("test2");
    items.add("test3");
    list.insertList(items);

    assertThat(list)
            .hasSize(3)
            .containsExactly("test1", "test2", "test3");
    verify(callback).onItemRangeInserted(list, 0, 1);
    verify(callback).onItemRangeInserted(list, 1, 2);
}
 
开发者ID:evant,项目名称:binding-collection-adapter,代码行数:18,代码来源:MergeObservableTest.java


示例24: addingItemToBackingListAddsItemToList

import android.databinding.ObservableArrayList; //导入依赖的package包/类
@Test
public void addingItemToBackingListAddsItemToList() {
    MergeObservableList<String> list = new MergeObservableList<>();
    ObservableList.OnListChangedCallback callback = mock(ObservableList.OnListChangedCallback.class);
    list.addOnListChangedCallback(callback);
    list.insertItem("test1");
    ObservableList<String> items = new ObservableArrayList<>();
    items.add("test2");
    list.insertList(items);
    list.insertItem("test4");
    items.add("test3");

    assertThat(list)
            .hasSize(4)
            .containsExactly("test1", "test2", "test3", "test4");
    verify(callback).onItemRangeInserted(list, 0, 1);
    verify(callback).onItemRangeInserted(list, 1, 1);
    verify(callback, times(2)).onItemRangeInserted(list, 2, 1);
}
 
开发者ID:evant,项目名称:binding-collection-adapter,代码行数:20,代码来源:MergeObservableTest.java


示例25: removingItemFromBackingListRemovesItemFromList

import android.databinding.ObservableArrayList; //导入依赖的package包/类
@Test
public void removingItemFromBackingListRemovesItemFromList() {
    MergeObservableList<String> list = new MergeObservableList<>();
    ObservableList.OnListChangedCallback callback = mock(ObservableList.OnListChangedCallback.class);
    list.addOnListChangedCallback(callback);
    list.insertItem("test1");
    ObservableList<String> items = new ObservableArrayList<>();
    items.add("test2");
    list.insertList(items);
    list.insertItem("test3");
    items.clear();

    assertThat(list)
            .hasSize(2)
            .containsExactly("test1", "test3");
    verify(callback).onItemRangeInserted(list, 0, 1);
    verify(callback).onItemRangeInserted(list, 1, 1);
    verify(callback).onItemRangeInserted(list, 2, 1);
    verify(callback).onItemRangeRemoved(list, 1, 1);
}
 
开发者ID:evant,项目名称:binding-collection-adapter,代码行数:21,代码来源:MergeObservableTest.java


示例26: changingItemFromBackingListChangesItInList

import android.databinding.ObservableArrayList; //导入依赖的package包/类
@Test
public void changingItemFromBackingListChangesItInList() {
    MergeObservableList<String> list = new MergeObservableList<>();
    ObservableList.OnListChangedCallback callback = mock(ObservableList.OnListChangedCallback.class);
    list.addOnListChangedCallback(callback);
    list.insertItem("test1");
    ObservableList<String> items = new ObservableArrayList<>();
    items.add("test2");
    list.insertList(items);
    items.set(0, "test3");
    
    assertThat(list)
            .hasSize(2)
            .containsExactly("test1", "test3");
    verify(callback).onItemRangeInserted(list, 0, 1);
    verify(callback).onItemRangeInserted(list, 1, 1);
    verify(callback).onItemRangeChanged(list, 1, 1);
}
 
开发者ID:evant,项目名称:binding-collection-adapter,代码行数:19,代码来源:MergeObservableTest.java


示例27: adapterDoesntChangeForSameItemBindingInRecylerView

import android.databinding.ObservableArrayList; //导入依赖的package包/类
@Test
@UiThreadTest
public void adapterDoesntChangeForSameItemBindingInRecylerView() {
    ObservableList<String> items = new ObservableArrayList<>();
    items.addAll(Arrays.asList("one", "two", "three"));
    TestHelpers.ViewModel viewModel = new TestHelpers.ViewModel(items, ItemBinding.<String>of(BR.item, item));

    ViewDataBinding binding = DataBindingUtil.inflate(inflater, R.layout.recycler_view, null, false);
    binding.setVariable(BR.viewModel, viewModel);
    binding.executePendingBindings();

    RecyclerView recyclerView1 = (RecyclerView) binding.getRoot();
    BindingCollectionAdapter<String> adapter1 = (BindingCollectionAdapter<String>) recyclerView1.getAdapter();

    items.add("four");

    RecyclerView recyclerView2 = (RecyclerView) binding.getRoot();
    @SuppressWarnings("unchecked")
    BindingCollectionAdapter<String> adapter2 = (BindingCollectionAdapter<String>) recyclerView2.getAdapter();

    assertThat(adapter1).isSameAs(adapter2);
}
 
开发者ID:evant,项目名称:binding-collection-adapter,代码行数:23,代码来源:DynamicItemViewTest.java


示例28: MainActivityViewModel

import android.databinding.ObservableArrayList; //导入依赖的package包/类
public MainActivityViewModel(IMainActivityAccess access) {

        this.access = access;

        people = new ObservableArrayList<>();
        people.add(new PersonModel("Wojciech", "Sura", "PGS Software S.A."));
        people.add(new PersonModel("Bill", "Gates", "Microsoft"));
        people.add(new PersonModel("Steve", "Jobs", "Apple"));
    }
 
开发者ID:PGSSoft,项目名称:ForgetAdapters,代码行数:10,代码来源:MainActivityViewModel.java


示例29: setItems

import android.databinding.ObservableArrayList; //导入依赖的package包/类
@BindingAdapter(value = {"items", "viewProvider"}, requireAll = true)
public static <TModel, TView extends View & IDataViewModelProvider<TModel>> void setItems(RecyclerView recyclerView, ObservableArrayList<TModel> items, RecyclerViewProvider<TModel, TView> viewProvider) {

    if (recyclerView.getAdapter() != null &&
            recyclerView.getAdapter() instanceof RecyclerViewListAdapter &&
            ((RecyclerViewListAdapter)recyclerView.getAdapter()).getList() == items)
        return;

    RecyclerViewListAdapter<TModel, TView> adapter = new RecyclerViewListAdapter<>(items, viewProvider);
    recyclerView.setAdapter(adapter);
}
 
开发者ID:PGSSoft,项目名称:ForgetAdapters,代码行数:12,代码来源:BindingAdapters.java


示例30: RecyclerViewListAdapter

import android.databinding.ObservableArrayList; //导入依赖的package包/类
public RecyclerViewListAdapter(ObservableArrayList<TModel> observableList, RecyclerViewProvider<TModel, TView> viewProvider) {

        this.observableList = observableList;
        this.viewProvider = viewProvider;

        observableList.addOnListChangedCallback(listChangeListener);
        setHasStableIds(viewProvider.hasStableIds());
    }
 
开发者ID:PGSSoft,项目名称:ForgetAdapters,代码行数:9,代码来源:RecyclerViewListAdapter.java


示例31: ListViewListAdapter

import android.databinding.ObservableArrayList; //导入依赖的package包/类
public ListViewListAdapter(ObservableArrayList<TModel> list, ListViewProvider<TModel, TView> provider, boolean stableIds) {
    this.list = list;
    this.provider = provider;
    this.stableIds = stableIds;

    this.list.addOnListChangedCallback(listChangedCallback);
}
 
开发者ID:PGSSoft,项目名称:ForgetAdapters,代码行数:8,代码来源:ListViewListAdapter.java


示例32: requestData

import android.databinding.ObservableArrayList; //导入依赖的package包/类
public void requestData() {
    getHouseListUseCase.execute(new DisposableObserver<List<HouseEntity>>() {

        @Override
        protected void onStart() {
            Toast.makeText(activity, "加载开始", Toast.LENGTH_SHORT);
        }

        @Override
        public void onNext(List<HouseEntity> value) {
            ObservableArrayList<HouseItemViewModel> houseItemViewModels = new ObservableArrayList<>();
            for (HouseEntity houseEntity : value) {
                HouseItemViewModel itemViewModel = new HouseItemViewModel(activity, houseEntity);
                houseItemViewModels.add(itemViewModel);
            }
            setHouses(houseItemViewModels);
        }

        @Override
        public void onError(Throwable e) {
            Toast.makeText(activity, "加载失败", Toast.LENGTH_SHORT);
        }

        @Override
        public void onComplete() {
            Toast.makeText(activity, "加载开始", Toast.LENGTH_SHORT);
        }
    }, GetHouseList.Params.setHouse(1, 1, 1, ""));
}
 
开发者ID:syy555,项目名称:mvvm-clean,代码行数:30,代码来源:HouseListViewModel.java


示例33: RecyclerViewModel

import android.databinding.ObservableArrayList; //导入依赖的package包/类
public RecyclerViewModel(int itemVariableId, @LayoutRes int itemLayoutResId, MvvmAdapter<T> adapter, OnItemClickListener<T> listener, int listenerVariableId) {
    this.items = new ObservableArrayList<>();
    this.adapter = null == adapter ? new MvvmAdapter<T>() : adapter;
    this.listener = listener;
    this.bindingItem = BindingItem.<T>of(itemVariableId, itemLayoutResId);
    if (null != listener) {
        this.bindingItem.bindExtra(listenerVariableId, listener);
    }
    this.itemDecoration = new ObservableField<>();
    this.layoutManager = new ObservableField<>();
}
 
开发者ID:zxmmmmmm,项目名称:Mvvm,代码行数:12,代码来源:RecyclerViewModel.java


示例34: Listener

import android.databinding.ObservableArrayList; //导入依赖的package包/类
Listener(final ObservableArrayList<T> observableArrayList,
    final Observer<? super ObservableArrayListItemRangeChangeEvent<T>> observer) {
  this.observableArrayList = observableArrayList;
  this.onListChangedCallback =
      new ObservableList.OnListChangedCallback<ObservableArrayList<T>>() {
        @Override public void onChanged(ObservableArrayList<T> observableArrayList) {
        }

        @Override
        public void onItemRangeChanged(ObservableArrayList<T> observableArrayList,
            int positionStart, int itemCount) {
          observer.onNext(
              ObservableArrayListItemRangeChangeEvent.create(observableArrayList, positionStart,
                  itemCount));
        }

        @Override
        public void onItemRangeInserted(ObservableArrayList<T> observableArrayList,
            int positionStart, int itemCount) {
        }

        @Override
        public void onItemRangeMoved(ObservableArrayList<T> observableArrayList,
            int positionStart, int positionEnd, int itemCount) {
        }

        @Override
        public void onItemRangeRemoved(ObservableArrayList<T> observableArrayList,
            int positionStart, int itemCount) {
        }
      };
}
 
开发者ID:oldergod,项目名称:RxDataBinding,代码行数:33,代码来源:ObservableArrayListItemRangeChangeEventObservable.java


示例35: itemRangeInsertionEvents

import android.databinding.ObservableArrayList; //导入依赖的package包/类
/**
 * Create an observable of item range insertion events on {@code observableArrayList}.
 * <p>
 * <em>Warning:</em> The created observable keeps a strong reference to {@code
 * observableArrayList}.
 * Unsubscribe to free this reference.
 */
@CheckResult @NonNull
public static <T> Observable<ObservableArrayListItemRangeInsertionEvent<T>>
itemRangeInsertionEvents(
    @NonNull ObservableArrayList<T> observableArrayList) {
  checkNotNull(observableArrayList, "observableArrayList == null");
  return new ObservableArrayListItemRangeInsertionEventObservable<>(observableArrayList);
}
 
开发者ID:oldergod,项目名称:RxDataBinding,代码行数:15,代码来源:RxObservableArrayList.java


示例36: Listener

import android.databinding.ObservableArrayList; //导入依赖的package包/类
Listener(final ObservableArrayList<T> observableArrayList,
    final Observer<? super ObservableArrayListItemRangeInsertionEvent<T>> observer) {
  this.observableArrayList = observableArrayList;
  this.onListChangedCallback =
      new ObservableList.OnListChangedCallback<ObservableArrayList<T>>() {
        @Override public void onChanged(ObservableArrayList<T> observableArrayList) {
        }

        @Override
        public void onItemRangeChanged(ObservableArrayList<T> observableArrayList,
            int positionStart, int itemCount) {
        }

        @Override
        public void onItemRangeInserted(ObservableArrayList<T> observableArrayList,
            int positionStart, int itemCount) {
          observer.onNext(ObservableArrayListItemRangeInsertionEvent.create(observableArrayList,
              positionStart, itemCount));
        }

        @Override
        public void onItemRangeMoved(ObservableArrayList<T> observableArrayList,
            int positionStart, int positionEnd, int itemCount) {
        }

        @Override
        public void onItemRangeRemoved(ObservableArrayList<T> observableArrayList,
            int positionStart, int itemCount) {
        }
      };
}
 
开发者ID:oldergod,项目名称:RxDataBinding,代码行数:32,代码来源:ObservableArrayListItemRangeInsertionEventObservable.java


示例37: Listener

import android.databinding.ObservableArrayList; //导入依赖的package包/类
Listener(final ObservableArrayList<T> observableArrayList,
    final Observer<? super ObservableArrayListItemRangeRemovalEvent<T>> observer) {
  this.observableArrayList = observableArrayList;
  this.onListChangedCallback =
      new ObservableList.OnListChangedCallback<ObservableArrayList<T>>() {
        @Override public void onChanged(ObservableArrayList<T> observableArrayList) {
        }

        @Override
        public void onItemRangeChanged(ObservableArrayList<T> observableArrayList,
            int positionStart, int itemCount) {
        }

        @Override
        public void onItemRangeInserted(ObservableArrayList<T> observableArrayList,
            int positionStart, int itemCount) {
        }

        @Override
        public void onItemRangeMoved(ObservableArrayList<T> observableArrayList,
            int positionStart, int positionEnd, int itemCount) {
        }

        @Override
        public void onItemRangeRemoved(ObservableArrayList<T> observableArrayList,
            int positionStart, int itemCount) {
          observer.onNext(ObservableArrayListItemRangeRemovalEvent.create(observableArrayList,
              positionStart, itemCount));
        }
      };
}
 
开发者ID:oldergod,项目名称:RxDataBinding,代码行数:32,代码来源:ObservableArrayListItemRangeRemovalEventObservable.java


示例38: CurrencyListViewModel

import android.databinding.ObservableArrayList; //导入依赖的package包/类
public CurrencyListViewModel(Navigator navigator, GetCurrenciesUseCase currenciesUseCase, GetCurrenciesRatesDate getCurrenciesRatesDate) {
    mCurrencies = new ObservableArrayList<>();
    mCurrenciesUseCase = checkNotNull(currenciesUseCase);
    mGetCurrenciesRatesDate = checkNotNull(getCurrenciesRatesDate);
    mNavigator = checkNotNull(navigator);
    setReadDate(new Date());
}
 
开发者ID:krokers,项目名称:exchange-rates-mvvm,代码行数:8,代码来源:CurrencyListViewModel.java



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