Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
严琪
/
paysplug-in
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7e491c77
authored
Mar 08, 2018
by
jeffrey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
加入多线程解析
parent
3b4892fc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
167 additions
and
28 deletions
+167
-28
app/src/main/java/com/yuqirong/listenwechatnotification/MainActivity.java
+7
-15
app/src/main/java/com/yuqirong/listenwechatnotification/function/ParseImageFunc.java
+155
-0
app/src/main/java/com/yuqirong/listenwechatnotification/function/QRCodeFunction.java
+3
-0
app/src/main/java/com/yuqirong/listenwechatnotification/service/MyAccessibilityService.java
+2
-13
No files found.
app/src/main/java/com/yuqirong/listenwechatnotification/MainActivity.java
View file @
7e491c77
...
...
@@ -130,25 +130,14 @@ public class MainActivity extends ParentActivity {
my
=
new
MyCashReceiver
();
registerReceiver
(
my
,
filter
);
ArrayList
<
String
>
result
=
ActivePullCashList
.
moneyWithFilter
();
QRCodeFunction
qrThread
=
new
QRCodeFunction
(
"QRCodeFunction---ZFB"
,
Utils
.
ZFBImgPath
);
qrThread
.
start
();
// ArrayList<String> result = ActivePullCashList.moneyWithFilter();
// timingRequest();
// ArrayList<String> result = ActivePullCashList.generateMoneys();
// new Runnable() {
// @Override
// public void run() {
// QRCodeFunction qrThread = new QRCodeFunction("QRCodeFunction---ZFB", Utils.ZFBImgPath);
// qrThread.run();
// }
// }.run();
// String strResult = MyApplication.get().getSharedPreferences("result", Context.MODE_PRIVATE).getString("result","");
// try {
// writeString2File(strResult);
// } catch (IOException e) {
// e.printStackTrace();
// }
// StringBuilder sb = new StringBuilder();
...
...
@@ -296,4 +285,7 @@ private void checkNotificationPermission() {
super
.
onDestroy
();
am
.
cancel
(
pi
);
}
}
app/src/main/java/com/yuqirong/listenwechatnotification/function/ParseImageFunc.java
0 → 100644
View file @
7e491c77
package
com
.
yuqirong
.
listenwechatnotification
.
function
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
android.graphics.Bitmap
;
import
android.os.Environment
;
import
android.util.Log
;
import
com.google.gson.Gson
;
import
com.google.zxing.BinaryBitmap
;
import
com.google.zxing.ChecksumException
;
import
com.google.zxing.FormatException
;
import
com.google.zxing.NotFoundException
;
import
com.google.zxing.RGBLuminanceSource
;
import
com.google.zxing.Result
;
import
com.google.zxing.common.HybridBinarizer
;
import
com.google.zxing.qrcode.QRCodeReader
;
import
com.yuqirong.listenwechatnotification.MyApplication
;
import
com.yuqirong.listenwechatnotification.bean.ImageBean
;
import
com.yuqirong.listenwechatnotification.bean.OneBatchResult
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.concurrent.ConcurrentLinkedQueue
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
static
android
.
graphics
.
BitmapFactory
.
decodeFile
;
/**
* 创建日期:2018/3/8 on 15:48
* 描述:
* 作者:Li
*/
public
class
ParseImageFunc
{
private
final
String
TAG
=
ParseImageFunc
.
class
.
getSimpleName
();
private
List
<
ImageBean
>
imageBeanList
=
new
ArrayList
<>()
;
private
ConcurrentLinkedQueue
<
File
>
queue
=
new
ConcurrentLinkedQueue
<
File
>();
public
void
start
(
String
filePath
){
final
List
<
File
>
imageFiles
=
foundImageFile
(
filePath
);
if
(
imageFiles
==
null
||
imageFiles
.
size
()
==
0
){
return
;
}
for
(
File
file
:
imageFiles
){
queue
.
add
(
file
);
}
ExecutorService
service
=
Executors
.
newFixedThreadPool
(
3
);
for
(
int
i
=
0
;
i
<
3
;
i
++){
service
.
submit
(
new
Runnable
()
{
@Override
public
void
run
()
{
while
(!
queue
.
isEmpty
()){
File
file
=
queue
.
poll
();
ImageBean
result
=
parseCode
(
file
);
if
(
result
!=
null
){
imageBeanList
.
add
(
result
);
}
}
Collections
.
sort
(
imageBeanList
,
new
Comparator
<
ImageBean
>()
{
@Override
public
int
compare
(
ImageBean
o1
,
ImageBean
o2
)
{
float
left
=
Float
.
parseFloat
(
o1
.
getDescription
());
float
right
=
Float
.
parseFloat
(
o2
.
getDescription
());
return
left
<
right
?
-
1
:
1
;
}
});
OneBatchResult
result
=
new
OneBatchResult
(
new
ArrayList
<
ImageBean
>(
imageBeanList
));
String
stringResult
=
new
Gson
().
toJson
(
result
);
SharedPreferences
sp
=
MyApplication
.
get
().
getSharedPreferences
(
"result"
,
Context
.
MODE_PRIVATE
);
sp
.
edit
().
putString
(
"result"
,
stringResult
).
apply
();
Log
.
d
(
"fei"
,
"parse done"
);
}
});
}
}
/**
* 支付宝保存的图片只存在于 DCIM/CAMERA 华为手机
*/
private
List
<
File
>
foundImageFile
(
String
filePath
){
//有sd卡
if
(
Environment
.
MEDIA_MOUNTED
.
equals
(
Environment
.
getExternalStorageState
()))
{
// 创建一个文件夹对象,赋值为外部存储器的目录
File
sdcardDir
=
Environment
.
getExternalStorageDirectory
();
// 得到一个路径,内容是sdcard的文件夹路径和名字
String
path
=
sdcardDir
.
getPath
()
+
filePath
;
File
path1
=
new
File
(
path
);
if
(
path1
.
exists
()){
Log
.
d
(
TAG
,
"文件夹存在"
);
File
[]
files
=
path1
.
listFiles
();
if
(
files
.
length
>
0
)
{
return
Arrays
.
asList
(
files
);
}
else
{
Log
.
d
(
TAG
,
"没有图片文件"
);
}
}
else
{
Log
.
d
(
TAG
,
"文件不存在"
);
}
}
else
{
}
return
null
;
}
public
ImageBean
parseCode
(
File
file
)
{
Bitmap
obmp
=
decodeFile
(
file
.
getPath
());
int
width
=
obmp
.
getWidth
();
int
height
=
obmp
.
getHeight
();
int
[]
data
=
new
int
[
width
*
height
];
obmp
.
getPixels
(
data
,
0
,
width
,
0
,
0
,
width
,
height
);
RGBLuminanceSource
source
=
new
RGBLuminanceSource
(
width
,
height
,
data
);
BinaryBitmap
bitmap1
=
new
BinaryBitmap
(
new
HybridBinarizer
(
source
));
QRCodeReader
reader
=
new
QRCodeReader
();
Result
re
=
null
;
try
{
re
=
reader
.
decode
(
bitmap1
);
ImageBean
bean
=
new
ImageBean
();
bean
.
setUrl
(
re
.
getText
());
bean
.
setDescription
(
file
.
getName
());
Log
.
d
(
TAG
,
"parseCode: "
+
bean
.
getUrl
());
return
bean
;
}
catch
(
NotFoundException
e
)
{
e
.
printStackTrace
();
Log
.
d
(
TAG
,
"fei error: "
+
e
.
getMessage
()
+
" file name "
+
file
.
getName
());
}
catch
(
ChecksumException
e
)
{
e
.
printStackTrace
();
Log
.
d
(
TAG
,
"fei error: "
+
e
.
getMessage
()
+
" file name "
+
file
.
getName
());
}
catch
(
FormatException
e
)
{
e
.
printStackTrace
();
Log
.
d
(
TAG
,
"fei error: "
+
e
.
getMessage
()
+
" file name "
+
file
.
getName
());
}
return
null
;
}
}
app/src/main/java/com/yuqirong/listenwechatnotification/function/QRCodeFunction.java
View file @
7e491c77
...
...
@@ -71,6 +71,9 @@ public class QRCodeFunction extends Thread{
public
void
run
()
{
super
.
run
();
List
<
File
>
imageFiles
=
functionFoundImageFile
(
this
.
filePath
);
if
(
imageFiles
==
null
||
imageFiles
.
size
()
==
0
){
return
;
}
List
<
ImageBean
>
imageBeanList
=
functionQRCode
((
File
[])
imageFiles
.
toArray
());
OneBatchResult
result
=
new
OneBatchResult
(
new
ArrayList
<
ImageBean
>(
imageBeanList
));
...
...
app/src/main/java/com/yuqirong/listenwechatnotification/service/MyAccessibilityService.java
View file @
7e491c77
...
...
@@ -88,22 +88,12 @@ public class MyAccessibilityService extends AccessibilityService {
Log
.
d
(
TAG
,
"这次任务已经完成!"
);
if
(
PayTypeSingleTon
.
newInstance
().
getPayType
().
equals
(
Utils
.
payTypeZFB
)){
new
Runnable
()
{
@Override
public
void
run
()
{
QRCodeFunction
qrThread
=
new
QRCodeFunction
(
"QRCodeFunction---ZFB"
,
Utils
.
ZFBImgPath
);
qrThread
.
run
();
}
}.
run
();
qrThread
.
start
();
}
else
{
new
Runnable
()
{
@Override
public
void
run
()
{
QRCodeFunction
qrThread
=
new
QRCodeFunction
(
"QRCodeFunction---WEIXIN"
,
Utils
.
WeiXinImgPath
);
qrThread
.
run
();
}
}.
run
();
qrThread
.
start
();
}
moneylist
.
clear
();
...
...
@@ -209,7 +199,6 @@ public class MyAccessibilityService extends AccessibilityService {
}
if
(
info
.
getChildCount
()
==
0
)
{
Log
.
i
(
"fei "
,
"child widget----------------------------"
+
info
.
getClassName
());
Log
.
i
(
"fei "
,
"showDialog:"
+
info
.
canOpenPopup
());
Log
.
i
(
"fei "
,
"Text:"
+
info
.
getText
());
Log
.
i
(
"fei "
,
"windowId:"
+
info
.
getWindowId
());
// if (!TextUtils.isEmpty(info.getText()) && searchText.equals(info.getText())){
...
...
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