Search in sources :

Example 1 with HomeLaoLayoutBinding

use of com.github.dedis.popstellar.databinding.HomeLaoLayoutBinding in project popstellar by dedis.

the class LAOListAdapter method getView.

@Override
public View getView(int position, View view, ViewGroup viewGroup) {
    HomeLaoLayoutBinding binding;
    if (view == null) {
        // inflate
        LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext());
        binding = HomeLaoLayoutBinding.inflate(inflater, viewGroup, false);
    } else {
        binding = DataBindingUtil.getBinding(view);
    }
    if (binding == null)
        throw new IllegalStateException("Binding could not be find in the view");
    LAOItemUserActionsListener userActionsListener = lao -> {
        if (openLaoDetail) {
            homeViewModel.openLAO(lao.getId());
        } else {
            homeViewModel.openLaoWallet(lao.getId());
        }
    };
    binding.setLao(laos.get(position));
    binding.setLifecycleOwner(lifecycleOwner);
    binding.setListener(userActionsListener);
    binding.executePendingBindings();
    return binding.getRoot();
}
Also used : List(java.util.List) BaseAdapter(android.widget.BaseAdapter) LifecycleOwner(androidx.lifecycle.LifecycleOwner) Lao(com.github.dedis.popstellar.model.objects.Lao) LayoutInflater(android.view.LayoutInflater) HomeLaoLayoutBinding(com.github.dedis.popstellar.databinding.HomeLaoLayoutBinding) View(android.view.View) ViewGroup(android.view.ViewGroup) DataBindingUtil(androidx.databinding.DataBindingUtil) LayoutInflater(android.view.LayoutInflater) HomeLaoLayoutBinding(com.github.dedis.popstellar.databinding.HomeLaoLayoutBinding)

Aggregations

LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 BaseAdapter (android.widget.BaseAdapter)1 DataBindingUtil (androidx.databinding.DataBindingUtil)1 LifecycleOwner (androidx.lifecycle.LifecycleOwner)1 HomeLaoLayoutBinding (com.github.dedis.popstellar.databinding.HomeLaoLayoutBinding)1 Lao (com.github.dedis.popstellar.model.objects.Lao)1 List (java.util.List)1