@@ -0,0 +1,3267 @@
+package me.panpf.adapter;%0A%0Aimport android.content.Context;%0Aimport android.support.annotation.LayoutRes;%0Aimport android.support.annotation.NonNull;%0Aimport android.support.annotation.Nullable;%0Aimport android.view.LayoutInflater;%0Aimport android.view.View;%0Aimport android.view.ViewGroup;%0A%0A@SuppressWarnings(%7B%22WeakerAccess%22, %22unused%22%7D)%0Apublic class ViewItemFactory extends AssemblyItemFactory%3CViewItemFactory.ViewItem%3E %7B%0A%0A    @NonNull%0A    private ViewFactory viewFactory;%0A    @Nullable%0A    private Class%3C?%3E dataClazz;%0A    @Nullable%0A    private OnClickViewListener listener;%0A%0A    public ViewItemFactory(@NonNull ViewFactory viewFactory, @Nullable Class%3C?%3E dataClazz, @Nullable OnClickViewListener listener) %7B%0A        this.viewFactory = viewFactory;%0A        this.dataClazz = dataClazz;%0A        this.listener = listener;%0A    %7D%0A%0A    public ViewItemFactory(@NonNull ViewFactory viewFactory, @Nullable Class%3C?%3E dataClazz) %7B%0A        this(viewFactory, dataClazz, null);%0A    %7D%0A%0A    public ViewItemFactory(@NonNull ViewFactory viewFactory, @Nullable OnClickViewListener listener) %7B%0A        this(viewFactory, null, listener);%0A    %7D%0A%0A    public ViewItemFactory(@NonNull ViewFactory viewFactory) %7B%0A        this(viewFactory, null, null);%0A    %7D%0A%0A    public ViewItemFactory(@LayoutRes final int layoutResId, @Nullable Class%3C?%3E dataClazz, @Nullable OnClickViewListener listener) %7B%0A        this(new ViewFactory() %7B%0A            @NonNull%0A            @Override%0A            public View createItemView(@NonNull ViewGroup parent) %7B%0A                return LayoutInflater.from(parent.getContext()).inflate(layoutResId, parent, false);%0A            %7D%0A        %7D, dataClazz, listener);%0A    %7D%0A%0A    public ViewItemFactory(@LayoutRes final int layoutResId, @Nullable Class%3C?%3E dataClazz) %7B%0A        this(layoutResId, dataClazz, null);%0A    %7D%0A%0A    public ViewItemFactory(@LayoutRes final int layoutResId, @Nullable OnClickViewListener listener) %7B%0A        this(layoutResId, null, listener);%0A    %7D%0A%0A    public ViewItemFactory(@LayoutRes final int layoutResId) %7B%0A        this(layoutResId, null, null);%0A    %7D%0A%0A    @Override%0A    public boolean isTarget(@Nullable Object data) %7B%0A        return dataClazz == null %7C%7C dataClazz.isInstance(data);%0A    %7D%0A%0A    @NonNull%0A    @Override%0A    public ViewItem createAssemblyItem(@NonNull ViewGroup parent) %7B%0A        return new ViewItem(viewFactory.createItemView(parent));%0A    %7D%0A%0A    public interface ViewFactory %7B%0A        @NonNull%0A        View createItemView(@NonNull ViewGroup parent);%0A    %7D%0A%0A    public interface OnClickViewListener %7B%0A        void onClickView(int position, @Nullable Object data);%0A    %7D%0A%0A    public class ViewItem extends AssemblyItem%3CObject%3E %7B%0A%0A        ViewItem(@NonNull View itemView) %7B%0A            super(itemView);%0A        %7D%0A%0A        @Override%0A        protected void onConfigViews(@NonNull Context context) %7B%0A            if (listener != null) %7B%0A                getItemView().setOnClickListener(new View.OnClickListener() %7B%0A                    @Override%0A                    public void onClick(View v) %7B%0A                        listener.onClickView(getAdapterPosition(), getData());%0A                    %7D%0A                %7D);%0A            %7D%0A        %7D%0A%0A        @Override%0A        protected void onSetData(int position, @Nullable Object o) %7B%0A%0A        %7D%0A    %7D%0A%7D%0A

Add ViewItemFactory