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
30fd4309
Commit
30fd4309
authored
5 years ago
by
林生雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
ff2695bd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
15 deletions
+19
-15
workspace.xml
.idea/workspace.xml
+0
-0
AlbumModel.dart
example/lib/AlbumModel/page/album/AlbumModel.dart
+1
-1
AlbumPage.dart
example/lib/AlbumModel/page/album/AlbumPage.dart
+1
-1
AlbumRepository.dart
example/lib/AlbumModel/repository/AlbumRepository.dart
+4
-4
GengmeiFlutterPlugin.m
ios/Classes/GengmeiFlutterPlugin.m
+13
-9
No files found.
.idea/workspace.xml
View file @
30fd4309
This diff is collapsed.
Click to expand it.
example/lib/AlbumModel/page/album/AlbumModel.dart
View file @
30fd4309
...
@@ -148,7 +148,7 @@ class AlbumModel {
...
@@ -148,7 +148,7 @@ class AlbumModel {
if
(
value
!=
null
)
{
if
(
value
!=
null
)
{
_mainValue
=
value
;
_mainValue
=
value
;
value
.
forEach
((
key
,
eachValue
)
{
value
.
forEach
((
key
,
eachValue
)
{
print
(
"VALUE!!!
$key
"
);
//
print("VALUE!!! $key");
if
(
eachValue
!=
null
&&
!
eachValue
.
isEmpty
)
{
if
(
eachValue
!=
null
&&
!
eachValue
.
isEmpty
)
{
if
(
key
==
MainDir
)
{
if
(
key
==
MainDir
)
{
titleData
.
notifyView
(
MainDirExplain
);
titleData
.
notifyView
(
MainDirExplain
);
...
...
This diff is collapsed.
Click to expand it.
example/lib/AlbumModel/page/album/AlbumPage.dart
View file @
30fd4309
...
@@ -115,7 +115,7 @@ class AlbumState extends State<AlbumPage> {
...
@@ -115,7 +115,7 @@ class AlbumState extends State<AlbumPage> {
initialData:
_model
.
albumLive
.
data
,
initialData:
_model
.
albumLive
.
data
,
builder:
builder:
(
BuildContext
context
,
AsyncSnapshot
<
List
<
ScanImageItem
>>
imgList
)
{
(
BuildContext
context
,
AsyncSnapshot
<
List
<
ScanImageItem
>>
imgList
)
{
print
(
"FINALL
$imgList
${imgList.data}
"
);
//
print("FINALL $imgList ${imgList.data}");
if
(
imgList
.
data
==
null
)
{
if
(
imgList
.
data
==
null
)
{
return
Center
(
child:
CircularProgressIndicator
());
return
Center
(
child:
CircularProgressIndicator
());
}
}
...
...
This diff is collapsed.
Click to expand it.
example/lib/AlbumModel/repository/AlbumRepository.dart
View file @
30fd4309
...
@@ -24,10 +24,10 @@ class AlbumRepository {
...
@@ -24,10 +24,10 @@ class AlbumRepository {
Observable
<
Map
<
String
,
List
<
ScanImageItem
>>>
scanPhoneImg
()
{
Observable
<
Map
<
String
,
List
<
ScanImageItem
>>>
scanPhoneImg
()
{
return
Observable
.
fromFuture
(
GengmeiFlutterPlugin
.
phoneImages
())
return
Observable
.
fromFuture
(
GengmeiFlutterPlugin
.
phoneImages
())
.
map
((
value
)
{
.
map
((
value
)
{
if
(
value
!=
null
)
{
//
if (value != null) {
_cacheList
.
clear
();
//
_cacheList.clear();
_cacheList
.
addAll
(
value
);
//
_cacheList.addAll(value);
}
//
}
return
value
;
return
value
;
});
});
}
}
...
...
This diff is collapsed.
Click to expand it.
ios/Classes/GengmeiFlutterPlugin.m
View file @
30fd4309
...
@@ -45,7 +45,7 @@ NSString *cacheDirectory;
...
@@ -45,7 +45,7 @@ NSString *cacheDirectory;
[
registrar
addMethodCallDelegate
:
instance
channel
:
channel
];
[
registrar
addMethodCallDelegate
:
instance
channel
:
channel
];
assetCollectionList
=
[
NSMutableArray
array
];
assetCollectionList
=
[
NSMutableArray
array
];
viewController
=
[
UIApplication
sharedApplication
].
delegate
.
window
.
rootViewController
;
viewController
=
[
UIApplication
sharedApplication
].
delegate
.
window
.
rootViewController
;
// queue = dispatch_queue_create("com.gengmei_flutter_plugin", DISPATCH_QUEUE_CONCURRENT);
// queue = dispatch_queue_create("com.gengmei_flutter_plugin", DISPATCH_QUEUE_CONCURRENT);
queue
=
dispatch_queue_create
(
"com.gengmei_flutter_plugin"
,
DISPATCH_QUEUE_SERIAL
);
queue
=
dispatch_queue_create
(
"com.gengmei_flutter_plugin"
,
DISPATCH_QUEUE_SERIAL
);
FlutterEventChannel
*
chargingChannel
=
[
FlutterEventChannel
FlutterEventChannel
*
chargingChannel
=
[
FlutterEventChannel
eventChannelWithName
:
@"gengmei_flutter_plugin_event"
eventChannelWithName
:
@"gengmei_flutter_plugin_event"
...
@@ -298,7 +298,7 @@ NSString *cacheDirectory;
...
@@ -298,7 +298,7 @@ NSString *cacheDirectory;
CGSize
temp
=
CGSizeMake
(
picWidth
*
tempScareSize
,
picHeight
*
tempScareSize
);
CGSize
temp
=
CGSizeMake
(
picWidth
*
tempScareSize
,
picHeight
*
tempScareSize
);
[[
PHImageManager
defaultManager
]
requestImageDataForAsset
:
assets
options
:
imageRequestOption
resultHandler
:^
(
NSData
*
_Nullable
imageData
,
NSString
*
_Nullable
dataUTI
,
UIImageOrientation
orientation
,
NSDictionary
*
_Nullable
info
)
{
[[
PHImageManager
defaultManager
]
requestImageDataForAsset
:
assets
options
:
imageRequestOption
resultHandler
:^
(
NSData
*
_Nullable
imageData
,
NSString
*
_Nullable
dataUTI
,
UIImageOrientation
orientation
,
NSDictionary
*
_Nullable
info
)
{
// [[PHImageManager defaultManager] requestImageForAsset:assets targetSize:temp contentMode:PHImageContentModeDefault options:imageRequestOption resultHandler:^(UIImage * _Nullable res, NSDictionary * _Nullable info) {
// [[PHImageManager defaultManager] requestImageForAsset:assets targetSize:temp contentMode:PHImageContentModeDefault options:imageRequestOption resultHandler:^(UIImage * _Nullable res, NSDictionary * _Nullable info) {
@autoreleasepool
{
@autoreleasepool
{
UIImage
*
res
=
[
UIImage
imageWithData
:
imageData
];
UIImage
*
res
=
[
UIImage
imageWithData
:
imageData
];
NSData
*
data
=
UIImageJPEGRepresentation
(
res
,
0
.
8
)
;
NSData
*
data
=
UIImageJPEGRepresentation
(
res
,
0
.
8
)
;
...
@@ -321,10 +321,10 @@ NSString *cacheDirectory;
...
@@ -321,10 +321,10 @@ NSString *cacheDirectory;
}];
}];
}
}
}
}
}
else
if
([[
self
.
takePhotoMap
allKeys
]
containsObject
:
path
]){
}
else
if
([[
self
.
takePhotoMap
allKeys
]
containsObject
:
path
[
i
]
]){
NSMutableDictionary
*
dict
=
[[
NSMutableDictionary
alloc
]
init
];
NSMutableDictionary
*
dict
=
[[
NSMutableDictionary
alloc
]
init
];
[
dict
setObject
:
path
[
i
]
forKey
:
@"path"
];
[
dict
setObject
:
path
[
i
]
forKey
:
@"path"
];
[
dict
setObject
:
self
.
takePhotoMap
[
path
]
forKey
:
@"realImagePath"
];
[
dict
setObject
:
self
.
takePhotoMap
[
path
[
i
]
]
forKey
:
@"realImagePath"
];
@synchronized
(
self
)
{
@synchronized
(
self
)
{
self
.
channelSize
++
;
self
.
channelSize
++
;
[
self
.
channelList
addObject
:
dict
];
[
self
.
channelList
addObject
:
dict
];
...
@@ -392,7 +392,7 @@ NSString *cacheDirectory;
...
@@ -392,7 +392,7 @@ NSString *cacheDirectory;
[
image
drawInRect
:
CGRectMake
(
0
,
0
,
newSize
.
width
,
newSize
.
height
)];
[
image
drawInRect
:
CGRectMake
(
0
,
0
,
newSize
.
width
,
newSize
.
height
)];
UIImage
*
newImage
=
UIGraphicsGetImageFromCurrentImageContext
();
UIImage
*
newImage
=
UIGraphicsGetImageFromCurrentImageContext
();
UIGraphicsEndImageContext
();
UIGraphicsEndImageContext
();
NSData
*
data
=
UIImageJPEGRepresentation
(
newImage
,
0
.
8
);
NSData
*
data
=
UIImageJPEGRepresentation
(
newImage
,
0
.
6
);
NSString
*
guid
=
[[
NSProcessInfo
processInfo
]
globallyUniqueString
];
NSString
*
guid
=
[[
NSProcessInfo
processInfo
]
globallyUniqueString
];
NSString
*
tmpFile
=
[
NSString
stringWithFormat
:
@"image_picker_%@"
,
guid
];
NSString
*
tmpFile
=
[
NSString
stringWithFormat
:
@"image_picker_%@"
,
guid
];
NSString
*
tmpPath
=
[
cacheDirectory
stringByAppendingPathComponent
:
tmpFile
];
NSString
*
tmpPath
=
[
cacheDirectory
stringByAppendingPathComponent
:
tmpFile
];
...
@@ -485,7 +485,7 @@ NSString *cacheDirectory;
...
@@ -485,7 +485,7 @@ NSString *cacheDirectory;
}
}
-
(
void
)
scanPhoneImage
{
-
(
void
)
scanPhoneImage
{
//
//
PHFetchResult
<
PHAssetCollection
*>
*
favoritesCollection
=
[
PHAssetCollection
fetchAssetCollectionsWithType
:
PHAssetCollectionTypeSmartAlbum
subtype
:
PHAssetCollectionSubtypeSmartAlbumFavorites
options
:
nil
];
PHFetchResult
<
PHAssetCollection
*>
*
favoritesCollection
=
[
PHAssetCollection
fetchAssetCollectionsWithType
:
PHAssetCollectionTypeSmartAlbum
subtype
:
PHAssetCollectionSubtypeSmartAlbumFavorites
options
:
nil
];
// 获得相机胶卷
// 获得相机胶卷
PHFetchResult
<
PHAssetCollection
*>
*
assetCollections
=
[
PHAssetCollection
fetchAssetCollectionsWithType
:
PHAssetCollectionTypeAlbum
subtype
:
PHAssetCollectionSubtypeSmartAlbumUserLibrary
options
:
nil
];
PHFetchResult
<
PHAssetCollection
*>
*
assetCollections
=
[
PHAssetCollection
fetchAssetCollectionsWithType
:
PHAssetCollectionTypeAlbum
subtype
:
PHAssetCollectionSubtypeSmartAlbumUserLibrary
options
:
nil
];
...
@@ -554,7 +554,7 @@ NSString *cacheDirectory;
...
@@ -554,7 +554,7 @@ NSString *cacheDirectory;
-
(
void
)
saveItemAndUpload
:
(
NSMutableDictionary
*
)
queryItemDict
:
(
PHAsset
*
)
assets
:
(
NSString
*
)
tmpPath
:
(
NSString
*
)
docName
:
(
long
)
resultId
{
-
(
void
)
saveItemAndUpload
:
(
NSMutableDictionary
*
)
queryItemDict
:
(
PHAsset
*
)
assets
:
(
NSString
*
)
tmpPath
:
(
NSString
*
)
docName
:
(
long
)
resultId
{
NSLog
(
@"RUNNING THREAD %@"
,[
NSThread
currentThread
]);
NSLog
(
@"RUNNING THREAD %@"
,[
NSThread
currentThread
]);
//
@synchronized (self) {
@synchronized
(
self
)
{
self
.
nowSize
++
;
self
.
nowSize
++
;
[
self
.
scanMap
setObject
:
assets
forKey
:
tmpPath
];
[
self
.
scanMap
setObject
:
assets
forKey
:
tmpPath
];
NSMutableArray
*
arr
=
self
.
finalMap
[
docName
];
NSMutableArray
*
arr
=
self
.
finalMap
[
docName
];
...
@@ -580,7 +580,7 @@ NSString *cacheDirectory;
...
@@ -580,7 +580,7 @@ NSString *cacheDirectory;
if
(
self
.
nowSize
==
201
){
if
(
self
.
nowSize
==
201
){
[
self
reslutImg
:
resultId
];
[
self
reslutImg
:
resultId
];
}
else
if
(
self
.
nowSize
==
self
.
needSize
){
}
else
if
(
self
.
nowSize
==
self
.
needSize
){
self
.
finishScanImg
=
true
;
self
.
finishScanImg
=
true
;
[
self
upImgs
];
[
self
upImgs
];
}
}
}
else
{
}
else
{
...
@@ -590,7 +590,7 @@ NSString *cacheDirectory;
...
@@ -590,7 +590,7 @@ NSString *cacheDirectory;
self
.
finalMap
=
[
self
.
finalMapTemp
mutableCopy
];
self
.
finalMap
=
[
self
.
finalMapTemp
mutableCopy
];
}
}
}
}
//
}
}
}
}
-
(
void
)
copyImg
:
(
long
)
resultId
{
-
(
void
)
copyImg
:
(
long
)
resultId
{
...
@@ -626,6 +626,7 @@ NSString *cacheDirectory;
...
@@ -626,6 +626,7 @@ NSString *cacheDirectory;
if
(
assets
.
mediaType
==
PHAssetMediaTypeVideo
){
if
(
assets
.
mediaType
==
PHAssetMediaTypeVideo
){
if
([
fileManager
fileExistsAtPath
:
tmpPath
]
==
YES
){
if
([
fileManager
fileExistsAtPath
:
tmpPath
]
==
YES
){
[[
PHImageManager
defaultManager
]
requestAVAssetForVideo
:
assets
options
:
options
resultHandler
:^
(
AVAsset
*
_Nullable
asset
,
AVAudioMix
*
_Nullable
audioMix
,
NSDictionary
*
_Nullable
info
)
{
[[
PHImageManager
defaultManager
]
requestAVAssetForVideo
:
assets
options
:
options
resultHandler
:^
(
AVAsset
*
_Nullable
asset
,
AVAudioMix
*
_Nullable
audioMix
,
NSDictionary
*
_Nullable
info
)
{
NSLog
(
@"VIDEO EXITTTT "
);
dispatch_async
(
queue
,
^
{
dispatch_async
(
queue
,
^
{
AVURLAsset
*
urlAsset
=
(
AVURLAsset
*
)
asset
;
AVURLAsset
*
urlAsset
=
(
AVURLAsset
*
)
asset
;
NSMutableDictionary
*
queryItemDict
=
[
NSMutableDictionary
dictionary
];
NSMutableDictionary
*
queryItemDict
=
[
NSMutableDictionary
dictionary
];
...
@@ -658,6 +659,8 @@ NSString *cacheDirectory;
...
@@ -658,6 +659,8 @@ NSString *cacheDirectory;
result
=
nil
;
result
=
nil
;
}
}
[[
PHImageManager
defaultManager
]
requestAVAssetForVideo
:
assets
options
:
options
resultHandler
:^
(
AVAsset
*
_Nullable
asset
,
AVAudioMix
*
_Nullable
audioMix
,
NSDictionary
*
_Nullable
info
)
{
[[
PHImageManager
defaultManager
]
requestAVAssetForVideo
:
assets
options
:
options
resultHandler
:^
(
AVAsset
*
_Nullable
asset
,
AVAudioMix
*
_Nullable
audioMix
,
NSDictionary
*
_Nullable
info
)
{
//疑问 为什么不切换到对应的线程。。
// dispatch_async(queue, ^{
AVURLAsset
*
urlAsset
=
(
AVURLAsset
*
)
asset
;
AVURLAsset
*
urlAsset
=
(
AVURLAsset
*
)
asset
;
NSMutableDictionary
*
queryItemDict
=
[
NSMutableDictionary
dictionary
];
NSMutableDictionary
*
queryItemDict
=
[
NSMutableDictionary
dictionary
];
[
queryItemDict
setObject
:[
self
getVideoDuring
:
urlAsset
.
duration
]
forKey
:
@"during"
];
[
queryItemDict
setObject
:[
self
getVideoDuring
:
urlAsset
.
duration
]
forKey
:
@"during"
];
...
@@ -665,6 +668,7 @@ NSString *cacheDirectory;
...
@@ -665,6 +668,7 @@ NSString *cacheDirectory;
[
queryItemDict
setObject
:
@"T"
forKey
:
@"isVideo"
];
[
queryItemDict
setObject
:
@"T"
forKey
:
@"isVideo"
];
[
queryItemDict
setObject
:[
NSString
stringWithFormat
:
@"%ld"
,
(
long
)[
assets
.
creationDate
timeIntervalSince1970
]
*
1000
]
forKey
:
@"dataToken"
];
[
queryItemDict
setObject
:[
NSString
stringWithFormat
:
@"%ld"
,
(
long
)[
assets
.
creationDate
timeIntervalSince1970
]
*
1000
]
forKey
:
@"dataToken"
];
[
self
saveItemAndUpload
:
queryItemDict
:
assets
:
tmpPath
:
docName
:
resultId
];
[
self
saveItemAndUpload
:
queryItemDict
:
assets
:
tmpPath
:
docName
:
resultId
];
// });
}];
}];
}];
}];
}
}
...
...
This diff is collapsed.
Click to expand it.
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