Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile-Cn-Ko-En
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-Cn-Ko-En
Commits
34d96ae1
Commit
34d96ae1
authored
Sep 21, 2021
by
kenan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
精准点击事件
parent
f79deedb
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
315 additions
and
53 deletions
+315
-53
gradle.properties
gradle.properties
+1
-1
libcore/android/android_tools.cpp
libcore/android/android_tools.cpp
+9
-1
libcore/src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
.../src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
+94
-21
libcore/src/main/java/cn/garymb/ygomobile/controller/InputQueueCompat.java
...java/cn/garymb/ygomobile/controller/InputQueueCompat.java
+131
-0
libcore/src/main/java/cn/garymb/ygomobile/utils/AndroidHideApi.java
...c/main/java/cn/garymb/ygomobile/utils/AndroidHideApi.java
+38
-0
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
+9
-1
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
+4
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivity.java
...ava/cn/garymb/ygomobile/ui/cards/DeckManagerActivity.java
+29
-29
No files found.
gradle.properties
View file @
34d96ae1
...
...
@@ -11,7 +11,7 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Mon Aug 31 19:03:54 CST 2020
org.gradle.jvmargs
=
-Xmx4096M -Dkotlin.daemon.jvm.options="-Xmx4096M"
-Dfile.encoding=UTF-8
org.gradle.jvmargs
=
-Xmx4096M -Dkotlin.daemon.jvm.options="-Xmx4096M"
org.gradle.parallel
=
true
android.enableJetifier
=
true
android.useAndroidX
=
true
...
...
libcore/android/android_tools.cpp
View file @
34d96ae1
...
...
@@ -868,9 +868,13 @@ void toggleOverlayView(ANDROID_APP app, bool pShow) {
jni
->
DeleteLocalRef
(
ClassNativeActivity
);
app
->
activity
->
vm
->
DetachCurrentThread
();
}
static
bool
test
=
false
;
void
process_input
(
ANDROID_APP
app
,
struct
android_poll_source
*
source
)
{
if
(
test
==
false
)
{
test
=
true
;
ALOGD
(
"inputQueue:%lld"
,
(
jlong
)
app
->
inputQueue
);
}
AInputEvent
*
event
=
NULL
;
if
(
AInputQueue_getEvent
(
app
->
inputQueue
,
&
event
)
>=
0
)
{
int
type
=
AInputEvent_getType
(
event
);
...
...
@@ -908,6 +912,10 @@ void onGameExit(ANDROID_APP app){
}
s32
handleInput
(
ANDROID_APP
app
,
AInputEvent
*
androidEvent
)
{
if
(
test
==
false
)
{
test
=
true
;
ALOGD
(
"inputQueue:%lld"
,
(
jlong
)
app
->
inputQueue
);
}
IrrlichtDevice
*
device
=
(
IrrlichtDevice
*
)
app
->
userData
;
s32
Status
=
0
;
...
...
libcore/src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
View file @
34d96ae1
...
...
@@ -6,6 +6,7 @@
*/
package
cn.garymb.ygomobile
;
import
android.annotation.SuppressLint
;
import
android.app.NativeActivity
;
import
android.content.Context
;
import
android.content.Intent
;
...
...
@@ -19,7 +20,9 @@ import android.os.Process;
import
android.util.Log
;
import
android.view.Gravity
;
import
android.view.HapticFeedbackConstants
;
import
android.view.InputQueue
;
import
android.view.KeyEvent
;
import
android.view.MotionEvent
;
import
android.view.SurfaceHolder
;
import
android.view.SurfaceView
;
import
android.view.View
;
...
...
@@ -32,6 +35,7 @@ import java.nio.ByteBuffer;
import
java.util.Arrays
;
import
cn.garymb.ygodata.YGOGameOptions
;
import
cn.garymb.ygomobile.controller.InputQueueCompat
;
import
cn.garymb.ygomobile.controller.NetworkController
;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
import
cn.garymb.ygomobile.lib.R
;
...
...
@@ -59,13 +63,11 @@ public class YGOMobileActivity extends NativeActivity implements
private
static
final
int
CHAIN_CONTROL_PANEL_Y_REVERT_POSITION
=
100
;
private
static
final
int
MAX_REFRESH
=
30
*
1000
;
protected
final
int
windowsFlags
=
Build
.
VERSION
.
SDK_INT
>=
19
?
(
View
.
SYSTEM_UI_FLAG_LAYOUT_STABLE
|
View
.
SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
View
.
SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
View
.
SYSTEM_UI_FLAG_FULLSCREEN
|
View
.
SYSTEM_UI_FLAG_IMMERSIVE_STICKY
)
:
View
.
SYSTEM_UI_FLAG_LOW_PROFILE
;
View
.
SYSTEM_UI_FLAG_LAYOUT_STABLE
|
View
.
SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
View
.
SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
View
.
SYSTEM_UI_FLAG_FULLSCREEN
|
View
.
SYSTEM_UI_FLAG_IMMERSIVE_STICKY
;
protected
View
mContentView
;
protected
ComboBoxCompat
mGlobalComboBox
;
protected
EditWindowCompat
mGlobalEditText
;
...
...
@@ -87,6 +89,9 @@ public class YGOMobileActivity extends NativeActivity implements
private
static
boolean
USE_SURFACE
=
true
;
private
String
[]
mArgV
;
private
boolean
onGameExiting
;
//尝试调准触摸事件
private
static
final
boolean
USE_MY_INPUT
=
true
;
private
InputQueueCompat
inputQueueCompat
;
// public static int notchHeight;
...
...
@@ -111,6 +116,12 @@ public class YGOMobileActivity extends NativeActivity implements
if
(
USE_SURFACE
)
{
mSurfaceView
=
new
SurfaceView
(
this
);
}
if
(
USE_MY_INPUT
)
{
inputQueueCompat
=
new
InputQueueCompat
();
if
(!
inputQueueCompat
.
isValid
())
{
inputQueueCompat
=
null
;
}
}
mFullScreenUtils
=
new
FullScreenUtils
(
this
,
app
().
isImmerSiveMode
());
mFullScreenUtils
.
fullscreen
();
mFullScreenUtils
.
onCreate
();
...
...
@@ -245,6 +256,7 @@ public class YGOMobileActivity extends NativeActivity implements
}
}
@SuppressLint
(
"ClickableViewAccessibility"
)
@Override
public
void
setContentView
(
View
view
)
{
int
[]
size
=
getGameSize
();
...
...
@@ -260,10 +272,22 @@ public class YGOMobileActivity extends NativeActivity implements
app
().
attachGame
(
this
);
changeGameSize
();
getWindow
().
takeSurface
(
null
);
if
(
USE_MY_INPUT
&&
inputQueueCompat
!=
null
)
{
getWindow
().
takeInputQueue
(
null
);
}
replaced
=
true
;
mSurfaceView
.
getHolder
().
addCallback
(
this
);
mSurfaceView
.
requestFocus
();
getWindow
().
setGravity
(
Gravity
.
CENTER
);
if
(
USE_MY_INPUT
&&
inputQueueCompat
!=
null
)
{
Log
.
e
(
IrrlichtBridge
.
TAG
,
"use java input queue:"
+
inputQueueCompat
.
getNativePtr
());
mSurfaceView
.
setOnTouchListener
((
v
,
event
)
->
{
if
(
inputQueueCompat
!=
null
)
{
inputQueueCompat
.
sendInputEvent
(
event
,
v
,
true
);
}
return
true
;
});
}
}
else
{
mLayout
.
addView
(
view
,
lp
);
getWindow
().
setGravity
(
Gravity
.
CENTER
);
...
...
@@ -272,18 +296,25 @@ public class YGOMobileActivity extends NativeActivity implements
}
private
void
changeGameSize
()
{
//游戏大小
int
[]
size
=
getGameSize
();
int
w
=
(
int
)
app
().
getScreenHeight
();
int
h
=
(
int
)
app
().
getScreenWidth
();
int
spX
=
(
int
)
((
w
-
size
[
0
])
/
2.0f
);
int
spY
=
(
int
)
((
h
-
size
[
1
])
/
2.0f
);
boolean
update
=
false
;
synchronized
(
this
)
{
if
(
spX
!=
mPositionX
||
spY
!=
mPositionY
)
{
mPositionX
=
spX
;
mPositionY
=
spY
;
update
=
true
;
if
(
USE_MY_INPUT
&&
inputQueueCompat
!=
null
)
{
//Ignore
update
=
true
;
mPositionX
=
0
;
mPositionY
=
0
;
}
else
{
//游戏大小
int
[]
size
=
getGameSize
();
int
w
=
(
int
)
app
().
getScreenHeight
();
int
h
=
(
int
)
app
().
getScreenWidth
();
int
spX
=
(
int
)
((
w
-
size
[
0
])
/
2.0f
);
int
spY
=
(
int
)
((
h
-
size
[
1
])
/
2.0f
);
synchronized
(
this
)
{
if
(
spX
!=
mPositionX
||
spY
!=
mPositionY
)
{
mPositionX
=
spX
;
mPositionY
=
spY
;
update
=
true
;
}
}
}
if
(
update
)
{
...
...
@@ -310,9 +341,15 @@ public class YGOMobileActivity extends NativeActivity implements
// Log.e("YGOMobileActivity","窗口变化"+hasFocus);
if
(
hasFocus
)
{
fullscreen
();
if
(
inputQueueCompat
!=
null
)
{
super
.
onInputQueueCreated
(
inputQueueCompat
.
getInputQueue
());
}
mContentView
.
setHapticFeedbackEnabled
(
true
);
}
else
{
mContentView
.
setHapticFeedbackEnabled
(
false
);
if
(
inputQueueCompat
!=
null
)
{
super
.
onInputQueueDestroyed
(
inputQueueCompat
.
getInputQueue
());
}
}
super
.
onWindowFocusChanged
(
hasFocus
);
}
...
...
@@ -531,15 +568,51 @@ public class YGOMobileActivity extends NativeActivity implements
}
});
}
//
// @Override
// public boolean onKeyDown(int keyCode, KeyEvent event) {
// if(inputQueueCompat != null) {
// if (keyCode == KeyEvent.KEYCODE_BACK) {
// inputQueueCompat.sendInputEvent(event, this, true);
// return true;
// }
// }
// return super.onKeyDown(keyCode, event);
// }
//
// @Override
// public boolean onKeyUp(int keyCode, KeyEvent event) {
// if(inputQueueCompat != null) {
// if (keyCode == KeyEvent.KEYCODE_BACK) {
// inputQueueCompat.sendInputEvent(event, this, true);
// return true;
// }
// }
// return super.onKeyUp(keyCode, event);
// }
@Override
public
void
onBackPressed
()
{
if
(
mGlobalComboBox
!=
null
&&
mGlobalComboBox
.
isShowing
()){
mGlobalComboBox
.
dismiss
();
return
;
}
if
(
mGlobalEditText
!=
null
&&
mGlobalEditText
.
isShowing
()){
mGlobalEditText
.
dismiss
();
return
;
}
super
.
onBackPressed
();
}
@Override
public
void
onGameExit
()
{
if
(
onGameExiting
)
{
if
(
onGameExiting
)
{
return
;
}
onGameExiting
=
true
;
Log
.
e
(
IrrlichtBridge
.
TAG
,
"game exit"
);
final
Intent
intent
=
new
Intent
(
IrrlichtBridge
.
ACTION_OPEN_GAME_HOME
);
final
Intent
intent
=
new
Intent
(
IrrlichtBridge
.
ACTION_OPEN_GAME_HOME
);
intent
.
addCategory
(
Intent
.
CATEGORY_DEFAULT
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
);
...
...
@@ -558,7 +631,7 @@ public class YGOMobileActivity extends NativeActivity implements
}
boolean
isRoot
=
isTaskRoot
();
Log
.
d
(
IrrlichtBridge
.
TAG
,
"isRoot="
+
isRoot
+
",kill:"
+
Process
.
myPid
());
if
(
isRoot
)
{
if
(
isRoot
)
{
finishAndRemoveTask
();
}
else
{
finish
();
...
...
libcore/src/main/java/cn/garymb/ygomobile/controller/InputQueueCompat.java
0 → 100644
View file @
34d96ae1
package
cn.garymb.ygomobile.controller
;
import
android.os.Looper
;
import
android.util.Log
;
import
android.view.InputEvent
;
import
android.view.InputQueue
;
import
java.lang.reflect.Constructor
;
import
java.lang.reflect.InvocationHandler
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Proxy
;
import
cn.garymb.ygomobile.utils.AndroidHideApi
;
public
class
InputQueueCompat
implements
InvocationHandler
{
private
static
final
String
TAG
=
"kk-java"
;
private
static
Constructor
<
InputQueue
>
InputQueue_ctr
;
private
static
Method
getNativePtr_method
;
private
static
Class
<?>
FinishedInputEventCallback_class
;
//sendInputEvent(InputEvent e, Object token, boolean predispatch,
// FinishedInputEventCallback callback)
private
static
Method
sendInputEvent_method
;
private
FinishedInputEventCallbackCompat
finishedInputEventCallbackCompat
;
static
{
AndroidHideApi
.
enableHideApi
();
try
{
Looper
.
getMainLooper
();
InputQueue_ctr
=
InputQueue
.
class
.
getDeclaredConstructor
();
// InputQueue_ctr.setAccessible(true);
getNativePtr_method
=
InputQueue
.
class
.
getMethod
(
"getNativePtr"
);
// getNativePtr_method.setAccessible(true);
FinishedInputEventCallback_class
=
Class
.
forName
(
InputQueue
.
class
.
getName
()
+
"$FinishedInputEventCallback"
);
sendInputEvent_method
=
InputQueue
.
class
.
getMethod
(
"sendInputEvent"
,
InputEvent
.
class
,
Object
.
class
,
boolean
.
class
,
FinishedInputEventCallback_class
);
}
catch
(
Throwable
e
)
{
Log
.
e
(
TAG
,
"InputQueueCompat init"
,
e
);
}
}
private
final
InputQueue
inputQueue
;
private
final
Object
callback
;
public
InputQueueCompat
(
InputQueue
inputQueue
)
{
this
.
inputQueue
=
inputQueue
;
if
(
inputQueue
!=
null
)
{
callback
=
Proxy
.
newProxyInstance
(
InputQueue
.
class
.
getClassLoader
(),
new
Class
[]{
FinishedInputEventCallback_class
},
this
);
}
else
{
callback
=
null
;
}
}
@Override
public
Object
invoke
(
Object
proxy
,
Method
method
,
Object
[]
args
)
{
//void onFinishedInputEvent(Object token, boolean handled);
if
(
"onFinishedInputEvent"
.
equals
(
method
.
getName
()))
{
Object
token
=
args
[
0
];
boolean
handled
=
(
boolean
)
args
[
1
];
onFinishedInputEvent
(
token
,
handled
);
return
0
;
}
return
0
;
}
public
InputQueueCompat
()
{
this
(
create
());
}
public
void
setFinishedInputEventCallback
(
FinishedInputEventCallbackCompat
finishedInputEventCallbackCompat
)
{
this
.
finishedInputEventCallbackCompat
=
finishedInputEventCallbackCompat
;
}
public
boolean
isValid
()
{
return
inputQueue
!=
null
&&
sendInputEvent_method
!=
null
&&
getNativePtr_method
!=
null
;
}
private
static
InputQueue
create
()
{
try
{
return
InputQueue_ctr
.
newInstance
();
}
catch
(
Throwable
e
)
{
Log
.
w
(
TAG
,
"InputQueue<init>"
,
e
);
return
null
;
}
}
public
long
getNativePtr
()
{
if
(
getNativePtr_method
==
null
||
inputQueue
==
null
)
{
return
0
;
}
try
{
Long
ret
=
(
Long
)
getNativePtr_method
.
invoke
(
inputQueue
);
if
(
ret
==
null
)
{
return
0
;
}
return
ret
;
}
catch
(
Throwable
e
)
{
Log
.
w
(
TAG
,
"getNativePtr"
,
e
);
return
0
;
}
}
public
InputQueue
getInputQueue
()
{
return
inputQueue
;
}
public
void
sendInputEvent
(
InputEvent
e
,
Object
token
,
boolean
predispatch
)
{
if
(
sendInputEvent_method
==
null
)
{
return
;
}
try
{
Log
.
d
(
TAG
,
"inputQueue:sendInputEvent:"
+
e
);
sendInputEvent_method
.
invoke
(
inputQueue
,
e
,
token
,
predispatch
,
callback
);
}
catch
(
Throwable
ex
)
{
Log
.
w
(
TAG
,
"inputQueue:sendInputEvent"
,
ex
);
}
}
public
void
onFinishedInputEvent
(
Object
token
,
boolean
handled
)
{
//TODO
Log
.
d
(
TAG
,
"onFinishedInputEvent:"
+
token
+
", handled="
+
handled
);
if
(
this
.
finishedInputEventCallbackCompat
!=
null
){
finishedInputEventCallbackCompat
.
onFinishedInputEvent
(
token
,
handled
);
}
}
public
interface
FinishedInputEventCallbackCompat
{
void
onFinishedInputEvent
(
Object
token
,
boolean
handled
);
}
}
libcore/src/main/java/cn/garymb/ygomobile/utils/AndroidHideApi.java
0 → 100644
View file @
34d96ae1
package
cn.garymb.ygomobile.utils
;
import
android.os.Build
;
import
java.lang.reflect.Method
;
public
class
AndroidHideApi
{
private
static
boolean
sBypassedP
=
false
;
public
static
void
enableHideApi
()
{
if
(
sBypassedP
)
{
return
;
}
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
P
)
{
try
{
Method
forNameMethod
=
Class
.
class
.
getDeclaredMethod
(
"forName"
,
String
.
class
);
Class
<?>
clazz
=
(
Class
<?>)
forNameMethod
.
invoke
(
null
,
"dalvik.system.VMRuntime"
);
Method
getMethodMethod
=
Class
.
class
.
getDeclaredMethod
(
"getDeclaredMethod"
,
String
.
class
,
Class
[].
class
);
Method
getRuntime
=
(
Method
)
getMethodMethod
.
invoke
(
clazz
,
"getRuntime"
,
new
Class
[
0
]);
Method
setHiddenApiExemptions
=
(
Method
)
getMethodMethod
.
invoke
(
clazz
,
"setHiddenApiExemptions"
,
new
Class
[]{
String
[].
class
});
Object
runtime
=
getRuntime
.
invoke
(
null
);
setHiddenApiExemptions
.
invoke
(
runtime
,
new
Object
[]{
new
String
[]{
"Landroid/"
,
"Lcom/android/"
,
"Ljava/lang/"
,
"Ldalvik/system/"
,
"Llibcore/io/"
,
"Lhuawei/"
}
});
}
catch
(
Throwable
e
)
{
e
.
printStackTrace
();
}
}
sBypassedP
=
true
;
}
}
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
View file @
34d96ae1
...
...
@@ -18,6 +18,7 @@ import java.util.Arrays;
import
java.util.List
;
import
java.util.Locale
;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.preference.PreferenceFragmentPlus
;
import
cn.garymb.ygomobile.utils.DeckUtil
;
...
...
@@ -33,6 +34,7 @@ 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_ONLY_GAME
;
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_SENSOR_REFRESH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_FONT_SIZE
;
...
...
@@ -43,6 +45,7 @@ import static cn.garymb.ygomobile.Constants.PREF_NOTCH_HEIGHT;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_ONLY_GAME
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_READ_EX
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_SENSOR_REFRESH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_WINDOW_TOP_BOTTOM
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
WINDBOT_DECK_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
WINDBOT_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
YDK_FILE_EX
;
...
...
@@ -134,6 +137,7 @@ public class AppsSettings {
}
public
float
getXScale
(
int
w
,
int
h
)
{
//曲面屏
if
(
isKeepScale
())
{
float
sx
=
getScreenHeight
()
/
w
;
float
sy
=
getScreenWidth
()
/
h
;
...
...
@@ -165,7 +169,11 @@ public class AppsSettings {
w
=
mScreenSize
.
x
;
h
=
mScreenSize
.
y
;
}
return
Math
.
min
(
w
,
h
);
int
ret
=
Math
.
min
(
w
,
h
);
//测试代码,曲面屏左右2变需要留空白,但是游戏画面比例不对,需要修改c那边代码
int
fix_h
=
mSharedPreferences
.
getInt
(
PREF_WINDOW_TOP_BOTTOM
,
DEF_PREF_WINDOW_TOP_BOTTOM
);
Log
.
i
(
IrrlichtBridge
.
TAG
,
"get width="
+
ret
+
"->"
+
(
ret
-
fix_h
*
2
));
return
ret
-
fix_h
*
2
;
}
public
float
getScreenHeight
()
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
View file @
34d96ae1
...
...
@@ -117,6 +117,10 @@ public interface Constants {
String
PREF_KEEP_SCALE
=
"pref_settings_keep_scale"
;
boolean
DEF_PREF_KEEP_SCALE
=
false
;
//dp单位,游戏高度减少,留空白
String
PREF_WINDOW_TOP_BOTTOM
=
"pref_settings_window_top_bottom"
;
int
DEF_PREF_WINDOW_TOP_BOTTOM
=
50
;
int
REQUEST_CUT_IMG
=
0x1000
+
0x10
;
int
REQUEST_CHOOSE_FILE
=
0x1000
+
0x20
;
int
REQUEST_CHOOSE_IMG
=
0x1000
+
0x21
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivity.java
View file @
34d96ae1
...
...
@@ -157,9 +157,9 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
$
(
R
.
id
.
btn_nav_list
).
setOnClickListener
((
v
)
->
doMenu
(
R
.
id
.
action_card_list
));
//
final
File
_file
;
//
打开指定卡组
//
打开指定卡组
if
(!
TextUtils
.
isEmpty
(
preLoadFile
)
&&
(
mPreLoadFile
=
new
File
(
preLoadFile
)).
exists
())
{
//
外面卡组
//
外面卡组
_file
=
mPreLoadFile
;
}
else
{
mPreLoadFile
=
null
;
...
...
@@ -167,7 +167,7 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
if
(
TextUtils
.
isEmpty
(
path
)){
_file
=
null
;
}
else
{
//
最后卡组
//
最后卡组
_file
=
new
File
(
path
);
}
}
...
...
@@ -260,13 +260,13 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
DialogPlus
dlg
=
DialogPlus
.
show
(
this
,
null
,
getString
(
R
.
string
.
loading
));
VUiKit
.
defer
().
when
(()
->
{
DataManager
.
get
().
load
(
true
);
//
默认第一个卡表
//
默认第一个卡表
if
(
mLimitManager
.
getCount
()
>
0
)
{
mCardLoader
.
setLimitList
(
mLimitManager
.
getTopLimit
());
}
File
file
=
ydk
;
if
(
file
==
null
||
!
file
.
exists
())
{
//
当默认卡组不存在的时候
//
当默认卡组不存在的时候
List
<
File
>
files
=
getYdkFiles
();
if
(
files
!=
null
&&
files
.
size
()
>
0
)
{
file
=
files
.
get
(
0
);
...
...
@@ -288,15 +288,15 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
mCardSelector
.
initItems
();
initLimitListSpinners
(
mLimitSpinner
,
mCardLoader
.
getLimitList
());
initDecksListSpinners
(
mDeckSpinner
,
rs
.
source
);
//
设置当前卡组
//
设置当前卡组
setCurDeck
(
rs
);
//
设置收藏夹
//
设置收藏夹
mCardSelector
.
showFavorites
(
false
);
});
}
/**
*
设置当前卡组
*
设置当前卡组
*/
private
void
setCurDeck
(
DeckInfo
deckInfo
)
{
if
(
deckInfo
==
null
)
{
...
...
@@ -307,7 +307,7 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
String
name
=
IOUtils
.
tirmName
(
file
.
getName
(),
Constants
.
YDK_FILE_EX
);
setActionBarSubTitle
(
name
);
// if (inDeckDir(file)) {
//
记住最后打开的卡组
//
记住最后打开的卡组
mSettings
.
setLastDeckPath
(
file
.
getAbsolutePath
());
tv_deck
.
setText
(
name
);
...
...
@@ -383,7 +383,7 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
@Override
public
void
onItemDoubleClick
(
View
view
,
int
pos
)
{
//
拖拽中,就不显示
//
拖拽中,就不显示
if
(
isShowDrawer
())
{
return
;
}
...
...
@@ -627,7 +627,7 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
// mDeckAdapater.notifyDataSetChanged();
// break;
case
R
.
id
.
action_search
:
//
弹条件对话框
//
弹条件对话框
showSearch
(
true
);
break
;
case
R
.
id
.
action_card_list
:
...
...
@@ -642,7 +642,7 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
break
;
case
R
.
id
.
action_save
:
if
(
mPreLoadFile
!=
null
&&
mPreLoadFile
==
mDeckAdapater
.
getYdkFile
())
{
//
需要保存到deck文件夹
//
需要保存到deck文件夹
inputDeckName
(
mPreLoadFile
,
null
,
true
);
}
else
{
if
(
mDeckAdapater
.
getYdkFile
()
==
null
)
{
...
...
@@ -709,7 +709,7 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
}
break
;
case
R
.
id
.
action_unsort
:
//
打乱
//
打乱
mDeckAdapater
.
unSort
();
break
;
case
R
.
id
.
action_sort
:
...
...
@@ -729,7 +729,7 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
builder
.
setMessageGravity
(
Gravity
.
CENTER_HORIZONTAL
);
builder
.
setLeftButtonListener
((
dlg
,
rs
)
->
{
dlg
.
dismiss
();
//
复制当前卡组
//
复制当前卡组
inputDeckName
(
old
,
savePath
,
true
);
});
builder
.
setRightButtonListener
((
dlg
,
rs
)
->
{
...
...
@@ -757,11 +757,11 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
builderShareLoading
.
setMessage
(
R
.
string
.
Pre_share
);
builderShareLoading
.
show
();
//
先排序
//
先排序
// mDeckAdapater.sort();
//
保存
//
保存
// if (mPreLoadFile != null && mPreLoadFile == mDeckAdapater.getYdkFile()) {
// //
需要保存到deck文件夹
// //
需要保存到deck文件夹
// inputDeckName(mPreLoadFile, null, true);
// } else {
// if (mDeckAdapater.getYdkFile() == null) {
...
...
@@ -770,27 +770,27 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
// save(mDeckAdapater.getYdkFile());
// }
// }
// //
保存成功后重新加载卡组
// //
保存成功后重新加载卡组
// File file = getSelectDeck(mDeckSpinner);
// if (file != null) {
// loadDeckFromFile(file);
// }
//
延时半秒,使整体看起来更流畅
//
延时半秒,使整体看起来更流畅
new
Handler
().
postDelayed
(
this
::
shareDeck1
,
500
);
}
private
void
shareDeck1
()
{
//
开启绘图缓存
//
开启绘图缓存
mRecyclerView
.
setDrawingCacheEnabled
(
true
);
//
这个方法可调可不调,因为在getDrawingCache()里会自动判断有没有缓存有没有准备好,
//
如果没有,会自动调用
buildDrawingCache()
//
这个方法可调可不调,因为在getDrawingCache()里会自动判断有没有缓存有没有准备好,
//
如果没有,会自动调用build
DrawingCache()
mRecyclerView
.
buildDrawingCache
();
//
获取绘图缓存 这里直接创建了一个新的b
itmap
//
因为我们在最后需要释放缓存资源,会释放掉缓存中创建的bitmap对象
//
获取绘图缓存 这里直接创建了一个新的bitmap
//
因为我们在最后需要释放缓存资源,会释放掉缓存中创建的bitmap对象
Bitmap
bitmap
=
BitmapUtil
.
drawBg4Bitmap
(
Color
.
parseColor
(
"#e6f3fd"
),
Bitmap
.
createBitmap
(
mRecyclerView
.
getDrawingCache
(),
0
,
0
,
mRecyclerView
.
getMeasuredWidth
(),
mRecyclerView
.
getMeasuredHeight
()));
//
清理绘图缓存,释放资源
//
清理绘图缓存,释放资源
mRecyclerView
.
destroyDrawingCache
();
// shotRecyclerView(mRecyclerView)
...
...
@@ -817,7 +817,7 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
stopService
(
new
Intent
(
this
,
DuelAssistantService
.
class
));
YGOUtil
.
copyMessage
(
this
,
et_code
.
getText
().
toString
().
trim
());
showToast
(
getString
(
R
.
string
.
deck_text_copyed
));
//
复制完毕开启决斗助手
//
复制完毕开启决斗助手
YGOUtil
.
startDuelService
(
this
);
});
...
...
@@ -844,7 +844,7 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
});
//
复制前关闭决斗助手
//
复制前关闭决斗助手
// String label = TextUtils.isEmpty(deck.getName()) ? getString(R.string.share_deck) : deck.getName();
...
...
@@ -1075,9 +1075,9 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
addMenuButton
(
mMenuIds
,
menu
,
R
.
id
.
action_sort
,
R
.
string
.
sort
,
R
.
drawable
.
sort
);
addMenuButton
(
mMenuIds
,
menu
,
R
.
id
.
action_deck_backup_n_restore
,
R
.
string
.
deck_backup_n_restore
,
R
.
drawable
.
downloadimages
);
//
设置展开或隐藏的延时。 默认值为 800ms。
//
设置展开或隐藏的延时。 默认值为 800ms。
menu
.
setDuration
(
150
);
//
设置每两个子按钮之间动画的延时(ms为单位)。 比如,如果延时设为0,那么所有子按钮都会同时展开或隐藏,默认值为100ms。
//
设置每两个子按钮之间动画的延时(ms为单位)。 比如,如果延时设为0,那么所有子按钮都会同时展开或隐藏,默认值为100ms。
menu
.
setDelay
(
10
);
menu
.
setOnBoomListener
(
new
DefaultOnBoomListener
()
{
...
...
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