kimi
2021-02-18 749a5510a9f014446a3cd6ba57b3cb0cc8148dc1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
 * Copyright (c) 2020 WildFireChat. All rights reserved.
 */
 
package cn.wildfire.chat.kit.channel;
 
import android.view.ViewGroup;
 
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
 
public abstract class CategoryAdapter<VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> {
 
    @NonNull
    @Override
    final public VH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return null;
    }
 
    @Override
    final public void onBindViewHolder(@NonNull VH holder, int position) {
 
    }
 
    @Override
    final public int getItemCount() {
        int categoryCount = getCategoryCount();
        int contentItemCount = 0;
        for (int i = 0; i < categoryCount; i++) {
            contentItemCount += getCategoryContentItemCount(i);
        }
        return categoryCount + contentItemCount;
    }
 
    @Override
    final public int getItemViewType(int position) {
        return 0;
    }
 
 
    protected abstract int getCategoryCount();
 
    protected abstract int getCategoryViewType(int categoryPosition);
 
    protected abstract VH onCreateCategoryViewHolder(ViewGroup parent, int categoryViewType);
 
    protected abstract void onBindCategoryViewHolder(VH holder, int categoryPosition);
 
 
    protected abstract int getCategoryContentItemCount(int categoryPosition);
 
    protected abstract int getCategoryContentItemViewType(int categoryContentItemPosition);
 
    protected abstract VH onCreateCategoryContentItemViewHolder(ViewGroup parent, int categoryContentItemPosition);
 
    protected abstract void onBindCategoryContentItemViewHolder(VH holder, int categoryContentItemPosition);
 
 
    // TODO
    //public void notifyCategorxx();
}