Skip to content

Commit 5826300

Browse files
committed
增加联系人框
1 parent f731a08 commit 5826300

22 files changed

+1732
-42
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ hs_err_pid*
2626
# IDEA config
2727
*.impl
2828
*.iml
29-
.idea/
29+
.idea/

config/nbs-conf.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ nbs.client.merkle.add.log.name=.merkle
55
nbs.client.merkle.root.hash=skjfhsafkdasfd
66

77
nbs.client.profile.root=profile
8+
nbs.client.files.root=nbs
89

910
nbs.server.address=/ip4/127.0.0.1/tcp/5001

nbs/readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#NBS 文件目录

src/main/java/UI/AppMainWindow.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ public class AppMainWindow {
7171

7272
public static String PROFILE_NICKNAME = "";
7373

74+
/**
75+
*
76+
*/
77+
public static String NBS_FILES_ROOT_PATH ;
78+
79+
public static String NBS_FILES_IPFS_ROOT;
80+
7481
/**
7582
*
7683
*/
@@ -183,6 +190,12 @@ private void loadEnv(){
183190
logger.info(k+"="+v);
184191
}
185192
logger.info("ENV ============================<<");
193+
NBS_FILES_ROOT_PATH = ConfigHelper.CURRENT_DIR + ConfigHelper.getNbsFilesRoot();
194+
NBS_FILES_IPFS_ROOT = NBS_FILES_ROOT_PATH + File.separator +"ipfs";
195+
File ipfsDir = new File(NBS_FILES_IPFS_ROOT);
196+
if(ipfsDir.isDirectory()&& !ipfsDir.exists()){
197+
ipfsDir.mkdirs();
198+
}
186199

187200
File f = new File(ConstantsUI.PROFILE_ROOT);
188201
if(!f.exists()){
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
package com.nbs.biz.model;
2+
3+
/**
4+
* @Package : com.nbs.biz.model
5+
* @Description :
6+
* <p></p>
7+
* @Author : lambor.c
8+
* @Date : 2018/6/24-9:06
9+
* Copyright (c) 2018, NBS , lambor.c<[email protected]>.
10+
* All rights reserved.
11+
*/
12+
public class ContactsModel extends BasicModel {
13+
14+
private String id;
15+
private String nick;
16+
/**
17+
* hash58
18+
*/
19+
private String avatar;
20+
/**
21+
* .png
22+
*/
23+
private String avatarSuffix;
24+
25+
private String remark;
26+
private String extJson;
27+
private String seckey;
28+
private Integer ctime;
29+
private Integer lmtime;
30+
31+
public ContactsModel(String id, String nick, String avatar, String avatarSuffix) {
32+
this.id = id;
33+
this.nick = nick;
34+
this.avatar = avatar;
35+
this.avatarSuffix = avatarSuffix;
36+
}
37+
38+
public ContactsModel(String id, String nick) {
39+
this.id = id;
40+
this.nick = nick;
41+
}
42+
43+
public String getId() {
44+
return id;
45+
}
46+
47+
public void setId(String id) {
48+
this.id = id;
49+
}
50+
51+
public String getNick() {
52+
return nick;
53+
}
54+
55+
public void setNick(String nick) {
56+
this.nick = nick;
57+
}
58+
59+
public String getAvatar() {
60+
return avatar;
61+
}
62+
63+
public void setAvatar(String avatar) {
64+
this.avatar = avatar;
65+
}
66+
67+
public String getAvatarSuffix() {
68+
return avatarSuffix;
69+
}
70+
71+
public void setAvatarSuffix(String avatarSuffix) {
72+
this.avatarSuffix = avatarSuffix;
73+
}
74+
75+
public String getRemark() {
76+
return remark;
77+
}
78+
79+
public void setRemark(String remark) {
80+
this.remark = remark;
81+
}
82+
83+
public String getExtJson() {
84+
return extJson;
85+
}
86+
87+
public void setExtJson(String extJson) {
88+
this.extJson = extJson;
89+
}
90+
91+
public String getSeckey() {
92+
return seckey;
93+
}
94+
95+
public void setSeckey(String seckey) {
96+
this.seckey = seckey;
97+
}
98+
99+
public Integer getCtime() {
100+
return ctime;
101+
}
102+
103+
public void setCtime(Integer ctime) {
104+
this.ctime = ctime;
105+
}
106+
107+
public Integer getLmtime() {
108+
return lmtime;
109+
}
110+
111+
public void setLmtime(Integer lmtime) {
112+
this.lmtime = lmtime;
113+
}
114+
}
Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,44 @@
11
package com.nbs.entity;
22

3+
import com.nbs.utils.CharacterParser;
4+
35
/**
46
* @Package : com.nbs.entity
57
* @Description : <p></p>
68
* @Author : lambor.c
7-
* @Date : 2018/6/23-22:44
9+
* @Date : 2018/6/24-9:13
810
* Copyright (c) 2018, NBS , lambor.c<[email protected]>.
911
* All rights reserved.
1012
*/
11-
public class ContactsItem implements Comparable<ContactsItem>{
12-
private String hash;
13+
public class ContactsItem implements Comparable<ContactsItem> {
14+
/**
15+
* hash58
16+
*/
17+
private String id;
18+
1319
private String name;
20+
1421
private String type;
1522

16-
private ContactsItem(String hash) {
17-
this.hash = hash;
18-
this.type = TYPE.p.toString();
19-
}
23+
public ContactsItem() { }
2024

21-
public ContactsItem(String hash, String name) {
22-
this.hash = hash;
25+
public ContactsItem(String id, String name) {
26+
this.id = id;
2327
this.name = name;
24-
this.type = TYPE.p.toString();
2528
}
2629

27-
public ContactsItem(String hash, String name, String type) {
28-
this.hash = hash;
30+
public ContactsItem(String id, String name, String type) {
31+
this.id = id;
2932
this.name = name;
3033
this.type = type;
3134
}
3235

33-
public String getHash() {
34-
return hash;
36+
public String getId() {
37+
return id;
3538
}
3639

37-
public void setHash(String hash) {
38-
this.hash = hash;
40+
public void setId(String id) {
41+
this.id = id;
3942
}
4043

4144
public String getName() {
@@ -54,15 +57,30 @@ public void setType(String type) {
5457
this.type = type;
5558
}
5659

60+
@Override
61+
public String toString() {
62+
StringBuffer sb = new StringBuffer();
63+
sb.append("ContactsItem : {");
64+
sb.append("id : ").append(this.id==null ? "" : this.id).append(",");
65+
sb.append("name : ").append(this.name==null ? "" : this.name).append(",");
66+
sb.append("type : ").append(this.type==null ? "" : this.type);
67+
sb.append("}");
68+
return sb.toString();
69+
}
70+
5771
@Override
5872
public int compareTo(ContactsItem o) {
59-
return 0;
73+
if(o==null)return -1;
74+
String tc = CharacterParser.getSelling(this.name).toUpperCase();
75+
String oc = CharacterParser.getSelling(o.name).toUpperCase();
76+
int r = tc.compareTo(oc);
77+
return 0==r ? this.id.compareTo(o.getId()) : r;
6078
}
6179

6280
/**
63-
* 群、点
81+
*
6482
*/
6583
public static enum TYPE{
66-
p,q;
84+
Q,P;
6785
}
6886
}

src/main/java/com/nbs/tools/ConfigHelper.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424
*/
2525
public class ConfigHelper {
2626
private static final Logger logger = LoggerFactory.getLogger(ConfigHelper.class);
27-
private static final String CONF_ROOT = ConstantsUI.CURRENT_DIR + File.separator+"config" + File.separator;
27+
/**
28+
* 系统当前路径
29+
*/
30+
public final static String CURRENT_DIR = System.getProperty("user.dir");
31+
private static final String CONF_ROOT = CURRENT_DIR + File.separator+"config" + File.separator;
2832
private static final String CONF_FILE = "nbs-conf.properties";
2933
public static final String PK_SERVER_STATS = "ipfs.server.stats";
3034
public static final String PK_CFG_IPFS_ADDR = "nbs.server.address";
@@ -63,6 +67,16 @@ public static String getProperty(String key){
6367
return env.getProperty(key);
6468
}
6569

70+
/**
71+
*
72+
* @param key
73+
* @param defaultVal
74+
* @return
75+
*/
76+
public static String getProperty(String key,String defaultVal){
77+
return env.getProperty(key,defaultVal);
78+
}
79+
6680
/**
6781
*
6882
* @param key
@@ -114,6 +128,13 @@ public static String getIpfsAddress(){
114128
return v;
115129
}
116130

131+
/**
132+
*
133+
* @return
134+
*/
135+
public static String getNbsFilesRoot(){
136+
return env.getProperty("nbs.client.files.root","nbs");
137+
}
117138
/**
118139
*
119140
* @return
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.nbs.ui;
2+
3+
import com.nbs.ui.cnst.FontUtil;
4+
import com.nbs.ui.components.ColorCnst;
5+
import com.nbs.ui.components.GBC;
6+
import com.nbs.ui.components.NbsBorder;
7+
8+
import javax.swing.*;
9+
import java.awt.*;
10+
11+
/**
12+
* @Package : com.nbs.ui
13+
* @Description : <p></p>
14+
* @Author : lambor.c
15+
* @Date : 2018/6/24-7:47
16+
* Copyright (c) 2018, NBS , lambor.c<[email protected]>.
17+
* All rights reserved.
18+
*/
19+
public class ContactsItemViewHolder extends ViewHolder {
20+
public JLabel avatar = new JLabel();
21+
public JLabel roomName = new JLabel();
22+
23+
public ContactsItemViewHolder() {
24+
initComponents();
25+
initView();
26+
}
27+
28+
private void initComponents(){
29+
setPreferredSize(new Dimension(100,50));
30+
setBackground(ColorCnst.DARK);
31+
setBorder(new NbsBorder(NbsBorder.BOTTOM));
32+
setOpaque(true);
33+
setForeground(ColorCnst.FONT_WHITE);
34+
35+
roomName.setFont(FontUtil.getDefaultFont(13));
36+
roomName.setForeground(ColorCnst.FONT_WHITE);
37+
}
38+
39+
/**
40+
*
41+
*/
42+
private void initView()
43+
{
44+
setLayout(new GridBagLayout());
45+
add(avatar, new GBC(0, 0).setWeight(1, 1).setFill(GBC.BOTH).setInsets(0,5,0,0));
46+
add(roomName, new GBC(1, 0).setWeight(10, 1).setFill(GBC.BOTH));
47+
}
48+
}

src/main/java/com/nbs/ui/adapter/BaseAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public abstract class BaseAdapter<T extends ViewHolder> {
2121
public abstract T onCreateViewHolder(int viewType);
2222

2323

24-
public AvatarViewHolder onCreateHeaderViewHolder(int viewType,int postion){
24+
public AvatarViewHolder onCreateHeaderViewHolder(int viewType,int position){
2525
return null;
2626
}
2727

0 commit comments

Comments
 (0)