Java Code Examples for android.databinding.DataBindingUtil#bind()
The following examples show how to use
android.databinding.DataBindingUtil#bind() .
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: 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 3
Source File: GirlInfoPresenter.java From AndroidAgeraTutorial with Apache License 2.0 | 5 votes |
@Override public void bind(@NonNull Result<List<GirlInfo>> data, int index, @NonNull RecyclerView.ViewHolder holder) { if (data.isAbsent() || data.failed()) { return; } final GirlInfo info = data.get().get(index); final RecyclerItemViewBinding binding = DataBindingUtil.bind(holder.itemView); binding.setVariable(BR.info, info); }
Example 4
Source File: FindFragment.java From POCenter with MIT License | 5 votes |
@Override protected void initView(View view) { bind = DataBindingUtil.bind(view); // init recycler view findAdapter = new FindAdapter(new ArrayList<ProjectBean>(0)); bind.rv.setAdapter(findAdapter); bind.rv.setLayoutManager(new LinearLayoutManager(getContext())); DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL); dividerItemDecoration.setDrawable(getResources().getDrawable(R.drawable.shape_drive_line)); bind.rv.addItemDecoration(dividerItemDecoration); initEvent(); }
Example 5
Source File: ViewPagerAdapterTest.java From android-mvvm with Apache License 2.0 | 5 votes |
@Test @UiThreadTest public void destroyItemUnbindsAndRemovesChildView() throws Exception { ViewGroup container = new LinearLayout(InstrumentationRegistry.getContext()); Object pagerObject = sut.instantiateItem(container, 0); View child = container.getChildAt(0); ViewDataBinding binding = DataBindingUtil.bind(child); sut.destroyItem(container, 0, pagerObject); assertEquals(0, container.getChildCount()); assertTrue(testBinder.lastBinding == binding); assertTrue(testBinder.lastViewModel == null); }
Example 6
Source File: ViewPagerAdapterTest.java From android-mvvm with Apache License 2.0 | 5 votes |
@Test @UiThreadTest public void instantiateItemAddsBindedView() throws Exception { ViewGroup container = new LinearLayout(InstrumentationRegistry.getContext()); sut.instantiateItem(container, 0); View child = container.getChildAt(0); ViewDataBinding binding = DataBindingUtil.bind(child); assertEquals(1, container.getChildCount()); assertEquals("com.manaschaudhari.android_mvvm.test.databinding.LayoutTestBinding", binding.getClass().getName()); assertTrue(testBinder.lastBinding == binding); assertTrue(testBinder.lastViewModel == viewModelsSource.getValue().get(0)); }
Example 7
Source File: HistoryFragment.java From chaoli-forum-for-android-2 with GNU General Public License v3.0 | 5 votes |
@Override public void setViewModel(BaseViewModel viewModel) { this.viewModel = (HistoryFragmentVM) viewModel; //this.viewModel.setUrl(Constants.GET_ACTIVITIES_URL + mUserId); HomepageHistoryBinding binding = DataBindingUtil.bind(mSwipyRefreshLayout); binding.setViewModel(this.viewModel); }
Example 8
Source File: ListAdapter.java From example with Apache License 2.0 | 4 votes |
public ListItemHolder(View itemView) { super(itemView); binding = DataBindingUtil.bind(itemView); }
Example 9
Source File: XLazyFragment.java From XDroid-Databinding with MIT License | 4 votes |
public void bindUI(View rootView) { binding = DataBindingUtil.bind(rootView); }
Example 10
Source File: FileListAdapter.java From FileTransfer with GNU General Public License v3.0 | 4 votes |
public MyViewHolder(View view) { super(view); mBinding = DataBindingUtil.bind(view); }
Example 11
Source File: PeopleAdapter.java From triviums with MIT License | 4 votes |
public PeopleViewHolder(@NonNull View itemView) { super(itemView); binding = DataBindingUtil.bind(itemView); itemView.setTag(getBinding()); }
Example 12
Source File: CartProductAdapter.java From mobikul-standalone-pos with MIT License | 4 votes |
public ViewHolder(View itemView) { super(itemView); binding = DataBindingUtil.bind(itemView); }
Example 13
Source File: StagesAdapter.java From triviums with MIT License | 4 votes |
public StageViewHolder(@NonNull View itemView) { super(itemView); binding = DataBindingUtil.bind(itemView); itemView.setTag(getBinding()); }
Example 14
Source File: XFragment.java From XDroid-Databinding with MIT License | 4 votes |
public void bindUI(View rootView) { binding = DataBindingUtil.bind(rootView); }
Example 15
Source File: ComplexRvAdapter.java From AndroidAgeraTutorial with Apache License 2.0 | 4 votes |
public ViewHolder(View itemView) { super(itemView); mBinding = DataBindingUtil.bind(itemView); }
Example 16
Source File: SpellAdapter.java From Theogony with MIT License | 4 votes |
public ViewHolder(View itemView) { super(itemView); binder = DataBindingUtil.bind(itemView); ButterKnife.bind(this, itemView); }
Example 17
Source File: HoldCartAdapter.java From mobikul-standalone-pos with MIT License | 4 votes |
public ViewHolder(View itemView) { super(itemView); binding = DataBindingUtil.bind(itemView.getRootView()); }
Example 18
Source File: MyAdapter.java From Fairy with Apache License 2.0 | 4 votes |
public MyViewHolder(View itemView) { super(itemView); binding = DataBindingUtil.bind(itemView); }
Example 19
Source File: BindingHolder.java From droidkaigi2016 with Apache License 2.0 | 4 votes |
public BindingHolder(@NonNull Context context, @NonNull ViewGroup parent, @LayoutRes int layoutResId) { super(LayoutInflater.from(context).inflate(layoutResId, parent, false)); binding = DataBindingUtil.bind(itemView); }
Example 20
Source File: CharacterViewHolder.java From marvel with MIT License | 3 votes |
public CharacterViewHolder(View view) { super(view); this.view = view; binding = DataBindingUtil.bind(view); }