Commit 9e406c65 authored by 林生雨's avatar 林生雨

commit

parent c8220c04
......@@ -6,6 +6,9 @@
</component>
<component name="ChangeListManager">
<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" />
</list>
<ignored path="$PROJECT_DIR$/.dart_tool/" />
......@@ -55,7 +58,7 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/lib/ScanImagePlugn.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="352">
......@@ -67,10 +70,10 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/gengmei_flutter_plugin.dart">
<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" />
<folding>
<element signature="e#0#20#0" expanded="true" />
......@@ -103,8 +106,8 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/ios/Classes/GengmeiFlutterPlugin.m">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="11638">
<caret line="550" column="22" selection-start-line="550" selection-start-column="22" selection-end-line="550" selection-end-column="22" />
<state relative-caret-position="11616">
<caret line="549" column="22" selection-start-line="549" selection-start-column="22" selection-end-line="549" selection-end-column="22" />
</state>
</provider>
</entry>
......@@ -248,6 +251,11 @@
<item name="AlbumModel" type="462c0819:PsiDirectoryNode" />
<item name="repository" type="462c0819:PsiDirectoryNode" />
</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>
<select />
</subPane>
......@@ -299,7 +307,7 @@
<component name="ToolWindowManager">
<frame x="9" y="23" width="1440" height="811" extended-state="6" />
<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="Structure" order="2" side_tool="true" />
<window_info id="Image Layers" order="3" />
......@@ -314,7 +322,7 @@
<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="Debug" order="5" />
<window_info active="true" anchor="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="Flutter Performance" order="8" side_tool="true" />
<window_info anchor="bottom" id="Version Control" order="9" />
......@@ -526,8 +534,8 @@
</entry>
<entry file="file://$PROJECT_DIR$/ios/Classes/GengmeiFlutterPlugin.m">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="11638">
<caret line="550" column="22" selection-start-line="550" selection-start-column="22" selection-end-line="550" selection-end-column="22" />
<state relative-caret-position="11616">
<caret line="549" column="22" selection-start-line="549" selection-start-column="22" selection-end-line="549" selection-end-column="22" />
</state>
</provider>
</entry>
......@@ -577,22 +585,22 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/ScanImagePlugn.dart">
<entry file="file://$PROJECT_DIR$/lib/gengmei_flutter_plugin.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="352">
<caret line="19" column="71" selection-start-line="19" selection-start-column="10" selection-end-line="19" selection-end-column="71" />
<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" />
<folding>
<element signature="e#45#86#0" expanded="true" />
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/gengmei_flutter_plugin.dart">
<entry file="file://$PROJECT_DIR$/lib/ScanImagePlugn.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="95">
<caret line="26" column="41" selection-start-line="26" selection-start-column="41" selection-end-line="26" selection-end-column="41" />
<state relative-caret-position="352">
<caret line="19" column="71" selection-start-line="19" selection-start-column="10" selection-end-line="19" selection-end-column="71" />
<folding>
<element signature="e#0#20#0" expanded="true" />
<element signature="e#45#86#0" expanded="true" />
</folding>
</state>
</provider>
......
......@@ -465,12 +465,6 @@ CFAbsoluteTime startTime;
[self copyImg:resultId];
});
}
//- (void)thread:(NSString*)resultId {
// long result=[resultId longLongValue];
// [self scanPhoneImage];
// [self copyImg:result];
//}
- (void)enumerateAssetsInAssetCollection:(PHAssetCollection *)assetCollection original:(BOOL)original
{
......@@ -547,6 +541,7 @@ CFAbsoluteTime startTime;
-(void)upImgs{
dispatch_async(dispatch_get_main_queue(), ^{
if(_eventSink!=nil&&!self.quitPage){
NSLog(@"LSY=====>>>> UP IMG");
_eventSink(self.finalMap);
}
});
......@@ -555,51 +550,67 @@ CFAbsoluteTime startTime;
-(void)reslutImg:(long)resultId{
dispatch_async(dispatch_get_main_queue(), ^{
if(!self.quitPage){
NSLog(@"LSY=====>>>> RESULT IMG");
[[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{
NSLog(@"RUNNING THREAD %@",[NSThread currentThread]);
self.nowSize++;
[self.scanMap setObject:assets forKey:tmpPath];
NSMutableArray * arr=self.finalMap[docName];
if (arr==nil) {
self.finalMap[docName]=[NSMutableArray array];
[self.finalMap[docName] addObject:queryItemDict];
}else{
[self.finalMap[docName] addObject:queryItemDict];
}
[self.finalMap[@"IsGengmeiAlbumAllImages"] 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];
NSLog(@"SCARE SIZEEE %d %d %d",self.nowSize,self.copySize,self.needSize);
@synchronized (self) {
self.nowSize++;
[self.scanMap setObject:assets forKey:tmpPath];
NSMutableArray * arr=self.finalMap[docName];
if (arr==nil) {
self.finalMap[docName]=[NSMutableArray array];
[self.finalMap[docName] addObject:queryItemDict];
}else{
[self.finalMap[docName] addObject:queryItemDict];
}
}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];
[self.finalMap[@"IsGengmeiAlbumAllImages"] addObject:queryItemDict];
if(self.needSize>200){
if(self.copySize<=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.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;
@autoreleasepool{
NSData *data = UIImageJPEGRepresentation(result, 0.8) ;
[data writeToFile:tmpPath atomically:YES];
// data=nil;
// result=nil;
data=nil;
result=nil;
}
}
NSMutableDictionary* queryItemDict = [NSMutableDictionary dictionary];
......@@ -638,10 +649,10 @@ CFAbsoluteTime startTime;
// imageRequestOption.deliveryMode=PHImageRequestOptionsDeliveryModeFastFormat;
imageRequestOption.resizeMode=PHImageRequestOptionsResizeModeFast;
imageRequestOption.version=PHImageRequestOptionsVersionUnadjusted;//PHImageManagerMaximumSize
PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
options.version = PHImageRequestOptionsVersionCurrent;
options.networkAccessAllowed = true;
options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic;
// PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
// options.version = PHImageRequestOptionsVersionCurrent;
// options.networkAccessAllowed = true;
// options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic;
NSFileManager *fileManager = [NSFileManager defaultManager];
for (int j=0; j<assetCollectionList.count; j++) {
AlbumItem * item=assetCollectionList[j];
......@@ -658,47 +669,48 @@ CFAbsoluteTime startTime;
NSString *tmpPath=[cacheDirectory stringByAppendingPathComponent:imgName];
if(assets.mediaType==PHAssetMediaTypeVideo){
if ([fileManager fileExistsAtPath:tmpPath]==YES){
[[PHImageManager defaultManager]requestAVAssetForVideo:assets options:options resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) {
AVURLAsset *urlAsset = (AVURLAsset *)asset;
// [[PHImageManager defaultManager]requestAVAssetForVideo:assets options:options resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) {
// 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];
[queryItemDict setObject:[self getVideoDuring:urlAsset.duration] forKey:@"during"];
[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{
[[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{
if ([fileManager fileExistsAtPath:tmpPath]==YES){
......@@ -722,6 +734,7 @@ CFAbsoluteTime startTime;
}
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];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment