Java Code Examples for android.databinding.ViewDataBinding#executePendingBindings()
The following examples show how to use
android.databinding.ViewDataBinding#executePendingBindings() .
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: DataBindingRepositoryPresenterCompiler.java From agera with Apache License 2.0 | 6 votes |
@Override public void bind(@NonNull final Object data, final int index, @NonNull final RecyclerView.ViewHolder holder) { final Object item = getItems(data).get(index); final View view = holder.itemView; final ViewDataBinding viewDataBinding = DataBindingUtil.bind(view); final Integer itemVariable = itemId.apply(item); if (itemVariable != BR_NO_ID) { viewDataBinding.setVariable(itemVariable, item); view.setTag(R.id.agera__rvdatabinding__item_id, itemVariable); } if (collectionId != BR_NO_ID) { viewDataBinding.setVariable(collectionId, data); view.setTag(R.id.agera__rvdatabinding__collection_id, collectionId); } for (int i = 0; i < handlers.size(); i++) { final int variableId = handlers.keyAt(i); viewDataBinding.setVariable(variableId, handlers.valueAt(i)); } viewDataBinding.executePendingBindings(); }
Example 2
Source File: WeatherDailyAdapter.java From MVVMArms with Apache License 2.0 | 6 votes |
@Override protected void convert(BaseBindHolder helper, WeatherDailyResponse.DailyResult.Daily item) { ViewDataBinding binding = helper.getBinding(); binding.setVariable(BR.daily, item); binding.executePendingBindings(); SuperTextView superTextView = helper.getView(R.id.super_item_daily); ArmsUtils.INSTANCE.obtainArmsComponent(mContext).imageLoader() .loadImage(mContext, ImageConfigImpl.builder() .url(String.format(Locale.CHINESE, Api.API_WEATHER_ICON_URL, item.getCodeDay())) .placeholder(R.mipmap.ic_placeholder) .errorPic(R.mipmap.weather_unknown) .transformation(new FitCenter()) .imageView(superTextView.getRightIconIV()) .build()); }
Example 3
Source File: ComplexRvAdapter.java From AndroidAgeraTutorial with Apache License 2.0 | 5 votes |
@Override public void onBindItemViewHolder(RecyclerView.ViewHolder holder, int position) { final GirlInfo info = getItem(position); if(holder instanceof ViewHolder){ ViewDataBinding binding = ((ViewHolder) holder).getBinding(); binding.setVariable(BR.info, info); binding.executePendingBindings(); } }
Example 4
Source File: DataBindingRepositoryPresenterCompiler.java From agera with Apache License 2.0 | 5 votes |
@Override public void recycle(@NonNull final RecyclerView.ViewHolder holder) { if (recycleConfig != 0) { final View view = holder.itemView; final ViewDataBinding viewDataBinding = DataBindingUtil.bind(view); if ((recycleConfig & CLEAR_ITEM) != 0) { final Object tag = view.getTag(R.id.agera__rvdatabinding__item_id); view.setTag(R.id.agera__rvdatabinding__item_id, null); if (tag instanceof Integer) { viewDataBinding.setVariable((int) tag, null); } } if ((recycleConfig & CLEAR_COLLECTION) != 0) { final Object collectionTag = view.getTag(R.id.agera__rvdatabinding__collection_id); view.setTag(R.id.agera__rvdatabinding__collection_id, null); if (collectionTag instanceof Integer) { viewDataBinding.setVariable((int) collectionTag, null); } } if ((recycleConfig & CLEAR_HANDLERS) != 0) { for (int i = 0; i < handlers.size(); i++) { viewDataBinding.setVariable(handlers.keyAt(i), null); } } viewDataBinding.executePendingBindings(); } }
Example 5
Source File: DataBindingLayoutPresenters.java From agera with Apache License 2.0 | 5 votes |
@Override public void recycle(@NonNull final View view) { if ((recycleConfig & CLEAR_HANDLERS) != 0) { final ViewDataBinding viewDataBinding = DataBindingUtil.bind(view); for (int i = 0; i < handlers.size(); i++) { viewDataBinding.setVariable(handlers.keyAt(i), null); } viewDataBinding.executePendingBindings(); } }
Example 6
Source File: DataBindingLayoutPresenters.java From agera with Apache License 2.0 | 5 votes |
@Override public void bind(@NonNull final View view) { final ViewDataBinding viewDataBinding = DataBindingUtil.bind(view); for (int i = 0; i < handlers.size(); i++) { final int variableId = handlers.keyAt(i); viewDataBinding.setVariable(variableId, handlers.get(variableId)); } viewDataBinding.executePendingBindings(); }
Example 7
Source File: SpinnerResourceAdapter.java From moserp with Apache License 2.0 | 5 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { View view; if (convertView == null) { LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext()); view = layoutInflater.inflate(layoutId, parent, false); } else { view = convertView; } final ViewDataBinding binding = DataBindingUtil.bind(view); binding.setVariable(BR.item, getResource(position)); binding.executePendingBindings(); return view; }
Example 8
Source File: BaseExpandableAdapter.java From ExpandableRecyclerview-Databinding with Apache License 2.0 | 5 votes |
@Override public void onBindViewHolder(BindingViewHolder holder, int position) { Object o = mDataList.get(position); ViewDataBinding binding = holder.getBinding(); binding.setVariable(getVariable(o, position), o); binding.executePendingBindings(); if (o instanceof BaseExpandableObservable) { BaseExpandableObservable baseExpandableObservable = (BaseExpandableObservable) o; ObservableArrayList<Object> childList = baseExpandableObservable.getChildList(); if (childList != null && !childList.isEmpty()) baseExpandableObservable.setItemListExpandCollapseListener(this); } }
Example 9
Source File: RecyclerViewDatabindingAdapter.java From Android-App-Architecture-MVVM-Databinding with Apache License 2.0 | 5 votes |
@Override public void onBindViewHolder(final RecyclerViewDatabindingAdapter<ItemTypeT>.BindingHolder holder, final int position) { final Object item = getItemForBinding(position); final ViewDataBinding itemBinding = holder.getBinding(); itemBinding.setVariable(itemDataBrId, item); itemBinding.executePendingBindings(); }
Example 10
Source File: GirlListAdapter.java From AndroidAgeraTutorial with Apache License 2.0 | 5 votes |
@Override public void onBindItemViewHolder(RecyclerView.ViewHolder holder, int position) { final GirlInfo info = getItem(position); if(holder instanceof ViewHolder){ ViewDataBinding binding = ((ViewHolder) holder).getBinding(); binding.setVariable(BR.info, info); binding.executePendingBindings(); } }
Example 11
Source File: ViewPagerAdapter.java From android-mvvm with Apache License 2.0 | 5 votes |
@Override public void destroyItem(ViewGroup container, int position, Object object) { ViewDataBinding binding = (ViewDataBinding) object; binder.bind(binding, null); binding.executePendingBindings(); container.removeView(binding.getRoot()); }
Example 12
Source File: ViewGroupBindings.java From okuki with Apache License 2.0 | 5 votes |
@BindingAdapter("component") public static void loadComponent(ViewGroup viewGroup, MvvmComponent component) { if (component != null) { ViewDataBinding binding = DataBindingUtil.inflate(LayoutInflater.from(viewGroup.getContext()), component.getLayoutResId(), viewGroup, false); View view = binding.getRoot(); binding.setVariable(BR.vm, component.getViewModel()); binding.executePendingBindings(); viewGroup.removeAllViews(); viewGroup.addView(view); } }
Example 13
Source File: MainActivity.java From okuki with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ViewDataBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main); vm = new MainViewModel(); binding.setVariable(BR.vm, vm); binding.executePendingBindings(); }
Example 14
Source File: HeaderedRecyclerViewDatabindingAdapter.java From Android-App-Architecture-MVVM-Databinding with Apache License 2.0 | 5 votes |
@Override public void onBindViewHolder(final RecyclerViewDatabindingAdapter<ItemTypeT>.BindingHolder holder, final int position) { if (position == 0) { final ViewDataBinding itemBinding = holder.getBinding(); itemBinding.setVariable(headerParams.headerDataBrId, headerParams.headerData); itemBinding.executePendingBindings(); return; } super.onBindViewHolder(holder, position); }
Example 15
Source File: ReviewsAdapter.java From AndroidSchool with Apache License 2.0 | 4 votes |
public ViewHolder(ViewDataBinding viewDataBinding) { super(viewDataBinding.getRoot()); viewDataBinding.executePendingBindings(); mDataBinding = viewDataBinding; }
Example 16
Source File: TrailersAdapter.java From AndroidSchool with Apache License 2.0 | 4 votes |
public ViewHolder(ViewDataBinding viewDataBinding) { super(viewDataBinding.getRoot()); viewDataBinding.executePendingBindings(); mDataBinding = viewDataBinding; }
Example 17
Source File: TextContentAdapter.java From MVVMArms with Apache License 2.0 | 4 votes |
@Override protected void convert(BaseBindHolder helper, TextContent item) { ViewDataBinding binding = helper.getBinding(); binding.setVariable(BR.content, item); binding.executePendingBindings(); }