Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
RvApp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lify
RvApp
Commits
44e13026
Commit
44e13026
authored
Dec 24, 2019
by
jianglx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
im 2019-12-24
parent
687f1048
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
116 additions
and
28 deletions
+116
-28
ChatContentAdapter.java
...m/src/main/java/com/rv/im/adapter/ChatContentAdapter.java
+60
-13
FriendDao.java
plugin_im/src/main/java/com/rv/im/db/dao/FriendDao.java
+27
-11
NewFriendActivity.java
..._im/src/main/java/com/rv/im/friend/NewFriendActivity.java
+13
-1
NewFriendPresenter.java
...src/main/java/com/rv/im/presenter/NewFriendPresenter.java
+14
-3
chat_be_pass_item.xml
plugin_im/src/main/res/layout/chat_be_pass_item.xml
+1
-0
chat_pass_item.xml
plugin_im/src/main/res/layout/chat_pass_item.xml
+1
-0
No files found.
plugin_im/src/main/java/com/rv/im/adapter/ChatContentAdapter.java
View file @
44e13026
...
...
@@ -107,6 +107,10 @@ public class ChatContentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
return
new
MsgBePassHolder
(
LayoutInflater
.
from
(
mContext
).
inflate
(
R
.
layout
.
chat_be_pass_item
,
viewGroup
,
false
));
case
71
:
return
new
MsgPassHolder
(
LayoutInflater
.
from
(
mContext
).
inflate
(
R
.
layout
.
chat_pass_item
,
viewGroup
,
false
));
case
72
:
return
new
MsgAddSuccessHolder
(
LayoutInflater
.
from
(
mContext
).
inflate
(
R
.
layout
.
chat_pass_item
,
viewGroup
,
false
));
case
73
:
return
new
MsgBeFriendHolder
(
LayoutInflater
.
from
(
mContext
).
inflate
(
R
.
layout
.
chat_be_pass_item
,
viewGroup
,
false
));
}
return
null
;
}
...
...
@@ -140,9 +144,13 @@ public class ChatContentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
}
else
if
(
viewHolder
instanceof
MsgToVideoCallHolder
)
{
setToVideoCallContentView
(
bean
,
(
MsgToVideoCallHolder
)
viewHolder
);
}
else
if
(
viewHolder
instanceof
MsgBePassHolder
)
{
setBe
FriendContentView
(
bean
,
(
MsgBeFriendHolder
)
viewHolder
)
;
setBe
PassContentView
(
bean
,
(
MsgBePassHolder
)
viewHolder
)
;
}
else
if
(
viewHolder
instanceof
MsgPassHolder
)
{
setPassContentView
(
bean
,
(
MsgPassHolder
)
viewHolder
)
;
}
else
if
(
viewHolder
instanceof
MsgBeFriendHolder
)
{
setBeFriendContentView
(
bean
,
(
MsgBeFriendHolder
)
viewHolder
);
}
else
if
(
viewHolder
instanceof
MsgAddSuccessHolder
)
{
setMsgAddSuccessContentView
(
bean
,
(
MsgAddSuccessHolder
)
viewHolder
);
}
}
}
...
...
@@ -206,12 +214,33 @@ public class ChatContentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
}
}
private
void
setBePassContentView
(
ChatMessage
bean
,
MsgBeFriendHolder
holder
)
{
showTime
(
holder
.
tvTime
,
bean
);
private
void
setBePassContentView
(
ChatMessage
bean
,
MsgBePassHolder
holder
)
{
showTime
(
holder
.
tvSendTime
,
bean
);
holder
.
chatText
.
setText
(
"我通过了你的朋友验证请求,现在我们开始可以聊天了"
);
}
private
void
setBeFriendContentView
(
ChatMessage
bean
,
MsgBeFriendHolder
holder
)
{
showTime
(
holder
.
tvTime
,
bean
);
showTime
(
holder
.
tvSendTime
,
bean
);
holder
.
chatText
.
setText
(
"我已添加你为好友,现在我们开始可以聊天了"
);
}
private
void
setMsgAddSuccessContentView
(
ChatMessage
bean
,
MsgAddSuccessHolder
holder
)
{
showTime
(
holder
.
tvSendTime
,
bean
);
holder
.
chatText
.
setText
(
"我已添加你为好友,现在我们开始可以聊天了"
);
if
(!
TextUtils
.
isEmpty
(
myHeaderUrl
))
{
GlideManager
.
getInstance
(
mContext
).
loadImage
(
myHeaderUrl
,
holder
.
ivHeader
);
}
}
private
void
setPassContentView
(
ChatMessage
bean
,
MsgPassHolder
holder
)
{
showTime
(
holder
.
tvSendTime
,
bean
);
holder
.
chatText
.
setText
(
"我通过了你的朋友验证请求,现在我们开始可以聊天了"
);
if
(!
TextUtils
.
isEmpty
(
myHeaderUrl
))
{
GlideManager
.
getInstance
(
mContext
).
loadImage
(
myHeaderUrl
,
holder
.
ivHeader
);
}
}
private
void
setToTextContentView
(
ChatMessage
bean
,
MsgToTextHolder
holder
)
{
...
...
@@ -524,22 +553,39 @@ public class ChatContentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
}
}
class
MsgBeFriendHolder
extends
RecyclerView
.
ViewHolder
{
TextView
tvTime
;
class
MsgBePassHolder
extends
RecyclerView
.
ViewHolder
{
TextView
tvSendTime
;
RoundImageView
ivHeader
;
TextView
chatText
;
public
MsgBePassHolder
(
@NonNull
View
itemView
)
{
super
(
itemView
);
tvSendTime
=
itemView
.
findViewById
(
R
.
id
.
tv_send_time
);
ivHeader
=
itemView
.
findViewById
(
R
.
id
.
iv_header
);
chatText
=
itemView
.
findViewById
(
R
.
id
.
chat_text
);
}
}
public
MsgBeFriendHolder
(
@NonNull
View
itemView
)
{
class
MsgPassHolder
extends
RecyclerView
.
ViewHolder
{
TextView
tvSendTime
;
RoundImageView
ivHeader
;
TextView
chatText
;
public
MsgPassHolder
(
@NonNull
View
itemView
)
{
super
(
itemView
);
tvTime
=
itemView
.
findViewById
(
R
.
id
.
tv_time
);
tvSendTime
=
itemView
.
findViewById
(
R
.
id
.
tv_send_time
);
ivHeader
=
itemView
.
findViewById
(
R
.
id
.
iv_header
);
chatText
=
itemView
.
findViewById
(
R
.
id
.
chat_text
);
}
}
class
Msg
BePa
ssHolder
extends
RecyclerView
.
ViewHolder
{
class
Msg
AddSucce
ssHolder
extends
RecyclerView
.
ViewHolder
{
TextView
tvSendTime
;
RoundImageView
ivHeader
;
TextView
chatText
;
public
Msg
BePa
ssHolder
(
@NonNull
View
itemView
)
{
public
Msg
AddSucce
ssHolder
(
@NonNull
View
itemView
)
{
super
(
itemView
);
tvSendTime
=
itemView
.
findViewById
(
R
.
id
.
tv_send_time
);
ivHeader
=
itemView
.
findViewById
(
R
.
id
.
iv_header
);
...
...
@@ -547,12 +593,13 @@ public class ChatContentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
}
}
class
MsgPassHolder
extends
RecyclerView
.
ViewHolder
{
class
MsgBeFriendHolder
extends
RecyclerView
.
ViewHolder
{
TextView
tvSendTime
;
RoundImageView
ivHeader
;
TextView
chatText
;
public
Msg
Pass
Holder
(
@NonNull
View
itemView
)
{
public
Msg
BeFriend
Holder
(
@NonNull
View
itemView
)
{
super
(
itemView
);
tvSendTime
=
itemView
.
findViewById
(
R
.
id
.
tv_send_time
);
ivHeader
=
itemView
.
findViewById
(
R
.
id
.
iv_header
);
...
...
plugin_im/src/main/java/com/rv/im/db/dao/FriendDao.java
View file @
44e13026
...
...
@@ -81,8 +81,9 @@ public class FriendDao {
return
;
}
Log
.
d
(
TAG
,
friend
.
toString
());
if
(
isExit
(
friend
))
{
updateFriend
(
friend
);
Friend
oldFriend
=
null
;
if
((
oldFriend
=
isExit
(
friend
))
!=
null
)
{
updateFriend
(
friend
,
oldFriend
);
return
;
}
try
{
...
...
@@ -124,20 +125,35 @@ public class FriendDao {
* 更新消息
* @param friend
*/
public
void
updateFriend
(
Friend
frien
d
)
{
public
int
updateFriend
(
Friend
friend
,
Friend
ol
d
)
{
if
(
dao
==
null
)
{
LogUtil
.
e
(
TAG
,
"dao is null"
);
return
;
return
-
1
;
}
if
(
friend
==
null
)
{
LogUtil
.
e
(
TAG
,
"friend is null"
);
return
;
return
-
1
;
}
if
(
old
==
null
)
{
LogUtil
.
e
(
TAG
,
"old is null"
);
return
-
1
;
}
update
(
friend
,
old
);
int
result
=
0
;
try
{
dao
.
update
(
friend
);
result
=
dao
.
update
(
old
);
// dao.update(friend);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
return
result
;
}
private
void
update
(
Friend
f1
,
Friend
f2
)
{
f2
.
setStatus
(
f1
.
getStatus
());
f2
.
setTimeCreate
(
f1
.
getTimeCreate
());
f2
.
setAction
(
f1
.
getAction
());
f2
.
setRead
(
f1
.
isRead
());
}
/*******
...
...
@@ -145,21 +161,21 @@ public class FriendDao {
* @param friend
* @return
*/
public
boolean
isExit
(
Friend
friend
)
{
public
Friend
isExit
(
Friend
friend
)
{
if
(
dao
==
null
)
{
LogUtil
.
e
(
TAG
,
"dao is null"
);
return
false
;
return
null
;
}
if
(
friend
==
null
)
{
LogUtil
.
e
(
TAG
,
"friend is null"
);
return
false
;
return
null
;
}
try
{
List
<
Friend
>
lists
=
dao
.
queryForEq
(
"userId"
,
friend
.
getUserId
());
return
lists
==
null
?
false
:
lists
.
size
()
==
0
?
false
:
true
;
return
lists
==
null
?
null
:
lists
.
size
()
==
0
?
null
:
lists
.
get
(
0
)
;
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
return
false
;
return
null
;
}
}
plugin_im/src/main/java/com/rv/im/friend/NewFriendActivity.java
View file @
44e13026
...
...
@@ -128,7 +128,19 @@ public class NewFriendActivity extends BaseStatusActivity<NewFriendPresenter> im
@Override
public
void
agree
(
Friend
item
)
{
agreeFriend
=
item
;
mPresenter
.
doAgreeOrAttention
(
agreeFriend
);
mPresenter
.
doAgreeOrAttention
(
agreeFriend
,
attentionListener
);
}
};
private
NewFriendPresenter
.
AttentionListener
attentionListener
=
new
NewFriendPresenter
.
AttentionListener
()
{
@Override
public
void
success
()
{
getAddRecord
();
}
@Override
public
void
failed
()
{
}
}
;
}
plugin_im/src/main/java/com/rv/im/presenter/NewFriendPresenter.java
View file @
44e13026
...
...
@@ -16,6 +16,7 @@ import com.rv.im.AppConfig;
import
com.rv.im.Constants
;
import
com.rv.im.ImSetting
;
import
com.rv.im.bean.ImBaseBean
;
import
com.rv.im.db.service.ChatMessageServiceImp
;
import
com.rv.im.db.service.FriendServiceImp
;
import
com.rv.im.db.table.ChatMessage
;
import
com.rv.im.db.table.Friend
;
...
...
@@ -66,7 +67,7 @@ public class NewFriendPresenter extends CommonPresenter {
/**
* 同意别人的加好友
*/
public
void
doAgreeOrAttention
(
final
Friend
item
)
{
public
void
doAgreeOrAttention
(
final
Friend
item
,
AttentionListener
listener
)
{
AppConfig
appConfig
=
(
AppConfig
)
RvCache
.
getInstance
().
get
(
CacheEnum
.
IM_CONFIG
);
if
(
appConfig
==
null
)
return
;
StringBuffer
buffer
=
new
StringBuffer
();
...
...
@@ -87,15 +88,18 @@ public class NewFriendPresenter extends CommonPresenter {
ImBaseBean
bean
=
new
Gson
().
fromJson
(
data
,
ImBaseBean
.
class
);
if
(
bean
!=
null
&&
bean
.
resultCode
==
1
)
{
((
BaseStatusActivity
)
getPresenterContext
()).
showToast
(
"已同意"
);
doAgree
(
item
.
getUserName
(),
item
.
getUserId
());
ChatMessage
chatMessage
=
doAgree
(
item
.
getUserName
(),
item
.
getUserId
());
ChatMessageServiceImp
.
getInstance
(
ImSetting
.
getContext
()).
addMessage
(
chatMessage
);
item
.
setStatus
(
Friend
.
STATUS_12
);
FriendServiceImp
.
getInstance
(
getPresenterContext
()).
addMessage
(
item
);
listener
.
success
();
}
else
if
(
bean
!=
null
)
{
((
BaseStatusActivity
)
getPresenterContext
()).
showToast
(
bean
.
resultMsg
);
if
(
bean
.
resultCode
==
100512
)
{
if
(
bean
.
resultCode
==
100512
)
{
item
.
setStatus
(
2
);
FriendServiceImp
.
getInstance
(
getPresenterContext
()).
addMessage
(
item
);
}
listener
.
failed
();
}
}
}
...
...
@@ -106,4 +110,11 @@ public class NewFriendPresenter extends CommonPresenter {
}
});
}
public
interface
AttentionListener
{
void
success
();
void
failed
();
}
}
plugin_im/src/main/res/layout/chat_be_pass_item.xml
View file @
44e13026
...
...
@@ -38,6 +38,7 @@
android:layout_height=
"wrap_content"
android:layout_centerInParent=
"true"
android:layout_marginLeft=
"@dimen/dp10"
android:background=
"@drawable/shape_from_chat_msg"
android:layout_marginTop=
"@dimen/chat_head_top"
android:clickable=
"true"
android:focusable=
"true"
...
...
plugin_im/src/main/res/layout/chat_pass_item.xml
View file @
44e13026
...
...
@@ -32,6 +32,7 @@
android:layout_centerInParent=
"true"
android:layout_marginLeft=
"@dimen/dp5"
android:layout_marginTop=
"@dimen/chat_head_top"
android:background=
"@drawable/shape_to_chat_msg"
android:clickable=
"true"
android:focusable=
"true"
android:gravity=
"left|center_vertical"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment