當前位置: 首頁>>代碼示例>>Java>>正文


Java ObservableList類代碼示例

本文整理匯總了Java中android.databinding.ObservableList的典型用法代碼示例。如果您正苦於以下問題:Java ObservableList類的具體用法?Java ObservableList怎麽用?Java ObservableList使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ObservableList類屬於android.databinding包,在下文中一共展示了ObservableList類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getTwirledDownLayersForGroup

import android.databinding.ObservableList; //導入依賴的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: setupSelectionCallback

import android.databinding.ObservableList; //導入依賴的package包/類
public void setupSelectionCallback(){
    try {
        if (removeSelectionCallback != null) {
            removeSelectionCallback.close();
        }

        if(selectedItems!=null) {
            selectedItems.addOnListChangedCallback(selectionCallback);

            ObservableList old = selectedItems;

            removeSelectionCallback = new ClosableAction(() -> {
                old.removeOnListChangedCallback(selectionCallback);
            });
        }else{
            removeSelectionCallback = null;
        }

    }catch (Exception ex){
        ex.printStackTrace();
    }
}
 
開發者ID:neurospeech,項目名稱:ui-atoms-android,代碼行數:23,代碼來源:AtomListView.java

示例3: createAdapterStaggeredGrid

import android.databinding.ObservableList; //導入依賴的package包/類
@BindingAdapter({
        "bind:items",
        "bind:itemLayout",
        "bind:itemBindingId",
        "bind:spanCount",
        "bind:layoutType",
        "bind:orientation"})
public static void createAdapterStaggeredGrid(final RecyclerView list,
                                              ObservableList items,
                                              int itemLayout, int itemBindingId,
                                              int spanCount,
                                              @LayoutManagerType.LayoutType int layoutType,
                                              int orientation) {
    if (null == list.getAdapter()) {
        SimpleBindingListAdapter adapter = new SimpleBindingListAdapter(items, itemBindingId, itemLayout);
        RecyclerView.LayoutManager layoutManager = createLayoutManager(list, spanCount, layoutType, orientation);
        list.setLayoutManager(layoutManager);
        list.setAdapter(adapter);
    }
}
 
開發者ID:krokers,項目名稱:recycler-binding,代碼行數:21,代碼來源:RecyclerViewExtensions.java

示例4: multipleReplaceButFilteredAll

import android.databinding.ObservableList; //導入依賴的package包/類
@Test
@SuppressWarnings("unchecked")
public void multipleReplaceButFilteredAll() {
    FilteredReadOnlyObservableList<String> list
            = new FilteredReadOnlyObservableList<>(rule.getSource(), new Filter<String>() {
        @Override
        public boolean execute(String element) {
            return !element.contains("2") && !element.contains("3");
        }
    });
    rule.setUpList(list);

    rule.getSource().setAll(1, Arrays.asList("element2-2", "element3-2"));

    verify(rule.getCallback(), never())
            .onItemRangeChanged((ObservableList) any(), anyInt(), anyInt());
    assertThat(list.size(), is(3));
}
 
開發者ID:k-kagurazaka,項目名稱:filtered-observable-collection,代碼行數:19,代碼來源:FilteredReadOnlyObservableListTest.java

示例5: onItemRangeInserted

import android.databinding.ObservableList; //導入依賴的package包/類
@Override
public void onItemRangeInserted(ObservableList observableList,
        int start, int count) {
    if (mLayoutId == 0) {
        return;
    }
    startTransition(mTarget);
    final int end = start + count;
    LayoutInflater inflater = (LayoutInflater) mTarget.getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    for (int i = end - 1; i >= start; i--) {
        Object entry = observableList.get(i);
        ViewDataBinding binding =
                bindLayout(inflater, mTarget, mLayoutId, entry);
        mTarget.addView(binding.getRoot(), start);
    }
}
 
開發者ID:google,項目名稱:android-ui-toolkit-demos,代碼行數:18,代碼來源:ListBindingAdapters.java

示例6: moveButFilteredAll

import android.databinding.ObservableList; //導入依賴的package包/類
@Test
@SuppressWarnings("unchecked")
public void moveButFilteredAll() {
    FilteredReadOnlyObservableList<String> list
            = new FilteredReadOnlyObservableList<>(rule.getSource(), new Filter<String>() {
        @Override
        public boolean execute(String element) {
            return !element.contains("2") && !element.contains("3");
        }
    });
    rule.setUpList(list);

    rule.getSource().move(1, 0, 2);

    verify(rule.getCallback(), never())
            .onItemRangeRemoved((ObservableList) any(), anyInt(), anyInt());
    verify(rule.getCallback(), never())
            .onItemRangeInserted((ObservableList) any(), anyInt(), anyInt());
    assertThat(list.get(0), is("element1"));
    assertThat(list.get(1), is("element4"));
}
 
開發者ID:k-kagurazaka,項目名稱:filtered-observable-collection,代碼行數:22,代碼來源:FilteredReadOnlyObservableListTest.java

示例7: computableListElementsAreComputable

import android.databinding.ObservableList; //導入依賴的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

示例8: testRemoveWithIterator

import android.databinding.ObservableList; //導入依賴的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

示例9: remove

