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
Hide 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 {
var
premissionHandler
:
PermissionListener
?
=
null
var
nativeImage
:
File
?
=
null
const
val
IMAGE_PICKER
=
"scan_image_picker"
const
val
ADD_IMAGE_CACHE
=
"ADD_IMAGE_CACHE"
const
val
NATIVE_CAMERA
=
"native_camera"
const
val
QUIT_PAGE
=
"quit_page"
const
val
AI_CAMERA
=
"ai_camera"
...
...
@@ -128,11 +129,11 @@ class GengmeiFlutterPlugin : MethodCallHandler {
// true;
// }
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
)
{
CAMERA_REQUEST_CODE
->
{
if
(
resultCode
==
RESULT_OK
)
{
android
.
util
.
Log
.
e
(
"lsy"
,
" RESULT OKKKKK "
)
android
.
util
.
Log
.
e
(
"lsy"
,
" RESULT OKKKKK "
)
if
(
nativeImage
!=
null
&&
nativeImage
!!
.
exists
())
{
ImageRespository
.
getInstance
().
scareImg
(
nativeImage
!!
.
absolutePath
).
subscribe
({
val
map
=
HashMap
<
String
,
Any
>()
...
...
@@ -140,7 +141,7 @@ class GengmeiFlutterPlugin : MethodCallHandler {
map
.
put
(
"path"
,
it
.
second
)
map
.
put
(
"isVideo"
,
"F"
)
map
.
put
(
"folderName"
,
"GengmeiAlbum"
)
android
.
util
.
Log
.
e
(
"lsy"
,
" RESULT MAPPP "
)
android
.
util
.
Log
.
e
(
"lsy"
,
" RESULT MAPPP "
)
// try {
// MediaStore.Images.Media.insertImage(resign.context().applicationContext.getContentResolver(),
...
...
@@ -199,9 +200,9 @@ class GengmeiFlutterPlugin : MethodCallHandler {
// intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(nativeImage));
// }
val
broad
=
Intent
(
"com.alpha.flutter.album"
)
broad
.
putExtra
(
"PATH"
,
nativeImage
!!
.
absolutePath
)
broad
.
putExtra
(
"providerString"
,
providerString
)
broad
.
putExtra
(
"CAMERA_REQUEST_CODE"
,
CAMERA_REQUEST_CODE
)
broad
.
putExtra
(
"PATH"
,
nativeImage
!!
.
absolutePath
)
broad
.
putExtra
(
"providerString"
,
providerString
)
broad
.
putExtra
(
"CAMERA_REQUEST_CODE"
,
CAMERA_REQUEST_CODE
)
resign
.
sendBroadcast
(
broad
)
// resign.activity().startActivityForResult(intent, CAMERA_REQUEST_CODE);
}
...
...
@@ -214,8 +215,21 @@ class GengmeiFlutterPlugin : MethodCallHandler {
val
result
=
resultKey
;
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
->
{
gotoNativeCameraKey
=
resultKey
;
gotoNativeCameraKey
=
resultKey
;
gotoNativeCamera
(
call
.
argument
<
String
>(
"authority"
)
!!
)
}
SAVE_STRING_SHARED
->
{
...
...
@@ -327,7 +341,7 @@ class GengmeiFlutterPlugin : MethodCallHandler {
path
?.
run
{
val
intent
=
Intent
(
resign
,
VideoActivity
::
class
.
java
)
intent
.
putExtra
(
"PATH"
,
this
)
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
resign
.
startActivity
(
intent
)
}
}
...
...
@@ -337,7 +351,7 @@ class GengmeiFlutterPlugin : MethodCallHandler {
path
?.
run
{
val
intent
=
Intent
(
resign
,
PreviewActivity
::
class
.
java
)
intent
.
putExtra
(
"PATH"
,
this
)
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
resign
.
startActivity
(
intent
)
ResultManager
.
getInstance
().
resultSuccess
(
result
,
true
)
// ImageRespository.getInstance().getPreviewImg(resign.context().applicationContext,this, 800.0f).subscribe({
...
...
@@ -389,7 +403,7 @@ class GengmeiFlutterPlugin : MethodCallHandler {
@TargetApi
(
Build
.
VERSION_CODES
.
M
)
private
fun
checkPermission
(
listener
:
PermissionListener
)
{
premissionHandler
=
listener
premissionHandler
=
listener
listener
.
OK
()
// val activity = resign
// 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 {
}).
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
)
{
val
start
=
System
.
currentTimeMillis
();
val
needSize
=
recordImageListMap
.
size
;
...
...
@@ -119,7 +134,7 @@ class ImageRespository {
// if (it["realPath"] == null) {
// continue
// }
Log
.
e
(
"lsy"
,
"index ${index}"
)
Log
.
e
(
"lsy"
,
"index ${index}"
)
val
any
=
it
[
"path"
]
val
realPath
=
it
[
"realPath"
]
as
String
if
(
any
!=
null
&&
!
TextUtils
.
isEmpty
(
any
as
String
))
{
...
...
@@ -303,7 +318,7 @@ class ImageRespository {
// )
// .setName(getFileName(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}");
}
}
...
...
@@ -331,7 +346,7 @@ class ImageRespository {
}
}
finalList
[
"IsGengmeiAlbumAllImages"
]
=
imageListMap
;
return
finalList
;
return
finalList
}
fun
getPreviewImg
(
context
:
Context
,
realPath
:
String
,
scareSize
:
Float
):
Observable
<
String
>
{
...
...
@@ -343,7 +358,7 @@ class ImageRespository {
// val path = Luban.with(context).setTargetDir(fileDir).quality(100)
// .setName(getFileName(realPath)!! + "_preview.png")
// .get(realPath);
val
path
=
MyUtil
.
scareImg
(
realPath
,
scareSize
,
copyPath
,
90
,
0
);
val
path
=
MyUtil
.
scareImg
(
realPath
,
scareSize
,
copyPath
,
90
,
0
);
it
.
onNext
(
path
)
}).
subscribeOn
(
Schedulers
.
io
()).
observeOn
(
AndroidSchedulers
.
mainThread
());
}
...
...
lib/ScanImagePlugn.dart
View file @
4785e81b
...
...
@@ -25,6 +25,8 @@ Map<String, List<ScanImageItem>> changData(Map images) {
return
newMap
;
}
const
String
ADD_IMAGE_CACHE
=
"ADD_IMAGE_CACHE"
;
class
ScanImagePlugn
{
static
Future
<
Map
<
String
,
List
<
ScanImageItem
>>>
scanImages
(
MethodChannel
channel
)
async
{
...
...
@@ -38,6 +40,17 @@ class ScanImagePlugn {
.
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
(
MethodChannel
channel
,
String
path
,
int
scare
)
async
{
return
await
channel
...
...
lib/SharedPlugin.dart
View file @
4785e81b
...
...
@@ -31,6 +31,8 @@ class SharedPlugin {
.
invokeMethod
(
SAVE_INT_SHARED
,
{
"key"
:
key
,
"value"
:
value
});
}
static
Future
<
bool
>
saveDouble
(
String
key
,
double
value
,
MethodChannel
channel
)
async
{
return
await
channel
...
...
lib/gengmei_flutter_plugin.dart
View file @
4785e81b
...
...
@@ -39,6 +39,12 @@ class GengmeiFlutterPlugin {
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
{
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