mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-30 00:02:47 +00:00
Merge pull request #120 from vector-im/vector_113
Image Picker: Launch must be speed up
This commit is contained in:
commit
03861ee6bb
1 changed files with 59 additions and 44 deletions
|
@ -59,7 +59,11 @@ static void *RecordingContext = &RecordingContext;
|
|||
|
||||
PHFetchResult *recentCaptures;
|
||||
|
||||
NSMutableArray *userAlbums;
|
||||
/**
|
||||
User's albums
|
||||
*/
|
||||
dispatch_queue_t userAlbumsQueue;
|
||||
NSArray *userAlbums;
|
||||
|
||||
MXKImageView* validationView;
|
||||
|
||||
|
@ -128,7 +132,7 @@ static void *RecordingContext = &RecordingContext;
|
|||
|
||||
[self setBackgroundRecordingID:UIBackgroundTaskInvalid];
|
||||
|
||||
userAlbums = [NSMutableArray array];
|
||||
userAlbumsQueue = dispatch_queue_create("media.picker.user.albums", DISPATCH_QUEUE_SERIAL);
|
||||
|
||||
// Observe UIApplicationWillEnterForegroundNotification to refresh captures collection when app leaves the background state.
|
||||
UIApplicationWillEnterForegroundNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillEnterForegroundNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {
|
||||
|
@ -142,6 +146,8 @@ static void *RecordingContext = &RecordingContext;
|
|||
- (void)dealloc
|
||||
{
|
||||
cameraQueue = nil;
|
||||
userAlbumsQueue = nil;
|
||||
userAlbums = nil;
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
|
@ -468,10 +474,12 @@ static void *RecordingContext = &RecordingContext;
|
|||
|
||||
- (void)reloadUserLibraryAlbums
|
||||
{
|
||||
dispatch_async(userAlbumsQueue, ^{
|
||||
|
||||
// List user albums which are not empty
|
||||
PHFetchResult *albums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:nil];
|
||||
|
||||
[userAlbums removeAllObjects];
|
||||
NSMutableArray *updatedUserAlbums = [NSMutableArray array];
|
||||
|
||||
// Set up fetch options.
|
||||
PHFetchOptions *options = [[PHFetchOptions alloc] init];
|
||||
|
@ -498,11 +506,14 @@ static void *RecordingContext = &RecordingContext;
|
|||
|
||||
if (assets.count)
|
||||
{
|
||||
[userAlbums addObject:collection];
|
||||
[updatedUserAlbums addObject:collection];
|
||||
}
|
||||
|
||||
}];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
userAlbums = updatedUserAlbums;
|
||||
if (userAlbums.count)
|
||||
{
|
||||
self.userAlbumsTableView.hidden = NO;
|
||||
|
@ -516,6 +527,10 @@ static void *RecordingContext = &RecordingContext;
|
|||
self.userAlbumsTableView.hidden = YES;
|
||||
self.libraryViewContainerViewHeightConstraint.constant = 0;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
- (void)reset
|
||||
|
|
Loading…
Reference in a new issue