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
9e406c65
Commit
9e406c65
authored
Nov 01, 2019
by
林生雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
c8220c04
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
121 additions
and
100 deletions
+121
-100
workspace.xml
.idea/workspace.xml
+25
-17
GengmeiFlutterPlugin.m
ios/Classes/GengmeiFlutterPlugin.m
+96
-83
No files found.
.idea/workspace.xml
View file @
9e406c65
...
@@ -6,6 +6,9 @@
...
@@ -6,6 +6,9 @@
</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$/example/ios/.symlinks/plugins/gengmei_flutter_plugin/ios/Classes/GengmeiFlutterPlugin.m"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/example/ios/.symlinks/plugins/gengmei_flutter_plugin/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"
/>
<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/"
/>
...
@@ -55,7 +58,7 @@
...
@@ -55,7 +58,7 @@
</provider>
</provider>
</entry>
</entry>
</file>
</file>
<file
pinned=
"false"
current-in-tab=
"
fals
e"
>
<file
pinned=
"false"
current-in-tab=
"
tru
e"
>
<entry
file=
"file://$PROJECT_DIR$/lib/ScanImagePlugn.dart"
>
<entry
file=
"file://$PROJECT_DIR$/lib/ScanImagePlugn.dart"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"352"
>
<state
relative-caret-position=
"352"
>
...
@@ -67,10 +70,10 @@
...
@@ -67,10 +70,10 @@
</provider>
</provider>
</entry>
</entry>
</file>
</file>
<file
pinned=
"false"
current-in-tab=
"
tru
e"
>
<file
pinned=
"false"
current-in-tab=
"
fals
e"
>
<entry
file=
"file://$PROJECT_DIR$/lib/gengmei_flutter_plugin.dart"
>
<entry
file=
"file://$PROJECT_DIR$/lib/gengmei_flutter_plugin.dart"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"
95
"
>
<state
relative-caret-position=
"
572
"
>
<caret
line=
"26"
column=
"41"
selection-start-line=
"26"
selection-start-column=
"41"
selection-end-line=
"26"
selection-end-column=
"41"
/>
<caret
line=
"26"
column=
"41"
selection-start-line=
"26"
selection-start-column=
"41"
selection-end-line=
"26"
selection-end-column=
"41"
/>
<folding>
<folding>
<element
signature=
"e#0#20#0"
expanded=
"true"
/>
<element
signature=
"e#0#20#0"
expanded=
"true"
/>
...
@@ -103,8 +106,8 @@
...
@@ -103,8 +106,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=
"116
38
"
>
<state
relative-caret-position=
"116
16
"
>
<caret
line=
"5
50"
column=
"22"
selection-start-line=
"550"
selection-start-column=
"22"
selection-end-line=
"550
"
selection-end-column=
"22"
/>
<caret
line=
"5
49"
column=
"22"
selection-start-line=
"549"
selection-start-column=
"22"
selection-end-line=
"549
"
selection-end-column=
"22"
/>
</state>
</state>
</provider>
</provider>
</entry>
</entry>
...
@@ -248,6 +251,11 @@
...
@@ -248,6 +251,11 @@
<item
name=
"AlbumModel"
type=
"462c0819:PsiDirectoryNode"
/>
<item
name=
"AlbumModel"
type=
"462c0819:PsiDirectoryNode"
/>
<item
name=
"repository"
type=
"462c0819:PsiDirectoryNode"
/>
<item
name=
"repository"
type=
"462c0819:PsiDirectoryNode"
/>
</path>
</path>
<path>
<item
name=
"gengmei_flutter_plugin"
type=
"b2602c69:ProjectViewProjectNode"
/>
<item
name=
"gengmei_flutter_plugin"
type=
"462c0819:PsiDirectoryNode"
/>
<item
name=
"lib"
type=
"462c0819:PsiDirectoryNode"
/>
</path>
</expand>
</expand>
<select
/>
<select
/>
</subPane>
</subPane>
...
@@ -299,7 +307,7 @@
...
@@ -299,7 +307,7 @@
<component
name=
"ToolWindowManager"
>
<component
name=
"ToolWindowManager"
>
<frame
x=
"9"
y=
"23"
width=
"1440"
height=
"811"
extended-state=
"6"
/>
<frame
x=
"9"
y=
"23"
width=
"1440"
height=
"811"
extended-state=
"6"
/>
<layout>
<layout>
<window_info
content_ui=
"combo"
id=
"Project"
order=
"0"
visible=
"true"
weight=
"0.19742489"
/>
<window_info
active=
"true"
content_ui=
"combo"
id=
"Project"
order=
"0"
visible=
"true"
weight=
"0.19742489"
/>
<window_info
id=
"Captures"
order=
"1"
side_tool=
"true"
/>
<window_info
id=
"Captures"
order=
"1"
side_tool=
"true"
/>
<window_info
id=
"Structure"
order=
"2"
side_tool=
"true"
/>
<window_info
id=
"Structure"
order=
"2"
side_tool=
"true"
/>
<window_info
id=
"Image Layers"
order=
"3"
/>
<window_info
id=
"Image Layers"
order=
"3"
/>
...
@@ -314,7 +322,7 @@
...
@@ -314,7 +322,7 @@
<window_info
anchor=
"bottom"
id=
"Android Profiler"
order=
"3"
show_stripe_button=
"false"
/>
<window_info
anchor=
"bottom"
id=
"Android Profiler"
order=
"3"
show_stripe_button=
"false"
/>
<window_info
anchor=
"bottom"
id=
"Logcat"
order=
"4"
weight=
"0.4534075"
/>
<window_info
anchor=
"bottom"
id=
"Logcat"
order=
"4"
weight=
"0.4534075"
/>
<window_info
anchor=
"bottom"
id=
"Debug"
order=
"5"
/>
<window_info
anchor=
"bottom"
id=
"Debug"
order=
"5"
/>
<window_info
a
ctive=
"true"
a
nchor=
"bottom"
id=
"Terminal"
order=
"6"
visible=
"true"
weight=
"0.29346314"
/>
<window_info
anchor=
"bottom"
id=
"Terminal"
order=
"6"
visible=
"true"
weight=
"0.29346314"
/>
<window_info
anchor=
"bottom"
id=
"Event Log"
order=
"7"
side_tool=
"true"
/>
<window_info
anchor=
"bottom"
id=
"Event Log"
order=
"7"
side_tool=
"true"
/>
<window_info
anchor=
"bottom"
id=
"Flutter Performance"
order=
"8"
side_tool=
"true"
/>
<window_info
anchor=
"bottom"
id=
"Flutter Performance"
order=
"8"
side_tool=
"true"
/>
<window_info
anchor=
"bottom"
id=
"Version Control"
order=
"9"
/>
<window_info
anchor=
"bottom"
id=
"Version Control"
order=
"9"
/>
...
@@ -526,8 +534,8 @@
...
@@ -526,8 +534,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=
"116
38
"
>
<state
relative-caret-position=
"116
16
"
>
<caret
line=
"5
50"
column=
"22"
selection-start-line=
"550"
selection-start-column=
"22"
selection-end-line=
"550
"
selection-end-column=
"22"
/>
<caret
line=
"5
49"
column=
"22"
selection-start-line=
"549"
selection-start-column=
"22"
selection-end-line=
"549
"
selection-end-column=
"22"
/>
</state>
</state>
</provider>
</provider>
</entry>
</entry>
...
@@ -577,22 +585,22 @@
...
@@ -577,22 +585,22 @@
</state>
</state>
</provider>
</provider>
</entry>
</entry>
<entry
file=
"file://$PROJECT_DIR$/lib/
ScanImagePlug
n.dart"
>
<entry
file=
"file://$PROJECT_DIR$/lib/
gengmei_flutter_plugi
n.dart"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"
35
2"
>
<state
relative-caret-position=
"
57
2"
>
<caret
line=
"
19"
column=
"71"
selection-start-line=
"19"
selection-start-column=
"10"
selection-end-line=
"19"
selection-end-column=
"7
1"
/>
<caret
line=
"
26"
column=
"41"
selection-start-line=
"26"
selection-start-column=
"41"
selection-end-line=
"26"
selection-end-column=
"4
1"
/>
<folding>
<folding>
<element
signature=
"e#
45#86
#0"
expanded=
"true"
/>
<element
signature=
"e#
0#20
#0"
expanded=
"true"
/>
</folding>
</folding>
</state>
</state>
</provider>
</provider>
</entry>
</entry>
<entry
file=
"file://$PROJECT_DIR$/lib/
gengmei_flutter_plugi
n.dart"
>
<entry
file=
"file://$PROJECT_DIR$/lib/
ScanImagePlug
n.dart"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"
95
"
>
<state
relative-caret-position=
"
352
"
>
<caret
line=
"
26"
column=
"41"
selection-start-line=
"26"
selection-start-column=
"41"
selection-end-line=
"26"
selection-end-column=
"4
1"
/>
<caret
line=
"
19"
column=
"71"
selection-start-line=
"19"
selection-start-column=
"10"
selection-end-line=
"19"
selection-end-column=
"7
1"
/>
<folding>
<folding>
<element
signature=
"e#
0#20
#0"
expanded=
"true"
/>
<element
signature=
"e#
45#86
#0"
expanded=
"true"
/>
</folding>
</folding>
</state>
</state>
</provider>
</provider>
...
...
ios/Classes/GengmeiFlutterPlugin.m
View file @
9e406c65
...
@@ -465,12 +465,6 @@ CFAbsoluteTime startTime;
...
@@ -465,12 +465,6 @@ CFAbsoluteTime startTime;
[
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
{
{
...
@@ -547,6 +541,7 @@ CFAbsoluteTime startTime;
...
@@ -547,6 +541,7 @@ CFAbsoluteTime startTime;
-
(
void
)
upImgs
{
-
(
void
)
upImgs
{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
if
(
_eventSink
!=
nil
&&!
self
.
quitPage
){
if
(
_eventSink
!=
nil
&&!
self
.
quitPage
){
NSLog
(
@"LSY=====>>>> UP IMG"
);
_eventSink
(
self
.
finalMap
);
_eventSink
(
self
.
finalMap
);
}
}
});
});
...
@@ -555,51 +550,67 @@ CFAbsoluteTime startTime;
...
@@ -555,51 +550,67 @@ CFAbsoluteTime startTime;
-
(
void
)
reslutImg
:
(
long
)
resultId
{
-
(
void
)
reslutImg
:
(
long
)
resultId
{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
if
(
!
self
.
quitPage
){
if
(
!
self
.
quitPage
){
NSLog
(
@"LSY=====>>>> RESULT IMG"
);
[[
ResultManager
sharedSingleton
]
resultSuccess
:[
NSNumber
numberWithLong
:
resultId
]
:
self
.
finalMapTemp
];
[[
ResultManager
sharedSingleton
]
resultSuccess
:[
NSNumber
numberWithLong
:
resultId
]
:
self
.
finalMapTemp
];
}
}
});
});
}
}
-
(
void
)
reslutImgFinalMap
:
(
long
)
resultId
{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
if
(
!
self
.
quitPage
){
NSLog
(
@"LSY=====>>>> RESULT IMG"
);
[[
ResultManager
sharedSingleton
]
resultSuccess
:[
NSNumber
numberWithLong
:
resultId
]
:
self
.
finalMap
];
}
});
}
-
(
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
]);
self
.
nowSize
++
;
NSLog
(
@"SCARE SIZEEE %d %d %d"
,
self
.
nowSize
,
self
.
copySize
,
self
.
needSize
);
[
self
.
scanMap
setObject
:
assets
forKey
:
tmpPath
];
@synchronized
(
self
)
{
NSMutableArray
*
arr
=
self
.
finalMap
[
docName
];
self
.
nowSize
++
;
if
(
arr
==
nil
)
{
[
self
.
scanMap
setObject
:
assets
forKey
:
tmpPath
];
self
.
finalMap
[
docName
]
=
[
NSMutableArray
array
];
NSMutableArray
*
arr
=
self
.
finalMap
[
docName
];
[
self
.
finalMap
[
docName
]
addObject
:
queryItemDict
];
if
(
arr
==
nil
)
{
}
else
{
self
.
finalMap
[
docName
]
=
[
NSMutableArray
array
];
[
self
.
finalMap
[
docName
]
addObject
:
queryItemDict
];
[
self
.
finalMap
[
docName
]
addObject
:
queryItemDict
];
}
}
else
{
[
self
.
finalMap
[
@"IsGengmeiAlbumAllImages"
]
addObject
:
queryItemDict
];
[
self
.
finalMap
[
docName
]
addObject
:
queryItemDict
];
NSLog
(
@"SCARE SIZEEE %d %d "
,
self
.
nowSize
,
self
.
needSize
);
if
(
self
.
needSize
>
200
){
if
(
self
.
nowSize
<=
201
){
NSMutableArray
*
arr
=
self
.
finalMapTemp
[
docName
];
if
(
arr
==
nil
)
{
self
.
finalMapTemp
[
docName
]
=
[
NSMutableArray
array
];
[
self
.
finalMapTemp
[
docName
]
addObject
:
queryItemDict
];
}
else
{
[
self
.
finalMapTemp
[
docName
]
addObject
:
queryItemDict
];
}
[
self
.
finalMapTemp
[
@"IsGengmeiAlbumAllImages"
]
insertObject
:
queryItemDict
atIndex
:
self
.
nowSize
-
1
];
}
if
(
self
.
nowSize
==
201
){
[
self
reslutImg
:
resultId
];
}
else
if
(
self
.
nowSize
==
self
.
needSize
){
self
.
finishScanImg
=
true
;
CFAbsoluteTime
linkTime
=
(
CFAbsoluteTimeGetCurrent
()
-
startTime
);
NSLog
(
@"IOS COPY IMAGE 时间:%f ms"
,
linkTime
*
1000
.
0
);
[
self
upImgs
];
}
}
}
else
{
[
self
.
finalMap
[
@"IsGengmeiAlbumAllImages"
]
addObject
:
queryItemDict
];
if
(
self
.
nowSize
==
self
.
needSize
)
{
if
(
self
.
needSize
>
200
){
self
.
finishScanImg
=
true
;
if
(
self
.
copySize
<=
201
){
CFAbsoluteTime
linkTime
=
(
CFAbsoluteTimeGetCurrent
()
-
startTime
);
NSMutableArray
*
arr
=
self
.
finalMapTemp
[
docName
];
NSLog
(
@"IOS COPY IMAGE 时间:%f ms"
,
linkTime
*
1000
.
0
);
if
(
arr
==
nil
)
{
[
self
reslutImg
:
resultId
];
self
.
finalMapTemp
[
docName
]
=
[
NSMutableArray
array
];
self
.
finalMap
=
[
self
.
finalMapTemp
mutableCopy
];
[
self
.
finalMapTemp
[
docName
]
addObject
:
queryItemDict
];
}
else
{
[
self
.
finalMapTemp
[
docName
]
addObject
:
queryItemDict
];
}
[
self
.
finalMapTemp
[
@"IsGengmeiAlbumAllImages"
]
insertObject
:
queryItemDict
atIndex
:
self
.
nowSize
-
1
];
}
if
(
self
.
copySize
==
201
){
[
self
reslutImg
:
resultId
];
}
else
if
(
self
.
nowSize
==
self
.
needSize
){
self
.
finishScanImg
=
true
;
CFAbsoluteTime
linkTime
=
(
CFAbsoluteTimeGetCurrent
()
-
startTime
);
NSLog
(
@"IOS COPY IMAGE 时间:%f ms"
,
linkTime
*
1000
.
0
);
if
(
self
.
copySize
<
210
){
[
self
reslutImgFinalMap
:
resultId
];
}
else
{
[
self
upImgs
];
}
}
}
else
{
if
(
self
.
nowSize
==
self
.
needSize
)
{
self
.
finishScanImg
=
true
;
CFAbsoluteTime
linkTime
=
(
CFAbsoluteTimeGetCurrent
()
-
startTime
);
NSLog
(
@"IOS COPY IMAGE 时间:%f ms"
,
linkTime
*
1000
.
0
);
[
self
reslutImg
:
resultId
];
self
.
finalMap
=
[
self
.
finalMapTemp
mutableCopy
];
}
}
}
}
}
}
}
...
@@ -614,8 +625,8 @@ CFAbsoluteTime startTime;
...
@@ -614,8 +625,8 @@ 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
;
}
}
}
}
NSMutableDictionary
*
queryItemDict
=
[
NSMutableDictionary
dictionary
];
NSMutableDictionary
*
queryItemDict
=
[
NSMutableDictionary
dictionary
];
...
@@ -638,10 +649,10 @@ CFAbsoluteTime startTime;
...
@@ -638,10 +649,10 @@ CFAbsoluteTime startTime;
// imageRequestOption.deliveryMode=PHImageRequestOptionsDeliveryModeFastFormat;
// imageRequestOption.deliveryMode=PHImageRequestOptionsDeliveryModeFastFormat;
imageRequestOption
.
resizeMode
=
PHImageRequestOptionsResizeModeFast
;
imageRequestOption
.
resizeMode
=
PHImageRequestOptionsResizeModeFast
;
imageRequestOption
.
version
=
PHImageRequestOptionsVersionUnadjusted
;
//PHImageManagerMaximumSize
imageRequestOption
.
version
=
PHImageRequestOptionsVersionUnadjusted
;
//PHImageManagerMaximumSize
PHVideoRequestOptions
*
options
=
[[
PHVideoRequestOptions
alloc
]
init
];
//
PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
options
.
version
=
PHImageRequestOptionsVersionCurrent
;
//
options.version = PHImageRequestOptionsVersionCurrent;
options
.
networkAccessAllowed
=
true
;
//
options.networkAccessAllowed = true;
options
.
deliveryMode
=
PHVideoRequestOptionsDeliveryModeAutomatic
;
//
options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic;
NSFileManager
*
fileManager
=
[
NSFileManager
defaultManager
];
NSFileManager
*
fileManager
=
[
NSFileManager
defaultManager
];
for
(
int
j
=
0
;
j
<
assetCollectionList
.
count
;
j
++
)
{
for
(
int
j
=
0
;
j
<
assetCollectionList
.
count
;
j
++
)
{
AlbumItem
*
item
=
assetCollectionList
[
j
];
AlbumItem
*
item
=
assetCollectionList
[
j
];
...
@@ -658,47 +669,48 @@ CFAbsoluteTime startTime;
...
@@ -658,47 +669,48 @@ CFAbsoluteTime startTime;
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) {
AVURLAsset
*
urlAsset
=
(
AVURLAsset
*
)
asset
;
// AVURLAsset *urlAsset = (AVURLAsset *)asset;
NSString
*
during
=
[
NSString
stringWithFormat
:
@"%i"
,(
int
)(
assets
.
duration
*
1000
)];
NSMutableDictionary
*
queryItemDict
=
[
NSMutableDictionary
dictionary
];
[
queryItemDict
setObject
:
during
forKey
:
@"during"
];
[
queryItemDict
setObject
:
tmpPath
forKey
:
@"path"
];
[
queryItemDict
setObject
:
@"T"
forKey
:
@"isVideo"
];
[
queryItemDict
setObject
:[
NSString
stringWithFormat
:
@"%ld"
,
(
long
)[
assets
.
creationDate
timeIntervalSince1970
]
*
1000
]
forKey
:
@"dataToken"
];
[
self
saveItemAndUpload
:
queryItemDict
:
assets
:
tmpPath
:
docName
:
resultId
];
// }];
}
else
{
int
picWidth
=
[
assets
pixelWidth
];
int
picHeight
=
[
assets
pixelHeight
];
float
tempScareSize
=
1
;
if
(
picWidth
>
picHeight
){
if
(
picWidth
>
320
.
0
)
{
tempScareSize
=
320
.
0
/
picWidth
;
}
}
else
{
if
(
picHeight
>
320
.
0
)
{
tempScareSize
=
320
.
0
/
picHeight
;
}
}
CGSize
temp
=
CGSizeMake
(
picWidth
*
tempScareSize
,
picHeight
*
tempScareSize
);
[[
PHImageManager
defaultManager
]
requestImageForAsset
:
assets
targetSize
:
temp
contentMode
:
PHImageContentModeDefault
options
:
imageRequestOption
resultHandler
:^
(
UIImage
*
_Nullable
result
,
NSDictionary
*
_Nullable
info
)
{
self
.
copySize
++
;
@autoreleasepool
{
NSData
*
data
=
UIImageJPEGRepresentation
(
result
,
0
.
8
)
;
[
data
writeToFile
:
tmpPath
atomically
:
YES
];
data
=
nil
;
result
=
nil
;
}
NSString
*
during
=
[
NSString
stringWithFormat
:
@"%i"
,(
int
)(
assets
.
duration
*
1000
)];
NSLog
(
@"DDDduring %@"
,
during
);
NSMutableDictionary
*
queryItemDict
=
[
NSMutableDictionary
dictionary
];
NSMutableDictionary
*
queryItemDict
=
[
NSMutableDictionary
dictionary
];
[
queryItemDict
setObject
:
[
self
getVideoDuring
:
urlAsset
.
duration
]
forKey
:
@"during"
];
[
queryItemDict
setObject
:
during
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
];
}];
}];
}
else
{
[[
PHImageManager
defaultManager
]
requestAVAssetForVideo
:
assets
options
:
options
resultHandler
:^
(
AVAsset
*
_Nullable
asset
,
AVAudioMix
*
_Nullable
audioMix
,
NSDictionary
*
_Nullable
info
)
{
int
picWidth
=
[
assets
pixelWidth
];
int
picHeight
=
[
assets
pixelHeight
];
float
tempScareSize
=
1
;
if
(
picWidth
>
picHeight
){
if
(
picWidth
>
320
.
0
)
{
tempScareSize
=
320
.
0
/
picWidth
;
}
}
else
{
if
(
picHeight
>
320
.
0
)
{
tempScareSize
=
320
.
0
/
picHeight
;
}
}
CGSize
temp
=
CGSizeMake
(
picWidth
*
tempScareSize
,
picHeight
*
tempScareSize
);
[[
PHImageManager
defaultManager
]
requestImageForAsset
:
assets
targetSize
:
temp
contentMode
:
PHImageContentModeDefault
options
:
imageRequestOption
resultHandler
:^
(
UIImage
*
_Nullable
result
,
NSDictionary
*
_Nullable
info
)
{
@autoreleasepool
{
NSData
*
data
=
UIImageJPEGRepresentation
(
result
,
0
.
8
)
;
[
data
writeToFile
:
tmpPath
atomically
:
YES
];
data
=
nil
;
result
=
nil
;
}
AVURLAsset
*
urlAsset
=
(
AVURLAsset
*
)
asset
;
NSMutableDictionary
*
queryItemDict
=
[
NSMutableDictionary
dictionary
];
[
queryItemDict
setObject
:[
self
getVideoDuring
:
urlAsset
.
duration
]
forKey
:
@"during"
];
[
queryItemDict
setObject
:
tmpPath
forKey
:
@"path"
];
[
queryItemDict
setObject
:
@"T"
forKey
:
@"isVideo"
];
[
queryItemDict
setObject
:[
NSString
stringWithFormat
:
@"%ld"
,
(
long
)[
assets
.
creationDate
timeIntervalSince1970
]
*
1000
]
forKey
:
@"dataToken"
];
[
self
saveItemAndUpload
:
queryItemDict
:
assets
:
tmpPath
:
docName
:
resultId
];
}];
}];
}
}
}
else
{
}
else
{
if
([
fileManager
fileExistsAtPath
:
tmpPath
]
==
YES
){
if
([
fileManager
fileExistsAtPath
:
tmpPath
]
==
YES
){
...
@@ -722,6 +734,7 @@ CFAbsoluteTime startTime;
...
@@ -722,6 +734,7 @@ CFAbsoluteTime startTime;
}
}
CGSize
temp
=
CGSizeMake
(
picWidth
*
tempScareSize
,
picHeight
*
tempScareSize
);
CGSize
temp
=
CGSizeMake
(
picWidth
*
tempScareSize
,
picHeight
*
tempScareSize
);
[[
PHImageManager
defaultManager
]
requestImageForAsset
:
assets
targetSize
:
temp
contentMode
:
PHImageContentModeDefault
options
:
imageRequestOption
resultHandler
:^
(
UIImage
*
_Nullable
result
,
NSDictionary
*
_Nullable
info
)
{
[[
PHImageManager
defaultManager
]
requestImageForAsset
:
assets
targetSize
:
temp
contentMode
:
PHImageContentModeDefault
options
:
imageRequestOption
resultHandler
:^
(
UIImage
*
_Nullable
result
,
NSDictionary
*
_Nullable
info
)
{
self
.
copySize
++
;
@autoreleasepool
{
@autoreleasepool
{
NSData
*
data
=
UIImageJPEGRepresentation
(
result
,
0
.
8
)
;
NSData
*
data
=
UIImageJPEGRepresentation
(
result
,
0
.
8
)
;
[
data
writeToFile
:
tmpPath
atomically
:
YES
];
[
data
writeToFile
:
tmpPath
atomically
:
YES
];
...
...
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