Java Code Examples for androidx.databinding.DataBindingUtil#getBinding()
The following examples show how to use
androidx.databinding.DataBindingUtil#getBinding() .
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: MainAdapter.java From EspressoDescendantActions with Apache License 2.0 | 5 votes |
@Override public void onBindViewHolder(@NonNull BindingHolder holder, int position) { AdapterItemBinding binding = DataBindingUtil.getBinding(holder.itemView); if (binding != null) { binding.setDataItem(dataItems[position]); } }
Example 2
Source File: BookAdapter.java From CloudReader with Apache License 2.0 | 5 votes |
FooterViewHolder(View itemView) { super(itemView); mBindFooter = DataBindingUtil.getBinding(itemView); mBindFooter.rlMore.setGravity(Gravity.CENTER); // LinearLayoutCompat.LayoutParams params = new LinearLayoutCompat.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ScreenUtils.dipToPx(context, 40)); // itemView.setLayoutParams(params); }
Example 3
Source File: UserProfileAccomplishmentsFragment.java From edx-app-android with Apache License 2.0 | 5 votes |
@NonNull @Override protected UserProfileAccomplishmentsPresenter.ViewInterface createView() { final FragmentUserProfileAccomplishmentsBinding binding = DataBindingUtil.getBinding(getView()); final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext()); binding.list.setLayoutManager(linearLayoutManager); binding.list.addOnScrollListener(new InfiniteScrollUtils.RecyclerViewOnScrollListener(linearLayoutManager, new Runnable() { @Override public void run() { presenter.onScrolledToEnd(); } })); final AccomplishmentListAdapter adapter = createAdapter( new AccomplishmentListAdapter.Listener() { @Override public void onShare(@NonNull BadgeAssertion badgeAssertion) { presenter.onClickShare(badgeAssertion); } }); binding.list.setAdapter(adapter); return new UserProfileAccomplishmentsPresenter.ViewInterface() { @Override public void setModel(@NonNull UserProfileAccomplishmentsPresenter.ViewModel model) { adapter.setItems(model.badges); adapter.setPageLoading(model.pageLoading); adapter.setSharingEnabled(model.enableSharing); } @Override public void startBadgeShareIntent(@NonNull String badgeUrl) { final Map<String, CharSequence> shareTextParams = new HashMap<>(); shareTextParams.put("platform_name", getString(R.string.platform_name)); shareTextParams.put("badge_url", badgeUrl); final String shareText = ResourceUtil.getFormattedString(getResources(), R.string.share_accomplishment_message, shareTextParams).toString(); startActivity(ShareUtils.newShareIntent(shareText)); } }; }
Example 4
Source File: UserProfileBioFragment.java From edx-app-android with Apache License 2.0 | 5 votes |
@NonNull @Override protected UserProfileBioPresenter.ViewInterface createView() { final FragmentUserProfileBioBinding viewHolder = DataBindingUtil.getBinding(getView()); final View.OnClickListener listener = new View.OnClickListener() { @Override public void onClick(View v) { presenter.onEditProfile(); } }; viewHolder.parentalConsentEditProfileButton.setOnClickListener(listener); viewHolder.incompleteEditProfileButton.setOnClickListener(listener); return new UserProfileBioPresenter.ViewInterface() { @Override public void showBio(UserProfileBioModel bio) { viewHolder.profileBioContent.setVisibility(View.VISIBLE); viewHolder.parentalConsentRequired.setVisibility(bio.contentType == UserProfileBioModel.ContentType.PARENTAL_CONSENT_REQUIRED ? View.VISIBLE : View.GONE); viewHolder.incompleteContainer.setVisibility(bio.contentType == UserProfileBioModel.ContentType.INCOMPLETE ? View.VISIBLE : View.GONE); viewHolder.noAboutMe.setVisibility(bio.contentType == UserProfileBioModel.ContentType.NO_ABOUT_ME ? View.VISIBLE : View.GONE); viewHolder.bioText.setVisibility(bio.contentType == UserProfileBioModel.ContentType.ABOUT_ME ? View.VISIBLE : View.GONE); viewHolder.bioText.setText(bio.bioText); viewHolder.bioText.setContentDescription(ResourceUtil.getFormattedString(getResources(), R.string.profile_about_me_description, "about_me", bio.bioText)); prefersScrollingHeader = bio.contentType == UserProfileBioModel.ContentType.ABOUT_ME; ((ScrollingPreferenceParent)getParentFragment()).onChildScrollingPreferenceChanged(); } @Override public void navigateToProfileEditor(String username) { router.showUserProfileEditor(getActivity(), username); } }; }
Example 5
Source File: BookAdapter.java From CloudReader with Apache License 2.0 | 4 votes |
HeaderViewHolder(View view) { super(view); mBindBook = DataBindingUtil.getBinding(view); }
Example 6
Source File: BookAdapter.java From CloudReader with Apache License 2.0 | 4 votes |
BookViewHolder(View view) { super(view); mBindBook = DataBindingUtil.getBinding(view); }
Example 7
Source File: BaseBindingHolder.java From CloudReader with Apache License 2.0 | 4 votes |
public BaseBindingHolder(ViewGroup viewGroup, int layoutId) { super(DataBindingUtil.inflate(LayoutInflater.from(viewGroup.getContext()), layoutId, viewGroup, false).getRoot()); binding = DataBindingUtil.getBinding(this.itemView); }
Example 8
Source File: UserProfileAccomplishmentsFragmentTest.java From edx-app-android with Apache License 2.0 | 4 votes |
@Before public void before() { startFragment(new TestableUserProfileAccomplishmentsFragment(mockAdapter)); binding = DataBindingUtil.getBinding(fragment.getView()); assertThat(binding).isNotNull(); }
Example 9
Source File: UserProfileBioFragmentTest.java From edx-app-android with Apache License 2.0 | 4 votes |
@Before public void before() { startFragment(UserProfileBioFragment.newInstance()); binding = DataBindingUtil.getBinding(fragment.getView()); assertThat(binding).isNotNull(); }
Example 10
Source File: UserProfileFragmentTest.java From edx-app-android with Apache License 2.0 | 4 votes |
@Before public void before() { startFragment(TestableUserProfileFragment.newInstance(ProfileValues.USERNAME)); binding = DataBindingUtil.getBinding(fragment.getView()); assertNotNull(binding); }
Example 11
Source File: BaseViewHolder.java From GroupedRecyclerViewAdapter with Apache License 2.0 | 2 votes |
/** * 获取item对应的ViewDataBinding对象 * * @param <T> * @return */ public <T extends ViewDataBinding> T getBinding() { return DataBindingUtil.getBinding(this.itemView); }