Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
R
RatelExtension
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ratel
RatelExtension
Commits
1e65d0aa
Commit
1e65d0aa
authored
May 06, 2020
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
scroll 优化
parent
c0525124
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
5 deletions
+58
-5
SwipeUtils.java
...om/virjar/ratel/api/extension/superappium/SwipeUtils.java
+4
-1
ViewImage.java
...com/virjar/ratel/api/extension/superappium/ViewImage.java
+54
-4
No files found.
src/main/java/com/virjar/ratel/api/extension/superappium/SwipeUtils.java
View file @
1e65d0aa
...
...
@@ -99,7 +99,7 @@ public class SwipeUtils {
private
static
void
dealSimulateScroll
(
ViewImage
object
,
float
startX
,
float
startY
,
float
endX
,
float
endY
,
long
duration
,
int
period
)
{
if
(
isScrolling
)
{
Log
.
i
(
SuperAppium
.
TAG
,
"sc
ore
task is running.."
);
Log
.
i
(
SuperAppium
.
TAG
,
"sc
roll
task is running.."
);
return
;
}
isScrolling
=
true
;
...
...
@@ -123,6 +123,7 @@ public class SwipeUtils {
private
static
MotionEvent
genFingerEvent
(
int
action
,
float
x
,
float
y
)
{
// Log.i("HD_HOOK", "genFingerEvent action: " + action + " point:(" + x + " , " + y + ")");
long
downTime
=
SystemClock
.
uptimeMillis
();
long
eventTime
=
SystemClock
.
uptimeMillis
();
...
...
@@ -153,6 +154,8 @@ public class SwipeUtils {
public
void
handleMessage
(
Message
msg
)
{
ViewImage
theView
=
mView
.
get
();
if
(
theView
==
null
)
{
Log
.
e
(
SuperAppium
.
TAG
,
"scroll view has bean destroyed"
);
isScrolling
=
false
;
return
;
}
...
...
src/main/java/com/virjar/ratel/api/extension/superappium/ViewImage.java
View file @
1e65d0aa
...
...
@@ -8,6 +8,7 @@ import android.view.InputEvent;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.inputmethod.EditorInfo
;
import
android.webkit.WebView
;
import
android.widget.AdapterView
;
import
android.widget.EditText
;
...
...
@@ -285,6 +286,8 @@ public class ViewImage {
EditText
editText
=
(
EditText
)
originView
;
editText
.
getText
().
clear
();
editText
.
setText
(
content
);
//触发焦点到下一个输入框
editText
.
onEditorAction
(
EditorInfo
.
IME_ACTION_NEXT
);
return
true
;
}
...
...
@@ -394,15 +397,62 @@ public class ViewImage {
int
toX
=
(
int
)
(
fromX
+
viewWidth
*
(
ThreadLocalRandom
.
current
().
nextDouble
(
0.1
)));
int
fromY
=
(
int
)
(
locs
[
1
]
+
viewHeight
*
ThreadLocalRandom
.
current
().
nextDouble
(
0.1
));
if
(
fromY
<
2
)
{
fromY
=
2
;
int
fromY
,
toY
;
if
(
height
>
0
)
{
fromY
=
(
int
)
(
locs
[
1
]
+
viewHeight
*
ThreadLocalRandom
.
current
().
nextDouble
(
0.1
));
if
(
fromY
<
2
)
{
fromY
=
2
;
}
toY
=
fromY
+
height
;
}
else
{
fromY
=
(
int
)
(
locs
[
1
]
+
viewHeight
*
(
ThreadLocalRandom
.
current
().
nextDouble
(
0.1
)
+
0.9
));
toY
=
fromY
+
height
;
if
(
toY
<
2
)
{
toY
=
2
;
}
}
int
toY
=
fromY
+
height
;
SwipeUtils
.
simulateScroll
(
this
,
fromX
,
fromY
,
toX
,
toY
,
400
,
50
);
}
/**
* 向右滑动
*
* @param width 滑动宽度,如果为负数,则向左滑动
*/
@SuppressLint
(
"NewApi"
)
public
void
swipeRight
(
int
width
)
{
int
[]
locs
=
new
int
[
2
];
originView
.
getLocationOnScreen
(
locs
);
int
viewWidth
=
originView
.
getWidth
();
int
viewHeight
=
originView
.
getHeight
();
int
fromY
=
(
int
)
(
locs
[
1
]
+
viewHeight
*
(
ThreadLocalRandom
.
current
().
nextDouble
(
0.05
)
-
0.025
+
0.5
));
if
(
fromY
<
2
)
{
fromY
=
2
;
}
int
toY
=
(
int
)
(
fromY
+
viewHeight
*
(
ThreadLocalRandom
.
current
().
nextDouble
(
0.008
)));
int
fromX
,
toX
;
if
(
width
>
0
)
{
fromX
=
(
int
)
(
locs
[
0
]
+
viewWidth
*
ThreadLocalRandom
.
current
().
nextDouble
(
0.1
));
if
(
fromX
<
2
)
{
fromX
=
2
;
}
toX
=
fromX
+
width
;
}
else
{
fromX
=
(
int
)
(
locs
[
0
]
+
viewWidth
*
(
ThreadLocalRandom
.
current
().
nextDouble
(
0.1
)
+
0.9
));
toX
=
fromX
+
width
;
if
(
toX
<
2
)
{
toX
=
2
;
}
}
// Log.i(SuperAppium.TAG, "location on screen: (" + locs[0] + "," + locs[1] + ") from loc:("
// + fromX + "," + fromY + ") to loc:(" + toX + "," + toY + ") with and height: (" + viewWidth + "," + viewHeight + ")");
SwipeUtils
.
simulateScroll
(
this
,
fromX
,
fromY
,
toX
,
toY
,
300
,
50
);
}
private
MotionEvent
genMotionEvent
(
int
action
,
float
[]
point
)
{
long
downTime
=
SystemClock
.
uptimeMillis
();
...
...
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