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
02a223c1
Commit
02a223c1
authored
Jul 29, 2022
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化聊天室初始化登录
parent
6e4bf02f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
160 deletions
+82
-160
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/MyCard.java
...e/src/main/java/cn/garymb/ygomobile/ui/mycard/MyCard.java
+0
-34
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/MycardFragment.java
...in/java/cn/garymb/ygomobile/ui/mycard/MycardFragment.java
+2
-2
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/X5WebView.java
...rc/main/java/cn/garymb/ygomobile/ui/mycard/X5WebView.java
+18
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/ChatMessage.java
...ava/cn/garymb/ygomobile/ui/mycard/mcchat/ChatMessage.java
+2
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/SplashActivity.java
.../cn/garymb/ygomobile/ui/mycard/mcchat/SplashActivity.java
+60
-123
No files found.
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/MyCard.java
View file @
02a223c1
...
@@ -102,7 +102,6 @@ public class MyCard {
...
@@ -102,7 +102,6 @@ public class MyCard {
public
MyCard
(
Activity
context
)
{
public
MyCard
(
Activity
context
)
{
mContext
=
context
;
mContext
=
context
;
//context.getActionBar().hide();
lastModified
=
context
.
getSharedPreferences
(
"lastModified"
,
Context
.
MODE_PRIVATE
);
lastModified
=
context
.
getSharedPreferences
(
"lastModified"
,
Context
.
MODE_PRIVATE
);
mDefWebViewClient
=
new
DefWebViewClient
()
{
mDefWebViewClient
=
new
DefWebViewClient
()
{
@Override
@Override
...
@@ -258,40 +257,7 @@ public class MyCard {
...
@@ -258,40 +257,7 @@ public class MyCard {
this
.
activity
=
activity
;
this
.
activity
=
activity
;
mListener
=
listener
;
mListener
=
listener
;
}
}
/*
@JavascriptInterface
public void edit_deck() {
activity.startActivity(new Intent(activity, DeckManagerFragment.class));
}
@JavascriptInterface
public void watch_replay() {
if (mListener != null) {
activity.runOnUiThread(mListener::watchReplay);
}
}
@JavascriptInterface
public void puzzle_mode() {
if (mListener != null) {
activity.runOnUiThread(mListener::puzzleMode);
}
}
@JavascriptInterface
public void openDrawer() {
if (mListener != null) {
activity.runOnUiThread(mListener::openDrawer);
}
}
@JavascriptInterface
public void closeDrawer() {
if (mListener != null) {
activity.runOnUiThread(mListener::closeDrawer);
}
}
*/
@JavascriptInterface
@JavascriptInterface
public
void
backHome
()
{
public
void
backHome
()
{
if
(
mListener
!=
null
)
{
if
(
mListener
!=
null
)
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/MycardFragment.java
View file @
02a223c1
...
@@ -352,7 +352,7 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
...
@@ -352,7 +352,7 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
currentMessage
=
data
.
get
(
data
.
size
()
-
1
);
currentMessage
=
data
.
get
(
data
.
size
()
-
1
);
}
}
if
(
currentMessage
==
null
)
if
(
currentMessage
==
null
)
tv_message
.
setText
(
"聊天信息加载中"
);
tv_message
.
setText
(
R
.
string
.
loading
);
else
else
tv_message
.
setText
(
currentMessage
.
getName
()
+
":"
+
currentMessage
.
getMessage
());
tv_message
.
setText
(
currentMessage
.
getName
()
+
":"
+
currentMessage
.
getMessage
());
}
else
{
}
else
{
...
@@ -378,7 +378,7 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
...
@@ -378,7 +378,7 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
public
void
onChatUserNull
()
{
public
void
onChatUserNull
()
{
Log
.
e
(
"MyCardFragment"
,
"为空"
);
Log
.
e
(
"MyCardFragment"
,
"为空"
);
pb_chat_loading
.
setVisibility
(
View
.
GONE
);
pb_chat_loading
.
setVisibility
(
View
.
GONE
);
tv_message
.
setText
(
"登录失败,请退出登录后重新登录"
);
tv_message
.
setText
(
R
.
string
.
logining_failed
);
}
}
@Override
@Override
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/X5WebView.java
View file @
02a223c1
...
@@ -6,6 +6,8 @@ import android.graphics.Canvas;
...
@@ -6,6 +6,8 @@ import android.graphics.Canvas;
import
android.util.AttributeSet
;
import
android.util.AttributeSet
;
import
android.view.View
;
import
android.view.View
;
import
com.tencent.smtt.sdk.CookieManager
;
import
com.tencent.smtt.sdk.CookieSyncManager
;
import
com.tencent.smtt.sdk.WebSettings
;
import
com.tencent.smtt.sdk.WebSettings
;
import
com.tencent.smtt.sdk.WebView
;
import
com.tencent.smtt.sdk.WebView
;
import
com.tencent.smtt.sdk.WebViewClient
;
import
com.tencent.smtt.sdk.WebViewClient
;
...
@@ -95,5 +97,21 @@ public class X5WebView extends WebView {
...
@@ -95,5 +97,21 @@ public class X5WebView extends WebView {
return
super
.
drawChild
(
canvas
,
child
,
drawingTime
);
return
super
.
drawChild
(
canvas
,
child
,
drawingTime
);
}
}
//清除所有cookie
public
void
removeAllCookie
(
String
urlpath
)
{
CookieSyncManager
cookieSyncManager
=
CookieSyncManager
.
createInstance
(
getContext
());
CookieManager
cookieManager
=
CookieManager
.
getInstance
();
cookieManager
.
setAcceptCookie
(
true
);
cookieManager
.
removeSessionCookie
();
String
testcookie1
=
cookieManager
.
getCookie
(
urlpath
);
cookieManager
.
removeAllCookie
();
cookieSyncManager
.
sync
();
String
testcookie2
=
cookieManager
.
getCookie
(
urlpath
);
}
public
void
removeAllCookie
()
{
removeAllCookie
(
getUrl
());
}
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/ChatMessage.java
View file @
02a223c1
...
@@ -23,7 +23,8 @@ public class ChatMessage {
...
@@ -23,7 +23,8 @@ public class ChatMessage {
}
}
*/
*/
public
static
ChatMessage
toChatMessage
(
Message
message
)
{
public
static
ChatMessage
toChatMessage
(
Message
message
)
{
if
(
message
==
null
)
return
null
;
if
(
message
.
getBody
()
!=
null
)
{
if
(
message
.
getBody
()
!=
null
)
{
String
xs
=
message
.
toString
();
String
xs
=
message
.
toString
();
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/SplashActivity.java
View file @
02a223c1
package
cn.garymb.ygomobile.ui.mycard.mcchat
;
package
cn.garymb.ygomobile.ui.mycard.mcchat
;
import
android.annotation.SuppressLint
;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.
os.Handler
;
import
android.
text.TextUtils
;
import
android.
os.Message
;
import
android.
util.Log
;
import
android.view.View
;
import
android.view.View
;
import
android.view.View.OnClickListener
;
import
android.widget.LinearLayout
;
import
android.widget.LinearLayout
;
import
android.widget.ProgressBar
;
import
android.widget.ProgressBar
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
org.jivesoftware.smack.SmackException
;
import
com.ourygo.assistant.util.Util
;
import
org.jivesoftware.smack.XMPPException
;
import
java.io.IOException
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.mycard.
MycardFragment
;
import
cn.garymb.ygomobile.ui.mycard.
base.OnJoinChatListener
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.management.ServiceManagement
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.management.ServiceManagement
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.management.UserManagement
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.management.UserManagement
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
public
class
SplashActivity
extends
Activity
{
public
class
SplashActivity
extends
Activity
implements
OnJoinChatListener
{
public
static
final
int
CHAT_LOGIN_EXCEPTION_RE
=
0
;
public
static
final
int
CHAT_LOGIN_OK
=
1
;
public
static
final
int
CHAT_LOGIN_EXCEPTION
=
2
;
public
static
final
int
CHAT_LOGIN_LOADING
=
3
;
public
static
final
int
CHAT_JOIN_ROOM_LOADING
=
4
;
public
static
final
int
CHAT_USER_NULL
=
5
;
ServiceManagement
su
;
ServiceManagement
su
;
ProgressBar
sp_jz
;
ProgressBar
sp_jz
;
TextView
sp_tv
;
TextView
sp_tv
;
LinearLayout
sp_li
;
LinearLayout
sp_li
;
@SuppressLint
(
"HandlerLeak"
)
Handler
han
=
new
Handler
()
{
@Override
public
void
handleMessage
(
Message
msg
)
{
// TODO: Implement this method
super
.
handleMessage
(
msg
);
switch
(
msg
.
what
)
{
case
0
:
su
.
setIsConnected
(
false
);
sp_jz
.
setVisibility
(
View
.
GONE
);
sp_tv
.
setText
(
getString
(
R
.
string
.
logining_failed
));
YGOUtil
.
show
(
getString
(
R
.
string
.
failed_reason
)
+
msg
.
obj
);
break
;
case
1
:
startActivity
(
new
Intent
(
SplashActivity
.
this
,
McchatActivity
.
class
));
finish
();
break
;
case
2
:
su
.
setIsListener
(
false
);
sp_jz
.
setVisibility
(
View
.
GONE
);
sp_tv
.
setText
(
getString
(
R
.
string
.
logining_failed
));
break
;
case
3
:
sp_jz
.
setVisibility
(
View
.
VISIBLE
);
sp_tv
.
setText
(
getString
(
R
.
string
.
logining_in
));
break
;
case
4
:
sp_jz
.
setVisibility
(
View
.
VISIBLE
);
sp_tv
.
setText
(
getString
(
R
.
string
.
logining_in
));
break
;
case
5
:
/*sp_jz.setVisibility(View.GONE);
sp_tv.setText("用户名或密码为空");*/
startActivity
(
new
Intent
(
SplashActivity
.
this
,
MycardFragment
.
class
));
finish
();
break
;
}
}
};
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
@@ -94,92 +53,70 @@ public class SplashActivity extends Activity {
...
@@ -94,92 +53,70 @@ public class SplashActivity extends Activity {
UserManagement
.
setUserPassword
(
lastModified
.
getString
(
"user_external_id"
,
null
));
UserManagement
.
setUserPassword
(
lastModified
.
getString
(
"user_external_id"
,
null
));
su
=
ServiceManagement
.
getDx
();
su
=
ServiceManagement
.
getDx
();
join
();
su
.
addJoinRoomListener
(
this
);
su
.
start
();
}
}
private
void
join
()
{
if
(!
su
.
isListener
())
{
new
Thread
(()
->
{
if
(!
su
.
isConnected
())
{
han
.
sendEmptyMessage
(
4
);
login
();
}
if
(
su
.
isConnected
())
{
han
.
sendEmptyMessage
(
3
);
try
{
su
.
joinChat
();
han
.
sendEmptyMessage
(
1
);
}
catch
(
Exception
e
)
{
han
.
sendEmptyMessage
(
2
);
}
}
// TODO: Implement this method
}).
start
();
}
else
{
han
.
sendEmptyMessage
(
1
);
}
// TODO: Implement this method
}
private
void
initView
()
{
private
void
initView
()
{
sp_jz
=
findViewById
(
R
.
id
.
sp_jz
);
sp_jz
=
findViewById
(
R
.
id
.
sp_jz
);
sp_tv
=
findViewById
(
R
.
id
.
sp_tv
);
sp_tv
=
findViewById
(
R
.
id
.
sp_tv
);
sp_li
=
findViewById
(
R
.
id
.
sp_li
);
sp_li
=
findViewById
(
R
.
id
.
sp_li
);
sp_li
.
setOnClickListener
(
new
OnClickListener
()
{
sp_li
.
setOnClickListener
(
p1
->
{
su
.
start
();
@Override
// TODO: Implement this method
public
void
onClick
(
View
p1
)
{
join
();
// TODO: Implement this method
}
});
});
// TODO: Implement this method
// TODO: Implement this method
}
}
private
void
login
()
{
// @Override
// public void onLoginExceptionClickRe() {
String
name
=
UserManagement
.
getUserName
();
// su.setIsConnected(false);
String
password
=
UserManagement
.
getUserPassword
();
// sp_jz.setVisibility(View.GONE);
if
(
name
!=
null
&&
password
!=
null
)
{
// sp_tv.setText(getString(R.string.logining_failed));
Message
me
=
new
Message
();
// YGOUtil.show(getString(R.string.failed_reason) + msg.obj);
me
.
what
=
0
;
// }
try
{
@Override
su
.
login
(
name
,
password
);
public
void
onChatLogin
(
String
exception
)
{
}
catch
(
InterruptedException
e
)
{
Log
.
e
(
"SplashActivity"
,
"登录情况"
+
exception
);
e
.
printStackTrace
();
sp_jz
.
setVisibility
(
View
.
GONE
);
me
.
obj
=
"InterruptedException:"
+
e
;
if
(
TextUtils
.
isEmpty
(
exception
))
{
han
.
sendMessage
(
me
);
startActivity
(
new
Intent
(
SplashActivity
.
this
,
McchatActivity
.
class
));
}
catch
(
IOException
e
)
{
finish
();
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
{
}
else
{
han
.
sendEmptyMessage
(
5
);
su
.
setIsListener
(
false
);
sp_tv
.
setText
(
getString
(
R
.
string
.
logining_failed
));
YGOUtil
.
show
(
getString
(
R
.
string
.
failed_reason
)
+
exception
);
}
}
}
// TODO: Implement this method
@Override
public
void
onChatLoginLoading
()
{
Log
.
e
(
"SplashActivity"
,
"登录中"
);
sp_jz
.
setVisibility
(
View
.
VISIBLE
);
sp_tv
.
setText
(
getString
(
R
.
string
.
logining_in
));
}
@Override
public
void
onJoinRoomLoading
()
{
Log
.
e
(
"SplashActivity"
,
"加入房间中"
);
sp_jz
.
setVisibility
(
View
.
VISIBLE
);
sp_tv
.
setText
(
getString
(
R
.
string
.
logining_in
));
}
@Override
public
void
onChatUserNull
()
{
Log
.
e
(
"SplashActivity"
,
"用户为空"
);
finish
();
}
@Override
public
boolean
isListenerEffective
()
{
return
Util
.
isContextExisted
(
this
);
}
}
}
}
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