本文整理汇总了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;
}
示例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();
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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());
}
示例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);
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
示例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) {
}
};
}