Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyanan committed Oct 25, 2017
1 parent 9ec4c22 commit 1cfab87
Show file tree
Hide file tree
Showing 21 changed files with 74 additions and 20 deletions.
7 changes: 0 additions & 7 deletions chatapp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,10 @@ dependencies {
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.github.w446108264:AndroidEmoji:1.0.0'
compile 'com.github.chrisbanes.photoview:library:1.2.4'
compile files('libs/universal-image-loader-1.9.5.jar')
compile files('libs/BaiduLBS_Android.jar')
compile 'com.facebook.fresco:fresco:0.8.1'
compile files('libs/pinyin4j-2.5.0.jar')
compile 'org.greenrobot:eventbus:3.0.0'
compile 'io.reactivex:rxandroid:1.2.1'
compile project(':reclib-qq')
compile project(':reclib-testemoticons')
compile files('libs/picasso-2.5.2.jar')
compile files('libs/core-3.2.1.jar')
compile files('libs/gson-2.2.1.jar')
compile files('libs/jcore-android-1.1.6-debug-b152.jar')
compile 'com.contrarywind:Android-PickerView:3.2.4'
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added chatapp/libs/jcore-android-1.1.7.jar
Binary file not shown.
Binary file added chatapp/libs/jmessage-android_v2.3.0.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions chatapp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@
android:name="JPUSH_APPKEY"
android:value="4f7aef34fb361292c566a1cd"/>

<provider
android:name="cn.jpush.android.service.DataProvider"
android:authorities="${applicationId}.DataProvider"
android:exported="true" />

<activity
android:name=".activity.WelcomeActivity"
android:screenOrientation="portrait"
Expand Down
34 changes: 32 additions & 2 deletions chatapp/src/main/java/jiguang/chat/activity/ChatActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import cn.jpush.im.android.api.event.MessageEvent;
import cn.jpush.im.android.api.event.MessageReceiptStatusChangeEvent;
import cn.jpush.im.android.api.event.MessageRetractEvent;
import cn.jpush.im.android.api.event.OfflineMessageEvent;
import cn.jpush.im.android.api.model.Conversation;
import cn.jpush.im.android.api.model.GroupInfo;
import cn.jpush.im.android.api.model.Message;
Expand Down Expand Up @@ -538,6 +539,7 @@ protected void onResume() {
}
}
mChatAdapter.notifyDataSetChanged();
//发送名片返回聊天界面刷新信息
if (SharePreferenceManager.getIsOpen()) {
initData();
SharePreferenceManager.setIsOpen(false);
Expand Down Expand Up @@ -598,8 +600,8 @@ public void run() {
case group_member_exit:
EventNotificationContent content = (EventNotificationContent) message.getContent();
if (content.getUserNames().contains(JMessageClient.getMyInfo().getUserName())) {
finish();
}else {
mChatAdapter.notifyDataSetChanged();
} else {
refreshGroupNum();
}
break;
Expand Down Expand Up @@ -641,6 +643,34 @@ public void onEventMainThread(MessageRetractEvent event) {
mChatAdapter.delMsgRetract(retractedMessage);
}

/**
* 当在聊天界面断网再次连接时收离线事件刷新
*/
public void onEvent(OfflineMessageEvent event) {
Conversation conv = event.getConversation();
if (conv.getType().equals(ConversationType.single)) {
UserInfo userInfo = (UserInfo) conv.getTargetInfo();
String targetId = userInfo.getUserName();
String appKey = userInfo.getAppKey();
if (mIsSingle && targetId.equals(mTargetId) && appKey.equals(mTargetAppKey)) {
List<Message> singleOfflineMsgList = event.getOfflineMessageList();
if (singleOfflineMsgList != null && singleOfflineMsgList.size() > 0) {
mChatView.setToBottom();
mChatAdapter.addMsgListToList(singleOfflineMsgList);
}
}
} else {
long groupId = ((GroupInfo) conv.getTargetInfo()).getGroupID();
if (groupId == mGroupId) {
List<Message> offlineMessageList = event.getOfflineMessageList();
if (offlineMessageList != null && offlineMessageList.size() > 0) {
mChatView.setToBottom();
mChatAdapter.addMsgListToList(offlineMessageList);
}
}
}
}

private void refreshGroupNum() {
Conversation conv = JMessageClient.getGroupConversation(mGroupId);
GroupInfo groupInfo = (GroupInfo) conv.getTargetInfo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ public void gotResult(int responseCode, String responseMessage, UserInfo info) {
if (responseCode == 0) {
//拉取好友信息时候要更新数据库中的nickName.因为如果对方修改了nickName我们是无法感知的.如果不在拉取信息
//时候更新数据库的话会影响到搜索好友的nickName, 注意要在没有备注名并且有昵称时候去更新.因为备注名优先级更高
if (TextUtils.isEmpty(info.getNotename()) && !TextUtils.isEmpty(info.getNickname())) {
new Update(FriendEntry.class).set("DisplayName=?", info.getNickname()).where("Username=?", mTargetId).execute();
new Update(FriendEntry.class).set("NickName=?", info.getNickname()).where("Username=?", mTargetId).execute();
}
new Update(FriendEntry.class).set("DisplayName=?", info.getDisplayName()).where("Username=?", mTargetId).execute();
new Update(FriendEntry.class).set("NickName=?", info.getNickname()).where("Username=?", mTargetId).execute();
new Update(FriendEntry.class).set("NoteName=?", info.getNotename()).where("Username=?", mTargetId).execute();

if (info.getAvatarFile() != null) {
new Update(FriendEntry.class).set("Avatar=?", info.getAvatarFile().getAbsolutePath()).where("Username=?", mTargetId).execute();
}
Expand All @@ -118,7 +118,7 @@ public void gotResult(int responseCode, String responseMessage, UserInfo info) {
mTitle = info.getNickname();
}
mFriendInfoView.initInfo(info);
}else {
} else {
HandleResponseCode.onHandle(FriendInfoActivity.this, responseCode, false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import jiguang.chat.model.SearchResult;
import jiguang.chat.utils.DialogCreator;
import jiguang.chat.utils.HandleResponseCode;
import jiguang.chat.utils.SharePreferenceManager;
import jiguang.chat.utils.photochoose.SelectableRoundedImageView;
import jiguang.chat.utils.pinyin.CharacterParser;
import jiguang.chat.utils.query.TextSearcher;
Expand Down Expand Up @@ -209,6 +210,7 @@ public void onClick(View v) {
@Override
public void gotResult(int i, String s) {
if (i == 0) {
SharePreferenceManager.setIsOpen(true);
Toast.makeText(SearchFriendBusinessActivity.this, "发送成功", Toast.LENGTH_SHORT).show();
finish();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public void run() {
entry.save();
//收到好友邀请
} else if (event.getType() == ContactNotifyEvent.Type.invite_received) {
//如果同一个人申请多次,则只会出现一次;当点击进验证消息界面后,同一个人再次申请则可以收到
if (JGApplication.forAddFriend.size() > 0) {
for (String forAdd : JGApplication.forAddFriend) {
if (forAdd.equals(username)) {
Expand Down Expand Up @@ -206,6 +207,7 @@ public void gotResult(int status, String desc, UserInfo userInfo) {
entry.reason = reason;
}
entry.save();
//收到好友请求数字 +1
int showNum = SharePreferenceManager.getCachedNewFriendNum() + 1;
mContactsView.showNewFriends(showNum);
SharePreferenceManager.setCachedNewFriendNum(showNum);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ public void addMsgToList(Message msg) {
notifyDataSetChanged();
}

public void addMsgListToList(List<Message> singleOfflineMsgList) {
mMsgList.addAll(singleOfflineMsgList);
notifyDataSetChanged();
}

public void addMsgFromReceiptToList(Message msg) {
mMsgList.add(msg);
msg.setOnSendCompleteCallback(new BasicCallback() {
Expand All @@ -295,7 +300,7 @@ public void gotResult(int i, String s) {
if (i == 0) {
incrementStartPosition();
notifyDataSetChanged();
}else {
} else {
HandleResponseCode.onHandle(mContext, i, false);
notifyDataSetChanged();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import jiguang.chat.activity.GroupNotFriendActivity;
import jiguang.chat.activity.SearchFriendDetailActivity;
import jiguang.chat.application.JGApplication;
import jiguang.chat.database.FriendEntry;
import jiguang.chat.database.FriendRecommendEntry;
import jiguang.chat.entity.Event;
import jiguang.chat.entity.EventType;
Expand Down Expand Up @@ -110,14 +111,19 @@ public View getView(final int position, View convertView, ViewGroup parent) {

name.setText(item.displayName);
reason.setText(item.reason);

JMessageClient.getUserInfo(item.username, new GetUserInfoCallback() {
@Override
public void gotResult(int i, String s, UserInfo userInfo) {
if (i == 0) {
if (userInfo.isFriend()) {
item.state = FriendInvitation.ACCEPTED.getValue();
item.save();
FriendEntry entry = FriendEntry.getFriend(JGApplication.getUserEntry(), item.username, item.appKey);
if (entry == null) {
EventBus.getDefault().post(new Event.Builder().setType(EventType.addFriend)
.setFriendId(item.getId()).build());
}

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,12 +751,10 @@ private void sendingTextOrVoice(final ViewHolder holder, final Message msg) {
holder.sendingIv.setVisibility(View.VISIBLE);
holder.sendingIv.startAnimation(mSendingAnim);
//消息正在发送,重新注册一个监听消息发送完成的Callback
System.out.println("=================" + msg.isSendCompleteCallbackExists());
if (!msg.isSendCompleteCallbackExists()) {
msg.setOnSendCompleteCallback(new BasicCallback() {
@Override
public void gotResult(final int status, final String desc) {
System.out.println("=================" + status + desc);
holder.sendingIv.setVisibility(View.GONE);
holder.sendingIv.clearAnimation();
if (status == 803008) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import jiguang.chat.activity.SearchContactsActivity;
import jiguang.chat.activity.SearchForAddFriendActivity;
import jiguang.chat.adapter.StickyListAdapter;
import jiguang.chat.application.JGApplication;
import jiguang.chat.database.FriendEntry;
import jiguang.chat.database.UserEntry;
import jiguang.chat.utils.pinyin.HanziToPinyin;
Expand All @@ -38,6 +39,7 @@ public class ContactsController implements View.OnClickListener, SideBar.OnTouch
private Activity mContext;
private List<FriendEntry> mList = new ArrayList<>();
private StickyListAdapter mAdapter;
private List<FriendEntry> forDelete = new ArrayList<>();


public ContactsController(ContactsView mContactsView, FragmentActivity context) {
Expand Down Expand Up @@ -125,7 +127,7 @@ public void gotResult(int responseCode, String responseMessage, List<UserInfo> u
friend.save();
mList.add(friend);
}

forDelete.add(friend);
}
ActiveAndroid.setTransactionSuccessful();
} finally {
Expand All @@ -134,6 +136,13 @@ public void gotResult(int responseCode, String responseMessage, List<UserInfo> u
} else {
mContactsView.showLine();
}
//其他端删除好友后,登陆时把数据库中的也删掉
List<FriendEntry> friends = JGApplication.getUserEntry().getFriends();
friends.removeAll(forDelete);
for (FriendEntry del : friends) {
del.delete();
mList.remove(del);
}
Collections.sort(mList, new PinyinComparator());
mAdapter = new StickyListAdapter(mContext, mList, false);
mContactsView.setAdapter(mAdapter);
Expand Down
2 changes: 2 additions & 0 deletions chatapp/src/main/java/jiguang/chat/view/ContactsView.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import jiguang.chat.R;
import jiguang.chat.adapter.StickyListAdapter;
import jiguang.chat.application.JGApplication;
import jiguang.chat.controller.ContactsController;
import jiguang.chat.utils.SharePreferenceManager;
import jiguang.chat.utils.sidebar.SideBar;
Expand Down Expand Up @@ -114,6 +115,7 @@ public void showNewFriends(int num) {

public void dismissNewFriends() {
SharePreferenceManager.setCachedNewFriendNum(0);
JGApplication.forAddFriend.clear();
mNewFriendNum.setVisibility(INVISIBLE);
}

Expand Down
4 changes: 3 additions & 1 deletion chatapp/src/main/res/layout/activity_chat_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
android:id="@+id/tv_moreGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="19dp"
android:paddingBottom="19dp"
android:gravity="center_horizontal">

<TextView
Expand Down Expand Up @@ -165,6 +165,8 @@
android:text="聊天文件"/>

<TextView style="@style/ChatDetailItemContent"/>
<ImageView
style="@style/ChatDetailArrow"/>

</LinearLayout>

Expand Down

0 comments on commit 1cfab87

Please sign in to comment.