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
3062c6d4
Commit
3062c6d4
authored
Oct 25, 2018
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试数据库加载
parent
75eb6cd4
Changes
25
Show whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
336 additions
and
275 deletions
+336
-275
Classes/gframe/data_manager.cpp
Classes/gframe/data_manager.cpp
+13
-7
Classes/gframe/data_manager.h
Classes/gframe/data_manager.h
+1
-1
Classes/gframe/gframe.cpp
Classes/gframe/gframe.cpp
+5
-1
Classes/sqlite3/Android.mk
Classes/sqlite3/Android.mk
+2
-1
mobile/src/main/java/cn/garymb/ygomobile/App.java
mobile/src/main/java/cn/garymb/ygomobile/App.java
+2
-0
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
+7
-4
mobile/src/main/java/cn/garymb/ygomobile/YGOStarter.java
mobile/src/main/java/cn/garymb/ygomobile/YGOStarter.java
+3
-3
mobile/src/main/java/cn/garymb/ygomobile/loader/CardLoader.java
.../src/main/java/cn/garymb/ygomobile/loader/CardLoader.java
+13
-18
mobile/src/main/java/cn/garymb/ygomobile/loader/ICardLoader.java
...src/main/java/cn/garymb/ygomobile/loader/ICardLoader.java
+1
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/adapters/CardListAdapter.java
...java/cn/garymb/ygomobile/ui/adapters/CardListAdapter.java
+2
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/adapters/SimpleSpinnerAdapter.java
...cn/garymb/ygomobile/ui/adapters/SimpleSpinnerAdapter.java
+11
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/BaseCardsAcitivity.java
...java/cn/garymb/ygomobile/ui/cards/BaseCardsAcitivity.java
+4
-2
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardSearchActivityImpl.java
.../cn/garymb/ygomobile/ui/cards/CardSearchActivityImpl.java
+11
-12
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardSearcher.java
.../main/java/cn/garymb/ygomobile/ui/cards/CardSearcher.java
+19
-17
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivity3.java
...va/cn/garymb/ygomobile/ui/cards/DeckManagerActivity3.java
+4
-9
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivityImpl.java
...cn/garymb/ygomobile/ui/cards/DeckManagerActivityImpl.java
+12
-17
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivityImpl2.java
...n/garymb/ygomobile/ui/cards/DeckManagerActivityImpl2.java
+14
-19
mobile/src/main/java/cn/garymb/ygomobile/ui/home/ImageUpdater.java
...c/main/java/cn/garymb/ygomobile/ui/home/ImageUpdater.java
+2
-6
mobile/src/main/java/cn/garymb/ygomobile/ui/home/ResCheckTask.java
...c/main/java/cn/garymb/ygomobile/ui/home/ResCheckTask.java
+11
-2
mobile/src/main/java/cn/garymb/ygomobile/ui/preference/fragments/SettingFragment.java
...mb/ygomobile/ui/preference/fragments/SettingFragment.java
+23
-20
mobile/src/main/java/ocgcore/CardManager.java
mobile/src/main/java/ocgcore/CardManager.java
+43
-52
mobile/src/main/java/ocgcore/ConfigManager.java
mobile/src/main/java/ocgcore/ConfigManager.java
+10
-3
mobile/src/main/java/ocgcore/DataManager.java
mobile/src/main/java/ocgcore/DataManager.java
+67
-0
mobile/src/main/java/ocgcore/LimitManager.java
mobile/src/main/java/ocgcore/LimitManager.java
+38
-55
mobile/src/main/java/ocgcore/StringManager.java
mobile/src/main/java/ocgcore/StringManager.java
+18
-24
No files found.
Classes/gframe/data_manager.cpp
View file @
3062c6d4
...
@@ -9,14 +9,15 @@ DataManager dataManager;
...
@@ -9,14 +9,15 @@ DataManager dataManager;
bool
DataManager
::
LoadDB
(
const
char
*
file
)
{
bool
DataManager
::
LoadDB
(
const
char
*
file
)
{
sqlite3
*
pDB
;
sqlite3
*
pDB
;
if
(
sqlite3_open_v2
(
file
,
&
pDB
,
SQLITE_OPEN_READONLY
,
0
)
!=
SQLITE_OK
)
int
err
=
0
;
return
Error
(
pDB
);
if
((
err
=
sqlite3_open_v2
(
file
,
&
pDB
,
SQLITE_OPEN_READONLY
,
0
))
!=
SQLITE_OK
)
return
Error
(
pDB
,
NULL
,
err
);
sqlite3_stmt
*
pStmt
;
sqlite3_stmt
*
pStmt
;
const
char
*
sql_2
=
"select datas._id, ot, alias, setcode, type, atk, def, level, race, attribute, category, texts.* from datas,texts where datas._id = texts._id;"
;
const
char
*
sql_2
=
"select datas._id, ot, alias, setcode, type, atk, def, level, race, attribute, category, texts.* from datas,texts where datas._id = texts._id;"
;
const
char
*
sql
=
"select datas.id, ot, alias, setcode, type, atk, def, level, race, attribute, category, texts.* from datas,texts where datas.id = texts.id;"
;
const
char
*
sql
=
"select datas.id, ot, alias, setcode, type, atk, def, level, race, attribute, category, texts.* from datas,texts where datas.id = texts.id;"
;
if
(
sqlite3_prepare_v2
(
pDB
,
sql
,
-
1
,
&
pStmt
,
0
)
!=
SQLITE_OK
){
if
(
(
err
=
sqlite3_prepare_v2
(
pDB
,
sql
,
-
1
,
&
pStmt
,
0
)
)
!=
SQLITE_OK
){
if
(
sqlite3_prepare_v2
(
pDB
,
sql_2
,
-
1
,
&
pStmt
,
0
)
!=
SQLITE_OK
){
if
(
(
err
=
sqlite3_prepare_v2
(
pDB
,
sql_2
,
-
1
,
&
pStmt
,
0
)
)
!=
SQLITE_OK
){
return
Error
(
pDB
);
return
Error
(
pDB
,
NULL
,
err
);
}
}
}
}
CardDataC
cd
;
CardDataC
cd
;
...
@@ -102,10 +103,15 @@ bool DataManager::LoadStrings(const char* file) {
...
@@ -102,10 +103,15 @@ bool DataManager::LoadStrings(const char* file) {
myswprintf
(
numStrings
[
i
],
L"%d"
,
i
);
myswprintf
(
numStrings
[
i
],
L"%d"
,
i
);
return
true
;
return
true
;
}
}
bool
DataManager
::
Error
(
sqlite3
*
pDB
,
sqlite3_stmt
*
pStmt
)
{
bool
DataManager
::
Error
(
sqlite3
*
pDB
,
sqlite3_stmt
*
pStmt
,
int
errNo
)
{
BufferIO
::
DecodeUTF8
(
sqlite3_errmsg
(
pDB
),
strBuffer
);
const
char
*
msg
=
sqlite3_errmsg
(
pDB
);
BufferIO
::
DecodeUTF8
(
msg
,
strBuffer
);
if
(
pStmt
)
if
(
pStmt
)
sqlite3_finalize
(
pStmt
);
sqlite3_finalize
(
pStmt
);
int
len
=
strlen
(
msg
);
char
buff
[
len
+
32
];
sprintf
(
buff
,
"cdb Error code=%d,msg=%s"
,
errNo
,
msg
);
os
::
Printer
::
log
(
buff
);
sqlite3_close
(
pDB
);
sqlite3_close
(
pDB
);
return
false
;
return
false
;
}
}
...
...
Classes/gframe/data_manager.h
View file @
3062c6d4
...
@@ -17,7 +17,7 @@ public:
...
@@ -17,7 +17,7 @@ public:
DataManager
()
:
_datas
(
8192
),
_strings
(
8192
)
{}
DataManager
()
:
_datas
(
8192
),
_strings
(
8192
)
{}
bool
LoadDB
(
const
char
*
file
);
bool
LoadDB
(
const
char
*
file
);
bool
LoadStrings
(
const
char
*
file
);
bool
LoadStrings
(
const
char
*
file
);
bool
Error
(
sqlite3
*
pDB
,
sqlite3_stmt
*
pStmt
=
0
);
bool
Error
(
sqlite3
*
pDB
,
sqlite3_stmt
*
pStmt
=
0
,
int
err
=
0
);
bool
GetData
(
int
code
,
CardData
*
pData
);
bool
GetData
(
int
code
,
CardData
*
pData
);
code_pointer
GetCodePointer
(
int
code
);
code_pointer
GetCodePointer
(
int
code
);
bool
GetString
(
int
code
,
CardString
*
pStr
);
bool
GetString
(
int
code
,
CardString
*
pStr
);
...
...
Classes/gframe/gframe.cpp
View file @
3062c6d4
...
@@ -45,7 +45,11 @@ int main(int argc, char* argv[]) {
...
@@ -45,7 +45,11 @@ int main(int argc, char* argv[]) {
MultiByteToWideChar
(
CP_ACP
,
0
,
&
argv
[
i
][
2
],
-
1
,
fname
,
260
);
MultiByteToWideChar
(
CP_ACP
,
0
,
&
argv
[
i
][
2
],
-
1
,
fname
,
260
);
char
fname2
[
260
];
char
fname2
[
260
];
BufferIO
::
EncodeUTF8
(
fname
,
fname2
);
BufferIO
::
EncodeUTF8
(
fname
,
fname2
);
ygo
::
dataManager
.
LoadDB
(
fname2
);
if
(
ygo
::
dataManager
.
LoadDB
(
fname2
)){
os
::
Printer
::
log
(
"add cdb ok "
,
fname2
);
}
else
{
os
::
Printer
::
log
(
"add cdb fail "
,
fname2
);
}
#else
#else
ygo
::
dataManager
.
LoadDB
(
&
argv
[
i
][
2
]);
ygo
::
dataManager
.
LoadDB
(
&
argv
[
i
][
2
]);
#endif
#endif
...
...
Classes/sqlite3/Android.mk
View file @
3062c6d4
...
@@ -8,6 +8,7 @@ LOCAL_MODULE_FILENAME := libsqlite
...
@@ -8,6 +8,7 @@ LOCAL_MODULE_FILENAME := libsqlite
LOCAL_SRC_FILES
:=
sqlite3.c
LOCAL_SRC_FILES
:=
sqlite3.c
LOCAL_CFLAGS
:=
-O2
-Wall
LOCAL_CFLAGS
:=
-O2
-Wall
#LOCAL_CFLAGS += -DSQLITE_THREADSAFE=1
include
$(BUILD_STATIC_LIBRARY)
include
$(BUILD_STATIC_LIBRARY)
mobile/src/main/java/cn/garymb/ygomobile/App.java
View file @
3062c6d4
...
@@ -5,6 +5,8 @@ import android.app.Activity;
...
@@ -5,6 +5,8 @@ import android.app.Activity;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.support.v7.app.AppCompatDelegate
;
import
android.support.v7.app.AppCompatDelegate
;
import
ocgcore.DataManager
;
public
class
App
extends
GameApplication
{
public
class
App
extends
GameApplication
{
@Override
@Override
...
...
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
View file @
3062c6d4
package
cn.garymb.ygomobile
;
package
cn.garymb.ygomobile
;
import
android.annotation.SuppressLint
;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Context
;
import
android.os.Environment
;
import
android.os.Environment
;
...
@@ -18,7 +19,7 @@ import java.util.Locale;
...
@@ -18,7 +19,7 @@ import java.util.Locale;
import
cn.garymb.ygomobile.ui.preference.PreferenceFragmentPlus
;
import
cn.garymb.ygomobile.ui.preference.PreferenceFragmentPlus
;
import
cn.garymb.ygomobile.utils.SystemUtils
;
import
cn.garymb.ygomobile.utils.SystemUtils
;
import
ocgcore.
handler.
CardManager
;
import
ocgcore.CardManager
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_EXPANSIONS
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_EXPANSIONS
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_SYSTEM_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_SYSTEM_PATH
;
...
@@ -171,10 +172,11 @@ public class AppsSettings {
...
@@ -171,10 +172,11 @@ public class AppsSettings {
//
//
}
}
for
(
File
file
:
cdbs
)
{
for
(
File
file
:
cdbs
)
{
if
(
CardManager
.
checkDataBase
(
file
))
{
Log
.
i
(
"合法的数据库才会加载"
,
"菜菜辛苦了"
);
//if (CardManager.checkDataBase(file)) {
//合法数据库才会加载
//合法数据库才会加载
pathList
.
add
(
file
.
getAbsolutePath
());
pathList
.
add
(
file
.
getAbsolutePath
());
}
//
}
}
}
}
}
}
}
...
@@ -315,8 +317,9 @@ public class AppsSettings {
...
@@ -315,8 +317,9 @@ public class AppsSettings {
/***
/***
* 内置数据库文件夹
* 内置数据库文件夹
*/
*/
@SuppressLint
(
"WrongConstant"
)
public
String
getDataBaseDefault
()
{
public
String
getDataBaseDefault
()
{
return
context
.
getD
atabasePath
(
"test.db"
).
getParent
();
return
context
.
getD
ir
(
"game"
,
Context
.
MODE_MULTI_PROCESS
).
getPath
();
}
}
/***
/***
...
...
mobile/src/main/java/cn/garymb/ygomobile/YGOStarter.java
View file @
3062c6d4
...
@@ -160,8 +160,8 @@ public class YGOStarter {
...
@@ -160,8 +160,8 @@ public class YGOStarter {
int
x
=
(
int
)
(
Math
.
random
()
*
tipsList
.
length
);
int
x
=
(
int
)
(
Math
.
random
()
*
tipsList
.
length
);
String
tips
=
tipsList
[
x
];
String
tips
=
tipsList
[
x
];
Toast
.
makeText
(
activity
,
tips
,
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
activity
,
tips
,
Toast
.
LENGTH_LONG
).
show
();
}
else
{
//
} else {
options
=
null
;
//
options = null;
}
}
Intent
intent
=
new
Intent
(
activity
,
YGOMobileActivity
.
class
);
Intent
intent
=
new
Intent
(
activity
,
YGOMobileActivity
.
class
);
if
(
options
!=
null
)
{
if
(
options
!=
null
)
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/loader/CardLoader.java
View file @
3062c6d4
...
@@ -11,26 +11,25 @@ import java.util.Collections;
...
@@ -11,26 +11,25 @@ import java.util.Collections;
import
java.util.Comparator
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.List
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
ocgcore.CardManager
;
import
ocgcore.DataManager
;
import
ocgcore.LimitManager
;
import
ocgcore.LimitManager
;
import
ocgcore.data.Card
;
import
ocgcore.data.Card
;
import
ocgcore.data.LimitList
;
import
ocgcore.data.LimitList
;
import
ocgcore.enums.LimitType
;
import
ocgcore.enums.LimitType
;
import
ocgcore.handler.CardManager
;
public
class
CardLoader
implements
ICardLoader
{
public
class
CardLoader
implements
ICardLoader
{
// private StringManager mStringManager = StringManager.get()
;
private
LimitManager
mLimitManager
;
private
LimitManager
mLimitManager
=
LimitManager
.
get
()
;
private
CardManager
mCardManager
;
private
Context
context
;
private
Context
context
;
private
CallBack
mCallBack
;
private
CallBack
mCallBack
;
private
LimitList
mLimitList
;
private
LimitList
mLimitList
;
private
static
final
String
TAG
=
CardLoader
.
class
.
getSimpleName
();
private
static
final
String
TAG
=
CardLoader
.
class
.
getSimpleName
();
private
final
static
boolean
DEBUG
=
false
;
private
final
static
boolean
DEBUG
=
false
;
private
final
CardManager
mCardManager
;
public
interface
CallBack
{
public
interface
CallBack
{
void
onSearchStart
();
void
onSearchStart
();
...
@@ -44,9 +43,8 @@ public class CardLoader implements ICardLoader {
...
@@ -44,9 +43,8 @@ public class CardLoader implements ICardLoader {
public
CardLoader
(
Context
context
)
{
public
CardLoader
(
Context
context
)
{
this
.
context
=
context
;
this
.
context
=
context
;
mCardManager
=
new
CardManager
(
mLimitManager
=
DataManager
.
get
().
getLimitManager
();
AppsSettings
.
get
().
getDataBasePath
(),
mCardManager
=
DataManager
.
get
().
getCardManager
();
AppsSettings
.
get
().
getExpansionsPath
().
getAbsolutePath
());
}
}
@Override
@Override
...
@@ -74,11 +72,6 @@ public class CardLoader implements ICardLoader {
...
@@ -74,11 +72,6 @@ public class CardLoader implements ICardLoader {
return
map
;
return
map
;
}
}
public
boolean
openDb
()
{
mCardManager
.
loadCards
();
return
true
;
}
public
boolean
isOpen
()
{
public
boolean
isOpen
()
{
return
mCardManager
.
getCount
()
>
0
;
return
mCardManager
.
getCount
()
>
0
;
}
}
...
@@ -180,11 +173,10 @@ public class CardLoader implements ICardLoader {
...
@@ -180,11 +173,10 @@ public class CardLoader implements ICardLoader {
}
}
}
}
@Override
@Override
public
void
search
(
String
prefixWord
,
String
suffixWord
,
public
void
search
(
String
prefixWord
,
String
suffixWord
,
long
attribute
,
long
level
,
long
race
,
long
attribute
,
long
level
,
long
race
,
long
limitlist
,
long
limit
,
String
limitName
,
long
limit
,
String
atk
,
String
def
,
long
pscale
,
String
atk
,
String
def
,
long
pscale
,
long
setcode
,
long
category
,
long
ot
,
int
linkKey
,
long
...
types
)
{
long
setcode
,
long
category
,
long
ot
,
int
linkKey
,
long
...
types
)
{
CardSearchInfo
searchInfo
=
new
CardSearchInfo
();
CardSearchInfo
searchInfo
=
new
CardSearchInfo
();
...
@@ -208,8 +200,10 @@ public class CardLoader implements ICardLoader {
...
@@ -208,8 +200,10 @@ public class CardLoader implements ICardLoader {
searchInfo
.
race
=
race
;
searchInfo
.
race
=
race
;
searchInfo
.
pscale
=
(
int
)
pscale
;
searchInfo
.
pscale
=
(
int
)
pscale
;
searchInfo
.
setcode
=
setcode
;
searchInfo
.
setcode
=
setcode
;
LimitList
limitList
=
mLimitManager
.
getLimit
((
int
)
limitlist
);
LimitList
limitList
=
null
;
if
(
limitlist
>
0
)
{
if
(!
TextUtils
.
isEmpty
(
limitName
))
{
limitList
=
mLimitManager
.
getLimit
(
limitName
);
setLimitList
(
limitList
);
LimitType
cardLimitType
=
LimitType
.
valueOf
(
limit
);
LimitType
cardLimitType
=
LimitType
.
valueOf
(
limit
);
if
(
limitList
!=
null
)
{
if
(
limitList
!=
null
)
{
List
<
Integer
>
ids
;
List
<
Integer
>
ids
;
...
@@ -228,8 +222,9 @@ public class CardLoader implements ICardLoader {
...
@@ -228,8 +222,9 @@ public class CardLoader implements ICardLoader {
searchInfo
.
inCards
=
ids
;
searchInfo
.
inCards
=
ids
;
}
}
}
}
}
else
{
setLimitList
(
null
);
}
}
setLimitList
((
limitList
==
null
?
mLimitList
:
limitList
));
loadData
(
searchInfo
);
loadData
(
searchInfo
);
}
}
}
}
mobile/src/main/java/cn/garymb/ygomobile/loader/ICardLoader.java
View file @
3062c6d4
...
@@ -4,7 +4,7 @@ import ocgcore.data.LimitList;
...
@@ -4,7 +4,7 @@ import ocgcore.data.LimitList;
public
interface
ICardLoader
{
public
interface
ICardLoader
{
void
search
(
String
prefixWord
,
String
suffixWord
,
void
search
(
String
prefixWord
,
String
suffixWord
,
long
attribute
,
long
level
,
long
race
,
long
limitlist
,
long
limit
,
long
attribute
,
long
level
,
long
race
,
String
limitName
,
long
limit
,
String
atk
,
String
def
,
long
pscale
,
String
atk
,
String
def
,
long
pscale
,
long
setcode
,
long
category
,
long
ot
,
int
link
,
long
...
types
);
long
setcode
,
long
category
,
long
ot
,
int
link
,
long
...
types
);
void
onReset
();
void
onReset
();
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/adapters/CardListAdapter.java
View file @
3062c6d4
...
@@ -16,6 +16,7 @@ import cn.garymb.ygomobile.ui.cards.CardListProvider;
...
@@ -16,6 +16,7 @@ import cn.garymb.ygomobile.ui.cards.CardListProvider;
import
cn.garymb.ygomobile.ui.cards.deck.ImageTop
;
import
cn.garymb.ygomobile.ui.cards.deck.ImageTop
;
import
cn.garymb.ygomobile.bean.events.CardInfoEvent
;
import
cn.garymb.ygomobile.bean.events.CardInfoEvent
;
import
cn.garymb.ygomobile.utils.CardUtils
;
import
cn.garymb.ygomobile.utils.CardUtils
;
import
ocgcore.DataManager
;
import
ocgcore.StringManager
;
import
ocgcore.StringManager
;
import
ocgcore.data.Card
;
import
ocgcore.data.Card
;
import
ocgcore.data.LimitList
;
import
ocgcore.data.LimitList
;
...
@@ -33,7 +34,7 @@ public class CardListAdapter extends BaseRecyclerAdapterPlus<Card, ViewHolder> i
...
@@ -33,7 +34,7 @@ public class CardListAdapter extends BaseRecyclerAdapterPlus<Card, ViewHolder> i
public
CardListAdapter
(
Context
context
,
ImageLoader
imageLoader
)
{
public
CardListAdapter
(
Context
context
,
ImageLoader
imageLoader
)
{
super
(
context
);
super
(
context
);
this
.
imageLoader
=
imageLoader
;
this
.
imageLoader
=
imageLoader
;
mStringManager
=
StringManager
.
get
();
mStringManager
=
DataManager
.
get
().
getStringManager
();
}
}
@Override
@Override
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/adapters/SimpleSpinnerAdapter.java
View file @
3062c6d4
...
@@ -64,6 +64,17 @@ public class SimpleSpinnerAdapter extends BaseAdapterPlus<SimpleSpinnerItem> {
...
@@ -64,6 +64,17 @@ public class SimpleSpinnerAdapter extends BaseAdapterPlus<SimpleSpinnerItem> {
return
null
;
return
null
;
}
}
public
static
String
getSelectText
(
Spinner
spinner
)
{
if
(
spinner
.
getCount
()
>
0
)
{
Object
item
=
spinner
.
getSelectedItem
();
if
(
item
!=
null
&&
item
instanceof
SimpleSpinnerItem
)
{
SimpleSpinnerItem
spItem
=
(
SimpleSpinnerItem
)
item
;
return
spItem
.
text
;
}
}
return
null
;
}
public
static
long
getSelect
(
Spinner
spinner
)
{
public
static
long
getSelect
(
Spinner
spinner
)
{
if
(
spinner
.
getCount
()
>
0
)
{
if
(
spinner
.
getCount
()
>
0
)
{
Object
item
=
spinner
.
getSelectedItem
();
Object
item
=
spinner
.
getSelectedItem
();
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/BaseCardsAcitivity.java
View file @
3062c6d4
...
@@ -22,6 +22,7 @@ import cn.garymb.ygomobile.loader.CardLoader;
...
@@ -22,6 +22,7 @@ import cn.garymb.ygomobile.loader.CardLoader;
import
cn.garymb.ygomobile.loader.ImageLoader
;
import
cn.garymb.ygomobile.loader.ImageLoader
;
import
cn.garymb.ygomobile.ui.activities.BaseActivity
;
import
cn.garymb.ygomobile.ui.activities.BaseActivity
;
import
cn.garymb.ygomobile.ui.adapters.CardListAdapter
;
import
cn.garymb.ygomobile.ui.adapters.CardListAdapter
;
import
ocgcore.DataManager
;
import
ocgcore.LimitManager
;
import
ocgcore.LimitManager
;
import
ocgcore.StringManager
;
import
ocgcore.StringManager
;
import
ocgcore.data.Card
;
import
ocgcore.data.Card
;
...
@@ -34,14 +35,15 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
...
@@ -34,14 +35,15 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
protected
CardLoader
mCardLoader
;
protected
CardLoader
mCardLoader
;
protected
boolean
isLoad
=
false
;
protected
boolean
isLoad
=
false
;
private
ImageLoader
mImageLoader
;
private
ImageLoader
mImageLoader
;
protected
StringManager
mStringManager
=
StringManager
.
get
();
protected
StringManager
mStringManager
=
DataManager
.
get
().
getStringManager
();
protected
LimitManager
mLimitManager
=
LimitManager
.
get
();
protected
LimitManager
mLimitManager
=
DataManager
.
get
().
getLimitManager
();
@Override
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_deck_cards
);
setContentView
(
R
.
layout
.
activity_deck_cards
);
AnimationShake2
();
AnimationShake2
();
mImageLoader
=
ImageLoader
.
get
(
this
);
mImageLoader
=
ImageLoader
.
get
(
this
);
mDrawerlayout
=
$
(
R
.
id
.
drawer_layout
);
mDrawerlayout
=
$
(
R
.
id
.
drawer_layout
);
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardSearchActivityImpl.java
View file @
3062c6d4
...
@@ -29,6 +29,7 @@ import cn.garymb.ygomobile.ui.adapters.CardListAdapter;
...
@@ -29,6 +29,7 @@ import cn.garymb.ygomobile.ui.adapters.CardListAdapter;
import
cn.garymb.ygomobile.ui.plus.AOnGestureListener
;
import
cn.garymb.ygomobile.ui.plus.AOnGestureListener
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
ocgcore.DataManager
;
import
ocgcore.LimitManager
;
import
ocgcore.LimitManager
;
import
ocgcore.StringManager
;
import
ocgcore.StringManager
;
import
ocgcore.data.Card
;
import
ocgcore.data.Card
;
...
@@ -41,8 +42,8 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
...
@@ -41,8 +42,8 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
protected
CardListAdapter
mCardListAdapater
;
protected
CardListAdapter
mCardListAdapater
;
protected
CardLoader
mCardLoader
;
protected
CardLoader
mCardLoader
;
protected
boolean
isLoad
=
false
;
protected
boolean
isLoad
=
false
;
protected
StringManager
mStringManager
=
StringManager
.
get
();
protected
StringManager
mStringManager
=
DataManager
.
get
().
getStringManager
();
protected
LimitManager
mLimitManager
=
LimitManager
.
get
();
protected
LimitManager
mLimitManager
=
DataManager
.
get
().
getLimitManager
();
private
ImageLoader
mImageLoader
;
private
ImageLoader
mImageLoader
;
@Override
@Override
...
@@ -75,12 +76,10 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
...
@@ -75,12 +76,10 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
setListeners
();
setListeners
();
DialogPlus
dlg
=
DialogPlus
.
show
(
this
,
null
,
getString
(
R
.
string
.
loading
));
DialogPlus
dlg
=
DialogPlus
.
show
(
this
,
null
,
getString
(
R
.
string
.
loading
));
VUiKit
.
defer
().
when
(()
->
{
VUiKit
.
defer
().
when
(()
->
{
StringManager
.
get
().
load
();
//loadFile(stringfile.getAbsolutePath());
DataManager
.
get
().
load
(
false
);
LimitManager
.
get
().
load
();
//loadFile(stringfile.getAbsolutePath());
if
(
mLimitManager
.
getCount
()
>
0
)
{
if
(
mLimitManager
.
getCount
()
>
1
)
{
mCardLoader
.
setLimitList
(
mLimitManager
.
getTopLimit
());
mCardLoader
.
setLimitList
(
mLimitManager
.
getLimit
(
1
));
}
}
mCardLoader
.
openDb
();
}).
done
((
rs
)
->
{
}).
done
((
rs
)
->
{
dlg
.
dismiss
();
dlg
.
dismiss
();
isLoad
=
true
;
isLoad
=
true
;
...
@@ -112,7 +111,7 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
...
@@ -112,7 +111,7 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
super
.
onScrollStateChanged
(
recyclerView
,
newState
);
super
.
onScrollStateChanged
(
recyclerView
,
newState
);
switch
(
newState
)
{
switch
(
newState
)
{
case
RecyclerView
.
SCROLL_STATE_IDLE
:
case
RecyclerView
.
SCROLL_STATE_IDLE
:
if
(!
isFinishing
())
{
if
(!
isFinishing
())
{
Glide
.
with
(
getContext
()).
resumeRequests
();
Glide
.
with
(
getContext
()).
resumeRequests
();
}
}
break
;
break
;
...
@@ -120,7 +119,7 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
...
@@ -120,7 +119,7 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
Glide
.
with
(
getContext
()).
pauseRequests
();
Glide
.
with
(
getContext
()).
pauseRequests
();
break
;
break
;
case
RecyclerView
.
SCROLL_STATE_SETTLING
:
case
RecyclerView
.
SCROLL_STATE_SETTLING
:
if
(!
isFinishing
())
{
if
(!
isFinishing
())
{
Glide
.
with
(
getContext
()).
resumeRequests
();
Glide
.
with
(
getContext
()).
resumeRequests
();
}
}
break
;
break
;
...
@@ -257,13 +256,13 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
...
@@ -257,13 +256,13 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
mDialog
.
setView
(
mCardDetail
.
getView
());
mDialog
.
setView
(
mCardDetail
.
getView
());
mDialog
.
hideButton
();
mDialog
.
hideButton
();
mDialog
.
hideTitleBar
();
mDialog
.
hideTitleBar
();
mDialog
.
setOnGestureListener
(
new
AOnGestureListener
(){
mDialog
.
setOnGestureListener
(
new
AOnGestureListener
()
{
@Override
@Override
public
boolean
onFling
(
MotionEvent
e1
,
MotionEvent
e2
,
float
velocityX
,
float
velocityY
)
{
public
boolean
onFling
(
MotionEvent
e1
,
MotionEvent
e2
,
float
velocityX
,
float
velocityY
)
{
if
(
isLeftFling
(
e1
,
e2
,
velocityX
,
velocityY
))
{
if
(
isLeftFling
(
e1
,
e2
,
velocityX
,
velocityY
))
{
mCardDetail
.
onNextCard
();
mCardDetail
.
onNextCard
();
return
true
;
return
true
;
}
else
if
(
isRightFling
(
e1
,
e2
,
velocityX
,
velocityY
))
{
}
else
if
(
isRightFling
(
e1
,
e2
,
velocityX
,
velocityY
))
{
mCardDetail
.
onPreCard
();
mCardDetail
.
onPreCard
();
return
true
;
return
true
;
}
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardSearcher.java
View file @
3062c6d4
...
@@ -18,6 +18,7 @@ import android.widget.TextView.OnEditorActionListener;
...
@@ -18,6 +18,7 @@ import android.widget.TextView.OnEditorActionListener;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
...
@@ -26,6 +27,7 @@ import cn.garymb.ygomobile.ui.adapters.SimpleSpinnerAdapter;
...
@@ -26,6 +27,7 @@ import cn.garymb.ygomobile.ui.adapters.SimpleSpinnerAdapter;
import
cn.garymb.ygomobile.ui.adapters.SimpleSpinnerItem
;
import
cn.garymb.ygomobile.ui.adapters.SimpleSpinnerItem
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
ocgcore.LimitManager
;
import
ocgcore.LimitManager
;
import
ocgcore.DataManager
;
import
ocgcore.StringManager
;
import
ocgcore.StringManager
;
import
ocgcore.data.CardSet
;
import
ocgcore.data.CardSet
;
import
ocgcore.data.LimitList
;
import
ocgcore.data.LimitList
;
...
@@ -75,8 +77,8 @@ public class CardSearcher implements View.OnClickListener {
...
@@ -75,8 +77,8 @@ public class CardSearcher implements View.OnClickListener {
this
.
mContext
=
view
.
getContext
();
this
.
mContext
=
view
.
getContext
();
this
.
dataLoader
=
dataLoader
;
this
.
dataLoader
=
dataLoader
;
this
.
mSettings
=
AppsSettings
.
get
();
this
.
mSettings
=
AppsSettings
.
get
();
mStringManager
=
StringManager
.
get
();
mStringManager
=
DataManager
.
get
().
getStringManager
();
mLimitManager
=
LimitManager
.
get
();
mLimitManager
=
DataManager
.
get
().
getLimitManager
();
prefixWord
=
findViewById
(
R
.
id
.
edt_word1
);
prefixWord
=
findViewById
(
R
.
id
.
edt_word1
);
suffixWord
=
findViewById
(
R
.
id
.
edt_word2
);
suffixWord
=
findViewById
(
R
.
id
.
edt_word2
);
otSpinner
=
findViewById
(
R
.
id
.
sp_ot
);
otSpinner
=
findViewById
(
R
.
id
.
sp_ot
);
...
@@ -168,10 +170,10 @@ public class CardSearcher implements View.OnClickListener {
...
@@ -168,10 +170,10 @@ public class CardSearcher implements View.OnClickListener {
String
mLinkStr
=
BtnVals
[
8
]
+
BtnVals
[
7
]
+
BtnVals
[
6
]
+
BtnVals
[
5
]
+
"0"
String
mLinkStr
=
BtnVals
[
8
]
+
BtnVals
[
7
]
+
BtnVals
[
6
]
+
BtnVals
[
5
]
+
"0"
+
BtnVals
[
3
]
+
BtnVals
[
2
]
+
BtnVals
[
1
]
+
BtnVals
[
0
];
+
BtnVals
[
3
]
+
BtnVals
[
2
]
+
BtnVals
[
1
]
+
BtnVals
[
0
];
lineKey
=
Integer
.
parseInt
(
mLinkStr
,
2
);
lineKey
=
Integer
.
parseInt
(
mLinkStr
,
2
);
if
(
viewDialog
.
isShowing
())
{
if
(
viewDialog
.
isShowing
())
{
viewDialog
.
dismiss
();
viewDialog
.
dismiss
();
}
}
}
else
{
}
else
{
if
(
"0"
.
equals
(
BtnVals
[
index
]))
{
if
(
"0"
.
equals
(
BtnVals
[
index
]))
{
btn
.
setBackgroundResource
(
enImgs
[
index
]);
btn
.
setBackgroundResource
(
enImgs
[
index
]);
BtnVals
[
index
]
=
"1"
;
BtnVals
[
index
]
=
"1"
;
...
@@ -251,7 +253,7 @@ public class CardSearcher implements View.OnClickListener {
...
@@ -251,7 +253,7 @@ public class CardSearcher implements View.OnClickListener {
initTypeSpinners
(
typeSpinner
,
new
CardType
[]{
CardType
.
None
,
CardType
.
Monster
,
CardType
.
Spell
,
CardType
.
Trap
});
initTypeSpinners
(
typeSpinner
,
new
CardType
[]{
CardType
.
None
,
CardType
.
Monster
,
CardType
.
Spell
,
CardType
.
Trap
});
initTypeSpinners
(
typeMonsterSpinner
,
new
CardType
[]{
CardType
.
None
,
CardType
.
Normal
,
CardType
.
Effect
,
CardType
.
Fusion
,
CardType
.
Ritual
,
initTypeSpinners
(
typeMonsterSpinner
,
new
CardType
[]{
CardType
.
None
,
CardType
.
Normal
,
CardType
.
Effect
,
CardType
.
Fusion
,
CardType
.
Ritual
,
CardType
.
Synchro
,
CardType
.
Pendulum
,
CardType
.
Xyz
,
CardType
.
Link
,
CardType
.
Spirit
,
CardType
.
Union
,
CardType
.
Synchro
,
CardType
.
Pendulum
,
CardType
.
Xyz
,
CardType
.
Link
,
CardType
.
Spirit
,
CardType
.
Union
,
CardType
.
Dual
,
CardType
.
Tuner
,
CardType
.
Flip
,
CardType
.
Toon
,
CardType
.
Sp_Summon
,
CardType
.
Token
CardType
.
Dual
,
CardType
.
Tuner
,
CardType
.
Flip
,
CardType
.
Toon
,
CardType
.
Sp_Summon
,
CardType
.
Token
});
});
initTypeSpinners
(
typeMonsterSpinner2
,
new
CardType
[]{
CardType
.
None
,
CardType
.
Pendulum
,
CardType
.
Tuner
initTypeSpinners
(
typeMonsterSpinner2
,
new
CardType
[]{
CardType
.
None
,
CardType
.
Pendulum
,
CardType
.
Tuner
});
});
...
@@ -321,24 +323,20 @@ public class CardSearcher implements View.OnClickListener {
...
@@ -321,24 +323,20 @@ public class CardSearcher implements View.OnClickListener {
private
void
initLimitListSpinners
(
Spinner
spinner
)
{
private
void
initLimitListSpinners
(
Spinner
spinner
)
{
List
<
SimpleSpinnerItem
>
items
=
new
ArrayList
<>();
List
<
SimpleSpinnerItem
>
items
=
new
ArrayList
<>();
List
<
LimitList
>
limitLists
=
mLimitManager
.
getLimitList
s
();
List
<
String
>
limits
=
mLimitManager
.
getLimitName
s
();
int
index
=
-
1
;
int
index
=
-
1
;
int
count
=
mLimitManager
.
getCount
();
int
count
=
mLimitManager
.
getCount
();
LimitList
cur
=
null
;
LimitList
cur
=
null
;
if
(
dataLoader
!=
null
)
{
if
(
dataLoader
!=
null
)
{
cur
=
dataLoader
.
getLimitList
();
cur
=
dataLoader
.
getLimitList
();
}
}
items
.
add
(
new
SimpleSpinnerItem
(
0
,
getString
(
R
.
string
.
label_limitlist
)));
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
LimitList
list
=
limitLists
.
get
(
i
);
int
j
=
i
+
1
;
if
(
i
==
0
)
{
String
name
=
limits
.
get
(
i
);
items
.
add
(
new
SimpleSpinnerItem
(
i
,
getString
(
R
.
string
.
label_limitlist
)));
items
.
add
(
new
SimpleSpinnerItem
(
j
,
name
));
}
else
{
if
(
cur
!=
null
&&
TextUtils
.
equals
(
cur
.
getName
(),
name
))
{
items
.
add
(
new
SimpleSpinnerItem
(
i
,
list
.
getName
()));
index
=
j
;
}
if
(
cur
!=
null
)
{
if
(
TextUtils
.
equals
(
cur
.
getName
(),
list
.
getName
()))
{
index
=
i
;
}
}
}
}
}
SimpleSpinnerAdapter
adapter
=
new
SimpleSpinnerAdapter
(
mContext
);
SimpleSpinnerAdapter
adapter
=
new
SimpleSpinnerAdapter
(
mContext
);
...
@@ -473,6 +471,10 @@ public class CardSearcher implements View.OnClickListener {
...
@@ -473,6 +471,10 @@ public class CardSearcher implements View.OnClickListener {
return
SimpleSpinnerAdapter
.
getSelect
(
spinner
);
return
SimpleSpinnerAdapter
.
getSelect
(
spinner
);
}
}
private
String
getSelectText
(
Spinner
spinner
)
{
return
SimpleSpinnerAdapter
.
getSelectText
(
spinner
);
}
protected
String
text
(
EditText
editText
)
{
protected
String
text
(
EditText
editText
)
{
CharSequence
charSequence
=
editText
.
getText
();
CharSequence
charSequence
=
editText
.
getText
();
if
(
charSequence
==
null
)
{
if
(
charSequence
==
null
)
{
...
@@ -493,7 +495,7 @@ public class CardSearcher implements View.OnClickListener {
...
@@ -493,7 +495,7 @@ public class CardSearcher implements View.OnClickListener {
private
void
search
()
{
private
void
search
()
{
if
(
dataLoader
!=
null
)
{
if
(
dataLoader
!=
null
)
{
dataLoader
.
search
(
text
(
prefixWord
),
text
(
suffixWord
),
getSelect
(
attributeSpinner
)
dataLoader
.
search
(
text
(
prefixWord
),
text
(
suffixWord
),
getSelect
(
attributeSpinner
)
,
getSelect
(
levelSpinner
),
getSelect
(
raceSpinner
),
getSelect
(
limitListSpinner
),
getSelect
(
limitSpinner
),
,
getSelect
(
levelSpinner
),
getSelect
(
raceSpinner
),
getSelect
Text
(
limitListSpinner
),
getSelect
(
limitSpinner
),
text
(
atkText
),
text
(
defText
),
text
(
atkText
),
text
(
defText
),
getSelect
(
pScale
),
getSelect
(
pScale
),
getSelect
(
setcodeSpinner
)
getSelect
(
setcodeSpinner
)
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivity3.java
View file @
3062c6d4
...
@@ -23,6 +23,7 @@ import cn.garymb.ygomobile.ui.activities.BaseActivity;
...
@@ -23,6 +23,7 @@ import cn.garymb.ygomobile.ui.activities.BaseActivity;
import
cn.garymb.ygomobile.ui.cards.deck2.DeckAdapter
;
import
cn.garymb.ygomobile.ui.cards.deck2.DeckAdapter
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
ocgcore.DataManager
;
import
ocgcore.LimitManager
;
import
ocgcore.LimitManager
;
import
ocgcore.StringManager
;
import
ocgcore.StringManager
;
import
ocgcore.data.Card
;
import
ocgcore.data.Card
;
...
@@ -31,14 +32,13 @@ import ocgcore.data.LimitList;
...
@@ -31,14 +32,13 @@ import ocgcore.data.LimitList;
public
class
DeckManagerActivity3
extends
BaseActivity
implements
OnItemDragListener
,
CardLoader
.
CallBack
{
public
class
DeckManagerActivity3
extends
BaseActivity
implements
OnItemDragListener
,
CardLoader
.
CallBack
{
private
RecyclerView
mRecyclerView
;
private
RecyclerView
mRecyclerView
;
private
DeckAdapter
mDeckAdapter
;
private
DeckAdapter
mDeckAdapter
;
protected
StringManager
mStringManager
=
StringManager
.
get
();
protected
StringManager
mStringManager
=
DataManager
.
get
().
getStringManager
();
protected
LimitManager
mLimitManager
=
LimitManager
.
get
();
protected
LimitManager
mLimitManager
=
DataManager
.
get
().
getLimitManager
();
protected
CardLoader
mCardLoader
;
protected
CardLoader
mCardLoader
;
private
AppsSettings
mSettings
=
AppsSettings
.
get
();
private
AppsSettings
mSettings
=
AppsSettings
.
get
();
private
String
mPreLoad
;
private
String
mPreLoad
;
private
File
mYdkFile
;
private
File
mYdkFile
;
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
...
@@ -61,12 +61,7 @@ public class DeckManagerActivity3 extends BaseActivity implements OnItemDragList
...
@@ -61,12 +61,7 @@ public class DeckManagerActivity3 extends BaseActivity implements OnItemDragList
DialogPlus
dlg
=
DialogPlus
.
show
(
this
,
null
,
getString
(
R
.
string
.
loading
));
DialogPlus
dlg
=
DialogPlus
.
show
(
this
,
null
,
getString
(
R
.
string
.
loading
));
VUiKit
.
defer
().
when
(()
->
{
VUiKit
.
defer
().
when
(()
->
{
StringManager
.
get
().
load
();
//loadFile(stringfile.getAbsolutePath());
mCardLoader
.
setLimitList
(
mLimitManager
.
getTopLimit
());
LimitManager
.
get
().
load
();
//loadFile(stringfile.getAbsolutePath());
if
(
mLimitManager
.
getCount
()
>
1
)
{
mCardLoader
.
setLimitList
(
mLimitManager
.
getLimit
(
1
));
}
mCardLoader
.
openDb
();
File
file
=
new
File
(
mSettings
.
getResourcePath
(),
Constants
.
CORE_DECK_PATH
+
"/"
+
mSettings
.
getLastDeck
()
+
Constants
.
YDK_FILE_EX
);
File
file
=
new
File
(
mSettings
.
getResourcePath
(),
Constants
.
CORE_DECK_PATH
+
"/"
+
mSettings
.
getLastDeck
()
+
Constants
.
YDK_FILE_EX
);
if
(!
TextUtils
.
isEmpty
(
mPreLoad
))
{
if
(!
TextUtils
.
isEmpty
(
mPreLoad
))
{
file
=
new
File
(
mPreLoad
);
file
=
new
File
(
mPreLoad
);
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivityImpl.java
View file @
3062c6d4
...
@@ -59,6 +59,7 @@ import cn.garymb.ygomobile.ui.plus.DialogPlus;
...
@@ -59,6 +59,7 @@ import cn.garymb.ygomobile.ui.plus.DialogPlus;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.ShareUtil
;
import
cn.garymb.ygomobile.utils.ShareUtil
;
import
ocgcore.DataManager
;
import
ocgcore.LimitManager
;
import
ocgcore.LimitManager
;
import
ocgcore.StringManager
;
import
ocgcore.StringManager
;
import
ocgcore.data.Card
;
import
ocgcore.data.Card
;
...
@@ -128,12 +129,10 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
...
@@ -128,12 +129,10 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
//
//
DialogPlus
dlg
=
DialogPlus
.
show
(
this
,
null
,
getString
(
R
.
string
.
loading
));
DialogPlus
dlg
=
DialogPlus
.
show
(
this
,
null
,
getString
(
R
.
string
.
loading
));
VUiKit
.
defer
().
when
(()
->
{
VUiKit
.
defer
().
when
(()
->
{
StringManager
.
get
().
load
();
//loadFile(stringfile.getAbsolutePath());
DataManager
.
get
().
load
(
false
);
LimitManager
.
get
().
load
();
//loadFile(stringfile.getAbsolutePath());
if
(
mLimitManager
.
getCount
()
>
0
)
{
if
(
mLimitManager
.
getCount
()
>
1
)
{
mCardLoader
.
setLimitList
(
mLimitManager
.
getTopLimit
());
mCardLoader
.
setLimitList
(
mLimitManager
.
getLimit
(
1
));
}
}
mCardLoader
.
openDb
();
File
file
=
new
File
(
mSettings
.
getResourcePath
(),
Constants
.
CORE_DECK_PATH
+
"/"
+
mSettings
.
getLastDeck
()
+
Constants
.
YDK_FILE_EX
);
File
file
=
new
File
(
mSettings
.
getResourcePath
(),
Constants
.
CORE_DECK_PATH
+
"/"
+
mSettings
.
getLastDeck
()
+
Constants
.
YDK_FILE_EX
);
if
(!
TextUtils
.
isEmpty
(
mPreLoad
))
{
if
(!
TextUtils
.
isEmpty
(
mPreLoad
))
{
file
=
new
File
(
mPreLoad
);
file
=
new
File
(
mPreLoad
);
...
@@ -747,21 +746,17 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
...
@@ -747,21 +746,17 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
// }
// }
private
void
initLimitListSpinners
(
Spinner
spinner
)
{
private
void
initLimitListSpinners
(
Spinner
spinner
)
{
List
<
SimpleSpinnerItem
>
items
=
new
ArrayList
<>();
List
<
SimpleSpinnerItem
>
items
=
new
ArrayList
<>();
List
<
LimitList
>
limitLists
=
mLimitManager
.
getLimitList
s
();
List
<
String
>
limitLists
=
mLimitManager
.
getLimitName
s
();
int
index
=
-
1
;
int
index
=
-
1
;
int
count
=
mLimitManager
.
getCount
();
int
count
=
mLimitManager
.
getCount
();
LimitList
cur
=
mLimitList
;
LimitList
cur
=
mLimitList
;
items
.
add
(
new
SimpleSpinnerItem
(
0
,
getString
(
R
.
string
.
label_limitlist
)));
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
LimitList
list
=
limitLists
.
get
(
i
);
int
j
=
i
+
1
;
if
(
i
==
0
)
{
String
name
=
limitLists
.
get
(
i
);
items
.
add
(
new
SimpleSpinnerItem
(
i
,
getString
(
R
.
string
.
label_limitlist
)));
items
.
add
(
new
SimpleSpinnerItem
(
j
,
name
));
}
else
{
if
(
cur
!=
null
&&
TextUtils
.
equals
(
cur
.
getName
(),
name
))
{
items
.
add
(
new
SimpleSpinnerItem
(
i
,
list
.
getName
()));
index
=
j
;
}
if
(
cur
!=
null
)
{
if
(
TextUtils
.
equals
(
cur
.
getName
(),
list
.
getName
()))
{
index
=
i
;
}
}
}
}
}
SimpleSpinnerAdapter
adapter
=
new
SimpleSpinnerAdapter
(
this
);
SimpleSpinnerAdapter
adapter
=
new
SimpleSpinnerAdapter
(
this
);
...
@@ -774,7 +769,7 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
...
@@ -774,7 +769,7 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
spinner
.
setOnItemSelectedListener
(
new
AdapterView
.
OnItemSelectedListener
()
{
spinner
.
setOnItemSelectedListener
(
new
AdapterView
.
OnItemSelectedListener
()
{
@Override
@Override
public
void
onItemSelected
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
public
void
onItemSelected
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
setLimitList
(
mLimitManager
.
getLimit
(
position
));
setLimitList
(
mLimitManager
.
getLimit
(
SimpleSpinnerAdapter
.
getSelectText
(
spinner
)
));
}
}
@Override
@Override
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivityImpl2.java
View file @
3062c6d4
...
@@ -57,6 +57,7 @@ import cn.garymb.ygomobile.ui.plus.VUiKit;
...
@@ -57,6 +57,7 @@ import cn.garymb.ygomobile.ui.plus.VUiKit;
import
cn.garymb.ygomobile.ui.widget.DeckGroupView
;
import
cn.garymb.ygomobile.ui.widget.DeckGroupView
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.ShareUtil
;
import
cn.garymb.ygomobile.utils.ShareUtil
;
import
ocgcore.DataManager
;
import
ocgcore.LimitManager
;
import
ocgcore.LimitManager
;
import
ocgcore.StringManager
;
import
ocgcore.StringManager
;
import
ocgcore.data.Card
;
import
ocgcore.data.Card
;
...
@@ -68,8 +69,8 @@ import static cn.garymb.ygomobile.Constants.YDK_FILE_EX;
...
@@ -68,8 +69,8 @@ import static cn.garymb.ygomobile.Constants.YDK_FILE_EX;
class
DeckManagerActivityImpl2
extends
BaseActivity
implements
CardLoader
.
CallBack
{
class
DeckManagerActivityImpl2
extends
BaseActivity
implements
CardLoader
.
CallBack
{
private
DeckGroupView
mDeckView
;
private
DeckGroupView
mDeckView
;
protected
CardSearcher
mCardSelector
;
protected
CardSearcher
mCardSelector
;
protected
StringManager
mStringManager
=
StringManager
.
get
();
protected
StringManager
mStringManager
=
DataManager
.
get
().
getStringManager
();
protected
LimitManager
mLimitManager
=
LimitManager
.
get
();
protected
LimitManager
mLimitManager
=
DataManager
.
get
().
getLimitManager
();
protected
CardLoader
mCardLoader
;
protected
CardLoader
mCardLoader
;
protected
boolean
isLoad
=
false
;
protected
boolean
isLoad
=
false
;
private
String
mPreLoad
;
private
String
mPreLoad
;
...
@@ -183,12 +184,10 @@ class DeckManagerActivityImpl2 extends BaseActivity implements CardLoader.CallBa
...
@@ -183,12 +184,10 @@ class DeckManagerActivityImpl2 extends BaseActivity implements CardLoader.CallBa
EventBus
.
getDefault
().
register
(
this
);
EventBus
.
getDefault
().
register
(
this
);
DialogPlus
dlg
=
DialogPlus
.
show
(
this
,
null
,
getString
(
R
.
string
.
loading
));
DialogPlus
dlg
=
DialogPlus
.
show
(
this
,
null
,
getString
(
R
.
string
.
loading
));
VUiKit
.
defer
().
when
(()
->
{
VUiKit
.
defer
().
when
(()
->
{
StringManager
.
get
().
load
();
//loadFile(stringfile.getAbsolutePath());
DataManager
.
get
().
load
(
false
);
LimitManager
.
get
().
load
();
//loadFile(stringfile.getAbsolutePath());
if
(
mLimitManager
.
getCount
()
>
0
)
{
if
(
mLimitManager
.
getCount
()
>
1
)
{
mCardLoader
.
setLimitList
(
mLimitManager
.
getTopLimit
());
mCardLoader
.
setLimitList
(
mLimitManager
.
getLimit
(
1
));
}
}
mCardLoader
.
openDb
();
File
file
=
new
File
(
mSettings
.
getResourcePath
(),
Constants
.
CORE_DECK_PATH
+
"/"
+
mSettings
.
getLastDeck
()
+
YDK_FILE_EX
);
File
file
=
new
File
(
mSettings
.
getResourcePath
(),
Constants
.
CORE_DECK_PATH
+
"/"
+
mSettings
.
getLastDeck
()
+
YDK_FILE_EX
);
if
(!
TextUtils
.
isEmpty
(
mPreLoad
))
{
if
(!
TextUtils
.
isEmpty
(
mPreLoad
))
{
file
=
new
File
(
mPreLoad
);
file
=
new
File
(
mPreLoad
);
...
@@ -309,21 +308,17 @@ class DeckManagerActivityImpl2 extends BaseActivity implements CardLoader.CallBa
...
@@ -309,21 +308,17 @@ class DeckManagerActivityImpl2 extends BaseActivity implements CardLoader.CallBa
private
void
initLimitListSpinners
(
Spinner
spinner
)
{
private
void
initLimitListSpinners
(
Spinner
spinner
)
{
List
<
SimpleSpinnerItem
>
items
=
new
ArrayList
<>();
List
<
SimpleSpinnerItem
>
items
=
new
ArrayList
<>();
List
<
LimitList
>
limitLists
=
mLimitManager
.
getLimitList
s
();
List
<
String
>
limitLists
=
mLimitManager
.
getLimitName
s
();
int
index
=
-
1
;
int
index
=
-
1
;
int
count
=
mLimitManager
.
getCount
();
int
count
=
mLimitManager
.
getCount
();
LimitList
cur
=
mLimitList
;
LimitList
cur
=
mLimitList
;
items
.
add
(
new
SimpleSpinnerItem
(
0
,
getString
(
R
.
string
.
label_limitlist
)));
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
LimitList
list
=
limitLists
.
get
(
i
);
int
j
=
i
+
1
;
if
(
i
==
0
)
{
String
name
=
limitLists
.
get
(
i
);
items
.
add
(
new
SimpleSpinnerItem
(
i
,
getString
(
R
.
string
.
label_limitlist
)));
items
.
add
(
new
SimpleSpinnerItem
(
j
,
name
));
}
else
{
if
(
cur
!=
null
&&
TextUtils
.
equals
(
cur
.
getName
(),
name
))
{
items
.
add
(
new
SimpleSpinnerItem
(
i
,
list
.
getName
()));
index
=
j
;
}
if
(
cur
!=
null
)
{
if
(
TextUtils
.
equals
(
cur
.
getName
(),
list
.
getName
()))
{
index
=
i
;
}
}
}
}
}
SimpleSpinnerAdapter
adapter
=
new
SimpleSpinnerAdapter
(
this
);
SimpleSpinnerAdapter
adapter
=
new
SimpleSpinnerAdapter
(
this
);
...
@@ -336,7 +331,7 @@ class DeckManagerActivityImpl2 extends BaseActivity implements CardLoader.CallBa
...
@@ -336,7 +331,7 @@ class DeckManagerActivityImpl2 extends BaseActivity implements CardLoader.CallBa
spinner
.
setOnItemSelectedListener
(
new
AdapterView
.
OnItemSelectedListener
()
{
spinner
.
setOnItemSelectedListener
(
new
AdapterView
.
OnItemSelectedListener
()
{
@Override
@Override
public
void
onItemSelected
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
public
void
onItemSelected
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
setLimitList
(
mLimitManager
.
getLimit
(
position
));
setLimitList
(
mLimitManager
.
getLimit
(
SimpleSpinnerAdapter
.
getSelectText
(
spinner
)
));
}
}
@Override
@Override
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/ImageUpdater.java
View file @
3062c6d4
...
@@ -26,6 +26,7 @@ import cn.garymb.ygomobile.ui.activities.BaseActivity;
...
@@ -26,6 +26,7 @@ import cn.garymb.ygomobile.ui.activities.BaseActivity;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
ocgcore.DataManager
;
import
ocgcore.data.Card
;
import
ocgcore.data.Card
;
import
ocgcore.enums.CardType
;
import
ocgcore.enums.CardType
;
...
@@ -35,7 +36,6 @@ import ocgcore.enums.CardType;
...
@@ -35,7 +36,6 @@ import ocgcore.enums.CardType;
public
class
ImageUpdater
implements
DialogInterface
.
OnCancelListener
{
public
class
ImageUpdater
implements
DialogInterface
.
OnCancelListener
{
private
BaseActivity
mContext
;
private
BaseActivity
mContext
;
private
CardLoader
mCardLoader
;
private
final
static
int
SubThreads
=
4
;
private
final
static
int
SubThreads
=
4
;
private
int
mDownloading
=
0
;
private
int
mDownloading
=
0
;
private
final
List
<
Item
>
mCardStatus
=
new
ArrayList
<>();
private
final
List
<
Item
>
mCardStatus
=
new
ArrayList
<>();
...
@@ -54,7 +54,6 @@ public class ImageUpdater implements DialogInterface.OnCancelListener {
...
@@ -54,7 +54,6 @@ public class ImageUpdater implements DialogInterface.OnCancelListener {
public
ImageUpdater
(
BaseActivity
context
)
{
public
ImageUpdater
(
BaseActivity
context
)
{
mContext
=
context
;
mContext
=
context
;
mCardLoader
=
new
CardLoader
(
context
);
mPicsPath
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
Constants
.
CORE_IMAGE_PATH
);
mPicsPath
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
Constants
.
CORE_IMAGE_PATH
);
mPicsExPath
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
Constants
.
CORE_EXPANSIONS_IMAGE_PATH
);
mPicsExPath
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
Constants
.
CORE_EXPANSIONS_IMAGE_PATH
);
}
}
...
@@ -339,10 +338,7 @@ public class ImageUpdater implements DialogInterface.OnCancelListener {
...
@@ -339,10 +338,7 @@ public class ImageUpdater implements DialogInterface.OnCancelListener {
}
}
private
void
loadCardsLocked
()
{
private
void
loadCardsLocked
()
{
if
(!
mCardLoader
.
isOpen
())
{
SparseArray
<
Card
>
cards
=
DataManager
.
get
().
getCardManager
().
getAllCards
();
mCardLoader
.
openDb
();
}
SparseArray
<
Card
>
cards
=
mCardLoader
.
readAllCardCodes
();
mCardStatus
.
clear
();
mCardStatus
.
clear
();
mPicsPath
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
Constants
.
CORE_IMAGE_PATH
);
mPicsPath
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
Constants
.
CORE_IMAGE_PATH
);
File
picsPath
=
mPicsPath
;
File
picsPath
=
mPicsPath
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/ResCheckTask.java
View file @
3062c6d4
...
@@ -26,7 +26,8 @@ import cn.garymb.ygomobile.utils.IOUtils;
...
@@ -26,7 +26,8 @@ import cn.garymb.ygomobile.utils.IOUtils;
import
cn.garymb.ygomobile.utils.SystemUtils
;
import
cn.garymb.ygomobile.utils.SystemUtils
;
import
libwindbot.windbot.WindBot
;
import
libwindbot.windbot.WindBot
;
import
ocgcore.ConfigManager
;
import
ocgcore.ConfigManager
;
import
ocgcore.handler.CardManager
;
import
ocgcore.CardManager
;
import
ocgcore.DataManager
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ASSETS_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ASSETS_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_BOT_CONF_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_BOT_CONF_PATH
;
...
@@ -128,7 +129,10 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
...
@@ -128,7 +129,10 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
* }
* }
* }*/
* }*/
//设置字体
//设置字体
new
ConfigManager
(
mSettings
.
getSystemConfig
()).
setFontSize
(
mSettings
.
getFontSize
());
ConfigManager
systemConf
=
DataManager
.
openConfig
(
mSettings
.
getSystemConfig
());
systemConf
.
setFontSize
(
mSettings
.
getFontSize
());
systemConf
.
close
();
// copyCoreConfig(new File(mSettings.getResourcePath(), GameSettings.CORE_CONFIG_PATH).getAbsolutePath());
// copyCoreConfig(new File(mSettings.getResourcePath(), GameSettings.CORE_CONFIG_PATH).getAbsolutePath());
if
(
needsUpdate
)
{
if
(
needsUpdate
)
{
setMessage
(
mContext
.
getString
(
R
.
string
.
check_things
,
mContext
.
getString
(
R
.
string
.
tip_new_deck
)));
setMessage
(
mContext
.
getString
(
R
.
string
.
check_things
,
mContext
.
getString
(
R
.
string
.
tip_new_deck
)));
...
@@ -176,6 +180,7 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
...
@@ -176,6 +180,7 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
//checkWindbot();
//checkWindbot();
han
.
sendEmptyMessage
(
0
);
han
.
sendEmptyMessage
(
0
);
loadData
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
if
(
Constants
.
DEBUG
)
if
(
Constants
.
DEBUG
)
Log
.
e
(
TAG
,
"check"
,
e
);
Log
.
e
(
TAG
,
"check"
,
e
);
...
@@ -184,6 +189,10 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
...
@@ -184,6 +189,10 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
return
ERROR_NONE
;
return
ERROR_NONE
;
}
}
private
void
loadData
(){
setMessage
(
mContext
.
getString
(
R
.
string
.
loading
));
DataManager
.
get
().
load
(
false
);
}
void
copyCdbFile
(
boolean
needsUpdate
)
throws
IOException
{
void
copyCdbFile
(
boolean
needsUpdate
)
throws
IOException
{
File
dbFile
=
new
File
(
mSettings
.
getDataBasePath
(),
DATABASE_NAME
);
File
dbFile
=
new
File
(
mSettings
.
getDataBasePath
(),
DATABASE_NAME
);
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/preference/fragments/SettingFragment.java
View file @
3062c6d4
...
@@ -44,6 +44,7 @@ import cn.garymb.ygomobile.ui.preference.PreferenceFragmentPlus;
...
@@ -44,6 +44,7 @@ import cn.garymb.ygomobile.ui.preference.PreferenceFragmentPlus;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.SystemUtils
;
import
cn.garymb.ygomobile.utils.SystemUtils
;
import
ocgcore.ConfigManager
;
import
ocgcore.ConfigManager
;
import
ocgcore.DataManager
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ACTION_RELOAD
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ACTION_RELOAD
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_SKIN_AVATAR_SIZE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_SKIN_AVATAR_SIZE
;
...
@@ -95,9 +96,9 @@ public class SettingFragment extends PreferenceFragmentPlus {
...
@@ -95,9 +96,9 @@ public class SettingFragment extends PreferenceFragmentPlus {
addPreferencesFromResource
(
R
.
xml
.
preference_game
);
addPreferencesFromResource
(
R
.
xml
.
preference_game
);
bind
(
PREF_GAME_PATH
,
mSettings
.
getResourcePath
());
bind
(
PREF_GAME_PATH
,
mSettings
.
getResourcePath
());
// bind(PREF_GAME_VERSION, mSettings.getVersionString(mSettings.getGameVersion()));
// bind(PREF_GAME_VERSION, mSettings.getVersionString(mSettings.getGameVersion()));
bind
(
PREF_CHANGE_LOG
,
SystemUtils
.
getVersionName
(
getActivity
())
bind
(
PREF_CHANGE_LOG
,
SystemUtils
.
getVersionName
(
getActivity
())
+
"("
+
SystemUtils
.
getVersion
(
getActivity
())
+
")"
);
+
"("
+
SystemUtils
.
getVersion
(
getActivity
())
+
")"
);
bind
(
PREF_CHECK_UPDATE
,
getString
(
R
.
string
.
settings_about_author_pref
)
+
" : "
+
getString
(
R
.
string
.
settings_author
));
bind
(
PREF_CHECK_UPDATE
,
getString
(
R
.
string
.
settings_about_author_pref
)+
" : "
+
getString
(
R
.
string
.
settings_author
));
bind
(
PREF_SOUND_EFFECT
,
mSettings
.
isSoundEffect
());
bind
(
PREF_SOUND_EFFECT
,
mSettings
.
isSoundEffect
());
bind
(
PREF_LOCK_SCREEN
,
mSettings
.
isLockSreenOrientation
());
bind
(
PREF_LOCK_SCREEN
,
mSettings
.
isLockSreenOrientation
());
bind
(
PREF_FONT_ANTIALIAS
,
mSettings
.
isFontAntiAlias
());
bind
(
PREF_FONT_ANTIALIAS
,
mSettings
.
isFontAntiAlias
());
...
@@ -115,7 +116,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
...
@@ -115,7 +116,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
}
}
bind
(
PREF_DECK_DELETE_DILAOG
,
mSettings
.
isDialogDelete
());
bind
(
PREF_DECK_DELETE_DILAOG
,
mSettings
.
isDialogDelete
());
//bind(PREF_USE_EXTRA_CARD_CARDS, mSettings.isUseExtraCards());
//bind(PREF_USE_EXTRA_CARD_CARDS, mSettings.isUseExtraCards());
bind
(
SETTINGS_AVATAR
,
new
File
(
mSettings
.
getCoreSkinPath
(),
Constants
.
CORE_SKIN_AVATAR_ME
).
getAbsolutePath
());
bind
(
SETTINGS_AVATAR
,
new
File
(
mSettings
.
getCoreSkinPath
(),
Constants
.
CORE_SKIN_AVATAR_ME
).
getAbsolutePath
());
bind
(
SETTINGS_COVER
,
new
File
(
mSettings
.
getCoreSkinPath
(),
Constants
.
CORE_SKIN_COVER
).
getAbsolutePath
());
bind
(
SETTINGS_COVER
,
new
File
(
mSettings
.
getCoreSkinPath
(),
Constants
.
CORE_SKIN_COVER
).
getAbsolutePath
());
bind
(
SETTINGS_CARD_BG
,
new
File
(
mSettings
.
getCoreSkinPath
(),
Constants
.
CORE_SKIN_BG
).
getAbsolutePath
());
bind
(
SETTINGS_CARD_BG
,
new
File
(
mSettings
.
getCoreSkinPath
(),
Constants
.
CORE_SKIN_BG
).
getAbsolutePath
());
bind
(
PREF_FONT_SIZE
,
mSettings
.
getFontSize
());
bind
(
PREF_FONT_SIZE
,
mSettings
.
getFontSize
());
...
@@ -149,7 +150,9 @@ public class SettingFragment extends PreferenceFragmentPlus {
...
@@ -149,7 +150,9 @@ public class SettingFragment extends PreferenceFragmentPlus {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
}
}
new
ConfigManager
(
mSettings
.
getSystemConfig
()).
setFontSize
(
size
);
ConfigManager
configManager
=
DataManager
.
openConfig
(
mSettings
.
getSystemConfig
());
configManager
.
setFontSize
(
size
);
configManager
.
close
();
}
}
if
(
preference
instanceof
CheckBoxPreference
)
{
if
(
preference
instanceof
CheckBoxPreference
)
{
CheckBoxPreference
checkBoxPreference
=
(
CheckBoxPreference
)
preference
;
CheckBoxPreference
checkBoxPreference
=
(
CheckBoxPreference
)
preference
;
...
@@ -195,14 +198,14 @@ public class SettingFragment extends PreferenceFragmentPlus {
...
@@ -195,14 +198,14 @@ public class SettingFragment extends PreferenceFragmentPlus {
View
viewDialog
=
dialog
.
getContentView
();
View
viewDialog
=
dialog
.
getContentView
();
ImageView
avatar1
=
viewDialog
.
findViewById
(
R
.
id
.
me
);
ImageView
avatar1
=
viewDialog
.
findViewById
(
R
.
id
.
me
);
ImageView
avatar2
=
viewDialog
.
findViewById
(
R
.
id
.
opponent
);
ImageView
avatar2
=
viewDialog
.
findViewById
(
R
.
id
.
opponent
);
setImage
(
mSettings
.
getCoreSkinPath
()
+
"/"
+
Constants
.
CORE_SKIN_AVATAR_ME
,
CORE_SKIN_AVATAR_SIZE
[
0
],
CORE_SKIN_AVATAR_SIZE
[
1
],
avatar1
);
setImage
(
mSettings
.
getCoreSkinPath
()
+
"/"
+
Constants
.
CORE_SKIN_AVATAR_ME
,
CORE_SKIN_AVATAR_SIZE
[
0
],
CORE_SKIN_AVATAR_SIZE
[
1
],
avatar1
);
setImage
(
mSettings
.
getCoreSkinPath
()
+
"/"
+
Constants
.
CORE_SKIN_AVATAR_OPPONENT
,
CORE_SKIN_AVATAR_SIZE
[
0
],
CORE_SKIN_AVATAR_SIZE
[
1
],
avatar2
);
setImage
(
mSettings
.
getCoreSkinPath
()
+
"/"
+
Constants
.
CORE_SKIN_AVATAR_OPPONENT
,
CORE_SKIN_AVATAR_SIZE
[
0
],
CORE_SKIN_AVATAR_SIZE
[
1
],
avatar2
);
avatar1
.
setOnClickListener
((
v
)
->
{
avatar1
.
setOnClickListener
((
v
)
->
{
//打开系统文件相册
//打开系统文件相册
String
outFile
=
new
File
(
mSettings
.
getCoreSkinPath
(),
Constants
.
CORE_SKIN_AVATAR_ME
).
getAbsolutePath
();
String
outFile
=
new
File
(
mSettings
.
getCoreSkinPath
(),
Constants
.
CORE_SKIN_AVATAR_ME
).
getAbsolutePath
();
showImageDialog
(
preference
,
getString
(
R
.
string
.
settings_game_avatar
),
showImageDialog
(
preference
,
getString
(
R
.
string
.
settings_game_avatar
),
outFile
,
outFile
,
true
,
CORE_SKIN_AVATAR_SIZE
[
0
],
CORE_SKIN_AVATAR_SIZE
[
1
]);
true
,
CORE_SKIN_AVATAR_SIZE
[
0
],
CORE_SKIN_AVATAR_SIZE
[
1
]);
dialog
.
dismiss
();
dialog
.
dismiss
();
});
});
avatar2
.
setOnClickListener
((
v
)
->
{
avatar2
.
setOnClickListener
((
v
)
->
{
...
@@ -210,10 +213,10 @@ public class SettingFragment extends PreferenceFragmentPlus {
...
@@ -210,10 +213,10 @@ public class SettingFragment extends PreferenceFragmentPlus {
String
outFile
=
new
File
(
mSettings
.
getCoreSkinPath
(),
Constants
.
CORE_SKIN_AVATAR_OPPONENT
).
getAbsolutePath
();
String
outFile
=
new
File
(
mSettings
.
getCoreSkinPath
(),
Constants
.
CORE_SKIN_AVATAR_OPPONENT
).
getAbsolutePath
();
showImageDialog
(
preference
,
getString
(
R
.
string
.
settings_game_avatar
),
showImageDialog
(
preference
,
getString
(
R
.
string
.
settings_game_avatar
),
outFile
,
outFile
,
true
,
CORE_SKIN_AVATAR_SIZE
[
0
],
CORE_SKIN_AVATAR_SIZE
[
1
]);
true
,
CORE_SKIN_AVATAR_SIZE
[
0
],
CORE_SKIN_AVATAR_SIZE
[
1
]);
dialog
.
dismiss
();
dialog
.
dismiss
();
});
});
}
else
if
(
SETTINGS_COVER
.
equals
(
key
))
{
}
else
if
(
SETTINGS_COVER
.
equals
(
key
))
{
//显示卡背图片对话框
//显示卡背图片对话框
final
DialogPlus
dialog
=
new
DialogPlus
(
getContext
());
final
DialogPlus
dialog
=
new
DialogPlus
(
getContext
());
dialog
.
setContentView
(
R
.
layout
.
dialog_cover_select
);
dialog
.
setContentView
(
R
.
layout
.
dialog_cover_select
);
...
@@ -222,8 +225,8 @@ public class SettingFragment extends PreferenceFragmentPlus {
...
@@ -222,8 +225,8 @@ public class SettingFragment extends PreferenceFragmentPlus {
View
viewDialog
=
dialog
.
getContentView
();
View
viewDialog
=
dialog
.
getContentView
();
ImageView
cover1
=
viewDialog
.
findViewById
(
R
.
id
.
cover1
);
ImageView
cover1
=
viewDialog
.
findViewById
(
R
.
id
.
cover1
);
ImageView
cover2
=
viewDialog
.
findViewById
(
R
.
id
.
cover2
);
ImageView
cover2
=
viewDialog
.
findViewById
(
R
.
id
.
cover2
);
setImage
(
mSettings
.
getCoreSkinPath
()
+
"/"
+
Constants
.
CORE_SKIN_COVER
,
CORE_SKIN_CARD_COVER_SIZE
[
0
],
CORE_SKIN_CARD_COVER_SIZE
[
1
],
cover1
);
setImage
(
mSettings
.
getCoreSkinPath
()
+
"/"
+
Constants
.
CORE_SKIN_COVER
,
CORE_SKIN_CARD_COVER_SIZE
[
0
],
CORE_SKIN_CARD_COVER_SIZE
[
1
],
cover1
);
setImage
(
mSettings
.
getCoreSkinPath
()
+
"/"
+
Constants
.
CORE_SKIN_COVER2
,
CORE_SKIN_CARD_COVER_SIZE
[
0
],
CORE_SKIN_CARD_COVER_SIZE
[
1
],
cover2
);
setImage
(
mSettings
.
getCoreSkinPath
()
+
"/"
+
Constants
.
CORE_SKIN_COVER2
,
CORE_SKIN_CARD_COVER_SIZE
[
0
],
CORE_SKIN_CARD_COVER_SIZE
[
1
],
cover2
);
cover1
.
setOnClickListener
((
v
)
->
{
cover1
.
setOnClickListener
((
v
)
->
{
//打开系统文件相册
//打开系统文件相册
String
outFile
=
new
File
(
mSettings
.
getCoreSkinPath
(),
Constants
.
CORE_SKIN_COVER
).
getAbsolutePath
();
String
outFile
=
new
File
(
mSettings
.
getCoreSkinPath
(),
Constants
.
CORE_SKIN_COVER
).
getAbsolutePath
();
...
@@ -250,9 +253,9 @@ public class SettingFragment extends PreferenceFragmentPlus {
...
@@ -250,9 +253,9 @@ public class SettingFragment extends PreferenceFragmentPlus {
ImageView
bg
=
viewDialog
.
findViewById
(
R
.
id
.
bg
);
ImageView
bg
=
viewDialog
.
findViewById
(
R
.
id
.
bg
);
ImageView
bg_menu
=
viewDialog
.
findViewById
(
R
.
id
.
bg_menu
);
ImageView
bg_menu
=
viewDialog
.
findViewById
(
R
.
id
.
bg_menu
);
ImageView
bg_deck
=
viewDialog
.
findViewById
(
R
.
id
.
bg_deck
);
ImageView
bg_deck
=
viewDialog
.
findViewById
(
R
.
id
.
bg_deck
);
setImage
(
mSettings
.
getCoreSkinPath
()
+
"/"
+
Constants
.
CORE_SKIN_BG
,
CORE_SKIN_BG_SIZE
[
0
],
CORE_SKIN_BG_SIZE
[
1
],
bg
);
setImage
(
mSettings
.
getCoreSkinPath
()
+
"/"
+
Constants
.
CORE_SKIN_BG
,
CORE_SKIN_BG_SIZE
[
0
],
CORE_SKIN_BG_SIZE
[
1
],
bg
);
setImage
(
mSettings
.
getCoreSkinPath
()
+
"/"
+
Constants
.
CORE_SKIN_BG_MENU
,
CORE_SKIN_BG_SIZE
[
0
],
CORE_SKIN_BG_SIZE
[
1
],
bg_menu
);
setImage
(
mSettings
.
getCoreSkinPath
()
+
"/"
+
Constants
.
CORE_SKIN_BG_MENU
,
CORE_SKIN_BG_SIZE
[
0
],
CORE_SKIN_BG_SIZE
[
1
],
bg_menu
);
setImage
(
mSettings
.
getCoreSkinPath
()
+
"/"
+
Constants
.
CORE_SKIN_BG_DECK
,
CORE_SKIN_BG_SIZE
[
0
],
CORE_SKIN_BG_SIZE
[
1
],
bg_deck
);
setImage
(
mSettings
.
getCoreSkinPath
()
+
"/"
+
Constants
.
CORE_SKIN_BG_DECK
,
CORE_SKIN_BG_SIZE
[
0
],
CORE_SKIN_BG_SIZE
[
1
],
bg_deck
);
bg
.
setOnClickListener
((
v
)
->
{
bg
.
setOnClickListener
((
v
)
->
{
//打开系统文件相册
//打开系统文件相册
String
outFile
=
new
File
(
mSettings
.
getCoreSkinPath
(),
Constants
.
CORE_SKIN_BG
).
getAbsolutePath
();
String
outFile
=
new
File
(
mSettings
.
getCoreSkinPath
(),
Constants
.
CORE_SKIN_BG
).
getAbsolutePath
();
...
@@ -361,7 +364,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
...
@@ -361,7 +364,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
}
}
}
}
public
void
setImage
(
String
outFile
,
int
outWidth
,
int
outHeight
,
ImageView
imageView
)
{
public
void
setImage
(
String
outFile
,
int
outWidth
,
int
outHeight
,
ImageView
imageView
)
{
File
img
=
new
File
(
outFile
);
File
img
=
new
File
(
outFile
);
if
(
img
.
exists
())
{
if
(
img
.
exists
())
{
Glide
.
with
(
this
).
load
(
img
).
signature
(
new
StringSignature
(
img
.
getName
()
+
img
.
lastModified
()))
Glide
.
with
(
this
).
load
(
img
).
signature
(
new
StringSignature
(
img
.
getName
()
+
img
.
lastModified
()))
...
...
mobile/src/main/java/ocgcore/
handler/
CardManager.java
→
mobile/src/main/java/ocgcore/CardManager.java
View file @
3062c6d4
package
ocgcore
.handler
;
package
ocgcore
;
import
android.database.Cursor
;
import
android.database.Cursor
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.support.annotation.WorkerThread
;
import
android.support.annotation.WorkerThread
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.util.Log
;
import
android.util.SparseArray
;
import
android.util.SparseArray
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FilenameFilter
;
import
java.io.FilenameFilter
;
import
java.util.HashMap
;
import
java.util.Map
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.MD5Util
;
import
ocgcore.data.Card
;
import
ocgcore.data.Card
;
public
class
CardManager
{
public
class
CardManager
{
private
String
dbDir
,
exDbPath
;
private
String
dbDir
,
exDbPath
;
private
final
SparseArray
<
Card
>
cardDataHashMap
=
new
SparseArray
<>();
private
final
SparseArray
<
Card
>
cardDataHashMap
=
new
SparseArray
<>();
private
final
Map
<
String
,
String
>
mCardCache
=
new
HashMap
<>();
public
CardManager
(
String
dbDir
,
String
exPath
)
{
public
CardManager
(
String
dbDir
,
String
exPath
)
{
this
.
dbDir
=
dbDir
;
this
.
dbDir
=
dbDir
;
...
@@ -44,7 +39,7 @@ public class CardManager {
...
@@ -44,7 +39,7 @@ public class CardManager {
public
void
loadCards
()
{
public
void
loadCards
()
{
int
count
=
readAllCards
(
AppsSettings
.
get
().
getDataBaseFile
(),
cardDataHashMap
);
int
count
=
readAllCards
(
AppsSettings
.
get
().
getDataBaseFile
(),
cardDataHashMap
);
Log
.
i
(
"Irrlicht"
,
"load defualt cdb:"
+
count
);
Log
.
i
(
"Irrlicht"
,
"load defualt cdb:"
+
count
);
if
(
AppsSettings
.
get
().
isReadExpansions
())
{
/*
if (AppsSettings.get().isReadExpansions()) {
File dir = new File(exDbPath);
File dir = new File(exDbPath);
if (dir.exists()) {
if (dir.exists()) {
File[] files = dir.listFiles(new FilenameFilter() {
File[] files = dir.listFiles(new FilenameFilter() {
...
@@ -56,20 +51,18 @@ public class CardManager {
...
@@ -56,20 +51,18 @@ public class CardManager {
});
});
//读取全部卡片
//读取全部卡片
if (files != null) {
if (files != null) {
Log
.
i
(
"数量"
,
"数量"
+
files
.
length
);
for (File file : files) {
for (File file : files) {
final
String
path
=
file
.
getAbsolutePath
();
String
md5
=
MD5Util
.
getFileMD5
(
path
);
String
last
=
mCardCache
.
get
(
path
);
if
(!
TextUtils
.
equals
(
md5
,
last
))
{
mCardCache
.
put
(
path
,
md5
);
count = readAllCards(file, cardDataHashMap);
count = readAllCards(file, cardDataHashMap);
Log.i("Irrlicht", "load " + count + " cdb:" + file);
Log.i("Irrlicht", "load " + count + " cdb:" + file);
}
}
}
}
}
}
}*/
}
}
}
private
static
SQLiteDatabase
openDatabase
(
String
file
)
{
return
SQLiteDatabase
.
openDatabase
(
file
,
null
,
SQLiteDatabase
.
NO_LOCALIZED_COLLATORS
|
SQLiteDatabase
.
OPEN_READONLY
);
}
}
public
static
boolean
checkDataBase
(
File
file
)
{
public
static
boolean
checkDataBase
(
File
file
)
{
...
@@ -80,8 +73,8 @@ public class CardManager {
...
@@ -80,8 +73,8 @@ public class CardManager {
SQLiteDatabase
db
=
null
;
SQLiteDatabase
db
=
null
;
boolean
rs
=
false
;
boolean
rs
=
false
;
try
{
try
{
db
=
SQLiteDatabase
.
openOrCreateDatabase
(
file
,
null
);
db
=
openDatabase
(
file
.
getPath
()
);
reader
=
db
.
rawQuery
(
"select datas.id, ot, alias, setcode, type, level, race, attribute, atk, def,category,name,
desc
from datas,texts where datas.id = texts.id limit 1;"
,
null
);
reader
=
db
.
rawQuery
(
"select datas.id, ot, alias, setcode, type, level, race, attribute, atk, def,category,name,
\"desc\"
from datas,texts where datas.id = texts.id limit 1;"
,
null
);
rs
=
reader
!=
null
;
rs
=
reader
!=
null
;
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
//ignore
//ignore
...
@@ -90,7 +83,7 @@ public class CardManager {
...
@@ -90,7 +83,7 @@ public class CardManager {
}
}
if
(!
rs
)
{
if
(!
rs
)
{
try
{
try
{
reader
=
db
.
rawQuery
(
"select datas._id, ot, alias, setcode, type, level, race, attribute, atk, def,category,name,
desc
from datas,texts where datas._id = texts._id limit 1;"
,
null
);
reader
=
db
.
rawQuery
(
"select datas._id, ot, alias, setcode, type, level, race, attribute, atk, def,category,name,
\"desc\"
from datas,texts where datas._id = texts._id limit 1;"
,
null
);
rs
=
reader
!=
null
;
rs
=
reader
!=
null
;
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
//ignore
//ignore
...
@@ -111,13 +104,12 @@ public class CardManager {
...
@@ -111,13 +104,12 @@ public class CardManager {
Cursor
reader
=
null
;
Cursor
reader
=
null
;
SQLiteDatabase
db
=
null
;
SQLiteDatabase
db
=
null
;
try
{
try
{
db
=
SQLiteDatabase
.
openOrCreateDatabase
(
file
,
null
);
db
=
openDatabase
(
file
.
getPath
());
if
(
db
.
isOpen
())
{
try
{
try
{
reader
=
db
.
rawQuery
(
"select datas.id, ot, alias, setcode, type, level, race, attribute, atk, def,category,name,desc
from datas,texts where datas.id = texts.id;"
,
null
);
reader
=
db
.
rawQuery
(
"select datas.id, ot, alias, setcode, type, level, race, attribute, atk, def,category,name,\"desc\"
from datas,texts where datas.id = texts.id;"
,
null
);
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
//ignore
//ignore
reader
=
db
.
rawQuery
(
"select datas._id, ot, alias, setcode, type, level, race, attribute, atk, def,category,name,desc
from datas,texts where datas._id = texts._id;"
,
null
);
reader
=
db
.
rawQuery
(
"select datas._id, ot, alias, setcode, type, level, race, attribute, atk, def,category,name,\"desc\"
from datas,texts where datas._id = texts._id;"
,
null
);
}
}
if
(
reader
!=
null
&&
reader
.
moveToFirst
())
{
if
(
reader
!=
null
&&
reader
.
moveToFirst
())
{
do
{
do
{
...
@@ -143,7 +135,6 @@ public class CardManager {
...
@@ -143,7 +135,6 @@ public class CardManager {
cardMap
.
put
(
cardData
.
Code
,
cardData
);
cardMap
.
put
(
cardData
.
Code
,
cardData
);
}
while
(
reader
.
moveToNext
());
}
while
(
reader
.
moveToNext
());
}
}
}
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
Log
.
e
(
"Irrlicht"
,
"read cards "
+
file
,
e
);
Log
.
e
(
"Irrlicht"
,
"read cards "
+
file
,
e
);
...
...
mobile/src/main/java/ocgcore/ConfigManager.java
View file @
3062c6d4
...
@@ -2,9 +2,11 @@ package ocgcore;
...
@@ -2,9 +2,11 @@ package ocgcore;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.BufferedWriter
;
import
java.io.BufferedWriter
;
import
java.io.Closeable
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
java.io.OutputStreamWriter
;
import
java.io.OutputStreamWriter
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -13,15 +15,20 @@ import java.util.Locale;
...
@@ -13,15 +15,20 @@ import java.util.Locale;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
public
class
ConfigManager
{
public
class
ConfigManager
implements
Closeable
{
private
final
List
<
String
>
mLines
=
new
ArrayList
<>();
private
final
List
<
String
>
mLines
=
new
ArrayList
<>();
private
File
file
;
private
File
file
;
public
ConfigManager
(
File
file
)
{
ConfigManager
(
File
file
)
{
this
.
file
=
file
;
this
.
file
=
file
;
}
}
@Override
public
void
close
(){
mLines
.
clear
();
}
public
void
read
()
{
public
void
read
()
{
mLines
.
clear
();
mLines
.
clear
();
InputStreamReader
in
=
null
;
InputStreamReader
in
=
null
;
...
@@ -74,7 +81,7 @@ public class ConfigManager {
...
@@ -74,7 +81,7 @@ public class ConfigManager {
IOUtils
.
close
(
outputStream
);
IOUtils
.
close
(
outputStream
);
}
}
if
(
ok
)
{
if
(
ok
)
{
if
(
file
.
exists
())
{
if
(
file
.
exists
())
{
file
.
delete
();
file
.
delete
();
}
}
tmp
.
renameTo
(
file
);
tmp
.
renameTo
(
file
);
...
...
mobile/src/main/java/ocgcore/DataManager.java
0 → 100644
View file @
3062c6d4
package
ocgcore
;
import
java.io.File
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.loader.CardLoader
;
public
class
DataManager
{
private
static
DataManager
sLoader
=
null
;
public
static
DataManager
get
()
{
if
(
sLoader
!=
null
)
{
return
sLoader
;
}
synchronized
(
CardLoader
.
class
)
{
if
(
sLoader
==
null
)
{
sLoader
=
new
DataManager
();
}
}
return
sLoader
;
}
private
final
StringManager
mStringManager
;
private
final
LimitManager
mLimitManager
;
private
CardManager
mCardManager
;
private
DataManager
()
{
mStringManager
=
new
StringManager
();
mLimitManager
=
new
LimitManager
();
mCardManager
=
new
CardManager
(
AppsSettings
.
get
().
getDataBasePath
(),
AppsSettings
.
get
().
getExpansionsPath
().
getAbsolutePath
());
}
public
StringManager
getStringManager
()
{
return
mStringManager
;
}
public
LimitManager
getLimitManager
()
{
return
mLimitManager
;
}
public
static
ConfigManager
openConfig
(
File
conf
)
{
return
new
ConfigManager
(
conf
);
}
public
CardManager
getCardManager
()
{
return
mCardManager
;
}
private
boolean
mInit
;
public
void
load
(
boolean
force
)
{
boolean
needLoad
=
false
;
synchronized
(
this
)
{
if
(!
mInit
||
force
)
{
needLoad
=
true
;
}
mInit
=
true
;
}
if
(
needLoad
)
{
mStringManager
.
load
();
mLimitManager
.
load
();
mCardManager
.
loadCards
();
}
}
}
mobile/src/main/java/ocgcore/LimitManager.java
View file @
3062c6d4
package
ocgcore
;
package
ocgcore
;
import
android.support.annotation.NonNull
;
import
android.util.Log
;
import
android.util.Log
;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.Closeable
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
ocgcore.data.LimitList
;
import
ocgcore.data.LimitList
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_CUSTOM_LIMIT_PATH
;
public
class
LimitManager
implements
Closeable
{
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_LIMIT_PATH
;
private
final
Map
<
String
,
LimitList
>
mLimitLists
=
new
HashMap
<>();
private
final
List
<
String
>
mLimitNames
=
new
ArrayList
<>();
public
class
LimitManager
{
private
static
LimitManager
sManager
=
new
LimitManager
();
private
final
List
<
LimitList
>
mLimitLists
=
new
ArrayList
<>();
private
String
lastMd5
;
private
String
lastCustomMd5
;
private
int
mCount
;
private
int
mCount
;
private
LimitManager
()
{
LimitManager
()
{
}
}
public
static
LimitManager
get
()
{
@Override
return
sManager
;
public
void
close
()
{
mLimitNames
.
clear
();
mLimitLists
.
clear
();
}
}
public
int
getCount
()
{
public
int
getCount
()
{
return
mCount
;
return
mCount
;
}
}
public
List
<
LimitList
>
getLimitLists
()
{
public
Map
<
String
,
LimitList
>
getLimitLists
()
{
return
mLimitLists
;
return
mLimitLists
;
}
}
public
LimitList
getLimit
(
int
postion
)
{
if
(
postion
>=
0
&&
postion
<=
getCount
())
{
public
List
<
String
>
getLimitNames
()
{
return
mLimitLists
.
get
(
postion
);
return
mLimitNames
;
}
return
null
;
}
}
public
boolean
load_custom
()
{
public
@NonNull
LimitList
getLimit
(
String
name
)
{
File
stringfile
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
CORE_CUSTOM_LIMIT_PATH
);
return
mLimitLists
.
get
(
name
);
if
(
stringfile
==
null
)
{
return
false
;
}
}
/*
String md5 = MD5Util.getFileMD5(stringfile.getAbsolutePath());
public
LimitList
getTopLimit
()
{
if (
TextUtils.equals(md5, lastCustomMd5)
) {
if
(
mLimitNames
.
size
()
==
0
)
{
return
true
;
return
null
;
}
}
lastCustomMd5 = md5;
return
mLimitLists
.
get
(
mLimitNames
.
get
(
0
));
*/
return
loadFile
(
stringfile
.
getAbsolutePath
(),
false
);
}
}
public
boolean
load
()
{
public
boolean
load
()
{
boolean
custom_res
=
load_custom
(
);
File
stringFile
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
Constants
.
CORE_LIMIT_PATH
);
File
stringfile
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
CORE_LIMIT_PATH
);
boolean
rs1
=
loadFile
(
stringFile
);
/*
boolean
rs2
=
true
;
String md5 = MD5Util.getFileMD5(stringfile.getAbsolutePath());
if
(
AppsSettings
.
get
().
isReadExpansions
())
{
if (TextUtils.equals(md5, lastMd5)) {
File
stringFile2
=
new
File
(
AppsSettings
.
get
().
getExpansionsPath
(),
Constants
.
CORE_CUSTOM_LIMIT_PATH
);
r
eturn true
;
r
s2
=
loadFile
(
stringFile2
)
;
}
}
lastMd5 = md5;
return
rs1
&&
rs2
;
*/
return
loadFile
(
stringfile
.
getAbsolutePath
(),
custom_res
);
}
}
public
boolean
loadFile
(
String
path
,
boolean
leave
)
{
public
boolean
loadFile
(
File
file
)
{
if
(
path
==
null
||
path
.
length
()
==
0
)
{
return
false
;
}
File
file
=
new
File
(
path
);
if
(
file
.
isDirectory
()
||
!
file
.
exists
())
{
if
(
file
.
isDirectory
()
||
!
file
.
exists
())
{
return
false
;
return
false
;
}
}
if
(!
leave
)
{
mLimitLists
.
clear
();
mLimitLists
.
add
(
new
LimitList
(
null
));
}
InputStreamReader
in
=
null
;
InputStreamReader
in
=
null
;
FileInputStream
inputStream
=
null
;
FileInputStream
inputStream
=
null
;
try
{
try
{
...
@@ -100,10 +87,9 @@ public class LimitManager {
...
@@ -100,10 +87,9 @@ public class LimitManager {
}
}
if
(
line
.
startsWith
(
"!"
))
{
if
(
line
.
startsWith
(
"!"
))
{
name
=
line
.
substring
(
1
);
name
=
line
.
substring
(
1
);
if
(
tmp
!=
null
)
{
mLimitLists
.
add
(
tmp
);
}
tmp
=
new
LimitList
(
name
);
tmp
=
new
LimitList
(
name
);
mLimitLists
.
put
(
name
,
tmp
);
mLimitNames
.
add
(
name
);
}
else
if
(
tmp
!=
null
)
{
}
else
if
(
tmp
!=
null
)
{
String
[]
words
=
line
.
trim
().
split
(
"[\t| ]+"
);
String
[]
words
=
line
.
trim
().
split
(
"[\t| ]+"
);
if
(
words
.
length
>=
2
)
{
if
(
words
.
length
>=
2
)
{
...
@@ -124,9 +110,6 @@ public class LimitManager {
...
@@ -124,9 +110,6 @@ public class LimitManager {
}
}
}
}
if
(
tmp
!=
null
)
{
mLimitLists
.
add
(
tmp
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
Log
.
e
(
"kk"
,
"limit"
,
e
);
Log
.
e
(
"kk"
,
"limit"
,
e
);
}
finally
{
}
finally
{
...
...
mobile/src/main/java/ocgcore/StringManager.java
View file @
3062c6d4
...
@@ -4,8 +4,10 @@ import android.text.TextUtils;
...
@@ -4,8 +4,10 @@ import android.text.TextUtils;
import
android.util.SparseArray
;
import
android.util.SparseArray
;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.Closeable
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
...
@@ -14,45 +16,37 @@ import java.util.List;
...
@@ -14,45 +16,37 @@ import java.util.List;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.MD5Util
;
import
cn.garymb.ygomobile.utils.StringUtils
;
import
cn.garymb.ygomobile.utils.StringUtils
;
import
ocgcore.data.CardSet
;
import
ocgcore.data.CardSet
;
import
ocgcore.enums.CardOt
;
import
ocgcore.enums.CardOt
;
public
class
StringManager
{
public
class
StringManager
implements
Closeable
{
private
String
PRE_SYSTEM
=
"!system"
;
private
static
final
String
PRE_SYSTEM
=
"!system"
;
private
String
PRE_SETNAME
=
"!setname"
;
private
static
final
String
PRE_SETNAME
=
"!setname"
;
private
final
SparseArray
<
String
>
mSystem
=
new
SparseArray
<>();
private
final
SparseArray
<
String
>
mSystem
=
new
SparseArray
<>();
private
final
List
<
CardSet
>
mCardSets
=
new
ArrayList
<>();
private
final
List
<
CardSet
>
mCardSets
=
new
ArrayList
<>();
// private final Map<Long, String> mSetname = new HashMap<>();
private
static
StringManager
sStringManager
=
new
StringManager
();
private
String
lastMd5
,
lastMd52
;
private
StringManager
()
{
StringManager
()
{
}
}
public
static
StringManager
get
()
{
@Override
return
sStringManager
;
public
void
close
(){
mSystem
.
clear
();
mCardSets
.
clear
();
}
}
public
boolean
load
()
{
public
boolean
load
()
{
boolean
rs
=
false
;
mSystem
.
clear
();
File
stringfile
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
Constants
.
CORE_STRING_PATH
);
mCardSets
.
clear
();
String
md5
=
MD5Util
.
getFileMD5
(
stringfile
.
getAbsolutePath
());
File
stringFile
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
Constants
.
CORE_STRING_PATH
);
if
(!
TextUtils
.
equals
(
md5
,
lastMd5
))
{
boolean
rs1
=
loadFile
(
stringFile
.
getAbsolutePath
());
lastMd5
=
md5
;
boolean
rs2
=
true
;
rs
=
loadFile
(
stringfile
.
getAbsolutePath
());
}
if
(
AppsSettings
.
get
().
isReadExpansions
())
{
if
(
AppsSettings
.
get
().
isReadExpansions
())
{
stringfile
=
new
File
(
AppsSettings
.
get
().
getExpansionsPath
(),
Constants
.
CORE_STRING_PATH
);
File
stringFile2
=
new
File
(
AppsSettings
.
get
().
getExpansionsPath
(),
Constants
.
CORE_STRING_PATH
);
md5
=
MD5Util
.
getFileMD5
(
stringfile
.
getAbsolutePath
());
rs2
=
loadFile
(
stringFile2
.
getAbsolutePath
());
if
(!
TextUtils
.
equals
(
md5
,
lastMd5
))
{
lastMd52
=
md5
;
rs
=
loadFile
(
stringfile
.
getAbsolutePath
());
}
}
}
return
rs
;
return
rs
1
&&
rs2
;
}
}
public
boolean
loadFile
(
String
path
)
{
public
boolean
loadFile
(
String
path
)
{
...
...
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