kimi
2021-02-18 0ac056bb5b4c567293482286c80a1b83a467cd33
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package com.lqr.emoji;
 
 
import java.io.File;
import java.util.ArrayList;
import java.util.List;
 
public class StickerCategory {
    private static final long serialVersionUID = -81692490861539040L;
 
    private String name;//贴图包名
    private String title;//显示的标题
    private boolean system;//是否是系统内置表情
    private int order = 0;//默认顺序
 
    private transient List<StickerItem> stickers;
 
    public StickerCategory(String name, String title, boolean system, int order) {
        this.name = name;
        this.title = title;
        this.system = system;
        this.order = order;
        loadStickerData();
    }
 
 
    public String getName() {
        return name;
    }
 
    public void setName(String name) {
        this.name = name;
    }
 
    public String getTitle() {
        return title;
    }
 
    public void setTitle(String title) {
        this.title = title;
    }
 
    public boolean isSystem() {
        return system;
    }
 
    public void setSystem(boolean system) {
        this.system = system;
    }
 
    public int getOrder() {
        return order;
    }
 
    public void setOrder(int order) {
        this.order = order;
    }
 
    public List<StickerItem> getStickers() {
        return stickers;
    }
 
    public void setStickers(List<StickerItem> stickers) {
        this.stickers = stickers;
    }
 
    public boolean hasStickers() {
        return stickers != null && stickers.size() > 0;
    }
 
    public int getCount() {
        if (stickers == null || stickers.isEmpty()) {
            return 0;
        }
 
        return stickers.size();
    }
 
    public String getCoverImgPath() {
        for (File file : new File(LQREmotionKit.getStickerPath()).listFiles()) {
            if (file.isFile() && file.getName().startsWith(name)) {
                return "file://" + file.getAbsolutePath();
            }
        }
        return null;
    }
 
    public List<StickerItem> loadStickerData() {
        List<StickerItem> stickers = new ArrayList<>();
        File stickerDir = new File(LQREmotionKit.getStickerPath(), name);
        if (stickerDir.exists()) {
            File[] files = stickerDir.listFiles();
            for (File file : files) {
                //比如:tsj ---> tsj/tsj_001.gif
//                stickers.add(new StickerItem(name, name + File.separator + file.getName()));
                stickers.add(new StickerItem(name, file.getName()));
            }
        }
 
        //补充最后一页缺少的贴图
        int tmp = stickers.size() % EmotionLayout.STICKER_PER_PAGE;
        if (tmp != 0) {
            int tmp2 = EmotionLayout.STICKER_PER_PAGE - (stickers.size() - (stickers.size() / EmotionLayout.STICKER_PER_PAGE) * EmotionLayout.STICKER_PER_PAGE);
            for (int i = 0; i < tmp2; i++) {
                stickers.add(new StickerItem("", ""));
            }
        }
 
        this.setStickers(stickers);
        return stickers;
    }
 
    @Override
    public boolean equals(Object obj) {
        if (obj == null || !(obj instanceof StickerCategory)) {
            return false;
        }
        if (obj == this) {
            return true;
        }
        StickerCategory r = (StickerCategory) obj;
        return r.getName().equals(getName());
    }
 
    @Override
    public int hashCode() {
        return name.hashCode();
    }
}