Java 类android.databinding.ViewDataBinding 实例源码

项目:Demos    文件:MultiRecyclerViewAdapter.java   
@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;
}
项目:GitHub    文件:DataBindingUseAdapter.java   
@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;

    }
}
项目:MVVMArms    文件:WeatherDailyAdapter.java   
@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());
}
项目:LiteReader    文件:ViewInterfaceGen.java   
/**
 * 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;
        }
    };
}
项目:ui-atoms-android    文件:AtomListView.java   
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);
            }
        }
    });
}
项目:RecyclerViewPreferences    文件:CustomImageSetting.java   
@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();
}
项目:GitHub    文件:DataBindingUseAdapter.java   
@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;
}
项目:JZAndroidChart    文件:CandlestickChartModel.java   
@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);
}
项目:LiteReader    文件:ViewInterfaceGen.java   
/**
 * 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;
        }
    };
}
项目:Android-Code-Demos    文件:EmployeeAdapter.java   
@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);
}
项目:android-advanced-light    文件:SwordsmanAdapter.java   
public SwordsmanViewHolder(ViewDataBinding binding) {
    super(binding.getRoot());
    this.binding = (ItemSwordsmanBinding) binding;
}
项目:MVVM-JueJin    文件:ViewGroupAdapter.java   
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);
        }
    }
}
项目:ActivityBuilder    文件:BookListAdapter.java   
public BookViewHolder(ViewDataBinding binding, int variableId) {
  super(binding.getRoot());
  mBinding = binding;
  mVariableId = variableId;
}
项目:exchange-rates-mvvm    文件:CurrenciesActivity.java   
@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);
    }
}
项目:JZAndroidChart    文件:BarChartModel.java   
@Override
protected void setDataBindingVariables(ViewDataBinding binding) {
    if (binding instanceof LayoutBarChartBinding) {

        LayoutBarChartBinding barBinding = (LayoutBarChartBinding) binding;

        barBinding.barChart.setDataSet(barDataSet);
        barBinding.barChart.getAxisRight().setLabelTextColor(Color.BLACK);
    }
}
项目:okuki    文件:ViewGroupBindings.java   
@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);
    }
}
项目:CommonLibrary    文件:RecyclerViewAdapter.java   
@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);
}
项目:ui-atoms-android    文件:AtomListView.java   
@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) ;
}
项目:RecyclerViewPreferences    文件:SpinnerSetting.java   
@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();

}
项目:shortstories    文件:StoryAdapter.java   
@Override
public void onBindViewHolder(DataBindingViewHolder holder, int position) {
    super.onBindViewHolder(holder, position);
    ViewDataBinding binding = holder.getBinding();
    binding.setVariable(BR.listener, mStoryListener);
    binding.executePendingBindings();
}
项目:Mvvm    文件:MvvmAdapter.java   
@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);
    }
}
项目:Mvvm    文件:MvvmAdapter.java   
private RecyclerView.ViewHolder onCreateViewHolder(ViewDataBinding binding) {
    if (null != viewHolderFactory) {
        return viewHolderFactory.createViewHolder(binding);
    } else {
        return new BindingViewHolder(binding);
    }
}
项目:GmArchMvvm    文件:BaseBindAdapter.java   
@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;
}
项目:MarsBootProject    文件:RecyclerViewAdapter.java   
BaseViewHolder(ViewDataBinding binding) {
    super(binding.getRoot());
    mBinding = binding;
}
项目:RecyclerViewPreferences    文件:ColorSetting.java   
@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);
}
项目:exchange-rates-mvvm    文件:CurrencyDetailsActivity.java   
@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);
    }
}
项目:MarsBootProject    文件:RecyclerViewAdapter.java   
@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);
}
项目:Demos    文件:MultiRecyclerViewAdapter.java   
public ViewDataBinding getBinding() {
    return binding;
}
项目:Demos    文件:MultiRecyclerViewAdapter.java   
public void setBinding(ViewDataBinding binding) {
    this.binding = binding;
}
项目:MVVMArms    文件:BaseBindHolder.java   
public ViewDataBinding getBinding() {
    return (ViewDataBinding) itemView.getTag(R.id.BaseQuickAdapter_databinding_support);
}
项目:RecyclerViewPreferences    文件:TextSetting.java   
@Override
public void onShowChangeSetting(VH vh, Activity activity, ViewDataBinding binding, SettData settData, boolean global, CLASS customSettingsObject) {
    // nichts zu tun, EditText geht direkt
}
项目:GitHub    文件:DataBindingUseAdapter.java   
public ViewDataBinding getBinding() {
    return (ViewDataBinding) itemView.getTag(R.id.BaseQuickAdapter_databinding_support);
}
项目:GitHub    文件:DataBindingUseAdapter.java   
public ViewDataBinding getBinding() {
    return (ViewDataBinding) itemView.getTag(R.id.BaseQuickAdapter_databinding_support);
}
项目:RecyclerViewPreferences    文件:BaseCustomViewSetting.java   
@Override
public final void onShowChangeSetting(VH vh, Activity activity, ViewDataBinding binding, SettData settData, boolean global, CLASS customSettingsObject) {
    showCustomDialog(vh, activity, binding, settData, global, customSettingsObject);
}
项目:recyclerview-ext    文件:MyExtAdapter.java   
public void setBinding(ViewDataBinding binding) {
    this.binding = binding;
}
项目:recyclerview-ext    文件:MyExtAdapter.java   
public ViewDataBinding getBinding() {
    return this.binding;
}
项目:Material-File-Picker    文件:FileAdapter.java   
@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);
}
项目:LiteReader    文件:ReviewViewPagerAdapter.java   
@Override
protected Object initItem(ViewGroup container, SwipeRecyclerViewModel item, String title, int position) {
    ViewDataBinding binding = ViewModelBinder.bind(container, item);
    return binding.getRoot();
}
项目:LiteReader    文件:ColumnViewPagerAdapter.java   
@Override
protected Object initItem(ViewGroup container, SwipeRecyclerViewModel item, String title, int position) {
    ViewDataBinding binding = ViewModelBinder.bind(container, item);
    return binding.getRoot();
}
项目:MVVMArms    文件:TextContentAdapter.java   
@Override
protected void convert(BaseBindHolder helper, TextContent item) {
    ViewDataBinding binding = helper.getBinding();
    binding.setVariable(BR.content, item);
    binding.executePendingBindings();
}