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
122c7b3e
Commit
122c7b3e
authored
Dec 09, 2025
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化拖拽和长按的区分,避免拖拽时触发长按删除
优化后可以不需要删除确认了 长按判断时长缩短到0.5秒
parent
39c9f5bf
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
4 deletions
+13
-4
mobile/src/main/java/androidx/recyclerview/widget/ItemTouchHelperPlus.java
...ava/androidx/recyclerview/widget/ItemTouchHelperPlus.java
+11
-2
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
+1
-1
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
+1
-1
No files found.
mobile/src/main/java/androidx/recyclerview/widget/ItemTouchHelperPlus.java
View file @
122c7b3e
...
...
@@ -2529,6 +2529,8 @@ public class ItemTouchHelperPlus extends RecyclerView.ItemDecoration
//region callback
// 修改 ItemTouchHelperPlus.java 中的 Callback2 类
public
abstract
static
class
Callback2
extends
ItemTouchHelperPlus
.
Callback
{
private
Handler
mHandler
;
private
ItemTouchHelperPlus
mItemTouchHelper
;
...
...
@@ -2539,6 +2541,7 @@ public class ItemTouchHelperPlus extends RecyclerView.ItemDecoration
private
boolean
isLongPressCancel
=
false
;
private
int
mDx
=
2
;
private
int
mDy
=
2
;
private
boolean
isDragging
=
false
;
// 添加拖拽状态标识
public
void
setLongTime
(
long
longTime
)
{
mLongTime
=
longTime
;
...
...
@@ -2573,7 +2576,9 @@ public class ItemTouchHelperPlus extends RecyclerView.ItemDecoration
float
dX
,
float
dY
,
int
actionState
,
boolean
isCurrentlyActive
)
{
super
.
onChildDrawOver
(
c
,
recyclerView
,
viewHolder
,
dX
,
dY
,
actionState
,
isCurrentlyActive
);
if
(
isCurrentlyActive
&&
actionState
==
ItemTouchHelperPlus
.
ACTION_STATE_DRAG
)
{
if
(
dX
>
mDx
||
dY
>
mDy
)
{
// 检测到真正的拖拽移动,设置拖拽状态并取消长按
if
((
Math
.
abs
(
dX
)
>
mDx
||
Math
.
abs
(
dY
)
>
mDy
)
&&
!
isDragging
)
{
isDragging
=
true
;
if
(!
isLongPressMode
()
&&
!
isLongPressCancel
)
{
isLongPressCancel
=
true
;
endLongPressMode
();
...
...
@@ -2590,6 +2595,7 @@ public class ItemTouchHelperPlus extends RecyclerView.ItemDecoration
getOnDragListener
().
onDragStart
();
}
isLongPressCancel
=
false
;
isDragging
=
false
;
// 重置拖拽状态
mSelectId
=
viewHolder
.
getAdapterPosition
();
longPressTime
=
System
.
currentTimeMillis
();
mHandler
.
removeCallbacks
(
enterLongPress
);
...
...
@@ -2598,18 +2604,21 @@ public class ItemTouchHelperPlus extends RecyclerView.ItemDecoration
}
}
else
if
(
actionState
==
ItemTouchHelperPlus
.
ACTION_STATE_IDLE
)
{
endLongPressMode
();
isDragging
=
false
;
// 重置拖拽状态
if
(
getOnDragListener
()
!=
null
)
{
getOnDragListener
().
onDragEnd
();
}
}
else
if
(
actionState
==
ItemTouchHelperPlus
.
ACTION_STATE_SWIPE
)
{
endLongPressMode
();
isDragging
=
false
;
// 重置拖拽状态
}
}
private
final
Runnable
enterLongPress
=
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
System
.
currentTimeMillis
()
-
longPressTime
>=
mLongTime
)
{
// 只有在非拖拽状态下才触发长按
if
(!
isDragging
&&
System
.
currentTimeMillis
()
-
longPressTime
>=
mLongTime
)
{
mLongPressMode
=
true
;
if
(!
isLongPressCancel
)
{
if
(
getOnDragListener
()
!=
null
&&
mSelectId
>=
0
)
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
View file @
122c7b3e
...
...
@@ -131,7 +131,7 @@ public class AppsSettings {
}
public
boolean
isDialogDelete
()
{
return
tru
e
;
// mSharedPreferences.getBoolean(PREF_DECK_DELETE_DILAOG, PREF_DEF_DECK_DELETE_DILAOG);
return
fals
e
;
// mSharedPreferences.getBoolean(PREF_DECK_DELETE_DILAOG, PREF_DEF_DECK_DELETE_DILAOG);
}
public
int
getNotchHeight
()
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
View file @
122c7b3e
...
...
@@ -204,7 +204,7 @@ public interface Constants {
/***
* 长按删除
*/
long
LONG_PRESS_DRAG
=
8
00
;
long
LONG_PRESS_DRAG
=
5
00
;
/***
* adb shell am start -n cn.garymb.ygomobile/cn.garymb.ygomobile.ui.home.MainActivity -a ygomobile.intent.action.DECK --es android.intent.extra.TEXT 青眼白龙.ydk
* <p>
...
...
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