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
7a92d476
Commit
7a92d476
authored
Sep 27, 2021
by
qq247321453
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ImageLoader
parent
e98a7e0c
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
350 additions
and
221 deletions
+350
-221
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
+0
-2
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
+1
-0
mobile/src/main/java/cn/garymb/ygomobile/loader/ImageLoader.java
...src/main/java/cn/garymb/ygomobile/loader/ImageLoader.java
+229
-164
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/BaseCardsActivity.java
.../java/cn/garymb/ygomobile/ui/cards/BaseCardsActivity.java
+16
-9
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardDetailRandom.java
...n/java/cn/garymb/ygomobile/ui/cards/CardDetailRandom.java
+37
-20
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardSearchActivity.java
...java/cn/garymb/ygomobile/ui/cards/CardSearchActivity.java
+2
-8
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
...c/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
+16
-6
mobile/src/main/java/cn/garymb/ygomobile/ui/widget/CardGroupView.java
...ain/java/cn/garymb/ygomobile/ui/widget/CardGroupView.java
+9
-2
mobile/src/main/java/cn/garymb/ygomobile/ui/widget/CardView.java
...src/main/java/cn/garymb/ygomobile/ui/widget/CardView.java
+3
-3
mobile/src/main/java/cn/garymb/ygomobile/ui/widget/DeckGroupView.java
...ain/java/cn/garymb/ygomobile/ui/widget/DeckGroupView.java
+13
-7
mobile/src/main/java/cn/garymb/ygomobile/ui/widget/DeckView.java
...src/main/java/cn/garymb/ygomobile/ui/widget/DeckView.java
+11
-0
mobile/src/main/java/cn/garymb/ygomobile/utils/FileUtils.java
...le/src/main/java/cn/garymb/ygomobile/utils/FileUtils.java
+13
-0
No files found.
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
View file @
7a92d476
...
@@ -3,7 +3,6 @@ package cn.garymb.ygomobile;
...
@@ -3,7 +3,6 @@ package cn.garymb.ygomobile;
import
android.annotation.SuppressLint
;
import
android.annotation.SuppressLint
;
import
android.content.Context
;
import
android.content.Context
;
import
android.graphics.Point
;
import
android.graphics.Point
;
import
android.os.ParcelFileDescriptor
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.util.Log
;
import
android.view.WindowManager
;
import
android.view.WindowManager
;
...
@@ -36,7 +35,6 @@ import static cn.garymb.ygomobile.Constants.DEF_PREF_KEEP_SCALE;
...
@@ -36,7 +35,6 @@ import static cn.garymb.ygomobile.Constants.DEF_PREF_KEEP_SCALE;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
DEF_PREF_NOTCH_HEIGHT
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
DEF_PREF_NOTCH_HEIGHT
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
DEF_PREF_ONLY_GAME
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
DEF_PREF_ONLY_GAME
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
DEF_PREF_READ_EX
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
DEF_PREF_READ_EX
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
DEF_PREF_WINDOW_TOP_BOTTOM
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_DEF_IMMERSIVE_MODE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_DEF_IMMERSIVE_MODE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_DEF_SENSOR_REFRESH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_DEF_SENSOR_REFRESH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_FONT_SIZE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_FONT_SIZE
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
View file @
7a92d476
...
@@ -92,6 +92,7 @@ public interface Constants {
...
@@ -92,6 +92,7 @@ public interface Constants {
String
UNKNOWN_IMAGE
=
"unknown.jpg"
;
String
UNKNOWN_IMAGE
=
"unknown.jpg"
;
String
YDK_FILE_EX
=
".ydk"
;
String
YDK_FILE_EX
=
".ydk"
;
int
[]
CORE_SKIN_BG_SIZE
=
new
int
[]{
1280
,
720
};
int
[]
CORE_SKIN_BG_SIZE
=
new
int
[]{
1280
,
720
};
int
[]
CORE_SKIN_CARD_MINI_SIZE
=
new
int
[]{
177
,
254
};
int
[]
CORE_SKIN_CARD_COVER_SIZE
=
new
int
[]{
177
,
254
};
int
[]
CORE_SKIN_CARD_COVER_SIZE
=
new
int
[]{
177
,
254
};
int
[]
CORE_SKIN_AVATAR_SIZE
=
new
int
[]{
128
,
128
};
int
[]
CORE_SKIN_AVATAR_SIZE
=
new
int
[]{
128
,
128
};
boolean
SUPPORT_BPG
=
true
;
boolean
SUPPORT_BPG
=
true
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/loader/ImageLoader.java
View file @
7a92d476
package
cn.garymb.ygomobile.loader
;
package
cn.garymb.ygomobile.loader
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.graphics.Bitmap
;
import
android.graphics.drawable.Drawable
;
import
android.graphics.drawable.Drawable
;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.util.Log
;
import
android.util.Log
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
com.bumptech.glide.DrawableTypeRequest
;
import
com.bumptech.glide.DrawableTypeRequest
;
import
com.bumptech.glide.load.ResourceDecoder
;
import
com.bumptech.glide.load.ResourceDecoder
;
import
com.bumptech.glide.load.engine.Resource
;
import
com.bumptech.glide.load.engine.Resource
;
...
@@ -15,7 +17,7 @@ import com.bumptech.glide.load.model.ImageVideoWrapper;
...
@@ -15,7 +17,7 @@ import com.bumptech.glide.load.model.ImageVideoWrapper;
import
com.bumptech.glide.load.resource.bitmap.BitmapResource
;
import
com.bumptech.glide.load.resource.bitmap.BitmapResource
;
import
com.bumptech.glide.load.resource.gifbitmap.GifBitmapWrapper
;
import
com.bumptech.glide.load.resource.gifbitmap.GifBitmapWrapper
;
import
com.bumptech.glide.load.resource.gifbitmap.GifBitmapWrapperResource
;
import
com.bumptech.glide.load.resource.gifbitmap.GifBitmapWrapperResource
;
import
com.bumptech.glide.
request.target.GlideDrawableImageViewTarget
;
import
com.bumptech.glide.
signature.MediaStoreSignature
;
import
com.bumptech.glide.signature.StringSignature
;
import
com.bumptech.glide.signature.StringSignature
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
...
@@ -33,91 +35,104 @@ import java.util.zip.ZipFile;
...
@@ -33,91 +35,104 @@ import java.util.zip.ZipFile;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
import
cn.garymb.ygomobile.lite.BuildConfig
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.utils.
BitmapUtil
;
import
cn.garymb.ygomobile.utils.
FileUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.MD5Util
;
import
cn.garymb.ygomobile.utils.NetUtils
;
import
cn.garymb.ygomobile.utils.NetUtils
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_SKIN_BG_SIZE
;
import
static
com
.
bumptech
.
glide
.
Glide
.
with
;
import
static
com
.
bumptech
.
glide
.
Glide
.
with
;
public
class
ImageLoader
implements
Closeable
{
public
class
ImageLoader
implements
Closeable
{
private
static
final
String
TAG
=
ImageLoader
.
class
.
getSimpleName
();
public
static
final
ImageLoader
sImageLoader
=
new
ImageLoader
();
private
ZipFile
mZipFile
;
private
List
<
ZipFile
>
zipFileList
;
public
static
ImageLoader
get
()
{
private
LruBitmapPool
mLruBitmapPool
;
return
sImageLoader
;
// private ExecutorService mExecutorService = Executors.newSingleThreadExecutor();
private
boolean
isClose
=
false
;
private
Context
mContext
;
private
static
final
Map
<
Context
,
ImageLoader
>
IMAGE_LOADER_MAP
=
new
ConcurrentHashMap
<>();
public
static
ImageLoader
get
(
Context
context
)
{
ImageLoader
imageLoader
=
IMAGE_LOADER_MAP
.
get
(
context
);
if
(
imageLoader
==
null
)
{
synchronized
(
IMAGE_LOADER_MAP
)
{
imageLoader
=
IMAGE_LOADER_MAP
.
get
(
context
);
if
(
imageLoader
==
null
)
{
imageLoader
=
new
ImageLoader
(
context
);
IMAGE_LOADER_MAP
.
put
(
context
,
imageLoader
);
}
}
}
return
imageLoader
;
}
}
public
static
void
onDestory
(
Context
context
)
{
private
static
class
Cache
{
synchronized
(
IMAGE_LOADER_MAP
)
{
private
final
byte
[]
data
;
IMAGE_LOADER_MAP
.
remove
(
context
);
private
final
String
name
;
public
Cache
(
byte
[]
data
,
String
name
)
{
this
.
data
=
data
;
this
.
name
=
name
;
}
}
}
}
private
ImageLoader
(
Context
context
)
{
private
final
boolean
useCache
;
mContext
=
context
;
private
static
final
String
TAG
=
ImageLoader
.
class
.
getSimpleName
();
mLruBitmapPool
=
new
LruBitmapPool
(
100
);
private
final
Map
<
String
,
ZipFile
>
zipFileCache
=
new
ConcurrentHashMap
<>();
zipFileList
=
new
ArrayList
<>();
private
final
LruBitmapPool
mLruBitmapPool
=
new
LruBitmapPool
(
128
);
private
final
Map
<
Long
,
Cache
>
zipDataCache
=
new
ConcurrentHashMap
<>();
private
ZipFile
mDefaultZipFile
;
private
File
mPicsFile
;
public
ImageLoader
(){
this
(
false
);
}
}
private
class
BpgResourceDecoder
implements
ResourceDecoder
<
ImageVideoWrapper
,
GifBitmapWrapper
>
{
public
ImageLoader
(
boolean
useCache
)
{
String
id
;
this
.
useCache
=
useCache
;
}
private
BpgResourceDecoder
(
String
id
)
{
private
ZipFile
openPicsZip
()
{
this
.
id
=
id
;
if
(
mPicsFile
==
null
)
{
mPicsFile
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
Constants
.
CORE_PICS_ZIP
);
}
}
if
(
mDefaultZipFile
==
null
)
{
@Override
if
(
mPicsFile
.
exists
())
{
public
Resource
<
GifBitmapWrapper
>
decode
(
ImageVideoWrapper
source
,
int
width
,
int
height
)
throws
IOException
{
try
{
// Log.i("kk", "decode source:"+sourc
e);
mDefaultZipFile
=
new
ZipFile
(
mPicsFil
e
);
Bitmap
bitmap
=
IrrlichtBridge
.
getBpgImage
(
source
.
getStream
(),
Bitmap
.
Config
.
RGB_565
);
}
catch
(
IOException
e
)
{
// Log.i("kk", "decode bitmap:"+bitmap);
//Ignore
BitmapResource
resource
=
new
BitmapResource
(
bitmap
,
mLruBitmapPool
);
}
return
new
GifBitmapWrapperResource
(
new
GifBitmapWrapper
(
resource
,
null
));
}
}
}
return
mDefaultZipFile
;
}
@Override
public
void
resume
(){
public
String
getId
()
{
return
id
;
}
public
void
pause
(){
//关闭zip
for
(
ZipFile
zipFile
:
zipFileCache
.
values
())
{
IOUtils
.
closeZip
(
zipFile
);
}
zipFileCache
.
clear
();
if
(
mDefaultZipFile
!=
null
)
{
IOUtils
.
closeZip
(
mDefaultZipFile
);
}
}
}
}
@Override
@Override
public
void
close
()
throws
IOException
{
public
void
close
()
{
isClose
=
true
;
if
(
BuildConfig
.
DEBUG_MODE
)
{
// if (!mExecutorService.isShutdown()) {
Log
.
d
(
TAG
,
"close and clean cache"
);
// mExecutorService.shutdown();
}
// }
pause
();
zipDataCache
.
clear
();
}
private
void
bind
(
final
byte
[]
data
,
String
name
,
ImageView
imageview
,
Drawable
pre
,
int
[]
size
)
{
if
(
BuildConfig
.
DEBUG_MODE
)
{
Log
.
d
(
TAG
,
"bind data:"
+
name
+
", size="
+
(
size
==
null
?
"null"
:
size
[
0
]
+
"x"
+
size
[
1
]));
}
bindT
(
data
,
name
,
imageview
,
pre
,
size
);
}
}
private
Bitmap
loadImage
(
String
path
,
int
w
,
int
h
)
{
private
void
bind
(
final
Uri
uri
,
String
name
,
ImageView
imageview
,
Drawable
pre
,
int
[]
size
)
{
File
file
=
new
File
(
path
);
if
(
BuildConfig
.
DEBUG_MODE
)
{
if
(
file
.
exists
())
{
Log
.
d
(
TAG
,
"bind uri:"
+
name
+
", size="
+
(
size
==
null
?
"null"
:
size
[
0
]
+
"x"
+
size
[
1
]));
return
BitmapUtil
.
getBitmapFromFile
(
file
.
getAbsolutePath
(),
CORE_SKIN_BG_SIZE
[
0
],
CORE_SKIN_BG_SIZE
[
1
]);
}
}
return
null
;
bindT
(
uri
,
name
,
imageview
,
pre
,
size
)
;
}
}
private
void
bind
(
byte
[]
data
,
ImageView
imageview
,
boolean
isbpg
,
long
code
,
Drawable
pre
,
boolean
isBig
)
{
private
<
T
>
void
setDefaults
(
@NonNull
DrawableTypeRequest
<
T
>
resource
,
String
name
,
DrawableTypeRequest
<
byte
[]>
resource
=
with
(
mContext
).
load
(
data
);
@Nullable
com
.
bumptech
.
glide
.
load
.
Key
signature
,
@Nullable
Drawable
pre
,
@Nullable
int
[]
size
)
{
if
(
pre
!=
null
)
{
if
(
pre
!=
null
)
{
resource
.
placeholder
(
pre
);
resource
.
placeholder
(
pre
);
}
else
{
}
else
{
...
@@ -125,29 +140,26 @@ public class ImageLoader implements Closeable {
...
@@ -125,29 +140,26 @@ public class ImageLoader implements Closeable {
}
}
resource
.
error
(
R
.
drawable
.
unknown
);
resource
.
error
(
R
.
drawable
.
unknown
);
resource
.
animate
(
R
.
anim
.
push_in
);
resource
.
animate
(
R
.
anim
.
push_in
);
// if(isbpg){
if
(
size
!=
null
)
{
// resource.override(Constants.CORE_SKIN_CARD_COVER_SIZE[0], Constants.CORE_SKIN_CARD_COVER_SIZE[1]);
resource
.
override
(
size
[
0
],
size
[
1
]);
// }
}
resource
.
signature
(
new
StringSignature
(
MD5Util
.
getStringMD5
(
data
.
length
+
"_"
+
code
+
"_"
+
isBig
)));
if
(
signature
!=
null
)
{
if
(
isbpg
)
{
resource
.
signature
(
signature
);
resource
.
decoder
(
new
BpgResourceDecoder
(
"bpg@"
+
code
));
}
String
ex
=
FileUtils
.
getFileExpansion
(
name
);
if
(
"bpg"
.
equals
(
ex
))
{
resource
.
decoder
(
new
BpgResourceDecoder
(
name
,
mLruBitmapPool
));
}
}
resource
.
into
(
imageview
);
}
}
p
ublic
void
bind
(
final
File
file
,
ImageView
imageview
,
boolean
isbpg
,
long
code
,
Drawable
pre
,
boolean
isBig
)
{
p
rivate
<
T
>
void
bindT
(
final
T
data
,
String
name
,
ImageView
imageview
,
Drawable
pre
,
int
[]
size
)
{
try
{
try
{
DrawableTypeRequest
<
File
>
resource
=
with
(
mContext
).
load
(
file
);
DrawableTypeRequest
<
T
>
resource
=
with
(
imageview
.
getContext
()).
load
(
data
);
if
(
pre
!=
null
)
{
if
(
size
==
null
)
{
resource
.
placeholder
(
pre
);
setDefaults
(
resource
,
name
,
new
StringSignature
(
name
),
pre
,
size
);
resource
.
signature
(
new
StringSignature
(
name
));
}
else
{
}
else
{
resource
.
placeholder
(
R
.
drawable
.
unknown
);
setDefaults
(
resource
,
name
,
new
StringSignature
(
name
+
":"
+
size
[
0
]
+
"x"
+
size
[
1
]),
pre
,
size
);
}
resource
.
error
(
R
.
drawable
.
unknown
);
resource
.
animate
(
R
.
anim
.
push_in
);
resource
.
signature
(
new
StringSignature
(
MD5Util
.
getStringMD5
(
file
.
length
()
+
code
+
"_"
+
isBig
)));
if
(
isbpg
)
{
resource
.
decoder
(
new
BpgResourceDecoder
(
"bpg@"
+
code
));
}
}
resource
.
into
(
imageview
);
resource
.
into
(
imageview
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -155,122 +167,175 @@ public class ImageLoader implements Closeable {
...
@@ -155,122 +167,175 @@ public class ImageLoader implements Closeable {
}
}
}
}
private
void
bind
(
final
String
url
,
ImageView
imageview
,
long
code
,
Drawable
pre
,
boolean
isBig
)
{
private
void
bind
(
final
File
file
,
ImageView
imageview
,
Drawable
pre
,
int
[]
size
)
{
DrawableTypeRequest
<
Uri
>
resource
=
with
(
mContext
).
load
(
Uri
.
parse
(
url
));
if
(
BuildConfig
.
DEBUG_MODE
)
{
if
(
pre
!=
null
)
{
Log
.
d
(
TAG
,
"bind file:"
+
file
.
getPath
()
+
", size="
+
(
size
==
null
?
"null"
:
size
[
0
]
+
"x"
+
size
[
1
]));
resource
.
placeholder
(
pre
);
}
}
else
{
try
{
resource
.
placeholder
(
R
.
drawable
.
unknown
);
DrawableTypeRequest
<
File
>
resource
=
with
(
imageview
.
getContext
()).
load
(
file
);
long
key
=
size
==
null
?
0
:(
size
[
0
]
*
size
[
1
]);
setDefaults
(
resource
,
file
.
getName
(),
new
MediaStoreSignature
(
"image/*"
,
file
.
lastModified
()
+
key
,
0
),
pre
,
size
);
resource
.
into
(
imageview
);
}
catch
(
Exception
e
)
{
Log
.
e
(
TAG
,
"$"
,
e
);
}
}
resource
.
error
(
R
.
drawable
.
unknown
);
resource
.
override
(
Constants
.
CORE_SKIN_CARD_COVER_SIZE
[
0
],
Constants
.
CORE_SKIN_CARD_COVER_SIZE
[
1
]);
resource
.
signature
(
new
StringSignature
(
""
+
code
));
resource
.
into
(
new
GlideDrawableImageViewTarget
(
imageview
));
}
}
public
void
bindImage
(
ImageView
imageview
,
long
code
)
{
private
boolean
bindInZip
(
ImageView
imageView
,
long
code
,
Drawable
pre
,
ZipFile
zipFile
,
String
nameWithEx
,
int
[]
size
)
{
bindImage
(
imageview
,
code
,
null
);
ZipEntry
entry
;
InputStream
inputStream
=
null
;
ByteArrayOutputStream
outputStream
;
boolean
bind
=
false
;
try
{
entry
=
zipFile
.
getEntry
(
nameWithEx
);
if
(
entry
!=
null
)
{
inputStream
=
zipFile
.
getInputStream
(
entry
);
outputStream
=
new
ByteArrayOutputStream
();
IOUtils
.
copy
(
inputStream
,
outputStream
);
byte
[]
data
=
outputStream
.
toByteArray
();
if
(
useCache
){
zipDataCache
.
put
(
code
,
new
Cache
(
data
,
nameWithEx
));
}
bind
(
data
,
nameWithEx
,
imageView
,
pre
,
size
);
bind
=
true
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
IOUtils
.
close
(
inputStream
);
}
return
bind
;
}
private
void
cleanInValidZips
()
{
List
<
String
>
removes
=
new
ArrayList
<>();
for
(
String
old
:
zipFileCache
.
keySet
())
{
if
(!
FileUtils
.
isExist
(
old
))
{
removes
.
add
(
old
);
}
}
for
(
String
key
:
removes
)
{
zipFileCache
.
remove
(
key
);
}
}
}
public
void
bindImage
(
ImageView
imageview
,
long
code
,
Drawable
pre
)
{
bindImage
(
imageview
,
code
,
pre
,
false
);
/**
* 177x254
*/
public
void
bindImage
(
ImageView
imageview
,
long
code
)
{
bindImage
(
imageview
,
code
,
null
,
Constants
.
CORE_SKIN_CARD_MINI_SIZE
);
}
}
/**
* @param big true则是原始大小
*/
@Deprecated
public
void
bindImage
(
ImageView
imageview
,
long
code
,
Drawable
pre
,
boolean
big
)
{
bindImage
(
imageview
,
code
,
pre
,
big
?
null
:
Constants
.
CORE_SKIN_CARD_MINI_SIZE
);
}
public
void
bindImage
(
ImageView
imageview
,
long
code
,
Drawable
pre
,
boolean
isBig
)
{
public
void
bindImage
(
ImageView
imageview
,
long
code
,
Drawable
pre
,
int
[]
size
)
{
if
(
BuildConfig
.
DEBUG_MODE
)
{
Log
.
d
(
TAG
,
"bind image:"
+
code
+
", size="
+
(
size
==
null
?
"null"
:
size
[
0
]
+
"x"
+
size
[
1
]));
}
String
name
=
Constants
.
CORE_IMAGE_PATH
+
"/"
+
code
;
String
name
=
Constants
.
CORE_IMAGE_PATH
+
"/"
+
code
;
String
name_ex
=
Constants
.
CORE_EXPANSIONS_IMAGE_PATH
+
"/"
+
code
;
String
name_ex
=
Constants
.
CORE_EXPANSIONS_IMAGE_PATH
+
"/"
+
code
;
String
path
=
AppsSettings
.
get
().
getResourcePath
();
//1.图片文件
boolean
bind
=
false
;
File
zip
=
new
File
(
path
,
Constants
.
CORE_PICS_ZIP
);
List
<
File
>
zipList
=
new
ArrayList
<>();
for
(
String
ex
:
Constants
.
IMAGE_EX
)
{
for
(
String
ex
:
Constants
.
IMAGE_EX
)
{
File
file
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
name
+
ex
);
File
file
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
name
+
ex
);
File
file_ex
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
name_ex
+
ex
);
File
file_ex
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
name_ex
+
ex
);
if
(
file_ex
.
exists
())
{
if
(
file_ex
.
exists
())
{
bind
(
file_ex
,
imageview
,
Constants
.
BPG
.
equals
(
ex
),
code
,
pre
,
isBig
);
bind
(
file_ex
,
imageview
,
pre
,
size
);
bind
=
true
;
return
;
return
;
}
else
if
(
file
.
exists
())
{
}
else
bind
(
file
,
imageview
,
pre
,
size
);
if
(
file
.
exists
())
{
bind
(
file
,
imageview
,
Constants
.
BPG
.
equals
(
ex
),
code
,
pre
,
isBig
);
bind
=
true
;
return
;
return
;
}
}
}
}
if
(
zip
.
exists
())
{
//cache
ZipEntry
entry
=
null
;
if
(
useCache
)
{
InputStream
inputStream
=
null
;
Cache
cache
=
zipDataCache
.
get
(
code
);
ByteArrayOutputStream
outputStream
=
null
;
if
(
cache
!=
null
)
{
try
{
bind
(
cache
.
data
,
cache
.
name
,
imageview
,
pre
,
size
);
if
(
mZipFile
==
null
)
{
return
;
mZipFile
=
new
ZipFile
(
zip
);
}
}
}
//2.zip
{
ZipFile
pics
=
openPicsZip
();
if
(
pics
!=
null
)
{
for
(
String
ex
:
Constants
.
IMAGE_EX
)
{
for
(
String
ex
:
Constants
.
IMAGE_EX
)
{
entry
=
mZipFile
.
getEntry
(
name
+
ex
);
if
(
bindInZip
(
imageview
,
code
,
pre
,
pics
,
name
+
ex
,
size
))
{
if
(
entry
!=
null
)
{
return
;
inputStream
=
mZipFile
.
getInputStream
(
entry
);
outputStream
=
new
ByteArrayOutputStream
();
IOUtils
.
copy
(
inputStream
,
outputStream
);
bind
(
outputStream
.
toByteArray
(),
imageview
,
Constants
.
BPG
.
equals
(
ex
),
code
,
pre
,
isBig
);
bind
=
true
;
break
;
}
}
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
IOUtils
.
close
(
inputStream
);
}
}
}
}
if
(!
bind
)
{
//3.
File
[]
files
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
Constants
.
CORE_EXPANSIONS
).
listFiles
();
//zips
if
(
files
!=
null
)
{
File
[]
files
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
Constants
.
CORE_EXPANSIONS
)
for
(
File
file
:
files
)
{
.
listFiles
((
dir
,
name1
)
->
name1
.
endsWith
(
".zip"
)
||
name1
.
endsWith
(
".ypk"
));
if
(
file
.
isFile
()
&&
(
file
.
getName
().
endsWith
(
".zip"
)
||
file
.
getName
().
endsWith
(
".ypk"
)))
{
ZipEntry
entry
=
null
;
cleanInValidZips
();
InputStream
inputStream
=
null
;
ByteArrayOutputStream
outputStream
=
null
;
if
(
files
!=
null
)
{
for
(
File
file
:
files
)
{
if
(
file
.
isFile
())
{
ZipFile
zipFile
=
useCache
?
zipFileCache
.
get
(
file
.
getAbsolutePath
())
:
null
;
if
(
zipFile
==
null
)
{
try
{
try
{
ZipFile
zipFile
=
null
;
zipFile
=
new
ZipFile
(
file
);
for
(
ZipFile
zipFile1:
zipFileList
){
if
(
useCache
)
{
if
(
zipFile1
.
getName
().
equals
(
file
.
getAbsolutePath
())){
zipFileCache
.
put
(
file
.
getAbsolutePath
(),
zipFile
);
zipFile
=
zipFile1
;
break
;
}
}
}
if
(
zipFile
==
null
){
}
catch
(
Throwable
e
)
{
zipFile
=
new
ZipFile
(
file
.
getAbsoluteFile
());
//Ignore
zipFileList
.
add
(
zipFile
);
}
}
}
for
(
String
ex
:
Constants
.
IMAGE_EX
)
{
if
(
zipFile
==
null
)
{
entry
=
zipFile
.
getEntry
(
name
+
ex
);
continue
;
if
(
entry
!=
null
)
{
}
inputStream
=
zipFile
.
getInputStream
(
entry
);
for
(
String
ex
:
Constants
.
IMAGE_EX
)
{
outputStream
=
new
ByteArrayOutputStream
();
if
(
bindInZip
(
imageview
,
code
,
pre
,
zipFile
,
name
+
ex
,
size
))
{
IOUtils
.
copy
(
inputStream
,
outputStream
);
return
;
bind
(
outputStream
.
toByteArray
(),
imageview
,
Constants
.
BPG
.
equals
(
ex
),
code
,
pre
,
isBig
);
bind
=
true
;
break
;
}
}
if
(
bind
)
break
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
IOUtils
.
close
(
inputStream
);
}
}
}
}
}
}
}
}
}
}
if
(!
bind
)
{
//4 http
if
(
Constants
.
NETWORK_IMAGE
&&
NetUtils
.
isWifiConnected
(
imageview
.
getContext
()))
{
if
(
Constants
.
NETWORK_IMAGE
&&
NetUtils
.
isWifiConnected
(
imageview
.
getContext
()))
{
bind
(
String
.
format
(
Constants
.
IMAGE_URL
,
""
+
code
),
imageview
,
code
,
pre
,
isBig
);
bind
(
Uri
.
parse
(
String
.
format
(
Constants
.
IMAGE_URL
,
""
+
code
)),
code
+
".jpg"
,
imageview
,
pre
,
size
);
}
else
{
}
else
{
imageview
.
setImageResource
(
R
.
drawable
.
unknown
);
imageview
.
setImageResource
(
R
.
drawable
.
unknown
);
}
}
private
static
class
BpgResourceDecoder
implements
ResourceDecoder
<
ImageVideoWrapper
,
GifBitmapWrapper
>
{
private
final
String
id
;
private
final
LruBitmapPool
mLruBitmapPool
;
private
BpgResourceDecoder
(
String
id
,
LruBitmapPool
lruBitmapPool
)
{
this
.
id
=
id
;
this
.
mLruBitmapPool
=
lruBitmapPool
;
}
@Override
public
Resource
<
GifBitmapWrapper
>
decode
(
ImageVideoWrapper
source
,
int
width
,
int
height
)
{
Bitmap
bitmap
=
IrrlichtBridge
.
getBpgImage
(
source
.
getStream
(),
Bitmap
.
Config
.
RGB_565
);
if
(
bitmap
==
null
)
{
return
null
;
}
}
BitmapResource
resource
=
new
BitmapResource
(
bitmap
,
mLruBitmapPool
);
return
new
GifBitmapWrapperResource
(
new
GifBitmapWrapper
(
resource
,
null
));
}
@Override
public
String
getId
()
{
return
id
;
}
}
}
}
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/BaseCardsActivity.java
View file @
7a92d476
...
@@ -24,7 +24,6 @@ import com.app.hubert.guide.model.HighLight;
...
@@ -24,7 +24,6 @@ import com.app.hubert.guide.model.HighLight;
import
com.app.hubert.guide.model.HighlightOptions
;
import
com.app.hubert.guide.model.HighlightOptions
;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.Glide
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.List
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.Constants
;
...
@@ -45,7 +44,7 @@ public abstract class BaseCardsActivity extends BaseActivity implements CardLoad
...
@@ -45,7 +44,7 @@ public abstract class BaseCardsActivity extends BaseActivity implements CardLoad
protected
CardListAdapter
mCardListAdapter
;
protected
CardListAdapter
mCardListAdapter
;
protected
CardLoader
mCardLoader
;
protected
CardLoader
mCardLoader
;
protected
boolean
isLoad
=
false
;
protected
boolean
isLoad
=
false
;
pr
ivate
ImageLoader
mImageLoader
;
pr
otected
ImageLoader
mImageLoader
;
protected
StringManager
mStringManager
=
DataManager
.
get
().
getStringManager
();
protected
StringManager
mStringManager
=
DataManager
.
get
().
getStringManager
();
protected
LimitManager
mLimitManager
=
DataManager
.
get
().
getLimitManager
();
protected
LimitManager
mLimitManager
=
DataManager
.
get
().
getLimitManager
();
protected
int
screenWidth
;
protected
int
screenWidth
;
...
@@ -55,7 +54,7 @@ public abstract class BaseCardsActivity extends BaseActivity implements CardLoad
...
@@ -55,7 +54,7 @@ public abstract class BaseCardsActivity extends BaseActivity implements CardLoad
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
=
new
ImageLoader
(
true
);
mDrawerLayout
=
$
(
R
.
id
.
drawer_layout
);
mDrawerLayout
=
$
(
R
.
id
.
drawer_layout
);
screenWidth
=
getResources
().
getDisplayMetrics
().
widthPixels
;
screenWidth
=
getResources
().
getDisplayMetrics
().
widthPixels
;
mListView
=
$
(
R
.
id
.
list_cards
);
mListView
=
$
(
R
.
id
.
list_cards
);
...
@@ -217,14 +216,22 @@ public abstract class BaseCardsActivity extends BaseActivity implements CardLoad
...
@@ -217,14 +216,22 @@ public abstract class BaseCardsActivity extends BaseActivity implements CardLoad
}
}
}
}
@Override
protected
void
onResume
()
{
// mImageLoader.resume();
super
.
onResume
();
}
@Override
protected
void
onPause
()
{
//仅退出的时候才关闭zip
// mImageLoader.pause();
super
.
onPause
();
}
@Override
@Override
protected
void
onDestroy
()
{
protected
void
onDestroy
()
{
ImageLoader
.
onDestory
(
this
);
mImageLoader
.
close
();
try
{
mImageLoader
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
super
.
onDestroy
();
super
.
onDestroy
();
}
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardDetailRandom.java
View file @
7a92d476
...
@@ -16,26 +16,28 @@ import ocgcore.data.Card;
...
@@ -16,26 +16,28 @@ import ocgcore.data.Card;
import
ocgcore.enums.CardType
;
import
ocgcore.enums.CardType
;
import
static
android
.
view
.
View
.
inflate
;
import
static
android
.
view
.
View
.
inflate
;
import
static
android
.
view
.
View
.
resolveSize
;
public
class
CardDetailRandom
{
public
class
CardDetailRandom
{
private
static
View
viewCardDetail
;
private
View
viewCardDetail
;
private
static
ImageView
cardImage
;
private
ImageView
cardImage
;
private
static
TextView
name
;
private
TextView
name
;
private
static
TextView
desc
;
private
TextView
desc
;
private
static
TextView
level
;
private
TextView
level
;
private
static
TextView
type
;
private
TextView
type
;
private
static
TextView
race
;
private
TextView
race
;
private
static
TextView
cardAtk
;
private
TextView
cardAtk
;
private
static
TextView
cardDef
;
private
TextView
cardDef
;
private
static
TextView
attrView
;
private
TextView
attrView
;
private
static
View
monsterlayout
;
private
View
monsterlayout
;
private
static
View
atkdefView
,
textdefView
;
private
View
atkdefView
,
textdefView
;
private
static
ImageLoader
imageLoad
er
;
private
StringManager
mStringManag
er
;
private
static
StringManager
mStringManager
;
private
Context
mContext
;
public
static
void
RandomCardDetail
(
Context
context
,
Card
cardInfo
)
{
private
static
CardDetailRandom
sCardDetailRandom
=
null
;
if
(
cardInfo
==
null
)
return
;
imageLoader
=
ImageLoader
.
get
(
context
);
private
CardDetailRandom
(
Context
context
,
Card
cardInfo
)
{
mContext
=
context
;
viewCardDetail
=
inflate
(
context
,
R
.
layout
.
dialog_cardinfo_small
,
null
);
viewCardDetail
=
inflate
(
context
,
R
.
layout
.
dialog_cardinfo_small
,
null
);
cardImage
=
viewCardDetail
.
findViewById
(
R
.
id
.
card_image_toast
);
cardImage
=
viewCardDetail
.
findViewById
(
R
.
id
.
card_image_toast
);
name
=
viewCardDetail
.
findViewById
(
R
.
id
.
card_name_toast
);
name
=
viewCardDetail
.
findViewById
(
R
.
id
.
card_name_toast
);
...
@@ -51,7 +53,6 @@ public class CardDetailRandom {
...
@@ -51,7 +53,6 @@ public class CardDetailRandom {
desc
=
viewCardDetail
.
findViewById
(
R
.
id
.
text_desc_toast
);
desc
=
viewCardDetail
.
findViewById
(
R
.
id
.
text_desc_toast
);
mStringManager
=
DataManager
.
get
().
getStringManager
();
mStringManager
=
DataManager
.
get
().
getStringManager
();
imageLoader
.
bindImage
(
cardImage
,
cardInfo
.
Code
);
name
.
setText
(
cardInfo
.
Name
);
name
.
setText
(
cardInfo
.
Name
);
type
.
setText
(
CardUtils
.
getAllTypeString
(
cardInfo
,
mStringManager
).
replace
(
"/"
,
"|"
));
type
.
setText
(
CardUtils
.
getAllTypeString
(
cardInfo
,
mStringManager
).
replace
(
"/"
,
"|"
));
attrView
.
setText
(
mStringManager
.
getAttributeString
(
cardInfo
.
Attribute
));
attrView
.
setText
(
mStringManager
.
getAttributeString
(
cardInfo
.
Attribute
));
...
@@ -88,8 +89,24 @@ public class CardDetailRandom {
...
@@ -88,8 +89,24 @@ public class CardDetailRandom {
viewCardDetail
.
setRotationY
(
5
);
viewCardDetail
.
setRotationY
(
5
);
}
}
public
static
void
showRandromCardDetailToast
(
Context
context
)
{
public
static
CardDetailRandom
genRandomCardDetail
(
Context
context
,
ImageLoader
imageLoader
,
Card
cardInfo
)
{
Toast
toast
=
new
Toast
(
context
);
if
(
cardInfo
==
null
)
return
null
;
CardDetailRandom
cardDetailRandom
=
new
CardDetailRandom
(
context
,
cardInfo
);
cardDetailRandom
.
bindCardImage
(
imageLoader
,
cardInfo
.
Alias
!=
0
?
cardInfo
.
Alias
:
cardInfo
.
Code
);
sCardDetailRandom
=
cardDetailRandom
;
return
cardDetailRandom
;
}
public
void
bindCardImage
(
ImageLoader
imageLoader
,
long
code
)
{
imageLoader
.
bindImage
(
cardImage
,
code
,
null
,
true
);
}
public
View
getView
()
{
return
viewCardDetail
;
}
public
void
show
(){
Toast
toast
=
new
Toast
(
mContext
);
toast
.
setView
(
viewCardDetail
);
toast
.
setView
(
viewCardDetail
);
toast
.
setDuration
(
Toast
.
LENGTH_LONG
);
toast
.
setDuration
(
Toast
.
LENGTH_LONG
);
toast
.
setGravity
(
Gravity
.
LEFT
,
0
,
0
);
toast
.
setGravity
(
Gravity
.
LEFT
,
0
,
0
);
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardSearchActivity.java
View file @
7a92d476
...
@@ -27,7 +27,6 @@ import com.app.hubert.guide.model.HighlightOptions;
...
@@ -27,7 +27,6 @@ import com.app.hubert.guide.model.HighlightOptions;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.Glide
;
import
com.ourygo.assistant.util.DuelAssistantManagement
;
import
com.ourygo.assistant.util.DuelAssistantManagement
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.List
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.Constants
;
...
@@ -77,7 +76,7 @@ public class CardSearchActivity extends BaseActivity implements CardLoader.CallB
...
@@ -77,7 +76,7 @@ public class CardSearchActivity extends BaseActivity implements CardLoader.CallB
// setSupportActionBar(toolbar);
// setSupportActionBar(toolbar);
enableBackHome
();
enableBackHome
();
mDrawerlayout
=
$
(
R
.
id
.
drawer_layout
);
mDrawerlayout
=
$
(
R
.
id
.
drawer_layout
);
mImageLoader
=
ImageLoader
.
get
(
this
);
mImageLoader
=
new
ImageLoader
(
true
);
mListView
=
$
(
R
.
id
.
list_cards
);
mListView
=
$
(
R
.
id
.
list_cards
);
mCardListAdapter
=
new
CardListAdapter
(
this
,
mImageLoader
);
mCardListAdapter
=
new
CardListAdapter
(
this
,
mImageLoader
);
mCardListAdapter
.
setItemBg
(
true
);
mCardListAdapter
.
setItemBg
(
true
);
...
@@ -190,12 +189,7 @@ public class CardSearchActivity extends BaseActivity implements CardLoader.CallB
...
@@ -190,12 +189,7 @@ public class CardSearchActivity extends BaseActivity implements CardLoader.CallB
@Override
@Override
protected
void
onDestroy
()
{
protected
void
onDestroy
()
{
ImageLoader
.
onDestory
(
this
);
mImageLoader
.
close
();
try
{
mImageLoader
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
super
.
onDestroy
();
super
.
onDestroy
();
}
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
View file @
7a92d476
...
@@ -47,7 +47,6 @@ import com.ourygo.assistant.base.listener.OnDuelAssistantListener;
...
@@ -47,7 +47,6 @@ import com.ourygo.assistant.base.listener.OnDuelAssistantListener;
import
com.ourygo.assistant.util.DuelAssistantManagement
;
import
com.ourygo.assistant.util.DuelAssistantManagement
;
import
com.ourygo.assistant.util.Util
;
import
com.ourygo.assistant.util.Util
;
import
com.tencent.bugly.beta.Beta
;
import
com.tencent.bugly.beta.Beta
;
import
com.tencent.smtt.export.external.TbsCoreSettings
;
import
com.tencent.smtt.sdk.QbSdk
;
import
com.tencent.smtt.sdk.QbSdk
;
import
com.tubb.smrv.SwipeMenuRecyclerView
;
import
com.tubb.smrv.SwipeMenuRecyclerView
;
...
@@ -58,7 +57,6 @@ import org.greenrobot.eventbus.ThreadMode;
...
@@ -58,7 +57,6 @@ import org.greenrobot.eventbus.ThreadMode;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
cn.garymb.ygodata.YGOGameOptions
;
import
cn.garymb.ygodata.YGOGameOptions
;
...
@@ -71,6 +69,7 @@ import cn.garymb.ygomobile.bean.ServerList;
...
@@ -71,6 +69,7 @@ import cn.garymb.ygomobile.bean.ServerList;
import
cn.garymb.ygomobile.bean.events.ServerInfoEvent
;
import
cn.garymb.ygomobile.bean.events.ServerInfoEvent
;
import
cn.garymb.ygomobile.lite.BuildConfig
;
import
cn.garymb.ygomobile.lite.BuildConfig
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
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.activities.FileLogActivity
;
import
cn.garymb.ygomobile.ui.activities.FileLogActivity
;
import
cn.garymb.ygomobile.ui.activities.WebActivity
;
import
cn.garymb.ygomobile.ui.activities.WebActivity
;
...
@@ -108,13 +107,15 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
...
@@ -108,13 +107,15 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
private
ServerListManager
mServerListManager
;
private
ServerListManager
mServerListManager
;
private
DuelAssistantManagement
duelAssistantManagement
;
private
DuelAssistantManagement
duelAssistantManagement
;
private
CardManager
mCardManager
;
private
CardManager
mCardManager
;
private
SparseArray
<
Card
>
cards
;
private
CardDetailRandom
mCardDetailRandom
;
private
ImageLoader
mImageLoader
;
@Override
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_home
);
setContentView
(
R
.
layout
.
activity_home
);
setExitAnimEnable
(
false
);
setExitAnimEnable
(
false
);
mImageLoader
=
new
ImageLoader
(
false
);
mCardManager
=
DataManager
.
get
().
getCardManager
();
mCardManager
=
DataManager
.
get
().
getCardManager
();
//server list
//server list
initServerlist
();
initServerlist
();
...
@@ -158,10 +159,17 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
...
@@ -158,10 +159,17 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
@Override
@Override
protected
void
onResume
()
{
protected
void
onResume
()
{
mImageLoader
.
resume
();
super
.
onResume
();
super
.
onResume
();
BacktoDuel
();
BacktoDuel
();
}
}
@Override
protected
void
onPause
()
{
mImageLoader
.
pause
();
super
.
onPause
();
}
private
void
duelAssistantCheck
()
{
private
void
duelAssistantCheck
()
{
if
(
AppsSettings
.
get
().
isServiceDuelAssistant
())
{
if
(
AppsSettings
.
get
().
isServiceDuelAssistant
())
{
Handler
handler
=
new
Handler
();
Handler
handler
=
new
Handler
();
...
@@ -304,7 +312,9 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
...
@@ -304,7 +312,9 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
break
;
break
;
case
R
.
id
.
action_game
:
case
R
.
id
.
action_game
:
setRandomCardDetail
();
setRandomCardDetail
();
CardDetailRandom
.
showRandromCardDetailToast
(
this
);
if
(
mCardDetailRandom
!=
null
){
mCardDetailRandom
.
show
();
}
openGame
();
openGame
();
break
;
break
;
case
R
.
id
.
action_settings
:
{
case
R
.
id
.
action_settings
:
{
...
@@ -665,12 +675,12 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
...
@@ -665,12 +675,12 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
//加载数据库中所有卡片卡片
//加载数据库中所有卡片卡片
mCardManager
.
loadCards
();
mCardManager
.
loadCards
();
//mCardManager = DataManager.get().getCardManager();
//mCardManager = DataManager.get().getCardManager();
cards
=
mCardManager
.
getAllCards
();
SparseArray
<
Card
>
cards
=
mCardManager
.
getAllCards
();
int
y
=
(
int
)
(
Math
.
random
()
*
cards
.
size
());
int
y
=
(
int
)
(
Math
.
random
()
*
cards
.
size
());
Card
cardInfo
=
cards
.
valueAt
(
y
);
Card
cardInfo
=
cards
.
valueAt
(
y
);
if
(
cardInfo
==
null
)
if
(
cardInfo
==
null
)
return
;
return
;
CardDetailRandom
.
RandomCardDetail
(
this
,
cardInfo
);
mCardDetailRandom
=
CardDetailRandom
.
genRandomCardDetail
(
this
,
mImageLoader
,
cardInfo
);
}
}
public
void
showTipsToast
()
{
public
void
showTipsToast
()
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/widget/CardGroupView.java
View file @
7a92d476
...
@@ -13,7 +13,9 @@ import androidx.annotation.Nullable;
...
@@ -13,7 +13,9 @@ import androidx.annotation.Nullable;
import
java.util.List
;
import
java.util.List
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.loader.ImageLoader
;
import
cn.garymb.ygomobile.ui.cards.deck.ImageTop
;
import
cn.garymb.ygomobile.ui.cards.deck.ImageTop
;
import
ocgcore.data.Card
;
import
ocgcore.data.Card
;
import
ocgcore.data.LimitList
;
import
ocgcore.data.LimitList
;
...
@@ -23,8 +25,13 @@ public class CardGroupView extends FrameLayout {
...
@@ -23,8 +25,13 @@ public class CardGroupView extends FrameLayout {
private
int
mLineLimit
=
10
;
private
int
mLineLimit
=
10
;
private
int
mOrgLineLimit
=
10
;
private
int
mOrgLineLimit
=
10
;
private
int
mLineMaxCount
=
15
;
private
int
mLineMaxCount
=
15
;
private
int
mCardWidth
=
177
,
mCardHeight
=
255
;
private
int
mCardWidth
=
Constants
.
CORE_SKIN_CARD_MINI_SIZE
[
0
],
mCardHeight
=
Constants
.
CORE_SKIN_CARD_MINI_SIZE
[
1
]
;
private
boolean
mPausePadding
;
private
boolean
mPausePadding
;
private
ImageLoader
mImageLoader
;
public
void
setImageLoader
(
ImageLoader
imageLoader
)
{
mImageLoader
=
imageLoader
;
}
//region init
//region init
public
CardGroupView
(
@NonNull
Context
context
)
{
public
CardGroupView
(
@NonNull
Context
context
)
{
...
@@ -219,7 +226,7 @@ public class CardGroupView extends FrameLayout {
...
@@ -219,7 +226,7 @@ public class CardGroupView extends FrameLayout {
refreshLayoutParams
(
count
+
1
);
refreshLayoutParams
(
count
+
1
);
}
}
CardView
cardView
=
new
CardView
(
getContext
());
CardView
cardView
=
new
CardView
(
getContext
());
cardView
.
showCard
(
card
);
cardView
.
showCard
(
mImageLoader
,
card
);
addView
(
cardView
,
index
);
addView
(
cardView
,
index
);
return
true
;
return
true
;
}
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/widget/CardView.java
View file @
7a92d476
...
@@ -91,11 +91,11 @@ public class CardView extends FrameLayout {
...
@@ -91,11 +91,11 @@ public class CardView extends FrameLayout {
}
}
}
}
public
void
showCard
(
Card
cardInfo
)
{
public
void
showCard
(
ImageLoader
imageLoader
,
Card
cardInfo
)
{
if
(
mCard
!=
null
&&
mCard
.
equals
(
cardInfo
))
return
;
if
(
mCard
!=
null
&&
mCard
.
equals
(
cardInfo
))
return
;
mCard
=
cardInfo
;
mCard
=
cardInfo
;
if
(
cardInfo
!=
null
)
{
if
(
cardInfo
!=
null
&&
imageLoader
!=
null
)
{
ImageLoader
.
get
(
getContext
()).
bindImage
(
mCardView
,
cardInfo
.
Cod
e
);
imageLoader
.
bindImage
(
mCardView
,
cardInfo
.
Code
,
null
,
tru
e
);
}
else
{
}
else
{
mTopImage
.
setVisibility
(
View
.
GONE
);
mTopImage
.
setVisibility
(
View
.
GONE
);
mCardView
.
setImageBitmap
(
null
);
mCardView
.
setImageBitmap
(
null
);
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/widget/DeckGroupView.java
View file @
7a92d476
...
@@ -20,6 +20,7 @@ import java.util.Map;
...
@@ -20,6 +20,7 @@ import java.util.Map;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.bean.DeckInfo
;
import
cn.garymb.ygomobile.bean.DeckInfo
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.loader.ImageLoader
;
import
cn.garymb.ygomobile.ui.cards.deck.ImageTop
;
import
cn.garymb.ygomobile.ui.cards.deck.ImageTop
;
import
cn.garymb.ygomobile.ui.cards.deck.LabelInfo
;
import
cn.garymb.ygomobile.ui.cards.deck.LabelInfo
;
import
ocgcore.data.Card
;
import
ocgcore.data.Card
;
...
@@ -43,6 +44,11 @@ public class DeckGroupView extends FrameLayout implements View.OnClickListener {
...
@@ -43,6 +44,11 @@ public class DeckGroupView extends FrameLayout implements View.OnClickListener {
private
CardView
mLastView
;
private
CardView
mLastView
;
private
boolean
mAutoSort
;
private
boolean
mAutoSort
;
private
EditMode
mEditMode
;
private
EditMode
mEditMode
;
private
ImageLoader
mImageLoader
;
public
void
setImageLoader
(
ImageLoader
imageLoader
)
{
mImageLoader
=
imageLoader
;
}
public
enum
EditMode
{
public
enum
EditMode
{
None
,
None
,
...
@@ -257,7 +263,7 @@ public class DeckGroupView extends FrameLayout implements View.OnClickListener {
...
@@ -257,7 +263,7 @@ public class DeckGroupView extends FrameLayout implements View.OnClickListener {
cardView
.
setSelected
(
false
);
cardView
.
setSelected
(
false
);
if
(
i
<
mDeckInfo
.
getExtraCount
())
{
if
(
i
<
mDeckInfo
.
getExtraCount
())
{
if
(
i
==
index
&&
count
>
0
)
{
if
(
i
==
index
&&
count
>
0
)
{
cardView
.
showCard
(
mDeckInfo
.
getExtraCard
(
i
));
cardView
.
showCard
(
m
ImageLoader
,
m
DeckInfo
.
getExtraCard
(
i
));
index
++;
index
++;
count
--;
count
--;
}
}
...
@@ -265,7 +271,7 @@ public class DeckGroupView extends FrameLayout implements View.OnClickListener {
...
@@ -265,7 +271,7 @@ public class DeckGroupView extends FrameLayout implements View.OnClickListener {
cardView
.
updateLimit
(
getImageTop
(),
mLimitList
);
cardView
.
updateLimit
(
getImageTop
(),
mLimitList
);
}
}
}
else
{
}
else
{
cardView
.
showCard
(
null
);
cardView
.
showCard
(
mImageLoader
,
null
);
}
}
}
}
resizePadding
(
Type
.
Extra
,
mExtraViews
);
resizePadding
(
Type
.
Extra
,
mExtraViews
);
...
@@ -278,11 +284,11 @@ public class DeckGroupView extends FrameLayout implements View.OnClickListener {
...
@@ -278,11 +284,11 @@ public class DeckGroupView extends FrameLayout implements View.OnClickListener {
cardView
.
setSelected
(
false
);
cardView
.
setSelected
(
false
);
orgPos
=
i
%
Constants
.
DECK_WIDTH_MAX_COUNT
;
orgPos
=
i
%
Constants
.
DECK_WIDTH_MAX_COUNT
;
if
(
orgPos
>=
mMainLimit
)
{
if
(
orgPos
>=
mMainLimit
)
{
cardView
.
showCard
(
null
);
cardView
.
showCard
(
mImageLoader
,
null
);
}
else
{
}
else
{
if
(
index
<
mDeckInfo
.
getMainCount
())
{
if
(
index
<
mDeckInfo
.
getMainCount
())
{
if
(
targetIndex
==
i
&&
count
>
0
)
{
if
(
targetIndex
==
i
&&
count
>
0
)
{
cardView
.
showCard
(
mDeckInfo
.
getMainCard
(
index
));
cardView
.
showCard
(
m
ImageLoader
,
m
DeckInfo
.
getMainCard
(
index
));
index
++;
index
++;
targetIndex
=
(
index
/
mMainLimit
)
*
Constants
.
DECK_WIDTH_MAX_COUNT
+
(
index
%
mMainLimit
);
targetIndex
=
(
index
/
mMainLimit
)
*
Constants
.
DECK_WIDTH_MAX_COUNT
+
(
index
%
mMainLimit
);
count
--;
count
--;
...
@@ -295,7 +301,7 @@ public class DeckGroupView extends FrameLayout implements View.OnClickListener {
...
@@ -295,7 +301,7 @@ public class DeckGroupView extends FrameLayout implements View.OnClickListener {
mMainViews
.
get
(
i
).
updateLimit
(
getImageTop
(),
mLimitList
);
mMainViews
.
get
(
i
).
updateLimit
(
getImageTop
(),
mLimitList
);
}
}
}
else
{
}
else
{
cardView
.
showCard
(
null
);
cardView
.
showCard
(
mImageLoader
,
null
);
}
}
}
}
}
}
...
@@ -307,7 +313,7 @@ public class DeckGroupView extends FrameLayout implements View.OnClickListener {
...
@@ -307,7 +313,7 @@ public class DeckGroupView extends FrameLayout implements View.OnClickListener {
cardView
.
setSelected
(
false
);
cardView
.
setSelected
(
false
);
if
(
i
<
mDeckInfo
.
getSideCount
())
{
if
(
i
<
mDeckInfo
.
getSideCount
())
{
if
(
i
==
index
&&
count
>
0
)
{
if
(
i
==
index
&&
count
>
0
)
{
cardView
.
showCard
(
mDeckInfo
.
getSideCard
(
i
));
cardView
.
showCard
(
m
ImageLoader
,
m
DeckInfo
.
getSideCard
(
i
));
index
++;
index
++;
count
--;
count
--;
}
}
...
@@ -315,7 +321,7 @@ public class DeckGroupView extends FrameLayout implements View.OnClickListener {
...
@@ -315,7 +321,7 @@ public class DeckGroupView extends FrameLayout implements View.OnClickListener {
cardView
.
updateLimit
(
getImageTop
(),
mLimitList
);
cardView
.
updateLimit
(
getImageTop
(),
mLimitList
);
}
}
}
else
{
}
else
{
cardView
.
showCard
(
null
);
cardView
.
showCard
(
mImageLoader
,
null
);
}
}
}
}
resizePadding
(
Type
.
Side
,
mSideViews
);
resizePadding
(
Type
.
Side
,
mSideViews
);
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/widget/DeckView.java
View file @
7a92d476
...
@@ -7,6 +7,7 @@ import android.widget.LinearLayout;
...
@@ -7,6 +7,7 @@ import android.widget.LinearLayout;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
import
cn.garymb.ygomobile.bean.DeckInfo
;
import
cn.garymb.ygomobile.bean.DeckInfo
;
import
cn.garymb.ygomobile.loader.ImageLoader
;
import
cn.garymb.ygomobile.ui.cards.deck.ImageTop
;
import
cn.garymb.ygomobile.ui.cards.deck.ImageTop
;
import
cn.garymb.ygomobile.ui.cards.deck.LabelInfo
;
import
cn.garymb.ygomobile.ui.cards.deck.LabelInfo
;
import
ocgcore.data.Card
;
import
ocgcore.data.Card
;
...
@@ -20,6 +21,8 @@ public class DeckView extends LinearLayout {
...
@@ -20,6 +21,8 @@ public class DeckView extends LinearLayout {
private
final
ImageTop
mImageTop
;
private
final
ImageTop
mImageTop
;
private
boolean
mAutoSort
,
mEditMode
,
mLimitChanged
;
private
boolean
mAutoSort
,
mEditMode
,
mLimitChanged
;
private
ImageLoader
mImageLoader
;
//region init
//region init
public
DeckView
(
Context
context
)
{
public
DeckView
(
Context
context
)
{
this
(
context
,
null
);
this
(
context
,
null
);
...
@@ -40,6 +43,7 @@ public class DeckView extends LinearLayout {
...
@@ -40,6 +43,7 @@ public class DeckView extends LinearLayout {
mMainGroup
=
new
CardGroupView
(
context
);
mMainGroup
=
new
CardGroupView
(
context
);
mExtraGroup
=
new
CardGroupView
(
context
);
mExtraGroup
=
new
CardGroupView
(
context
);
mSideGroup
=
new
CardGroupView
(
context
);
mSideGroup
=
new
CardGroupView
(
context
);
int
cardWidth
=
0
;
int
cardWidth
=
0
;
int
cardHeight
=
0
;
int
cardHeight
=
0
;
if
(
cardWidth
<=
0
)
{
if
(
cardWidth
<=
0
)
{
...
@@ -67,6 +71,13 @@ public class DeckView extends LinearLayout {
...
@@ -67,6 +71,13 @@ public class DeckView extends LinearLayout {
addView
(
mSideGroup
,
new
LayoutParams
(
LayoutParams
.
MATCH_PARENT
,
cardHeight
));
addView
(
mSideGroup
,
new
LayoutParams
(
LayoutParams
.
MATCH_PARENT
,
cardHeight
));
}
}
public
void
setImageLoader
(
ImageLoader
imageLoader
)
{
mImageLoader
=
imageLoader
;
mMainGroup
.
setImageLoader
(
imageLoader
);
mExtraGroup
.
setImageLoader
(
imageLoader
);
mSideGroup
.
setImageLoader
(
imageLoader
);
}
public
ImageTop
getImageTop
()
{
public
ImageTop
getImageTop
()
{
return
mImageTop
;
return
mImageTop
;
}
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/FileUtils.java
View file @
7a92d476
...
@@ -27,6 +27,19 @@ import cn.garymb.ygomobile.Constants;
...
@@ -27,6 +27,19 @@ import cn.garymb.ygomobile.Constants;
public
class
FileUtils
{
public
class
FileUtils
{
public
static
boolean
isExist
(
String
path
){
return
path
!=
null
&&
new
File
(
path
).
exists
();
}
public
static
String
getFileExpansion
(
String
path
){
int
index
=
path
.
lastIndexOf
(
"."
);
if
(
index
>
0
){
return
path
.
substring
(
index
+
1
).
toLowerCase
();
}
return
""
;
}
public
static
void
closeQuietly
(
Closeable
closeable
)
{
public
static
void
closeQuietly
(
Closeable
closeable
)
{
if
(
closeable
!=
null
)
{
if
(
closeable
!=
null
)
{
try
{
try
{
...
...
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