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
4f0ba4da
Commit
4f0ba4da
authored
Jul 02, 2019
by
feihuaduo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
变量名优化
加入部分log
parent
e4996ead
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
23 deletions
+62
-23
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/SplashActivity.java
.../cn/garymb/ygomobile/ui/mycard/mcchat/SplashActivity.java
+35
-4
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/management/ServiceManagement.java
...mobile/ui/mycard/mcchat/management/ServiceManagement.java
+27
-19
No files found.
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/SplashActivity.java
View file @
4f0ba4da
package
cn.garymb.ygomobile.ui.mycard.mcchat
;
import
android.annotation.SuppressLint
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Intent
;
...
...
@@ -13,6 +14,11 @@ import android.widget.LinearLayout;
import
android.widget.ProgressBar
;
import
android.widget.TextView
;
import
org.jivesoftware.smack.SmackException
;
import
org.jivesoftware.smack.XMPPException
;
import
java.io.IOException
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.mycard.MyCardActivity
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.management.ServiceManagement
;
...
...
@@ -25,6 +31,7 @@ public class SplashActivity extends Activity {
ProgressBar
sp_jz
;
TextView
sp_tv
;
LinearLayout
sp_li
;
@SuppressLint
(
"HandlerLeak"
)
Handler
han
=
new
Handler
()
{
@Override
...
...
@@ -141,14 +148,38 @@ public class SplashActivity extends Activity {
String
name
=
UserManagement
.
getUserName
();
String
password
=
UserManagement
.
getUserPassword
();
if
(
name
!=
null
&&
password
!=
null
)
{
Message
me
=
new
Message
();
me
.
what
=
0
;
try
{
su
.
login
(
name
,
password
);
}
catch
(
Exception
e
)
{
Message
me
=
new
Message
();
me
.
obj
=
e
;
me
.
what
=
0
;
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
me
.
obj
=
"InterruptedException:"
+
e
;
han
.
sendMessage
(
me
);
}
catch
(
IOException
e
)
{
me
.
obj
=
"IOException:"
+
e
;
e
.
printStackTrace
();
han
.
sendMessage
(
me
);
}
catch
(
SmackException
e
)
{
me
.
obj
=
"SmackException:"
+
e
;
e
.
printStackTrace
();
han
.
sendMessage
(
me
);
}
catch
(
XMPPException
e
)
{
me
.
obj
=
"XMPPException:"
+
e
;
e
.
printStackTrace
();
han
.
sendMessage
(
me
);
}
catch
(
Exception
e
){
me
.
obj
=
"其他错误:"
+
e
;
e
.
printStackTrace
();
han
.
sendMessage
(
me
);
}
// catch (Exception e) {
// Message me = new Message();
// me.obj = e;
// me.what = 0;
// han.sendMessage(me);
// }
}
else
{
han
.
sendEmptyMessage
(
5
);
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/management/ServiceManagement.java
View file @
4f0ba4da
package
cn.garymb.ygomobile.ui.mycard.mcchat.management
;
import
android.annotation.SuppressLint
;
import
android.os.Handler
;
import
android.util.Log
;
...
...
@@ -24,6 +25,7 @@ import java.util.List;
import
cn.garymb.ygomobile.ui.mycard.mcchat.ChatListener
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.ChatMessage
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.util.TaxiConnectionListener
;
import
cn.garymb.ygomobile.utils.FileLogUtil
;
public
class
ServiceManagement
{
public
static
final
String
GROUP_ADDRESS
=
"ygopro_china_north@conference.mycard.moe"
;
...
...
@@ -33,8 +35,9 @@ public class ServiceManagement {
private
MultiUserChat
muc
;
private
boolean
isConnected
=
false
;
private
boolean
isListener
=
false
;
private
List
<
ChatMessage
>
data
=
new
ArrayList
<
ChatMessage
>();
private
List
<
ChatListener
>
cl
=
new
ArrayList
<
ChatListener
>();
private
List
<
ChatMessage
>
chatMessageList
;
private
List
<
ChatListener
>
chatListenerList
;
@SuppressLint
(
"HandlerLeak"
)
Handler
han
=
new
Handler
()
{
@Override
...
...
@@ -43,40 +46,39 @@ public class ServiceManagement {
super
.
handleMessage
(
msg
);
switch
(
msg
.
what
)
{
case
0
:
for
(
ChatListener
c
:
c
l
)
{
for
(
ChatListener
c
:
c
hatListenerList
)
{
if
(
c
!=
null
)
{
c
.
addMessage
((
Message
)
msg
.
obj
);
}
else
{
c
l
.
remove
(
c
);
c
hatListenerList
.
remove
(
c
);
}
}
break
;
case
1
:
for
(
ChatListener
c
:
c
l
)
{
for
(
ChatListener
c
:
c
hatListenerList
)
{
if
(
c
!=
null
)
{
c
.
reLogin
((
boolean
)
msg
.
obj
);
}
else
{
c
l
.
remove
(
c
);
c
hatListenerList
.
remove
(
c
);
}
}
break
;
case
2
:
for
(
ChatListener
c
:
c
l
)
{
for
(
ChatListener
c
:
c
hatListenerList
)
{
if
(
c
!=
null
)
{
c
.
reJoin
((
boolean
)
msg
.
obj
);
}
else
{
c
l
.
remove
(
c
);
c
hatListenerList
.
remove
(
c
);
}
}
break
;
}
}
};
private
ServiceManagement
()
{
chatMessageList
=
new
ArrayList
<>();
chatListenerList
=
new
ArrayList
<>();
}
public
static
ServiceManagement
getDx
()
{
...
...
@@ -84,11 +86,11 @@ public class ServiceManagement {
}
public
void
addListener
(
ChatListener
c
)
{
c
l
.
add
(
c
);
c
hatListenerList
.
add
(
c
);
}
public
List
<
ChatMessage
>
getData
()
{
return
data
;
return
chatMessageList
;
}
public
void
setIsListener
(
boolean
isListener
)
{
...
...
@@ -111,7 +113,7 @@ public class ServiceManagement {
return
con
;
}
private
XMPPTCPConnection
getConnextion
(
String
name
,
String
password
)
throws
XmppStringprep
Exception
{
private
XMPPTCPConnection
getConnextion
(
String
name
,
String
password
)
throws
IO
Exception
{
XMPPTCPConnectionConfiguration
config
=
XMPPTCPConnectionConfiguration
.
builder
()
.
setUsernameAndPassword
(
name
,
password
)
.
setXmppDomain
(
"mycard.moe"
)
...
...
@@ -119,18 +121,24 @@ public class ServiceManagement {
.
setSecurityMode
(
ConnectionConfiguration
.
SecurityMode
.
disabled
)
.
setHost
(
"chat.mycard.moe"
)
.
build
();
FileLogUtil
.
writeAndTime
(
"初始化配置"
);
con
=
new
XMPPTCPConnection
(
config
);
FileLogUtil
.
writeAndTime
(
"建立新配置"
);
return
con
;
}
public
boolean
login
(
String
name
,
String
password
)
throws
IOException
,
SmackException
,
XMPPException
,
InterruptedException
{
FileLogUtil
.
writeAndTime
(
"获取配置之前"
);
XMPPTCPConnection
con
=
getConnextion
(
name
,
password
);
FileLogUtil
.
writeAndTime
(
"获取配置完毕"
);
con
.
connect
();
FileLogUtil
.
writeAndTime
(
"连接完毕"
);
if
(
con
.
isConnected
())
{
con
.
login
();
FileLogUtil
.
writeAndTime
(
"登陆完毕"
);
con
.
addConnectionListener
(
new
TaxiConnectionListener
());
FileLogUtil
.
writeAndTime
(
"设置监听完毕"
);
setIsConnected
(
true
);
return
true
;
}
...
...
@@ -147,7 +155,7 @@ public class ServiceManagement {
MultiUserChatManager
multiUserChatManager
=
MultiUserChatManager
.
getInstanceFor
(
getCon
());
muc
=
multiUserChatManager
.
getMultiUserChat
(
JidCreate
.
entityBareFrom
(
GROUP_ADDRESS
));
muc
.
createOrJoin
(
Resourcepart
.
from
(
UserManagement
.
getUserName
()));
data
.
clear
();
chatMessageList
.
clear
();
muc
.
addMessageListener
(
new
MessageListener
()
{
@Override
public
void
processMessage
(
Message
message
)
{
...
...
@@ -155,7 +163,7 @@ public class ServiceManagement {
Log
.
e
(
"接收消息"
,
"接收"
+
message
);
ChatMessage
cm
=
ChatMessage
.
toChatMessage
(
message
);
if
(
cm
!=
null
)
{
data
.
add
(
cm
);
chatMessageList
.
add
(
cm
);
han
.
sendEmptyMessage
(
0
);
}
}
...
...
@@ -187,8 +195,8 @@ public class ServiceManagement {
disSerVice
();
setIsConnected
(
false
);
setIsListener
(
false
);
data
.
clear
();
c
l
.
clear
();
chatMessageList
.
clear
();
c
hatListenerList
.
clear
();
}
}
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