Search in sources :

Example 1 with ListHeaderBinding

use of com.owncloud.android.databinding.ListHeaderBinding in project android by nextcloud.

the class OCFileListAdapter method onCreateViewHolder.

@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
    switch(viewType) {
        default:
        case VIEWTYPE_ITEM:
            if (gridView) {
                return new OCFileListGridItemViewHolder(GridItemBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
            } else {
                return new OCFileListItemViewHolder(ListItemBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
            }
        case VIEWTYPE_IMAGE:
            if (gridView) {
                return new OCFileListGridImageViewHolder(GridImageBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
            } else {
                return new OCFileListItemViewHolder(ListItemBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
            }
        case VIEWTYPE_FOOTER:
            return new OCFileListFooterViewHolder(ListFooterBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
        case VIEWTYPE_HEADER:
            ListHeaderBinding binding = ListHeaderBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
            ViewGroup.LayoutParams layoutParams = binding.headerView.getLayoutParams();
            layoutParams.height = (int) (parent.getHeight() * 0.3);
            binding.headerView.setLayoutParams(layoutParams);
            return new OCFileListHeaderViewHolder(binding);
    }
}
Also used : ViewGroup(android.view.ViewGroup) ListHeaderBinding(com.owncloud.android.databinding.ListHeaderBinding) NonNull(androidx.annotation.NonNull)

Aggregations

ViewGroup (android.view.ViewGroup)1 NonNull (androidx.annotation.NonNull)1 ListHeaderBinding (com.owncloud.android.databinding.ListHeaderBinding)1