Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
flutter_plugin
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
林生雨
flutter_plugin
Commits
4785e81b
Commit
4785e81b
authored
Dec 23, 2019
by
林生雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
b30a2a42
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
64 additions
and
14 deletions
+64
-14
workspace.xml
.idea/workspace.xml
+0
-0
GengmeiFlutterPlugin.kt
...om/example/gengmei_flutter_plugin/GengmeiFlutterPlugin.kt
+24
-10
ImageRespository.kt
...flutter_plugin/ImagePlugin/repository/ImageRespository.kt
+19
-4
ScanImagePlugn.dart
lib/ScanImagePlugn.dart
+13
-0
SharedPlugin.dart
lib/SharedPlugin.dart
+2
-0
gengmei_flutter_plugin.dart
lib/gengmei_flutter_plugin.dart
+6
-0
No files found.
.idea/workspace.xml
View file @
4785e81b
This diff is collapsed.
Click to expand it.
android/src/main/kotlin/com/example/gengmei_flutter_plugin/GengmeiFlutterPlugin.kt
View file @
4785e81b
...
@@ -52,6 +52,7 @@ class GengmeiFlutterPlugin : MethodCallHandler {
...
@@ -52,6 +52,7 @@ class GengmeiFlutterPlugin : MethodCallHandler {
var
premissionHandler
:
PermissionListener
?
=
null
var
premissionHandler
:
PermissionListener
?
=
null
var
nativeImage
:
File
?
=
null
var
nativeImage
:
File
?
=
null
const
val
IMAGE_PICKER
=
"scan_image_picker"
const
val
IMAGE_PICKER
=
"scan_image_picker"
const
val
ADD_IMAGE_CACHE
=
"ADD_IMAGE_CACHE"
const
val
NATIVE_CAMERA
=
"native_camera"
const
val
NATIVE_CAMERA
=
"native_camera"
const
val
QUIT_PAGE
=
"quit_page"
const
val
QUIT_PAGE
=
"quit_page"
const
val
AI_CAMERA
=
"ai_camera"
const
val
AI_CAMERA
=
"ai_camera"
...
@@ -128,11 +129,11 @@ class GengmeiFlutterPlugin : MethodCallHandler {
...
@@ -128,11 +129,11 @@ class GengmeiFlutterPlugin : MethodCallHandler {
// true;
// true;
// }
// }
registrar
.
addActivityResultListener
{
requestCode
,
resultCode
,
intent
->
registrar
.
addActivityResultListener
{
requestCode
,
resultCode
,
intent
->
Log
.
e
(
"lsy"
,
" LSY ACTIVITY RESULT ${nativeImage?.exists()} ${requestCode} "
)
Log
.
e
(
"lsy"
,
" LSY ACTIVITY RESULT ${nativeImage?.exists()} ${requestCode} "
)
when
(
requestCode
)
{
when
(
requestCode
)
{
CAMERA_REQUEST_CODE
->
{
CAMERA_REQUEST_CODE
->
{
if
(
resultCode
==
RESULT_OK
)
{
if
(
resultCode
==
RESULT_OK
)
{
android
.
util
.
Log
.
e
(
"lsy"
,
" RESULT OKKKKK "
)
android
.
util
.
Log
.
e
(
"lsy"
,
" RESULT OKKKKK "
)
if
(
nativeImage
!=
null
&&
nativeImage
!!
.
exists
())
{
if
(
nativeImage
!=
null
&&
nativeImage
!!
.
exists
())
{
ImageRespository
.
getInstance
().
scareImg
(
nativeImage
!!
.
absolutePath
).
subscribe
({
ImageRespository
.
getInstance
().
scareImg
(
nativeImage
!!
.
absolutePath
).
subscribe
({
val
map
=
HashMap
<
String
,
Any
>()
val
map
=
HashMap
<
String
,
Any
>()
...
@@ -140,7 +141,7 @@ class GengmeiFlutterPlugin : MethodCallHandler {
...
@@ -140,7 +141,7 @@ class GengmeiFlutterPlugin : MethodCallHandler {
map
.
put
(
"path"
,
it
.
second
)
map
.
put
(
"path"
,
it
.
second
)
map
.
put
(
"isVideo"
,
"F"
)
map
.
put
(
"isVideo"
,
"F"
)
map
.
put
(
"folderName"
,
"GengmeiAlbum"
)
map
.
put
(
"folderName"
,
"GengmeiAlbum"
)
android
.
util
.
Log
.
e
(
"lsy"
,
" RESULT MAPPP "
)
android
.
util
.
Log
.
e
(
"lsy"
,
" RESULT MAPPP "
)
// try {
// try {
// MediaStore.Images.Media.insertImage(resign.context().applicationContext.getContentResolver(),
// MediaStore.Images.Media.insertImage(resign.context().applicationContext.getContentResolver(),
...
@@ -199,9 +200,9 @@ class GengmeiFlutterPlugin : MethodCallHandler {
...
@@ -199,9 +200,9 @@ class GengmeiFlutterPlugin : MethodCallHandler {
// intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(nativeImage));
// intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(nativeImage));
// }
// }
val
broad
=
Intent
(
"com.alpha.flutter.album"
)
val
broad
=
Intent
(
"com.alpha.flutter.album"
)
broad
.
putExtra
(
"PATH"
,
nativeImage
!!
.
absolutePath
)
broad
.
putExtra
(
"PATH"
,
nativeImage
!!
.
absolutePath
)
broad
.
putExtra
(
"providerString"
,
providerString
)
broad
.
putExtra
(
"providerString"
,
providerString
)
broad
.
putExtra
(
"CAMERA_REQUEST_CODE"
,
CAMERA_REQUEST_CODE
)
broad
.
putExtra
(
"CAMERA_REQUEST_CODE"
,
CAMERA_REQUEST_CODE
)
resign
.
sendBroadcast
(
broad
)
resign
.
sendBroadcast
(
broad
)
// resign.activity().startActivityForResult(intent, CAMERA_REQUEST_CODE);
// resign.activity().startActivityForResult(intent, CAMERA_REQUEST_CODE);
}
}
...
@@ -214,8 +215,21 @@ class GengmeiFlutterPlugin : MethodCallHandler {
...
@@ -214,8 +215,21 @@ class GengmeiFlutterPlugin : MethodCallHandler {
val
result
=
resultKey
;
val
result
=
resultKey
;
ScanImage
(
result
)
ScanImage
(
result
)
}
}
ADD_IMAGE_CACHE
->
{
val
result
=
resultKey
;
val
map
=
call
.
arguments
as
HashMap
<
String
,
String
>
ImageRespository
.
getInstance
().
addCacheItem
(
if
(
map
[
"isVideo"
]
==
"T"
)
true
else
false
,
map
[
"path"
]
!!
,
map
[
"realPath"
]
!!
,
map
[
"folderName"
]
!!
,
map
[
"during"
]
!!
.
toLong
()
)
ResultManager
.
getInstance
().
resultSuccess
(
result
,
true
)
}
NATIVE_CAMERA
->
{
NATIVE_CAMERA
->
{
gotoNativeCameraKey
=
resultKey
;
gotoNativeCameraKey
=
resultKey
;
gotoNativeCamera
(
call
.
argument
<
String
>(
"authority"
)
!!
)
gotoNativeCamera
(
call
.
argument
<
String
>(
"authority"
)
!!
)
}
}
SAVE_STRING_SHARED
->
{
SAVE_STRING_SHARED
->
{
...
@@ -327,7 +341,7 @@ class GengmeiFlutterPlugin : MethodCallHandler {
...
@@ -327,7 +341,7 @@ class GengmeiFlutterPlugin : MethodCallHandler {
path
?.
run
{
path
?.
run
{
val
intent
=
Intent
(
resign
,
VideoActivity
::
class
.
java
)
val
intent
=
Intent
(
resign
,
VideoActivity
::
class
.
java
)
intent
.
putExtra
(
"PATH"
,
this
)
intent
.
putExtra
(
"PATH"
,
this
)
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
resign
.
startActivity
(
intent
)
resign
.
startActivity
(
intent
)
}
}
}
}
...
@@ -337,7 +351,7 @@ class GengmeiFlutterPlugin : MethodCallHandler {
...
@@ -337,7 +351,7 @@ class GengmeiFlutterPlugin : MethodCallHandler {
path
?.
run
{
path
?.
run
{
val
intent
=
Intent
(
resign
,
PreviewActivity
::
class
.
java
)
val
intent
=
Intent
(
resign
,
PreviewActivity
::
class
.
java
)
intent
.
putExtra
(
"PATH"
,
this
)
intent
.
putExtra
(
"PATH"
,
this
)
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
resign
.
startActivity
(
intent
)
resign
.
startActivity
(
intent
)
ResultManager
.
getInstance
().
resultSuccess
(
result
,
true
)
ResultManager
.
getInstance
().
resultSuccess
(
result
,
true
)
// ImageRespository.getInstance().getPreviewImg(resign.context().applicationContext,this, 800.0f).subscribe({
// ImageRespository.getInstance().getPreviewImg(resign.context().applicationContext,this, 800.0f).subscribe({
...
@@ -389,7 +403,7 @@ class GengmeiFlutterPlugin : MethodCallHandler {
...
@@ -389,7 +403,7 @@ class GengmeiFlutterPlugin : MethodCallHandler {
@TargetApi
(
Build
.
VERSION_CODES
.
M
)
@TargetApi
(
Build
.
VERSION_CODES
.
M
)
private
fun
checkPermission
(
listener
:
PermissionListener
)
{
private
fun
checkPermission
(
listener
:
PermissionListener
)
{
premissionHandler
=
listener
premissionHandler
=
listener
listener
.
OK
()
listener
.
OK
()
// val activity = resign
// val activity = resign
// val writePremission = activity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
// val writePremission = activity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
...
...
android/src/main/kotlin/com/example/gengmei_flutter_plugin/ImagePlugin/repository/ImageRespository.kt
View file @
4785e81b
...
@@ -106,6 +106,21 @@ class ImageRespository {
...
@@ -106,6 +106,21 @@ class ImageRespository {
}).
subscribeOn
(
Schedulers
.
io
()).
observeOn
(
AndroidSchedulers
.
mainThread
())
}).
subscribeOn
(
Schedulers
.
io
()).
observeOn
(
AndroidSchedulers
.
mainThread
())
}
}
fun
addCacheItem
(
isVideo
:
Boolean
,
path
:
String
,
realPath
:
String
,
folderName
:
String
,
during
:
Long
)
{
val
itemMap
=
HashMap
<
String
,
Any
>()
itemMap
.
put
(
"folderName"
,
folderName
)
itemMap
.
put
(
"path"
,
path
)
itemMap
.
put
(
"realPath"
,
realPath
)
if
(
isVideo
)
{
itemMap
.
put
(
"isVideo"
,
"T"
)
itemMap
.
put
(
"during"
,
"${during}"
)
}
else
{
itemMap
.
put
(
"isVideo"
,
"F"
)
}
recordImageListMap
.
add
(
0
,
itemMap
)
}
fun
savePreviewImg
(
context
:
Context
,
listener
:
savePreviewListener
)
{
fun
savePreviewImg
(
context
:
Context
,
listener
:
savePreviewListener
)
{
val
start
=
System
.
currentTimeMillis
();
val
start
=
System
.
currentTimeMillis
();
val
needSize
=
recordImageListMap
.
size
;
val
needSize
=
recordImageListMap
.
size
;
...
@@ -119,7 +134,7 @@ class ImageRespository {
...
@@ -119,7 +134,7 @@ class ImageRespository {
// if (it["realPath"] == null) {
// if (it["realPath"] == null) {
// continue
// continue
// }
// }
Log
.
e
(
"lsy"
,
"index ${index}"
)
Log
.
e
(
"lsy"
,
"index ${index}"
)
val
any
=
it
[
"path"
]
val
any
=
it
[
"path"
]
val
realPath
=
it
[
"realPath"
]
as
String
val
realPath
=
it
[
"realPath"
]
as
String
if
(
any
!=
null
&&
!
TextUtils
.
isEmpty
(
any
as
String
))
{
if
(
any
!=
null
&&
!
TextUtils
.
isEmpty
(
any
as
String
))
{
...
@@ -303,7 +318,7 @@ class ImageRespository {
...
@@ -303,7 +318,7 @@ class ImageRespository {
// )
// )
// .setName(getFileName(realPath)!!)
// .setName(getFileName(realPath)!!)
// .get(realPath);
// .get(realPath);
it
[
"path"
]
=
MyUtil
.
scareImg
(
realPath
,
200f
,
fileDir
+
"/"
+
getFileName
(
realPath
)
!!
+
".png"
,
75
,
degree
)
it
[
"path"
]
=
MyUtil
.
scareImg
(
realPath
,
200f
,
fileDir
+
"/"
+
getFileName
(
realPath
)
!!
+
".png"
,
75
,
degree
)
// Log.e("lsy", "封面照片 ${get.absolutePath}");
// Log.e("lsy", "封面照片 ${get.absolutePath}");
}
}
}
}
...
@@ -331,7 +346,7 @@ class ImageRespository {
...
@@ -331,7 +346,7 @@ class ImageRespository {
}
}
}
}
finalList
[
"IsGengmeiAlbumAllImages"
]
=
imageListMap
;
finalList
[
"IsGengmeiAlbumAllImages"
]
=
imageListMap
;
return
finalList
;
return
finalList
}
}
fun
getPreviewImg
(
context
:
Context
,
realPath
:
String
,
scareSize
:
Float
):
Observable
<
String
>
{
fun
getPreviewImg
(
context
:
Context
,
realPath
:
String
,
scareSize
:
Float
):
Observable
<
String
>
{
...
@@ -343,7 +358,7 @@ class ImageRespository {
...
@@ -343,7 +358,7 @@ class ImageRespository {
// val path = Luban.with(context).setTargetDir(fileDir).quality(100)
// val path = Luban.with(context).setTargetDir(fileDir).quality(100)
// .setName(getFileName(realPath)!! + "_preview.png")
// .setName(getFileName(realPath)!! + "_preview.png")
// .get(realPath);
// .get(realPath);
val
path
=
MyUtil
.
scareImg
(
realPath
,
scareSize
,
copyPath
,
90
,
0
);
val
path
=
MyUtil
.
scareImg
(
realPath
,
scareSize
,
copyPath
,
90
,
0
);
it
.
onNext
(
path
)
it
.
onNext
(
path
)
}).
subscribeOn
(
Schedulers
.
io
()).
observeOn
(
AndroidSchedulers
.
mainThread
());
}).
subscribeOn
(
Schedulers
.
io
()).
observeOn
(
AndroidSchedulers
.
mainThread
());
}
}
...
...
lib/ScanImagePlugn.dart
View file @
4785e81b
...
@@ -25,6 +25,8 @@ Map<String, List<ScanImageItem>> changData(Map images) {
...
@@ -25,6 +25,8 @@ Map<String, List<ScanImageItem>> changData(Map images) {
return
newMap
;
return
newMap
;
}
}
const
String
ADD_IMAGE_CACHE
=
"ADD_IMAGE_CACHE"
;
class
ScanImagePlugn
{
class
ScanImagePlugn
{
static
Future
<
Map
<
String
,
List
<
ScanImageItem
>>>
scanImages
(
static
Future
<
Map
<
String
,
List
<
ScanImageItem
>>>
scanImages
(
MethodChannel
channel
)
async
{
MethodChannel
channel
)
async
{
...
@@ -38,6 +40,17 @@ class ScanImagePlugn {
...
@@ -38,6 +40,17 @@ class ScanImagePlugn {
.
invokeMethod
(
"native_camera"
,
{
"authority"
:
authority
});
.
invokeMethod
(
"native_camera"
,
{
"authority"
:
authority
});
}
}
static
Future
<
bool
>
addAlbumItem
(
bool
isVideo
,
String
path
,
String
realPath
,
String
folderName
,
int
during
,
MethodChannel
channel
)
async
{
return
await
channel
.
invokeMethod
(
ADD_IMAGE_CACHE
,
{
"isVideo"
:
isVideo
?
"T"
:
"F"
,
"path"
:
path
,
"realPath"
:
realPath
,
"folderName"
:
folderName
,
"during"
:
"
${during}
"
});
}
static
Future
<
String
>
scareImg
(
static
Future
<
String
>
scareImg
(
MethodChannel
channel
,
String
path
,
int
scare
)
async
{
MethodChannel
channel
,
String
path
,
int
scare
)
async
{
return
await
channel
return
await
channel
...
...
lib/SharedPlugin.dart
View file @
4785e81b
...
@@ -31,6 +31,8 @@ class SharedPlugin {
...
@@ -31,6 +31,8 @@ class SharedPlugin {
.
invokeMethod
(
SAVE_INT_SHARED
,
{
"key"
:
key
,
"value"
:
value
});
.
invokeMethod
(
SAVE_INT_SHARED
,
{
"key"
:
key
,
"value"
:
value
});
}
}
static
Future
<
bool
>
saveDouble
(
static
Future
<
bool
>
saveDouble
(
String
key
,
double
value
,
MethodChannel
channel
)
async
{
String
key
,
double
value
,
MethodChannel
channel
)
async
{
return
await
channel
return
await
channel
...
...
lib/gengmei_flutter_plugin.dart
View file @
4785e81b
...
@@ -39,6 +39,12 @@ class GengmeiFlutterPlugin {
...
@@ -39,6 +39,12 @@ class GengmeiFlutterPlugin {
return
await
ScanImagePlugn
.
playAlbumVideo
(
_channel
,
path
);
return
await
ScanImagePlugn
.
playAlbumVideo
(
_channel
,
path
);
}
}
static
Future
<
bool
>
addAlbumItem
(
bool
isVideo
,
String
path
,
String
realPath
,
String
folderName
,
int
during
)
async
{
return
await
ScanImagePlugn
.
addAlbumItem
(
isVideo
,
path
,
realPath
,
folderName
,
during
,
_channel
);
}
static
Future
<
bool
>
quitPage
()
async
{
static
Future
<
bool
>
quitPage
()
async
{
return
await
ScanImagePlugn
.
quitPage
(
_channel
);
return
await
ScanImagePlugn
.
quitPage
(
_channel
);
}
}
...
...
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