Commit c8220c04 authored by 林生雨's avatar 林生雨

commit

parent d502a751
......@@ -6,8 +6,6 @@
</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$/ios/Classes/GengmeiFlutterPlugin.m" beforeDir="false" afterPath="$PROJECT_DIR$/ios/Classes/GengmeiFlutterPlugin.m" afterDir="false" />
</list>
<ignored path="$PROJECT_DIR$/.dart_tool/" />
......@@ -105,8 +103,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="11418">
<caret line="540" column="22" selection-start-line="540" selection-start-column="22" selection-end-line="540" selection-end-column="22" />
<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>
</provider>
</entry>
......@@ -528,8 +526,8 @@
</entry>
<entry file="file://$PROJECT_DIR$/ios/Classes/GengmeiFlutterPlugin.m">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="11418">
<caret line="540" column="22" selection-start-line="540" selection-start-column="22" selection-end-line="540" selection-end-column="22" />
<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>
</provider>
</entry>
......
......@@ -346,6 +346,8 @@ NSString *cacheDirectory;
}
}
- (void)clearAllUserDefaultsData {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSDictionary *dic = [userDefaults dictionaryRepresentation];
......@@ -457,11 +459,18 @@ CFAbsoluteTime startTime;
self.nowSize=0;
self.needSize=0;
[assetCollectionList removeAllObjects];
// [NSThread detachNewThreadSelector:@selector(thread:) toTarget:self withObject:[NSString stringWithFormat:@"%ld",resultId]];
dispatch_async(queue, ^{
[self scanPhoneImage];
[self copyImg:resultId];
});
}
//- (void)thread:(NSString*)resultId {
// long result=[resultId longLongValue];
// [self scanPhoneImage];
// [self copyImg:result];
//}
- (void)enumerateAssetsInAssetCollection:(PHAssetCollection *)assetCollection original:(BOOL)original
{
......@@ -593,7 +602,28 @@ CFAbsoluteTime startTime;
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{
......@@ -617,20 +647,18 @@ CFAbsoluteTime startTime;
AlbumItem * item=assetCollectionList[j];
PHFetchResult<PHAsset *> * assetResult =[item assets];
for (int i=0; i<[assetResult count]; i++) {
__block NSString* docName=[item collectionTitle];
NSString* docName=[item collectionTitle];
PHAsset * assets=[assetResult objectAtIndex:i];
__block NSString * imgName=[assets valueForKey:@"filename"];
NSString * imgName=[assets valueForKey:@"filename"];
if (imgName==nil) {
NSLog(@"NEWWWW!!!!! image name is Null!!! ");
NSString *timeSp = [NSString stringWithFormat:@"%ld", (long)([[NSDate date] timeIntervalSince1970]*100000)];
imgName=[NSString stringWithFormat:@"IMG_%@",timeSp];
}
__block NSString *tmpPath=[cacheDirectory stringByAppendingPathComponent:imgName];
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) {
NSLog(@"VIDEO EXITTTT ");
dispatch_async(queue, ^{
AVURLAsset *urlAsset = (AVURLAsset *)asset;
NSMutableDictionary* queryItemDict = [NSMutableDictionary dictionary];
[queryItemDict setObject:[self getVideoDuring:urlAsset.duration] forKey:@"during"];
......@@ -638,11 +666,9 @@ CFAbsoluteTime startTime;
[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;
......@@ -660,10 +686,9 @@ CFAbsoluteTime startTime;
@autoreleasepool{
NSData *data = UIImageJPEGRepresentation(result, 0.8) ;
[data writeToFile:tmpPath atomically:YES];
// data=nil;
// result=nil;
data=nil;
result=nil;
}
dispatch_sync(queue, ^{
AVURLAsset *urlAsset = (AVURLAsset *)asset;
NSMutableDictionary* queryItemDict = [NSMutableDictionary dictionary];
[queryItemDict setObject:[self getVideoDuring:urlAsset.duration] forKey:@"during"];
......@@ -671,7 +696,6 @@ CFAbsoluteTime startTime;
[queryItemDict setObject:@"T" forKey:@"isVideo"];
[queryItemDict setObject:[NSString stringWithFormat:@"%ld", (long)[assets.creationDate timeIntervalSince1970]*1000] forKey:@"dataToken"];
[self saveItemAndUpload:queryItemDict :assets :tmpPath :docName :resultId];
});
}];
}];
......
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