Java Code Examples for android.databinding.ObservableList#isEmpty()
The following examples show how to use
android.databinding.ObservableList#isEmpty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ViewAdapter.java From AndroidWallet with GNU General Public License v3.0 | 5 votes |
@BindingAdapter({"itemView", "observableList"}) public static void addViews(ViewGroup viewGroup, final ItemBinding itemBinding, final ObservableList<IBindingItemViewModel> viewModelList) { if (viewModelList != null && !viewModelList.isEmpty()) { viewGroup.removeAllViews(); for (IBindingItemViewModel viewModel : viewModelList) { ViewDataBinding binding = DataBindingUtil.inflate(LayoutInflater.from(Utils.getContext()), itemBinding.layoutRes(), viewGroup, true); binding.setVariable(itemBinding.variableId(), viewModel); viewModel.injecDataBinding(binding); } } }
Example 2
Source File: BindableAdapter.java From mv2m with Apache License 2.0 | 5 votes |
public BindableAdapter(ObservableList<? extends T> items, ViewHolderFactory<T> defaultViewHolderFactory) { this.items = items; this.defaultViewHolderFactory = defaultViewHolderFactory; //saved in a field to maintain a reference and avoid garbage collection onListChangedCallback = new AdapterOnListChangedCallback<>(this); items.addOnListChangedCallback((ObservableList.OnListChangedCallback) new WeakOnListChangedCallback<>(onListChangedCallback)); if (!items.isEmpty()) { notifyDataSetChanged(); } }