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
21a1dac4
Commit
21a1dac4
authored
Dec 02, 2021
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
加载拓展卡后添加服务器信息
parent
c6261b0e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
9 deletions
+90
-9
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/WebActivity.java
...n/java/cn/garymb/ygomobile/ui/activities/WebActivity.java
+80
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
...c/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
+10
-8
No files found.
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/WebActivity.java
View file @
21a1dac4
package
cn.garymb.ygomobile.ui.activities
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ASSET_SERVER_LIST
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_YGO233_ADVANCE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_YGO233_FILE
;
import
static
cn
.
garymb
.
ygomobile
.
utils
.
DownloadUtil
.
TYPE_DOWNLOAD_EXCEPTION
;
...
...
@@ -10,9 +11,9 @@ import android.content.Intent;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Message
;
import
android.text.TextUtils
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.view.animation.AnimationUtils
;
import
android.widget.Button
;
import
android.widget.Toast
;
...
...
@@ -21,15 +22,29 @@ import androidx.annotation.Nullable;
import
androidx.appcompat.widget.Toolbar
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.OutputStream
;
import
java.util.ArrayList
;
import
java.util.List
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.bean.ServerInfo
;
import
cn.garymb.ygomobile.bean.ServerList
;
import
cn.garymb.ygomobile.lite.BuildConfig
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.home.HomeActivity
;
import
cn.garymb.ygomobile.ui.home.ServerListManager
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.ui.preference.SettingsActivity
;
import
cn.garymb.ygomobile.ui.widget.WebViewPlus
;
import
cn.garymb.ygomobile.utils.DownloadUtil
;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.SystemUtils
;
import
cn.garymb.ygomobile.utils.UnzipUtils
;
import
cn.garymb.ygomobile.utils.XmlUtils
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
ocgcore.DataManager
;
import
ocgcore.data.Card
;
...
...
@@ -39,6 +54,9 @@ public class WebActivity extends BaseActivity {
private
String
mUrl
;
private
String
mTitle
;
private
Button
btn_download
;
private
List
<
ServerInfo
>
serverInfos
;
private
ServerInfo
mServerInfo
;
private
File
xmlFile
;
@SuppressLint
(
"HandlerLeak"
)
Handler
handler
=
new
Handler
()
{
...
...
@@ -64,6 +82,14 @@ public class WebActivity extends BaseActivity {
DataManager
.
get
().
load
(
true
);
Toast
.
makeText
(
getContext
(),
R
.
string
.
ypk_installed
,
Toast
.
LENGTH_LONG
).
show
();
}
String
servername
=
""
;
if
(
getPackageName
().
equals
(
BuildConfig
.
APPLICATION_ID
))
servername
=
"23333先行服务器"
;
if
(
getPackageName
().
equals
((
BuildConfig
.
APPLICATION_ID
)
+
".KO"
))
servername
=
"YGOPRO 사전 게시 중국서버"
;
if
(
getPackageName
().
equals
((
BuildConfig
.
APPLICATION_ID
)
+
".EN"
))
servername
=
"Mercury23333 OCG/TCG Pre-release"
;
AddServer
(
servername
,
"s1.ygo233.com"
,
23333
,
"Knight of Hanoi"
);
btn_download
.
setVisibility
(
View
.
GONE
);
break
;
case
UnzipUtils
.
ZIP_UNZIP_EXCEPTION
:
...
...
@@ -82,6 +108,8 @@ public class WebActivity extends BaseActivity {
setSupportActionBar
(
toolbar
);
enableBackHome
();
mWebViewPlus
=
$
(
R
.
id
.
webbrowser
);
serverInfos
=
new
ArrayList
<>();
xmlFile
=
new
File
(
this
.
getFilesDir
(),
Constants
.
SERVER_FILE
);
initButton
();
/*mWebViewPlus.enableHtml5();
mWebViewPlus.setWebChromeClient(new DefWebChromeClient() {
...
...
@@ -197,6 +225,57 @@ public class WebActivity extends BaseActivity {
});
}
public
void
AddServer
(
String
name
,
String
Addr
,
int
port
,
String
playername
)
{
mServerInfo
=
new
ServerInfo
();
mServerInfo
.
setName
(
name
);
mServerInfo
.
setServerAddr
(
Addr
);
mServerInfo
.
setPort
(
port
);
mServerInfo
.
setPlayerName
(
playername
);
VUiKit
.
defer
().
when
(()
->
{
ServerList
assetList
=
ServerListManager
.
readList
(
this
.
getAssets
().
open
(
ASSET_SERVER_LIST
));
ServerList
fileList
=
xmlFile
.
exists
()
?
ServerListManager
.
readList
(
new
FileInputStream
(
xmlFile
))
:
null
;
if
(
fileList
==
null
)
{
return
assetList
;
}
if
(
fileList
.
getVercode
()
<
assetList
.
getVercode
())
{
xmlFile
.
delete
();
return
assetList
;
}
return
fileList
;
}).
done
((
list
)
->
{
if
(
list
!=
null
)
{
serverInfos
.
clear
();
serverInfos
.
addAll
(
list
.
getServerInfoList
());
boolean
hasServer
=
false
;
for
(
int
i
=
0
;
i
<
list
.
getServerInfoList
().
size
();
i
++)
{
if
(
mServerInfo
.
getPort
()
!=
serverInfos
.
get
(
i
).
getPort
()
&&
mServerInfo
.
getServerAddr
()
!=
serverInfos
.
get
(
i
).
getServerAddr
())
{
continue
;
}
else
{
hasServer
=
true
;
break
;
}
}
if
(!
hasServer
&&
!
serverInfos
.
contains
(
mServerInfo
))
{
serverInfos
.
add
(
mServerInfo
);
}
saveItems
();
}
});
}
public
void
saveItems
()
{
OutputStream
outputStream
=
null
;
try
{
outputStream
=
new
FileOutputStream
(
xmlFile
);
XmlUtils
.
get
().
saveXml
(
new
ServerList
(
SystemUtils
.
getVersion
(
getContext
()),
serverInfos
),
outputStream
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
IOUtils
.
close
(
outputStream
);
}
}
private
void
downloadfromWeb
()
{
File
file
=
new
File
(
AppsSettings
.
get
().
getResourcePath
()
+
".zip"
);
if
(
file
.
exists
())
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
View file @
21a1dac4
...
...
@@ -143,7 +143,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
};
//x5内核初始化接口
QbSdk
.
initX5Environment
(
this
,
cb
);
if
(!
BuildConfig
.
BUILD_TYPE
.
equals
(
"debug"
))
{
if
(!
BuildConfig
.
BUILD_TYPE
.
equals
(
"debug"
))
{
//release才检查版本
if
(!
Constants
.
ACTION_OPEN_GAME
.
equals
(
getIntent
().
getAction
()))
{
Log
.
d
(
Constants
.
TAG
,
"start check update"
);
...
...
@@ -166,6 +166,8 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
super
.
onResume
();
BacktoDuel
();
duelAssistantCheck
();
//server list
mServerListManager
.
syncLoadData
();
}
@Override
...
...
@@ -196,9 +198,9 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
}
@Override
public
void
onJoinRoom
(
String
host
,
int
port
,
String
password
,
int
id
)
{
public
void
onJoinRoom
(
String
host
,
int
port
,
String
password
,
int
id
)
{
if
(
id
==
ID_MAINACTIVITY
)
{
quickjoinRoom
(
host
,
port
,
password
);
quickjoinRoom
(
host
,
port
,
password
);
}
}
...
...
@@ -314,7 +316,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
break
;
case
R
.
id
.
action_game
:
setRandomCardDetail
();
if
(
mCardDetailRandom
!=
null
)
{
if
(
mCardDetailRandom
!=
null
)
{
mCardDetailRandom
.
show
();
}
openGame
();
...
...
@@ -620,7 +622,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
});
}
public
void
quickjoinRoom
(
String
host
,
int
port
,
String
password
)
{
public
void
quickjoinRoom
(
String
host
,
int
port
,
String
password
)
{
String
message
;
if
(!
TextUtils
.
isEmpty
(
host
))
...
...
@@ -657,10 +659,10 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
return
fileList
;
}).
done
((
list
)
->
{
if
(
list
!=
null
)
{
String
host1
=
host
;
int
port1
=
port
;
String
host1
=
host
;
int
port1
=
port
;
ServerInfo
serverInfo
=
list
.
getServerInfoList
().
get
(
0
);
if
(!
TextUtils
.
isEmpty
(
host1
)){
if
(!
TextUtils
.
isEmpty
(
host1
))
{
serverInfo
.
setServerAddr
(
host1
);
serverInfo
.
setPort
(
port1
);
}
...
...
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