Java Code Examples for android.databinding.DataBindingUtil#inflate()

The following examples show how to use android.databinding.DataBindingUtil#inflate() . 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: PullRequestAdapter.java    From Anago with Apache License 2.0 6 votes vote down vote up
@NonNull
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    PullRequestListItemBinding binding;
    if (convertView == null) {
        binding = DataBindingUtil.inflate(LayoutInflater.from(getContext()), R.layout.pull_request_list_item, parent, false);
        binding.setViewModel(injector.pullRequestListItemViewModel());
    } else {
        binding = DataBindingUtil.getBinding(convertView);
    }

    PullRequestListItemViewModel viewModel = binding.getViewModel();
    viewModel.pullRequest.set(getItem(position));

    return binding.getRoot();
}
 
Example 2
Source File: QuestionFragment.java    From triviums with MIT License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    binding = DataBindingUtil.inflate(inflater, R.layout.fragment_question, container,
            false);
    View view = binding.getRoot();
    binding.setClick(new MyHandler());

    getIntents();

    connectivityReceiver.observe(this, connectionModel -> {
        if (connectionModel.isConnected()) {
            isConnected = true;
            binding.loader.setVisibility(View.VISIBLE);
            getQuestion(categoryId, page);
        } else {
            isConnected = false;
            showDialogForTimeout();
        }
    });

    return view;
}
 
Example 3
Source File: VRAdapter.java    From VRPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    ItemVrListBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.item_vr_list, parent, false);
    ViewHolder viewHolder = new ViewHolder(binding);
    binding.setViewHolder(viewHolder);
    return viewHolder;
}
 
Example 4
Source File: MainRVAdapter.java    From Flubber with Apache License 2.0 5 votes vote down vote up
@Override
public BaseViewHolder<?> onCreateViewHolder(ViewGroup parent, int viewType) {
    final LayoutInflater inflater = LayoutInflater.from(parent.getContext());

    if (viewType == HEADER) {
        return new BaseViewHolder<>(inflater.inflate(R.layout.list_item_main_panel_header, parent, false));
    } else {
        final ListItemAnimationsBinding binding =
                DataBindingUtil.inflate(inflater, R.layout.list_item_animations, parent, false);

        binding.setModel(new AnimationsListItemModel());

        return new ItemViewHolder(binding);
    }
}
 
Example 5
Source File: AddTaxFragment.java    From mobikul-standalone-pos with MIT License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    binding = DataBindingUtil.inflate(inflater, R.layout.fragment_add_tax, container, false);
    return binding.getRoot();
}
 
Example 6
Source File: SourceAdapter.java    From NewsApp with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
@Override
public SourceViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) {
    if (layoutInflater == null) {
        layoutInflater = LayoutInflater.from(parent.getContext());
    }
    SourceItemBinding binding =
            DataBindingUtil.inflate(layoutInflater, R.layout.source_item, parent, false);
    return new SourceViewHolder(binding);
}
 
Example 7
Source File: LabelIfoAdapter.java    From YuanNewsForAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    LabelFragmentItemBinding binding= DataBindingUtil.inflate(inflater, R.layout.label_fragment_item,parent,false);
    convertView=binding.getRoot();
    final TasteVo tasteVo = tasteVos.get(position);
    binding.setLabel(tasteVo.getLabel());
    binding.num.setText((position+1)+"");
    binding.btnDelete.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onDeleteItemClick.onDelete(tasteVo,position);
        }
    });
    return convertView;
}
 
Example 8
Source File: FragmentHome.java    From StudentAttendanceCheck with MIT License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    b = DataBindingUtil.inflate(inflater, R.layout.fragment_home, container, false);
    View rootView = b.getRoot();
    initInstances(rootView, savedInstanceState);
    return rootView;
}
 
Example 9
Source File: PullRequestListFragment.java    From Anago with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    PullRequestListFragmentBinding binding = DataBindingUtil.inflate(inflater, R.layout.pull_request_list_fragment, container, false);
    binding.setViewModel(viewModel);

    binding.listView.setAdapter(new PullRequestAdapter(getContext(), getInjector(), viewModel.pullRequests));

    return binding.getRoot();
}
 
Example 10
Source File: FragmentData.java    From iGap-Android with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment

    fragmentDataBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_data, container, false);
    return attachToSwipeBack(fragmentDataBinding.getRoot());
}
 
Example 11
Source File: FragmentRegistrationNickname.java    From iGap-Android with GNU Affero General Public License v3.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

    fragmentRegistrationNicknameBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_registration_nickname, container, false);
    return fragmentRegistrationNicknameBinding.getRoot();
}
 
Example 12
Source File: BannerAdapter.java    From demo4Fish with MIT License 5 votes vote down vote up
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    ItemBannerListBinding binding = DataBindingUtil.inflate(
            LayoutInflater.from(mContext),
            R.layout.item_banner_list,
            parent,
            false);
    ViewHolder holder = new ViewHolder(binding);
    if (mListener != null) {
        binding.ivBanner.setOnClickListener(mListener);
    }
    return holder;
}
 