import android.databinding.ObservableList; //導入依賴的package包/類
@Test
@SuppressWarnings("unchecked")
public void remove() {
    FilteredReadOnlyObservableList<ObservableItem> list
            = new FilteredReadOnlyObservableList<>(rule.getSource());
    rule.setUpList(list);

    ObservableItem willBeRemoved = rule.getSource().get(0);
    rule.getSource().remove(new ObservableItem("element1"));

    verify(rule.getCallback()).onItemRangeRemoved(list, 0, 1);
    assertThat(list.get(0).getValue(), is("element2"));

    willBeRemoved.setValue("element1-changed");

    verify(rule.getCallback(), never())
            .onItemRangeChanged((ObservableList) any(), anyInt(), anyInt());
}
 
開發者ID:k-kagurazaka,項目名稱:filtered-observable-collection,代碼行數:19,代碼來源:FilteredReadOnlyObservableListTest.java

示例10: multipleRemoveButFilteredAll

import android.databinding.ObservableList; //導入依賴的package包/類
@Test
@SuppressWarnings("unchecked")
public void multipleRemoveButFilteredAll() {
    FilteredReadOnlyObservableList<String> list
            = new FilteredReadOnlyObservableList<>(rule.getSource(), new Filter<String>() {
        @Override
        public boolean execute(String element) {
            return !element.equals("element2") && !element.equals("element3");
        }
    });
    rule.setUpList(list);

    rule.getSource().removeRange(1, 3);

    verify(rule.getCallback(), never())
            .onItemRangeRemoved((ObservableList) any(), anyInt(), anyInt());
    assertThat(list.size(), is(3));
}
 
開發者ID:k-kagurazaka,項目名稱:filtered-observable-collection,代碼行數:19,代碼來源:FilteredReadOnlyObservableListTest.java

示例11: setSelectedItems

import android.databinding.ObservableList; //導入依賴的package包/類
@BindingAdapter("selectedItems")
public static <T> void setSelectedItems(
        AtomListView view,
        @Nullable ObservableList<T> list){
    if(view.getSelectedItems() == list)
        return;
    view.setSelectedItems(list);
}
 
開發者ID:neurospeech,項目名稱:ui-atoms-android,代碼行數:9,代碼來源:AtomListView.java

示例12: adapterSetItems

import android.databinding.ObservableList; //導入依賴的package包/類
@BindingAdapter("items")
public static <T> void adapterSetItems(AtomListView view, ObservableList<T> items){
    if(view.getItems() == items)
        return;
    view.setItems(items);
    if(view.getLayoutManager() == null){
        LinearLayoutManager linearLayoutManager =
                new LinearLayoutManager(view.getContext(),
                        LinearLayoutManager.VERTICAL,
                        false);
        view.setLayoutManager(linearLayoutManager);
    }
}
 
開發者ID:neurospeech,項目名稱:ui-atoms-android,代碼行數:14,代碼來源:AtomListView.java

示例13: addPropertyChangedCallbacks

import android.databinding.ObservableList; //導入依賴的package包/類
private void addPropertyChangedCallbacks(List<Layer> layers, int start, int end) {
    for (int i = start; i < end; i++) {
        Layer l = layers.get(i);
        l.addOnPropertyChangedCallback(mOnPropertyChangedCallback);
        if (l instanceof LayerGroup) {
            LayerGroup lg = (LayerGroup) l;
            ObservableList<Layer> childLayers = lg.getLayers();
            // Add list listener for future changes to the layer group's list of children
            childLayers.addOnListChangedCallback(mOnListChangedCallback);

            // Recursive call to add property listeners to each child layer
            addPropertyChangedCallbacks(childLayers);
        }
    }
}
 
開發者ID:google,項目名稱:spline,代碼行數:16,代碼來源:DocumentView.java

示例14: updateList

import android.databinding.ObservableList; //導入依賴的package包/類
private void updateList() {
    PickerViewModel viewModel = PickerViewModel.getInstance();
    ObservableList<File> files = viewModel.getFiles();

    if (mAdapter == null) {
        mAdapter = new FileAdapter();
        mList.setAdapter(mAdapter);
    }

    mAdapter.setFiles(files);
    mBinding.setViewModel(viewModel);
}
 
開發者ID:google,項目名稱:spline,代碼行數:13,代碼來源:ListFragment.java

示例15: FileAdapter

import android.databinding.ObservableList; //導入依賴的package包/類
public FileAdapter() {
    mOnListChangedCallback = new ObservableList
            .OnListChangedCallback<ObservableList<Layer>>() {
        @Override
        public void onChanged(ObservableList<Layer> layers) {

        }

        @Override
        public void onItemRangeChanged(ObservableList<Layer> layers, int i, int i1) {

        }

        @Override
        public void onItemRangeInserted(ObservableList<Layer> layers, int start, int
                count) {
            notifyItemRangeInserted(start, count);
        }

        @Override
        public void onItemRangeMoved(ObservableList<Layer> sender, int fromPosition, int
                toPosition, int itemCount) {

        }

        @Override
        public void onItemRangeRemoved(ObservableList<Layer> sender, int positionStart,
                                       int itemCount) {

        }
    };
}
 
開發者ID:google,項目名稱:spline,代碼行數:33,代碼來源:ListFragment.java


注:本文中的android.databinding.ObservableList類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。