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

commit

parent cb37d7ce
......@@ -5,7 +5,9 @@
<option name="TOOL_WINDOW_CONFIGURED_FILTER" value="Show only selected application" />
</component>
<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$/ios/Classes/GengmeiFlutterPlugin.m" beforeDir="false" afterPath="$PROJECT_DIR$/ios/Classes/GengmeiFlutterPlugin.m" afterDir="false" />
</list>
<ignored path="$PROJECT_DIR$/.dart_tool/" />
<ignored path="$PROJECT_DIR$/.idea/" />
<ignored path="$PROJECT_DIR$/.pub/" />
......@@ -103,7 +105,7 @@
<entry file="file://$PROJECT_DIR$/ios/Classes/GengmeiFlutterPlugin.m">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="10516">
<caret line="508" column="22" selection-start-line="508" selection-start-column="22" selection-end-line="508" selection-end-column="22" />
<caret line="507" column="22" selection-start-line="507" selection-start-column="22" selection-end-line="507" selection-end-column="22" />
</state>
</provider>
</entry>
......@@ -550,7 +552,7 @@
<entry file="file://$PROJECT_DIR$/ios/Classes/GengmeiFlutterPlugin.m">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="10516">
<caret line="508" column="22" selection-start-line="508" selection-start-column="22" selection-end-line="508" selection-end-column="22" />
<caret line="507" column="22" selection-start-line="507" selection-start-column="22" selection-end-line="507" selection-end-column="22" />
</state>
</provider>
</entry>
......
......@@ -237,7 +237,7 @@ NSString *cacheDirectory;
options.networkAccessAllowed = true;
options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic;
PHImageRequestOptions *imageRequestOption = [[PHImageRequestOptions alloc] init];
imageRequestOption.synchronous =YES;
imageRequestOption.synchronous =NO;
imageRequestOption.networkAccessAllowed = YES;
NSString *tempPath = NSTemporaryDirectory();
NSFileManager *fileManager = [NSFileManager defaultManager];
......@@ -696,116 +696,116 @@ NSString *cacheDirectory;
return videoDurationText;
}
-(void)execRealImg:(long)resultId{
dispatch_queue_t queue = dispatch_queue_create("execRealImg", DISPATCH_QUEUE_CONCURRENT);
self.nowSize=0;
self.copySize=0;
NSString *cacheDirectory = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject];
NSFileManager *fileManager = [NSFileManager defaultManager];
for (int j=0; j<assetCollectionList.count; j++) {
AlbumItem * item=assetCollectionList[j];
PHFetchResult<PHAsset *> * assetResult =[item assets];
for (int i=0; i<[assetResult count]; i++) {
if(self.quitPage){
return;
}
__block NSString* docName=[item collectionTitle];
PHAsset * assets=[assetResult objectAtIndex:i];
__block NSString * imgName=[assets valueForKey:@"filename"];
NSString * imgRealName=[NSString stringWithFormat:@"%@_REAL",imgName];
if (imgName==nil) {
NSLog(@"NEWWWW!!!!! image name is Null!!! ");
NSString *timeSp = [NSString stringWithFormat:@"%ld", (long)([[NSDate date] timeIntervalSince1970]*100000)];
imgName=[NSString stringWithFormat:@"IMG_%@",timeSp];
imgRealName=[NSString stringWithFormat:@"REAL_PATH_IMG_%@",timeSp];
}
__block NSString *realPath=[cacheDirectory stringByAppendingPathComponent:imgRealName];
NSLog(@"REALLL %@",realPath);
__block NSString *tmpPath=[cacheDirectory stringByAppendingPathComponent:imgName];
if ([fileManager fileExistsAtPath:realPath]==YES){
self.nowSize++;
NSLog(@"!!!REAL IS EXIE!! %@",realPath);
[self searchPath:realPath :tmpPath :docName];
NSLog(@"SIZEEE %d %d ",self.nowSize,self.needSize);
if (self.nowSize==self.needSize) {
// [self upImgs];
[self reslutImg:resultId];
self.finishScanImg=true;
}
}else{
NSLog(@"file NOT EXIT !! %@",realPath);
dispatch_async(queue, ^{
if(assets.mediaType==PHAssetMediaTypeVideo){
PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
options.version = PHImageRequestOptionsVersionCurrent;
options.networkAccessAllowed = true;
options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic;
[[PHImageManager defaultManager]requestAVAssetForVideo:assets options:options resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) {
self.nowSize++;
AVURLAsset *urlAsset = (AVURLAsset *)asset;
NSString* videoUrl=[NSString stringWithFormat:@"%@",urlAsset.URL];
[self searchPath:videoUrl :tmpPath :docName];
if (self.nowSize==self.needSize) {
[self upImgs];
// [self reslutImg:resultId];
self.finishScanImg=true;
}
}];
}else{
PHImageRequestOptions *imageRequestOption = [[PHImageRequestOptions alloc] init];
imageRequestOption.synchronous =NO;
int picWidth=[assets pixelWidth];
int picHeight=[assets pixelHeight];
float tempScareSize=1;
float limit=1560.0;
if(picWidth>picHeight){
if (picWidth>limit) {
tempScareSize=limit/picWidth;
}
}else{
if (picHeight>limit) {
tempScareSize=limit/picHeight;
}
}
NSLog(@"SCARE SZIE %d %d %f %f %f",picWidth,picHeight,tempScareSize,picWidth*tempScareSize,picHeight*tempScareSize);
CGSize temp=CGSizeMake(picWidth*tempScareSize, picHeight*tempScareSize);
imageRequestOption.networkAccessAllowed = YES;
imageRequestOption.deliveryMode=PHImageRequestOptionsDeliveryModeHighQualityFormat;
// imageRequestOption.deliveryMode=PHImageRequestOptionsDeliveryModeFastFormat;
imageRequestOption.resizeMode=PHImageRequestOptionsResizeModeFast;
imageRequestOption.version=PHImageRequestOptionsVersionUnadjusted;
[[PHImageManager defaultManager] requestImageDataForAsset:assets options:imageRequestOption resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {
self.nowSize++;
self.copySize++;
NSString* finalRealPath;
if([info objectForKey:@"PHImageFileURLKey"]){
NSURL * path=[info objectForKey:@"PHImageFileURLKey"];
NSLog(@"PATHHHH %@",path);
finalRealPath=[NSString stringWithFormat:@"%@",path];
}else{
NSLog(@"NOT HAVE IT!!! %@",realPath);
[imageData writeToFile:realPath atomically:YES];
finalRealPath=realPath;
}
[self searchPath:finalRealPath :tmpPath :docName];
NSLog(@"SIZEEE %d %d %d",self.nowSize,self.needSize,self.copySize);
if (self.nowSize==self.needSize) {
[self upImgs];
// [self reslutImg:resultId];
self.finishScanImg=true;
}
// else if(self.copySize%100==0||self.copySize==50){
// [self upImgs];
// }
}];
}
});
}
}
}
}
//-(void)execRealImg:(long)resultId{
// dispatch_queue_t queue = dispatch_queue_create("execRealImg", DISPATCH_QUEUE_CONCURRENT);
// self.nowSize=0;
// self.copySize=0;
// NSString *cacheDirectory = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject];
//
// NSFileManager *fileManager = [NSFileManager defaultManager];
// for (int j=0; j<assetCollectionList.count; j++) {
// AlbumItem * item=assetCollectionList[j];
// PHFetchResult<PHAsset *> * assetResult =[item assets];
// for (int i=0; i<[assetResult count]; i++) {
// if(self.quitPage){
// return;
// }
// __block NSString* docName=[item collectionTitle];
// PHAsset * assets=[assetResult objectAtIndex:i];
// __block NSString * imgName=[assets valueForKey:@"filename"];
// NSString * imgRealName=[NSString stringWithFormat:@"%@_REAL",imgName];
// if (imgName==nil) {
// NSLog(@"NEWWWW!!!!! image name is Null!!! ");
// NSString *timeSp = [NSString stringWithFormat:@"%ld", (long)([[NSDate date] timeIntervalSince1970]*100000)];
// imgName=[NSString stringWithFormat:@"IMG_%@",timeSp];
// imgRealName=[NSString stringWithFormat:@"REAL_PATH_IMG_%@",timeSp];
// }
// __block NSString *realPath=[cacheDirectory stringByAppendingPathComponent:imgRealName];
// NSLog(@"REALLL %@",realPath);
// __block NSString *tmpPath=[cacheDirectory stringByAppendingPathComponent:imgName];
// if ([fileManager fileExistsAtPath:realPath]==YES){
// self.nowSize++;
// NSLog(@"!!!REAL IS EXIE!! %@",realPath);
// [self searchPath:realPath :tmpPath :docName];
// NSLog(@"SIZEEE %d %d ",self.nowSize,self.needSize);
// if (self.nowSize==self.needSize) {
// // [self upImgs];
// [self reslutImg:resultId];
// self.finishScanImg=true;
// }
// }else{
// NSLog(@"file NOT EXIT !! %@",realPath);
// dispatch_async(queue, ^{
// if(assets.mediaType==PHAssetMediaTypeVideo){
// PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
// options.version = PHImageRequestOptionsVersionCurrent;
// options.networkAccessAllowed = true;
// options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic;
// [[PHImageManager defaultManager]requestAVAssetForVideo:assets options:options resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) {
// self.nowSize++;
// AVURLAsset *urlAsset = (AVURLAsset *)asset;
// NSString* videoUrl=[NSString stringWithFormat:@"%@",urlAsset.URL];
// [self searchPath:videoUrl :tmpPath :docName];
// if (self.nowSize==self.needSize) {
// [self upImgs];
// // [self reslutImg:resultId];
// self.finishScanImg=true;
//
// }
// }];
// }else{
// PHImageRequestOptions *imageRequestOption = [[PHImageRequestOptions alloc] init];
// imageRequestOption.synchronous =NO;
// int picWidth=[assets pixelWidth];
// int picHeight=[assets pixelHeight];
// float tempScareSize=1;
// float limit=1560.0;
// if(picWidth>picHeight){
// if (picWidth>limit) {
// tempScareSize=limit/picWidth;
// }
// }else{
// if (picHeight>limit) {
// tempScareSize=limit/picHeight;
// }
// }
// NSLog(@"SCARE SZIE %d %d %f %f %f",picWidth,picHeight,tempScareSize,picWidth*tempScareSize,picHeight*tempScareSize);
// CGSize temp=CGSizeMake(picWidth*tempScareSize, picHeight*tempScareSize);
// imageRequestOption.networkAccessAllowed = YES;
// imageRequestOption.deliveryMode=PHImageRequestOptionsDeliveryModeHighQualityFormat;
// // imageRequestOption.deliveryMode=PHImageRequestOptionsDeliveryModeFastFormat;
// imageRequestOption.resizeMode=PHImageRequestOptionsResizeModeFast;
// imageRequestOption.version=PHImageRequestOptionsVersionUnadjusted;
// [[PHImageManager defaultManager] requestImageDataForAsset:assets options:imageRequestOption resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {
// self.nowSize++;
// self.copySize++;
// NSString* finalRealPath;
// if([info objectForKey:@"PHImageFileURLKey"]){
// NSURL * path=[info objectForKey:@"PHImageFileURLKey"];
// NSLog(@"PATHHHH %@",path);
// finalRealPath=[NSString stringWithFormat:@"%@",path];
// }else{
// NSLog(@"NOT HAVE IT!!! %@",realPath);
// [imageData writeToFile:realPath atomically:YES];
// finalRealPath=realPath;
// }
// [self searchPath:finalRealPath :tmpPath :docName];
// NSLog(@"SIZEEE %d %d %d",self.nowSize,self.needSize,self.copySize);
// if (self.nowSize==self.needSize) {
// [self upImgs];
// // [self reslutImg:resultId];
// self.finishScanImg=true;
// }
// // else if(self.copySize%100==0||self.copySize==50){
// // [self upImgs];
// // }
// }];
// }
// });
// }
// }
// }
//}
-(void)resultImgs:(long)resultId{
dispatch_async(dispatch_get_main_queue(), ^{
......@@ -830,17 +830,17 @@ NSString *cacheDirectory;
}
-(void)searchPath:(NSString*)finalRealPath :(NSString*)tmpPath :(NSString*)docName{
NSMutableArray<NSMutableDictionary<NSString*,NSObject*>*>* array=self.finalMap[docName];
for (int x=0; x<[array count]; x++) {
NSMutableDictionary<NSString*,NSObject*>* map=[array objectAtIndex:x];
NSString* index=[map objectForKey:@"path"];
if ([index isEqualToString:tmpPath]) {
[map setObject:finalRealPath forKey:@"realPath"];
break;
}
}
}
//-(void)searchPath:(NSString*)finalRealPath :(NSString*)tmpPath :(NSString*)docName{
// NSMutableArray<NSMutableDictionary<NSString*,NSObject*>*>* array=self.finalMap[docName];
// for (int x=0; x<[array count]; x++) {
// NSMutableDictionary<NSString*,NSObject*>* map=[array objectAtIndex:x];
// NSString* index=[map objectForKey:@"path"];
// if ([index isEqualToString:tmpPath]) {
// [map setObject:finalRealPath forKey:@"realPath"];
// break;
// }
// }
//}
-(void)writeImage:(UIImage *)image dest:(NSString*)path{
@autoreleasepool {
......
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