diff --git a/package.json b/package.json index 7a29578..93d1399 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-mediapicker-dmcbig", - "version": "2.0.8", + "version": "2.0.9", "description": "android ios mediaPicker support selection of multiple image and video", "cordova": { "id": "cordova-plugin-mediapicker-dmcbig", diff --git a/plugin.xml b/plugin.xml index 75deb5a..2adc39a 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,6 +1,6 @@ - + MediaPicker diff --git a/src/ios/DMCMediaPicker/CollectionViewCell.h b/src/ios/DMCMediaPicker/CollectionViewCell.h index 1c5990c..0b29525 100644 --- a/src/ios/DMCMediaPicker/CollectionViewCell.h +++ b/src/ios/DMCMediaPicker/CollectionViewCell.h @@ -9,4 +9,5 @@ @property(nonatomic ,strong)UIImageView *checkView; @property(nonatomic ,strong)UILabel *labelL; @property(nonatomic ,strong)UILabel *labelR; +@property(nonatomic ,strong)UILabel *labeGIF; @end diff --git a/src/ios/DMCMediaPicker/CollectionViewCell.m b/src/ios/DMCMediaPicker/CollectionViewCell.m index e77711c..1828416 100644 --- a/src/ios/DMCMediaPicker/CollectionViewCell.m +++ b/src/ios/DMCMediaPicker/CollectionViewCell.m @@ -32,12 +32,28 @@ self.labelR.backgroundColor= [[UIColor blackColor] colorWithAlphaComponent:0.3f]; + self.labeGIF = [[UILabel alloc] initWithFrame:CGRectMake(width-width/5-5, width-labelH-2, width/5, labelH-5)]; + self.labeGIF.backgroundColor = [UIColor clearColor]; + self.labeGIF.textColor=[UIColor whiteColor]; + self.labeGIF.text=@"\tGIF\t"; + self.labeGIF.layer.cornerRadius =4; + self.labeGIF.layer.masksToBounds =YES; + self.labeGIF.textAlignment= NSTextAlignmentCenter; + self.labeGIF.baselineAdjustment= UIBaselineAdjustmentAlignCenters; + self.labeGIF.font=[UIFont systemFontOfSize:13.0]; + self.labeGIF.adjustsFontSizeToFitWidth = YES; + self.labeGIF.textAlignment=NSTextAlignmentRight; + self.labeGIF.backgroundColor= [[UIColor blackColor] colorWithAlphaComponent:0.4f]; + + + [self addSubview:self.imgView]; [self addSubview:self.whiteView]; [self addSubview:self.checkView]; [self addSubview:self.labelL]; [self addSubview:self.labelR]; + [self addSubview:self.labeGIF]; } return self; diff --git a/src/ios/DMCMediaPicker/DmcPickerViewController.m b/src/ios/DMCMediaPicker/DmcPickerViewController.m index 53e6dd5..f24612c 100644 --- a/src/ios/DMCMediaPicker/DmcPickerViewController.m +++ b/src/ios/DMCMediaPicker/DmcPickerViewController.m @@ -28,7 +28,7 @@ [[self view]setBackgroundColor:[UIColor greenColor]]; UIBarButtonItem *rightButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Done",nil) style:UIBarButtonItemStylePlain target:self action:@selector(done)]; - UIBarButtonItem *leftButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Cancel",nil) style:UIBarButtonItemStylePlain target:self action:@selector(done)]; + UIBarButtonItem *leftButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Cancel",nil) style:UIBarButtonItemStylePlain target:self action:@selector(cancel)]; self.navigationItem.rightBarButtonItem = rightButtonItem; [self setDoneBtnStatus]; self.navigationItem.leftBarButtonItem=leftButtonItem; @@ -163,11 +163,15 @@ if(asset.mediaType==PHAssetMediaTypeVideo){ cell.labelL.hidden=NO; cell.labelR.hidden=NO; + cell.labeGIF.hidden=YES; NSString *dtime=[NSString stringWithFormat:@"%.0f",asset.duration]; cell.labelL.text=[@"\t"stringByAppendingString:NSLocalizedString(@"Video",nil)]; cell.labelR.text=[[self getNewTimeFromDurationSecond:dtime.integerValue]stringByAppendingString:@"\t"]; }else{ + NSString *fileName =[asset valueForKey:@"filename"]; + NSString * fileExtension = [fileName pathExtension]; + cell.labeGIF.hidden=[@"GIF" caseInsensitiveCompare:fileExtension]?YES:NO; cell.labelL.hidden=YES; cell.labelR.hidden=YES; } @@ -183,7 +187,7 @@ //UICollectionView被选中时调用的方法 -( void )collectionView:( UICollectionView *)collectionView didSelectItemAtIndexPath:( NSIndexPath *)indexPath{ - NSLog(@"%ld",(long)indexPath.row); + PHAsset * asset=fetchResult[indexPath.row]; NSInteger i=[self isSelect:asset]; CollectionViewCell *cell = (CollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath]; diff --git a/src/ios/MediaPicker.m b/src/ios/MediaPicker.m index a1e8df2..2abdeb8 100644 --- a/src/ios/MediaPicker.m +++ b/src/ios/MediaPicker.m @@ -145,14 +145,14 @@ } else if(exportSession.status == AVAssetExportSessionStatusCompleted){ - NSLog(@"completed!"); + NSLog(@"completed!"); NSString *compressCompletedjs = [NSString stringWithFormat:@"MediaPicker.compressEvent('%@',%i)", @"completed",index]; [self.commandDelegate evalJs:compressCompletedjs]; - NSDictionary *dict=[NSDictionary dictionaryWithObjectsAndKeys:fullpath,@"path",@"video",@"mediaType" ,[NSNumber numberWithInt:index],@"index", nil]; - [aListArray addObject:dict]; - if([aListArray count]==[selectArray count]){ - [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:aListArray] callbackId:callbackId]; - } + NSDictionary *dict=[NSDictionary dictionaryWithObjectsAndKeys:fullpath,@"path",@"video",@"mediaType" ,[NSNumber numberWithInt:index],@"index", nil]; + [aListArray addObject:dict]; + if([aListArray count]==[selectArray count]){ + [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:aListArray] callbackId:callbackId]; + } } }];