Example 13
Source File: RadioRVAdapter.java    From Flubber with Apache License 2.0 5 votes vote down vote up
@Override
public BindingHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    final LayoutInflater inflater = LayoutInflater.from(context);

    final ListItemRadioBinding binding =
            DataBindingUtil.inflate(inflater, R.layout.list_item_radio, parent, false);

    return new BindingHolder(binding);
}
 
Example 14
Source File: StockSummaryFragment.java    From Building-Professional-Android-Applications with MIT License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    binding = DataBindingUtil.inflate(
            inflater, R.layout.portfolio_fragment_stock_summary, container, false);
    View view = binding.getRoot();
    return view;
}
 
Example 15
Source File: ChannelSearchResultAdapter.java    From Conversations with GNU General Public License v3.0 4 votes vote down vote up
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
    return new ViewHolder(DataBindingUtil.inflate(LayoutInflater.from(viewGroup.getContext()), R.layout.search_result_item, viewGroup, false));
}
 
Example 16
Source File: SaleNHAssetActivity.java    From AndroidWallet with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void initViewObservable() {
    dialog = new BottomSheetDialog(this);
    DialogSaleNhassetConfirmLayoutBinding binding = DataBindingUtil.inflate(LayoutInflater.from(Utils.getContext()), R.layout.dialog_sale_nhasset_confirm_layout, null, false);
    dialog.setContentView(binding.getRoot());
    View parent = (View) binding.getRoot().getParent();
    BottomSheetBehavior behavior = BottomSheetBehavior.from(parent);
    binding.getRoot().measure(0, 0);
    behavior.setPeekHeight(binding.getRoot().getMeasuredHeight());
    CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) parent.getLayoutParams();
    params.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
    parent.setLayoutParams(params);
    dialog.setCanceledOnTouchOutside(false);
    final SaleNhConfirmViewModel orderConfirmViewModel = new SaleNhConfirmViewModel(getApplication());
    binding.setViewModel(orderConfirmViewModel);
    viewModel.uc.saleNHNBtnObservable.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
        @Override
        public void onPropertyChanged(Observable observable, int i) {
            try {
                if (TextUtils.isEmpty(viewModel.salePricesAmount.get())) {
                    ToastUtils.showShort(R.string.module_mine_nh_asset_sale_price_hint);
                    return;
                }
                if (TextUtils.isEmpty(viewModel.saleValidTime.get())) {
                    ToastUtils.showShort(R.string.module_mine_nh_asset_sale_valid_time_hint);
                    return;
                }

                if (TextUtils.equals(viewModel.saleValidTime.get(), "0")) {
                    ToastUtils.showShort(R.string.module_mine_nh_asset_sale_valid_time_less_than_one);
                    return;
                }

                if (Long.valueOf(Objects.requireNonNull(viewModel.saleValidTime.get())) > viewModel.saleValidTimeMax) {
                    viewModel.saleValidTime.set(String.valueOf(viewModel.saleValidTimeMax));
                    return;
                }

                if (new BigDecimal(viewModel.salePricesAmount.get()).compareTo(BigDecimal.ZERO) < 0) {
                    ToastUtils.showShort(R.string.module_mine_sale_nh_price_error);
                    return;
                }
                SaleNHAssetParamsModel saleNHAssetParamsModel = new SaleNHAssetParamsModel();
                saleNHAssetParamsModel.setNhAssetId(nhAssetModelBean.id);
                saleNHAssetParamsModel.setPriceAmount(viewModel.salePricesAmount.get());
                saleNHAssetParamsModel.setPriceSymbol(viewModel.salePricesSymbol.get());
                saleNHAssetParamsModel.setOrderMemo(viewModel.saleMemo.get());
                saleNHAssetParamsModel.setValidTime(Long.parseLong(viewModel.saleValidTime.get()));
                orderConfirmViewModel.setSaleInfoData(saleNHAssetParamsModel);
                dialog.show();
            } catch (Exception e) {
            }
        }
    });

    viewModel.uc.choosePriceSymbolObservable.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
        @Override
        public void onPropertyChanged(Observable sender, int propertyId) {
            Bundle bundle = new Bundle();
            bundle.putInt(IntentKeyGlobal.SALE_TO_SYMBOL_SELECT, IntentKeyGlobal.GET_CONTACT);
            ARouter.getInstance().
                    build(RouterActivityPath.ACTIVITY_SYMBOL_LIST).
                    with(bundle).
                    navigation(SaleNHAssetActivity.this, IntentKeyGlobal.REQ_SYMBOL_SELECT_CODE);
        }
    });
}
 
