java大神有吗?compareTo return 失效 通过判断是否在map内条件下的return debug后发现似乎被忽略了,跑不到那里。
桃哥543 2018-05-14 04:40:08 java大神有吗?前4个return 似乎被编译器忽略了?继承的Comparable;
@Override
public int compareTo(Conversation another) {
if (another instanceof Conversation) {
Conversation anotherConversation = (Conversation) another;
if (type == TIMConversationType.Group) {
if (ImSettingManager.getTopContactMap().containsKey(BeanContactSetting.FONT_WORD_TYPE_GROUP +
getIdentify())) {
if (anotherConversation.type == TIMConversationType.Group) {
if (ImSettingManager.getTopContactMap().containsKey(BeanContactSetting.FONT_WORD_TYPE_GROUP +
anotherConversation.getIdentify()))
return 0;
else
return 1;
}else{
if (ImSettingManager.getTopContactMap().containsKey(BeanContactSetting.FONT_WORD_TYPE_PEOPLE +
anotherConversation.getIdentify()))
return 0;
else
return 1;
}
}
} else {
if (anotherConversation.type == TIMConversationType.Group) {
if (ImSettingManager.getTopContactMap().containsKey(BeanContactSetting.FONT_WORD_TYPE_GROUP +
anotherConversation.getIdentify()))
return 0;
else
return 1;
}else{
if (ImSettingManager.getTopContactMap().containsKey(BeanContactSetting.FONT_WORD_TYPE_PEOPLE +
anotherConversation.getIdentify()))
return 0;
else
return 1;
}
}
long timeGap = anotherConversation.getLastMessageTime() - getLastMessageTime();
if (timeGap > 0) return 1;
else if (timeGap < 0) return -1;
return 0;
} else {
throw new ClassCastException();
}