Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fallenstardust
YGOMobile
Commits
d4819f8c
Commit
d4819f8c
authored
Jul 30, 2022
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同步聊天室与萌卡的登录状态
parent
79e40df4
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
41 deletions
+56
-41
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardSearchFragment.java
...java/cn/garymb/ygomobile/ui/cards/CardSearchFragment.java
+1
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/MycardFragment.java
...in/java/cn/garymb/ygomobile/ui/mycard/MycardFragment.java
+23
-13
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/MycardChatFragment.java
...garymb/ygomobile/ui/mycard/mcchat/MycardChatFragment.java
+4
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/management/ServiceManagement.java
...mobile/ui/mycard/mcchat/management/ServiceManagement.java
+24
-24
mobile/src/main/res/layout/fragment_mycard.xml
mobile/src/main/res/layout/fragment_mycard.xml
+4
-3
No files found.
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardSearchFragment.java
View file @
d4819f8c
...
...
@@ -18,6 +18,7 @@ import androidx.annotation.Nullable;
import
androidx.appcompat.widget.RecyclerViewItemListener
;
import
androidx.drawerlayout.widget.DrawerLayout
;
import
androidx.recyclerview.widget.FastScrollLinearLayoutManager
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.ourygo.assistant.util.DuelAssistantManagement
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/MycardFragment.java
View file @
d4819f8c
...
...
@@ -59,7 +59,7 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
private
TextView
mNameView
,
mStatusView
;
private
TextView
tv_back_mc
;
//萌卡webview
p
rivate
MyCardWebView
mWebViewPlus
;
p
ublic
MyCardWebView
mWebViewPlus
;
private
MyCard
mMyCard
;
//聊天室
private
RelativeLayout
rl_chat
;
...
...
@@ -80,7 +80,9 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
}
mNameView
.
setText
(
ss
[
0
]);
mStatusView
.
setText
(
ss
[
2
]);
initData
();
}
}
};
...
...
@@ -92,7 +94,7 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
@Override
public
View
onCreateView
(
@NonNull
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreateView
(
inflater
,
container
,
savedInstanceState
);
homeActivity
=
(
HomeActivity
)
getActivity
();
homeActivity
=
(
HomeActivity
)
getActivity
();
View
view
;
view
=
inflater
.
inflate
(
R
.
layout
.
fragment_mycard
,
container
,
false
);
initView
(
view
);
...
...
@@ -119,14 +121,12 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
tv_message
=
view
.
findViewById
(
R
.
id
.
tv_message
);
pb_chat_loading
=
view
.
findViewById
(
R
.
id
.
pb_chat_loading
);
SharedPreferences
lastModified
=
getActivity
().
getSharedPreferences
(
"lastModified"
,
Context
.
MODE_PRIVATE
);
UserManagement
.
setUserName
(
lastModified
.
getString
(
"user_name"
,
null
));
UserManagement
.
setUserPassword
(
lastModified
.
getString
(
"user_external_id"
,
null
));
serviceManagement
=
ServiceManagement
.
getDx
();
serviceManagement
.
addJoinRoomListener
(
this
);
serviceManagement
.
addListener
(
this
);
initData
();
WebSettings
settings
=
mWebViewPlus
.
getSettings
();
settings
.
setUserAgentString
(
settings
.
getUserAgentString
()
+
MessageFormat
.
format
(
" YGOMobile/{0} ({1} {2,number,#})"
,
...
...
@@ -178,14 +178,14 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
});
mMyCard
.
attachWeb
(
mWebViewPlus
,
this
);
mWebViewPlus
.
loadUrl
(
mMyCard
.
getHomeUrl
());
getChildFragmentManager
().
beginTransaction
().
add
(
R
.
id
.
fragment_content
,
homeActivity
.
fragment_mycard_chatting_room
).
hide
(
homeActivity
.
fragment_mycard_chatting_room
).
commit
();
}
private
void
initData
()
{
SharedPreferences
lastModified
=
getActivity
().
getSharedPreferences
(
"lastModified"
,
Context
.
MODE_PRIVATE
);
UserManagement
.
setUserName
(
lastModified
.
getString
(
"user_name"
,
null
));
UserManagement
.
setUserPassword
(
lastModified
.
getString
(
"user_external_id"
,
null
));
if
(
UserManagement
.
getUserName
()
!=
null
)
{
serviceManagement
.
start
();
}
else
{
}
}
...
...
@@ -305,10 +305,20 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
break
;
case
R
.
id
.
rl_chat
:
//这里显示聊天室fragment
if
(
serviceManagement
.
isConnected
())
{
if
(!
homeActivity
.
fragment_mycard_chatting_room
.
isAdded
())
{
getChildFragmentManager
().
beginTransaction
().
add
(
R
.
id
.
fragment_content
,
homeActivity
.
fragment_mycard_chatting_room
).
commit
();
mWebViewPlus
.
setVisibility
(
View
.
INVISIBLE
);
}
else
{
if
(
homeActivity
.
fragment_mycard_chatting_room
.
isHidden
())
{
getChildFragmentManager
().
beginTransaction
().
show
(
homeActivity
.
fragment_mycard_chatting_room
).
commit
();
mWebViewPlus
.
setVisibility
(
View
.
INVISIBLE
);
}
else
{
getChildFragmentManager
().
beginTransaction
().
hide
(
homeActivity
.
fragment_mycard_chatting_room
).
commit
();
mWebViewPlus
.
setVisibility
(
View
.
VISIBLE
);
}
}
}
break
;
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/MycardChatFragment.java
View file @
d4819f8c
...
...
@@ -20,6 +20,7 @@ import com.ourygo.assistant.util.Util;
import
cn.garymb.ygomobile.base.BaseFragemnt
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.home.HomeActivity
;
import
cn.garymb.ygomobile.ui.mycard.MycardFragment
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.adapter.ChatAdapter
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.management.ServiceManagement
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
...
...
@@ -55,6 +56,7 @@ public class MycardChatFragment extends BaseFragemnt implements ChatListener {
main_send
=
view
.
findViewById
(
R
.
id
.
main_send
);
main_send_message
=
view
.
findViewById
(
R
.
id
.
main_send_message
);
main_title
=
view
.
findViewById
(
R
.
id
.
main_title
);
main_title
.
setText
(
getString
(
R
.
string
.
mc_chat
)
+
"("
+
serviceManagement
.
getMemberNum
()
+
")"
);
btn_hide
=
view
.
findViewById
(
R
.
id
.
btn_hide
);
main_bottom_bar
=
view
.
findViewById
(
R
.
id
.
main_bottom_bar
);
...
...
@@ -79,7 +81,7 @@ public class MycardChatFragment extends BaseFragemnt implements ChatListener {
public
void
reChatJoin
(
boolean
state
)
{
if
(
state
)
{
main_bottom_bar
.
setVisibility
(
View
.
VISIBLE
);
main_title
.
setText
(
getString
(
R
.
string
.
mc_chat
)
+
"("
+
serviceManagement
.
getMemberNum
()
+
")"
);
main_title
.
setText
(
getString
(
R
.
string
.
mc_chat
)
+
"("
+
serviceManagement
.
getMemberNum
()
+
")"
);
}
else
{
main_bottom_bar
.
setVisibility
(
View
.
GONE
);
main_title
.
setText
(
R
.
string
.
reChatJoining
);
...
...
@@ -117,6 +119,7 @@ public class MycardChatFragment extends BaseFragemnt implements ChatListener {
});
btn_hide
.
setOnClickListener
(
p1
->
{
getParentFragmentManager
().
beginTransaction
().
hide
(
homeActivity
.
fragment_mycard_chatting_room
).
commit
();
homeActivity
.
fragment_mycard
.
mWebViewPlus
.
setVisibility
(
View
.
VISIBLE
);
});
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/management/ServiceManagement.java
View file @
d4819f8c
...
...
@@ -70,9 +70,9 @@ public class ServiceManagement {
switch
(
msg
.
what
)
{
case
TYPE_ADD_MESSAGE:
while
(
i
<
chatListenerList
.
size
())
{
ChatListener
c
=
chatListenerList
.
get
(
i
);
if
(
c
.
isListenerEffective
())
{
c
.
addChatMessage
((
ChatMessage
)
msg
.
obj
);
ChatListener
c
hatListener
=
chatListenerList
.
get
(
i
);
if
(
c
hatListener
.
isListenerEffective
())
{
c
hatListener
.
addChatMessage
((
ChatMessage
)
msg
.
obj
);
i
++;
}
else
{
chatListenerList
.
remove
(
i
);
...
...
@@ -81,9 +81,9 @@ public class ServiceManagement {
break
;
case
TYPE_RE_LOGIN:
while
(
i
<
chatListenerList
.
size
())
{
ChatListener
c
=
chatListenerList
.
get
(
i
);
if
(
c
.
isListenerEffective
())
{
c
.
reChatLogin
((
boolean
)
msg
.
obj
);
ChatListener
c
hatListener
=
chatListenerList
.
get
(
i
);
if
(
c
hatListener
.
isListenerEffective
())
{
c
hatListener
.
reChatLogin
((
boolean
)
msg
.
obj
);
i
++;
}
else
{
chatListenerList
.
remove
(
i
);
...
...
@@ -93,9 +93,9 @@ public class ServiceManagement {
case
TYPE_RE_JOIN:
while
(
i
<
chatListenerList
.
size
())
{
ChatListener
c
=
chatListenerList
.
get
(
i
);
if
(
c
.
isListenerEffective
())
{
c
.
reChatJoin
((
boolean
)
msg
.
obj
);
ChatListener
c
hatListener
=
chatListenerList
.
get
(
i
);
if
(
c
hatListener
.
isListenerEffective
())
{
c
hatListener
.
reChatJoin
((
boolean
)
msg
.
obj
);
i
++;
}
else
{
chatListenerList
.
remove
(
i
);
...
...
@@ -115,9 +115,9 @@ public class ServiceManagement {
// break;
case
CHAT_LOGIN_OK:
while
(
i
<
joinChatListenerList
.
size
())
{
OnJoinChatListener
o
u
=
joinChatListenerList
.
get
(
i
);
if
(
o
u
.
isListenerEffective
())
{
o
u
.
onChatLogin
(
null
);
OnJoinChatListener
o
nJoinChatListener
=
joinChatListenerList
.
get
(
i
);
if
(
o
nJoinChatListener
.
isListenerEffective
())
{
o
nJoinChatListener
.
onChatLogin
(
null
);
i
++;
}
else
{
joinChatListenerList
.
remove
(
i
);
...
...
@@ -126,9 +126,9 @@ public class ServiceManagement {
break
;
case
CHAT_LOGIN_EXCEPTION:
while
(
i
<
joinChatListenerList
.
size
())
{
OnJoinChatListener
o
u
=
joinChatListenerList
.
get
(
i
);
if
(
o
u
.
isListenerEffective
())
{
o
u
.
onChatLogin
(
msg
.
obj
+
""
);
OnJoinChatListener
o
nJoinChatListener
=
joinChatListenerList
.
get
(
i
);
if
(
o
nJoinChatListener
.
isListenerEffective
())
{
o
nJoinChatListener
.
onChatLogin
(
msg
.
obj
+
""
);
i
++;
}
else
{
joinChatListenerList
.
remove
(
i
);
...
...
@@ -137,9 +137,9 @@ public class ServiceManagement {
break
;
case
CHAT_LOGIN_LOADING:
while
(
i
<
joinChatListenerList
.
size
())
{
OnJoinChatListener
o
u
=
joinChatListenerList
.
get
(
i
);
if
(
o
u
.
isListenerEffective
())
{
o
u
.
onChatLoginLoading
();
OnJoinChatListener
o
nJoinChatListener
=
joinChatListenerList
.
get
(
i
);
if
(
o
nJoinChatListener
.
isListenerEffective
())
{
o
nJoinChatListener
.
onChatLoginLoading
();
i
++;
}
else
{
joinChatListenerList
.
remove
(
i
);
...
...
@@ -148,9 +148,9 @@ public class ServiceManagement {
break
;
case
CHAT_JOIN_ROOM_LOADING:
while
(
i
<
joinChatListenerList
.
size
())
{
OnJoinChatListener
o
u
=
joinChatListenerList
.
get
(
i
);
if
(
o
u
.
isListenerEffective
())
{
o
u
.
onJoinRoomLoading
();
OnJoinChatListener
o
nJoinChatListener
=
joinChatListenerList
.
get
(
i
);
if
(
o
nJoinChatListener
.
isListenerEffective
())
{
o
nJoinChatListener
.
onJoinRoomLoading
();
i
++;
}
else
{
joinChatListenerList
.
remove
(
i
);
...
...
@@ -159,9 +159,9 @@ public class ServiceManagement {
break
;
case
CHAT_USER_NULL:
while
(
i
<
joinChatListenerList
.
size
())
{
OnJoinChatListener
o
u
=
joinChatListenerList
.
get
(
i
);
if
(
o
u
.
isListenerEffective
())
{
o
u
.
onChatUserNull
();
OnJoinChatListener
o
nJoinChatListener
=
joinChatListenerList
.
get
(
i
);
if
(
o
nJoinChatListener
.
isListenerEffective
())
{
o
nJoinChatListener
.
onChatUserNull
();
i
++;
}
else
{
joinChatListenerList
.
remove
(
i
);
...
...
mobile/src/main/res/layout/fragment_mycard.xml
View file @
d4819f8c
...
...
@@ -79,7 +79,7 @@
android:id=
"@+id/webbrowser"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_weight=
"1
0
"
>
android:layout_weight=
"1
1
"
>
<ProgressBar
android:id=
"@+id/progressBar"
...
...
@@ -103,8 +103,8 @@
android:id=
"@+id/tv_message_s"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/mc_chat"
android:layout_centerVertical=
"true"
android:text=
"@string/mc_chat"
android:textColor=
"@color/holo_green_bright"
android:textStyle=
"bold"
/>
...
...
@@ -114,6 +114,7 @@
android:layout_height=
"15dp"
android:layout_marginLeft=
"10dp"
android:layout_marginTop=
"5dp"
android:visibility=
"gone"
android:layout_centerVertical=
"true"
android:layout_toRightOf=
"@id/tv_message_s"
/>
...
...
@@ -126,7 +127,7 @@
android:layout_centerVertical=
"true"
android:ellipsize=
"end"
android:lines=
"1"
android:text=
""
android:text=
"
@string/login_mycard
"
android:textColor=
"@color/holo_orange_bright"
/>
</RelativeLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
...
...
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