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
c8220c04
Commit
c8220c04
authored
Oct 31, 2019
by
林生雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
d502a751
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
33 deletions
+55
-33
workspace.xml
.idea/workspace.xml
+4
-6
GengmeiFlutterPlugin.m
ios/Classes/GengmeiFlutterPlugin.m
+51
-27
No files found.
.idea/workspace.xml
View file @
c8220c04
...
@@ -6,8 +6,6 @@
...
@@ -6,8 +6,6 @@
</component>
</component>
<component
name=
"ChangeListManager"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"5be6bbb5-7d6e-4540-a24f-d2b3bf78b3ba"
name=
"Default Changelist"
comment=
""
>
<list
default=
"true"
id=
"5be6bbb5-7d6e-4540-a24f-d2b3bf78b3ba"
name=
"Default Changelist"
comment=
""
>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/example/ios/.symlinks/plugins/gengmei_flutter_plugin/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/example/ios/.symlinks/plugins/gengmei_flutter_plugin/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/ios/Classes/GengmeiFlutterPlugin.m"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/ios/Classes/GengmeiFlutterPlugin.m"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/ios/Classes/GengmeiFlutterPlugin.m"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/ios/Classes/GengmeiFlutterPlugin.m"
afterDir=
"false"
/>
</list>
</list>
<ignored
path=
"$PROJECT_DIR$/.dart_tool/"
/>
<ignored
path=
"$PROJECT_DIR$/.dart_tool/"
/>
...
@@ -105,8 +103,8 @@
...
@@ -105,8 +103,8 @@
<file
pinned=
"false"
current-in-tab=
"false"
>
<file
pinned=
"false"
current-in-tab=
"false"
>
<entry
file=
"file://$PROJECT_DIR$/ios/Classes/GengmeiFlutterPlugin.m"
>
<entry
file=
"file://$PROJECT_DIR$/ios/Classes/GengmeiFlutterPlugin.m"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"11
41
8"
>
<state
relative-caret-position=
"11
63
8"
>
<caret
line=
"5
40"
column=
"22"
selection-start-line=
"540"
selection-start-column=
"22"
selection-end-line=
"54
0"
selection-end-column=
"22"
/>
<caret
line=
"5
50"
column=
"22"
selection-start-line=
"550"
selection-start-column=
"22"
selection-end-line=
"55
0"
selection-end-column=
"22"
/>
</state>
</state>
</provider>
</provider>
</entry>
</entry>
...
@@ -528,8 +526,8 @@
...
@@ -528,8 +526,8 @@
</entry>
</entry>
<entry
file=
"file://$PROJECT_DIR$/ios/Classes/GengmeiFlutterPlugin.m"
>
<entry
file=
"file://$PROJECT_DIR$/ios/Classes/GengmeiFlutterPlugin.m"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"11
41
8"
>
<state
relative-caret-position=
"11
63
8"
>
<caret
line=
"5
40"
column=
"22"
selection-start-line=
"540"
selection-start-column=
"22"
selection-end-line=
"54
0"
selection-end-column=
"22"
/>
<caret
line=
"5
50"
column=
"22"
selection-start-line=
"550"
selection-start-column=
"22"
selection-end-line=
"55
0"
selection-end-column=
"22"
/>
</state>
</state>
</provider>
</provider>
</entry>
</entry>
...
...
ios/Classes/GengmeiFlutterPlugin.m
View file @
c8220c04
...
@@ -43,7 +43,7 @@ NSString *cacheDirectory;
...
@@ -43,7 +43,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"
...
@@ -346,6 +346,8 @@ NSString *cacheDirectory;
...
@@ -346,6 +346,8 @@ NSString *cacheDirectory;
}
}
}
}
-
(
void
)
clearAllUserDefaultsData
{
-
(
void
)
clearAllUserDefaultsData
{
NSUserDefaults
*
userDefaults
=
[
NSUserDefaults
standardUserDefaults
];
NSUserDefaults
*
userDefaults
=
[
NSUserDefaults
standardUserDefaults
];
NSDictionary
*
dic
=
[
userDefaults
dictionaryRepresentation
];
NSDictionary
*
dic
=
[
userDefaults
dictionaryRepresentation
];
...
@@ -457,11 +459,18 @@ CFAbsoluteTime startTime;
...
@@ -457,11 +459,18 @@ CFAbsoluteTime startTime;
self
.
nowSize
=
0
;
self
.
nowSize
=
0
;
self
.
needSize
=
0
;
self
.
needSize
=
0
;
[
assetCollectionList
removeAllObjects
];
[
assetCollectionList
removeAllObjects
];
// [NSThread detachNewThreadSelector:@selector(thread:) toTarget:self withObject:[NSString stringWithFormat:@"%ld",resultId]];
dispatch_async
(
queue
,
^
{
dispatch_async
(
queue
,
^
{
[
self
scanPhoneImage
];
[
self
scanPhoneImage
];
[
self
copyImg
:
resultId
];
[
self
copyImg
:
resultId
];
});
});
}
}
//- (void)thread:(NSString*)resultId {
// long result=[resultId longLongValue];
// [self scanPhoneImage];
// [self copyImg:result];
//}
-
(
void
)
enumerateAssetsInAssetCollection
:(
PHAssetCollection
*
)
assetCollection
original
:(
BOOL
)
original
-
(
void
)
enumerateAssetsInAssetCollection
:(
PHAssetCollection
*
)
assetCollection
original
:(
BOOL
)
original
{
{
...
@@ -593,7 +602,28 @@ CFAbsoluteTime startTime;
...
@@ -593,7 +602,28 @@ CFAbsoluteTime startTime;
self
.
finalMap
=
[
self
.
finalMapTemp
mutableCopy
];
self
.
finalMap
=
[
self
.
finalMapTemp
mutableCopy
];
}
}
}
}
}
-
(
void
)
imageOnThread
:
(
NSMutableDictionary
*
)
dict
{
PHAsset
*
assets
=
dict
[
@"assets"
];
UIImage
*
result
=
dict
[
@"result"
];
NSString
*
tmpPath
=
dict
[
@"tmpPath"
];
NSString
*
docName
=
dict
[
@"docName"
];
long
resultId
=
[
dict
[
@"resultId"
]
longLongValue
];
if
(
result
!=
nil
){
@autoreleasepool
{
NSData
*
data
=
UIImageJPEGRepresentation
(
result
,
0
.
8
)
;
[
data
writeToFile
:
tmpPath
atomically
:
YES
];
// data=nil;
// result=nil;
}
}
NSMutableDictionary
*
queryItemDict
=
[
NSMutableDictionary
dictionary
];
[
queryItemDict
setObject
:
tmpPath
forKey
:
@"path"
];
[
queryItemDict
setObject
:
@"F"
forKey
:
@"isVideo"
];
[
queryItemDict
setObject
:[
NSString
stringWithFormat
:
@"%ld"
,
(
long
)[
assets
.
creationDate
timeIntervalSince1970
]
*
1000
]
forKey
:
@"dataToken"
];
// self.copySize++;
[
self
saveItemAndUpload
:
queryItemDict
:
assets
:
tmpPath
:
docName
:
resultId
];
}
}
-
(
void
)
copyImg
:
(
long
)
resultId
{
-
(
void
)
copyImg
:
(
long
)
resultId
{
...
@@ -617,32 +647,28 @@ CFAbsoluteTime startTime;
...
@@ -617,32 +647,28 @@ CFAbsoluteTime startTime;
AlbumItem
*
item
=
assetCollectionList
[
j
];
AlbumItem
*
item
=
assetCollectionList
[
j
];
PHFetchResult
<
PHAsset
*>
*
assetResult
=
[
item
assets
];
PHFetchResult
<
PHAsset
*>
*
assetResult
=
[
item
assets
];
for
(
int
i
=
0
;
i
<
[
assetResult
count
];
i
++
)
{
for
(
int
i
=
0
;
i
<
[
assetResult
count
];
i
++
)
{
__block
NSString
*
docName
=
[
item
collectionTitle
];
NSString
*
docName
=
[
item
collectionTitle
];
PHAsset
*
assets
=
[
assetResult
objectAtIndex
:
i
];
PHAsset
*
assets
=
[
assetResult
objectAtIndex
:
i
];
__block
NSString
*
imgName
=
[
assets
valueForKey
:
@"filename"
];
NSString
*
imgName
=
[
assets
valueForKey
:
@"filename"
];
if
(
imgName
==
nil
)
{
if
(
imgName
==
nil
)
{
NSLog
(
@"NEWWWW!!!!! image name is Null!!! "
);
NSLog
(
@"NEWWWW!!!!! image name is Null!!! "
);
NSString
*
timeSp
=
[
NSString
stringWithFormat
:
@"%ld"
,
(
long
)([[
NSDate
date
]
timeIntervalSince1970
]
*
100000
)];
NSString
*
timeSp
=
[
NSString
stringWithFormat
:
@"%ld"
,
(
long
)([[
NSDate
date
]
timeIntervalSince1970
]
*
100000
)];
imgName
=
[
NSString
stringWithFormat
:
@"IMG_%@"
,
timeSp
];
imgName
=
[
NSString
stringWithFormat
:
@"IMG_%@"
,
timeSp
];
}
}
__block
NSString
*
tmpPath
=
[
cacheDirectory
stringByAppendingPathComponent
:
imgName
];
NSString
*
tmpPath
=
[
cacheDirectory
stringByAppendingPathComponent
:
imgName
];
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 "
);
AVURLAsset
*
urlAsset
=
(
AVURLAsset
*
)
asset
;
dispatch_async
(
queue
,
^
{
NSMutableDictionary
*
queryItemDict
=
[
NSMutableDictionary
dictionary
];
AVURLAsset
*
urlAsset
=
(
AVURLAsset
*
)
asset
;
[
queryItemDict
setObject
:[
self
getVideoDuring
:
urlAsset
.
duration
]
forKey
:
@"during"
];
NSMutableDictionary
*
queryItemDict
=
[
NSMutableDictionary
dictionary
];
[
queryItemDict
setObject
:
tmpPath
forKey
:
@"path"
];
[
queryItemDict
setObject
:[
self
getVideoDuring
:
urlAsset
.
duration
]
forKey
:
@"during"
];
[
queryItemDict
setObject
:
@"T"
forKey
:
@"isVideo"
];
[
queryItemDict
setObject
:
tmpPath
forKey
:
@"path"
];
[
queryItemDict
setObject
:[
NSString
stringWithFormat
:
@"%ld"
,
(
long
)[
assets
.
creationDate
timeIntervalSince1970
]
*
1000
]
forKey
:
@"dataToken"
];
[
queryItemDict
setObject
:
@"T"
forKey
:
@"isVideo"
];
[
self
saveItemAndUpload
:
queryItemDict
:
assets
:
tmpPath
:
docName
:
resultId
];
[
queryItemDict
setObject
:[
NSString
stringWithFormat
:
@"%ld"
,
(
long
)[
assets
.
creationDate
timeIntervalSince1970
]
*
1000
]
forKey
:
@"dataToken"
];
[
self
saveItemAndUpload
:
queryItemDict
:
assets
:
tmpPath
:
docName
:
resultId
];
});
}];
}];
}
else
{
}
else
{
[[
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
)
{
//疑问 为什么不切换到对应的线程。。
int
picWidth
=
[
assets
pixelWidth
];
int
picWidth
=
[
assets
pixelWidth
];
int
picHeight
=
[
assets
pixelHeight
];
int
picHeight
=
[
assets
pixelHeight
];
float
tempScareSize
=
1
;
float
tempScareSize
=
1
;
...
@@ -660,18 +686,16 @@ CFAbsoluteTime startTime;
...
@@ -660,18 +686,16 @@ CFAbsoluteTime startTime;
@autoreleasepool
{
@autoreleasepool
{
NSData
*
data
=
UIImageJPEGRepresentation
(
result
,
0
.
8
)
;
NSData
*
data
=
UIImageJPEGRepresentation
(
result
,
0
.
8
)
;
[
data
writeToFile
:
tmpPath
atomically
:
YES
];
[
data
writeToFile
:
tmpPath
atomically
:
YES
];
//
data=nil;
data
=
nil
;
//
result=nil;
result
=
nil
;
}
}
dispatch_sync
(
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"
];
[
queryItemDict
setObject
:
tmpPath
forKey
:
@"path"
];
[
queryItemDict
setObject
:
tmpPath
forKey
:
@"path"
];
[
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
];
});
}];
}];
}];
}];
...
...
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