@Override public MultiRecyclerViewAdapter.BindingHolder onCreateViewHolder(ViewGroup parent, int viewType) { ViewDataBinding binding; if (viewType == 0) { binding = DataBindingUtil.inflate( LayoutInflater.from(parent.getContext()), R.layout.adapter_recycler_view_other, parent, false); } else { binding = DataBindingUtil.inflate( LayoutInflater.from(parent.getContext()), R.layout.adapter_recycler_view, parent, false); } BindingHolder holder = new BindingHolder(binding.getRoot()); holder.setBinding(binding); return holder; }
@Override protected void convert(MovieViewHolder helper, Movie item) { ViewDataBinding binding = helper.getBinding(); binding.setVariable(BR.movie, item); binding.setVariable(BR.presenter, mPresenter); binding.executePendingBindings(); switch (helper.getLayoutPosition() % 2) { case 0: helper.setImageResource(R.id.iv, R.mipmap.m_img1); break; case 1: helper.setImageResource(R.id.iv, R.mipmap.m_img2); break; } }
@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()); }
/** * Generate an ActivityCompatInterface with given activity and binding. * * @param activity * @param binding * @param <V> * @return */ public static <V extends ViewDataBinding> ActivityCompatInterface<V> activityCompatInterface(final AppCompatActivity activity, final V binding) { return new ActivityCompatInterface<V>() { @Override public AppCompatActivity getCompatActivity() { return activity; } @Override public Context getContext() { return activity; } @Override public V getBinding() { return binding; } }; }
public ItemViewHolder(ViewDataBinding binding) { super(binding); itemModel = new ItemModel(); ReflectionHelper.run(binding,"set",itemModel); itemModel.selected.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() { @Override public void onPropertyChanged(Observable sender, int propertyId) { if(!updateSelected) return; if(selectedItems == null) return; if(selectedItems.contains(model)){ if(allowMultipleSelection){ selectedItems.remove(model); } }else{ if(!allowMultipleSelection){ selectedItems.clear(); } selectedItems.add(model); } } }); }
@Override protected void showCustomDialog(VH vh, Activity activity, ViewDataBinding binding, SettData settData, boolean global, CLASS customSettingsObject) { // show a dialog; make sure to register a custom dialog handler in the settings setup once!!! // this one then is responsible to save a user changed value Data data = getValue(customSettingsObject, global); // for this demo we use a single image picker for global values only, so we use this example image picker; // normally you would need a dialog you can add the settings id to so that the dialog can dispatch the selection event and // the settings manager can handle it // for this demo we simply handle the image select event in the activity and as we know // that we have a single setting for this event only we also now the settings id to use for disatching the event ImagePicker.with(activity) .setCameraOnly(false) .setMultipleMode(false) .setFolderMode(true) .setFolderTitle("Albums") .setImageTitle("Galleries") .setDoneTitle("Done") .setSavePath("ImagePicker") .start(); }
@Override protected View getItemView(int layoutResId, ViewGroup parent) { ViewDataBinding binding = DataBindingUtil.inflate(mLayoutInflater, layoutResId, parent, false); if (binding == null) { return super.getItemView(layoutResId, parent); } View view = binding.getRoot(); view.setTag(R.id.BaseQuickAdapter_databinding_support, binding); return view; }
@Override protected void setDataBindingVariables(ViewDataBinding binding) { LayoutCombineChartBinding b = (LayoutCombineChartBinding) binding; CandlestickDataSet dataSet = new CandlestickDataSet(candlestickValues); dataSet.setHighlightedVerticalEnable(true); b.combineChart.getAxisLeft().setAxisPosition(LEFT_OUTSIDE); b.combineChart.getAxisRight().setAxisPosition(RIGHT_INSIDE); b.combineChart.setMaxVisibleEntryCount(20); b.combineChart.setHighlightColor(Color.BLACK); b.combineChart.setOnHighlightStatusChangeListener(highlightStatusChangeListener); b.combineChart.setDataSet(dataSet); }
/** * Generate a ViewInterface with a given binding. * * @param binding the binding * @param <V> the type of the binding. * @return a ViewInterface with a context and a binding. */ public static <V extends ViewDataBinding> ViewInterface<V> viewInterface(final V binding) { return new ViewInterface<V>() { @Override public Context getContext() { return binding.getRoot().getContext(); } @Override public V getBinding() { return binding; } }; }
@Override public BindingViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { ViewDataBinding binding; if (viewType == ITEM_VIEW_TYPE_ON) { binding = DataBindingUtil.inflate(mLayoutInflater, R.layout.item_employee, parent, false); } else { binding = DataBindingUtil.inflate(mLayoutInflater, R.layout.item_employee_off, parent, false); } return new BindingViewHolder(binding); }
public SwordsmanViewHolder(ViewDataBinding binding) { super(binding.getRoot()); this.binding = (ItemSwordsmanBinding) binding; }
private static void bind(ViewGroup viewGroup, ItemView itemView, List<?> viewModelList, final OnItemClickListener<?> onItemClickListener) { if (viewModelList != null && !viewModelList.isEmpty()) { viewGroup.removeAllViews(); for (int pos=0; pos<viewModelList.size(); pos++) { final Object viewModel = viewModelList.get(pos); final ViewDataBinding binding = DataBindingUtil.inflate(LayoutInflater.from(viewGroup.getContext()), itemView.layoutRes(), viewGroup, true); binding.setVariable(itemView.bindingVariable(), viewModel); setListener(onItemClickListener, ViewHolder.createViewHolder(viewGroup.getContext(), binding.getRoot()), viewModel, pos); } } }
public BookViewHolder(ViewDataBinding binding, int variableId) { super(binding.getRoot()); mBinding = binding; mVariableId = variableId; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ViewDataBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_currencies); binding.setVariable(BR.model, mViewModel); if (!isRetained(savedInstanceState)) { mViewModel.onLoad(null); } }
@Override protected void setDataBindingVariables(ViewDataBinding binding) { if (binding instanceof LayoutBarChartBinding) { LayoutBarChartBinding barBinding = (LayoutBarChartBinding) binding; barBinding.barChart.setDataSet(barDataSet); barBinding.barChart.getAxisRight().setLabelTextColor(Color.BLACK); } }
@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); } }
@Override public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { if (viewType == 0) { return null; } ViewDataBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), viewType, parent, false); return new BaseViewHolder(binding); }
@Override public BindableViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { ViewDataBinding binding = DataBindingUtil.inflate(LayoutInflater.from(getContext()),viewType, parent, false); if(viewType == headerLayoutId || viewType == footerLayoutId){ return new HeaderFooterViewHolder(binding); } return new ItemViewHolder(binding) ; }
@Override public void onShowChangeSetting(VH vh, Activity activity, ViewDataBinding binding, SettData settData, boolean global, CLASS customSettingsObject) { // Spinner geht mit EventHook // Falls Container geklickt wird, leiten wir das Event an den Spinner weiter ((Spinner) vh.getValueTopView()).performClick(); }
@Override public void onBindViewHolder(DataBindingViewHolder holder, int position) { super.onBindViewHolder(holder, position); ViewDataBinding binding = holder.getBinding(); binding.setVariable(BR.listener, mStoryListener); binding.executePendingBindings(); }
@Override public final void onBindViewHolder(RecyclerView.ViewHolder holder, int position, List<Object> payloads) { if (isForDataBinding(payloads)) { ViewDataBinding binding = DataBindingUtil.getBinding(holder.itemView); binding.executePendingBindings(); } else { super.onBindViewHolder(holder, position, payloads); } }
private RecyclerView.ViewHolder onCreateViewHolder(ViewDataBinding binding) { if (null != viewHolderFactory) { return viewHolderFactory.createViewHolder(binding); } else { return new BindingViewHolder(binding); } }
BaseViewHolder(ViewDataBinding binding) { super(binding.getRoot()); mBinding = binding; }
@Override public void onShowChangeSetting(VH vh, Activity activity, ViewDataBinding binding, SettData settData, boolean global, CLASS customSettingsObject) { new ColorSettingsDialogFragmentBundleBuilder( getSettingId(), global, getValue(customSettingsObject, global), getTitle().toString() ) .createFragment() .show(((FragmentActivity) activity).getSupportFragmentManager(), null); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ViewDataBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_currency_details); binding.setVariable(BR.model, mViewModel); if (!isRetained(savedInstanceState)) { final String currencyCode = getIntent().getStringExtra(INTENT_EXTRA_PARAM_CURRENCY_CODE); Bundle bundle = new Bundle(); bundle.putString(CurrencyDetailsViewModel.KEY_CURRENCY_CODE, currencyCode); mViewModel.onLoad(bundle); } }
public ViewDataBinding getBinding() { return binding; }
public void setBinding(ViewDataBinding binding) { this.binding = binding; }
public ViewDataBinding getBinding() { return (ViewDataBinding) itemView.getTag(R.id.BaseQuickAdapter_databinding_support); }
@Override public void onShowChangeSetting(VH vh, Activity activity, ViewDataBinding binding, SettData settData, boolean global, CLASS customSettingsObject) { // nichts zu tun, EditText geht direkt }
@Override public final void onShowChangeSetting(VH vh, Activity activity, ViewDataBinding binding, SettData settData, boolean global, CLASS customSettingsObject) { showCustomDialog(vh, activity, binding, settData, global, customSettingsObject); }
public ViewDataBinding getBinding() { return this.binding; }
@Override public FileAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { ViewDataBinding binding = DataBindingUtil .inflate(LayoutInflater.from(parent.getContext()), R.layout.file_row, parent, false); return new ViewHolder(binding, this); }
@Override protected Object initItem(ViewGroup container, SwipeRecyclerViewModel item, String title, int position) { ViewDataBinding binding = ViewModelBinder.bind(container, item); return binding.getRoot(); }
@Override protected void convert(BaseBindHolder helper, TextContent item) { ViewDataBinding binding = helper.getBinding(); binding.setVariable(BR.content, item); binding.executePendingBindings(); }