Java 类android.databinding.ObservableArrayList 实例源码

项目:spline    文件:LayerListAdapter.java   
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;
}
项目:DereHelper    文件:SongVM.java   
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);
}
项目:Cinder    文件:CinderUnitTest.java   
@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);
}
项目:Cinder    文件:CinderUnitTest.java   
@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);
}
项目:Cinder    文件:CinderUnitTest.java   
@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);
}
项目:Cinder    文件:CinderComputableUnitTest.java   
@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());
}
项目:Cinder    文件:CinderComputableUnitTest.java   
@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());
}
项目:Cinder    文件:CinderComputableUnitTest.java   
@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());

}
项目:Cinder    文件:CinderComputableUnitTest.java   
@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());
}
项目:Cinder    文件:CinderComputableUnitTest.java   
@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());
}
项目:Cinder    文件:CinderComputableUnitTest.java   
@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());
}
项目:Cinder    文件:CinderArrayListUnitTest.java   
@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));
}
项目:Cinder    文件:CinderArrayListUnitTest.java   
@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));
}
项目:Cinder    文件:CinderArrayListUnitTest.java   
@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));
}
项目:Cook-E    文件:RecipeList.java   
@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);
    }
}
项目:Cook-E    文件:MealList.java   
@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);
    }
}
项目:Cook-E    文件:ObservableArrayListTest.java   
/**
     * 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());
    }
项目: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);
}
项目:ExpandableRecyclerview-Databinding    文件:BaseExpandableAdapter.java   
/**
 * 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);
        }
    }
}
项目:MVVMDemo    文件:ObservableModel.java   
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);

}
项目:kickmaterial    文件:DataManager.java   
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;
}
项目:onyxbeacon-android-sdk    文件:DataManager.java   
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;
}
项目:binding-collection-adapter    文件:DynamicItemViewTest.java   
@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);
}
项目:binding-collection-adapter    文件:MergeObservableTest.java   
@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);
}
项目:binding-collection-adapter    文件:MergeObservableTest.java   
@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);
}
项目:binding-collection-adapter    文件:MergeObservableTest.java   
@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);
}
项目:binding-collection-adapter    文件:MergeObservableTest.java   
@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);
}
项目:binding-collection-adapter    文件:DynamicItemViewTest.java   
@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);
}
项目:ForgetAdapters    文件:MainActivityViewModel.java   
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"));
    }
项目:ForgetAdapters    文件:BindingAdapters.java   
@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);
}
项目:ForgetAdapters    文件:BindingAdapters.java   
@BindingAdapter(value = {"items", "viewProvider"}, requireAll = true)
public static <TModel extends IIdProvider, TView extends View & IDataViewModelProvider<TModel>> void setItems(ListView listView, ObservableArrayList<TModel> items, ListViewProvider<TModel, TView> viewProvider) {

    if (listView.getAdapter() != null &&
            listView.getAdapter() instanceof ListViewCollectionAdapter &&
            ((ListViewCollectionAdapter)listView.getAdapter()).getItems() == items)
        return;

    ListViewListAdapter<TModel, TView> adapter = new ListViewListAdapter<TModel, TView>(items, viewProvider, false);
    listView.setAdapter(adapter);
}
项目:ForgetAdapters    文件:RecyclerViewListAdapter.java   
public RecyclerViewListAdapter(ObservableArrayList<TModel> observableList, RecyclerViewProvider<TModel, TView> viewProvider) {

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

        observableList.addOnListChangedCallback(listChangeListener);
        setHasStableIds(viewProvider.hasStableIds());
    }
项目:ForgetAdapters    文件:ListViewListAdapter.java   
public ListViewListAdapter(ObservableArrayList<TModel> list, ListViewProvider<TModel, TView> provider, boolean stableIds) {
    this.list = list;
    this.provider = provider;
    this.stableIds = stableIds;

    this.list.addOnListChangedCallback(listChangedCallback);
}
项目:mvvm-clean    文件:HouseListViewModel.java   
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, ""));
}
项目:Mvvm    文件:RecyclerViewModel.java   
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<>();
}
项目:RxDataBinding    文件:ObservableArrayListItemRangeChangeEventObservable.java   
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) {
        }
      };
}
项目:RxDataBinding    文件:RxObservableArrayList.java   
/**
 * 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);
}
项目:RxDataBinding    文件:ObservableArrayListItemRangeInsertionEventObservable.java   
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) {
        }
      };
}
项目:RxDataBinding    文件:ObservableArrayListItemRangeRemovalEventObservable.java   
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));
        }
      };
}
项目:exchange-rates-mvvm    文件:CurrencyListViewModel.java   
public CurrencyListViewModel(Navigator navigator, GetCurrenciesUseCase currenciesUseCase, GetCurrenciesRatesDate getCurrenciesRatesDate) {
    mCurrencies = new ObservableArrayList<>();
    mCurrenciesUseCase = checkNotNull(currenciesUseCase);
    mGetCurrenciesRatesDate = checkNotNull(getCurrenciesRatesDate);
    mNavigator = checkNotNull(navigator);
    setReadDate(new Date());
}