Search in sources :

Example 1 with SpecialViewHolder

use of com.amaze.filemanager.adapters.holders.SpecialViewHolder in project AmazeFileManager by TeamAmaze.

the class RecyclerAdapter method onCreateViewHolder.

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view;
    switch(viewType) {
        case TYPE_HEADER_FOLDERS:
        case TYPE_HEADER_FILES:
            if (mainFrag.IS_LIST) {
                view = mInflater.inflate(R.layout.list_header, parent, false);
            } else {
                view = mInflater.inflate(R.layout.grid_header, parent, false);
            }
            int type = viewType == TYPE_HEADER_FOLDERS ? SpecialViewHolder.HEADER_FOLDERS : SpecialViewHolder.HEADER_FILES;
            return new SpecialViewHolder(context, view, utilsProvider, type);
        case TYPE_ITEM:
            if (mainFrag.IS_LIST) {
                view = mInflater.inflate(R.layout.rowlayout, parent, false);
                sizeProvider.addView(VIEW_GENERIC, view.findViewById(R.id.generic_icon));
                sizeProvider.addView(VIEW_PICTURE, view.findViewById(R.id.picture_icon));
                sizeProvider.addView(VIEW_APK, view.findViewById(R.id.apk_icon));
            } else {
                view = mInflater.inflate(R.layout.griditem, parent, false);
                sizeProvider.addView(VIEW_GENERIC, view.findViewById(R.id.generic_icon));
                sizeProvider.addView(VIEW_THUMB, view.findViewById(R.id.icon_thumb));
            }
            sizeProvider.closeOffAddition();
            return new ItemViewHolder(view);
        case EMPTY_LAST_ITEM:
            int totalFabHeight = (int) context.getResources().getDimension(R.dimen.fab_height), marginFab = (int) context.getResources().getDimension(R.dimen.fab_margin);
            view = new View(context);
            view.setMinimumHeight(totalFabHeight + marginFab);
            return new EmptyViewHolder(view);
        default:
            throw new IllegalArgumentException("Illegal: " + viewType);
    }
}
Also used : SpecialViewHolder(com.amaze.filemanager.adapters.holders.SpecialViewHolder) EmptyViewHolder(com.amaze.filemanager.adapters.holders.EmptyViewHolder) ImageView(android.widget.ImageView) View(android.view.View) RoundedImageView(com.amaze.filemanager.ui.views.RoundedImageView) RecyclerView(android.support.v7.widget.RecyclerView) ItemViewHolder(com.amaze.filemanager.adapters.holders.ItemViewHolder)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 EmptyViewHolder (com.amaze.filemanager.adapters.holders.EmptyViewHolder)1 ItemViewHolder (com.amaze.filemanager.adapters.holders.ItemViewHolder)1 SpecialViewHolder (com.amaze.filemanager.adapters.holders.SpecialViewHolder)1 RoundedImageView (com.amaze.filemanager.ui.views.RoundedImageView)1