Example 17
Source File: QuestionFragment.java    From triviums with MIT License 4 votes vote down vote up
/**
 * This method shows the quiz score by calling a Dialog
 */
private void showScoreDialog() {

    //Create a dialog
    if (getActivity() != null) {

        dialog = new Dialog(getActivity());

        //Get custom view
        ScoreDialogBinding dialogBinding = DataBindingUtil.inflate(
                LayoutInflater.from(getActivity()), R.layout.score_dialog, null,
                false);
        dialog.setContentView(dialogBinding.getRoot());

        //Score conditions
        if (questionScore >= 8) {
            saveProgressInCloud();

            dialogBinding.playerName.setText(getResources().getString(R.string.score_pass));

            dialogBinding.congratsMsg.setText(getResources().getString(R.string.pass_message));

            dialogBinding.scoreTxt.setText(String.valueOf(questionScore));

        } else {
            dialogBinding.playerName.setText(getResources().getString(R.string.score_fail));

            dialogBinding.congratsMsg.setText(getResources().getString(R.string.fail_message));

            dialogBinding.scoreTxt.setText(String.valueOf(questionScore));
        }

        countDownTimer = new CountDownTimer(2L, TimeUnit.SECONDS) {
            @Override
            public void onTick(long tickValue) {

            }

            @Override
            public void onFinish() {
                dismissDialog();
            }
        };
        countDownTimer.start();

        dialog.show();
    }
}
 
Example 18
Source File: SongMenuFragment.java    From AndroidSkinAnimator with MIT License 4 votes vote down vote up
@Override
protected void onCreateVew(LayoutInflater inflater, Bundle savedInstanceState) {
    super.onCreateVew(inflater, savedInstanceState);
    mHeaderBinding = DataBindingUtil.inflate(LayoutInflater.from(getContext()), R.layout.header_song_item, null, false);
    initRecyclerView();
}
 
Example 19
Source File: WebViewAgreementDialogFragment.java    From nano-wallet-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    binding = DataBindingUtil.inflate(
            inflater, R.layout.fragment_webview_agreement, container, false);
    view = binding.getRoot();

    setStatusBarWhite(view);

    binding.webviewAgreementSwiperefresh.setOnRefreshListener(mSwipeRefreshListener);
    binding.setHandlers(new ClickHandlers());

    // set the listener for Navigation
    if (binding.dialogAppbar != null) {
        final WebViewAgreementDialogFragment window = this;
        binding.dialogAppbar.setTitle(mTitle);
        binding.dialogAppbar.setNavigationOnClickListener(v1 -> {
            KeyboardUtil.hideKeyboard(getActivity());
            window.dismiss();
        });

        binding.dialogAppBarProgress.setIndeterminate(true);
    }

    binding.webviewAgreementWebview.setWebViewClient(new WebViewClient() {});
    binding.webviewAgreementWebview.setWebChromeClient(mWebChromeClient);
    binding.webviewAgreementWebview.setInitialScale(1);
    binding.webviewAgreementWebview.getSettings().setDomStorageEnabled(true);
    binding.webviewAgreementWebview.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    binding.webviewAgreementWebview.getSettings().setLoadWithOverviewMode(true);
    binding.webviewAgreementWebview.getSettings().setUseWideViewPort(true);

    binding.webviewAgreementWebview.loadUrl(mUrl);

    binding.webviewAgreementWebview.setOnScrollChangedCallback((l, t, oldl, oldt) -> {
        int height = (int) Math.floor(binding.webviewAgreementWebview.getContentHeight() * binding.webviewAgreementWebview.getScale());
        int webViewHeight = binding.webviewAgreementWebview.getMeasuredHeight();
        if(binding.webviewAgreementWebview.getScrollY() + webViewHeight >= (height - 10)){
            binding.webviewAgreementAcceptButton.setEnabled(true);
        }
    });

    return view;
}
 
Example 20
Source File: ListBindingAdapters.java    From android-ui-toolkit-demos with Apache License 2.0 3 votes vote down vote up
/**
 * Inflates and binds a layout to an entry to the {@code data} variable
 * of the bound layout.
 *
 * @param inflater    The LayoutInflater
 * @param parent      The ViewGroup containing the list of Views
 * @param layoutId    The layout ID to use for the list item
 * @param entry       The data to bind to the inflated View
 * @return A ViewDataBinding, bound to a newly-inflated View with {@code entry}
 * set as the {@code data} variable.
 */
private static ViewDataBinding bindLayout(LayoutInflater inflater,
        ViewGroup parent, int layoutId, Object entry) {
    ViewDataBinding binding = DataBindingUtil.inflate(inflater,
            layoutId, parent, false);
    if (!binding.setVariable(BR.data, entry)) {
        String layoutName = parent.getResources().getResourceEntryName(layoutId);
        Log.w(TAG, "There is no variable 'data' in layout " + layoutName);
    }
    return binding;
}