Skip to content

Commit b6d7a25

Browse files
committed
Merge branch 'master' into custom-fetch
Conflicts: CTAssetsPickerController/CTAssetsGridViewController.h
2 parents 4654667 + e05c0b4 commit b6d7a25

39 files changed

+267
-131
lines changed

CTAssetsPickerController/CTAssetCollectionViewCell.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,23 @@
3232

3333
@interface CTAssetCollectionViewCell : UITableViewCell
3434

35-
@property (nonatomic, strong, readonly) CTAssetThumbnailStacks *thumbnailStacks;
35+
@property (nonatomic, strong, readonly, nonnull) CTAssetThumbnailStacks *thumbnailStacks;
3636

37-
@property (nonatomic, weak) UIFont *titleFont UI_APPEARANCE_SELECTOR;
38-
@property (nonatomic, strong) UIColor *titleTextColor UI_APPEARANCE_SELECTOR;
39-
@property (nonatomic, strong) UIColor *selectedTitleTextColor UI_APPEARANCE_SELECTOR;
37+
@property (nonatomic, weak, nullable) UIFont *titleFont UI_APPEARANCE_SELECTOR;
38+
@property (nonatomic, strong, nullable) UIColor *titleTextColor UI_APPEARANCE_SELECTOR;
39+
@property (nonatomic, strong, nullable) UIColor *selectedTitleTextColor UI_APPEARANCE_SELECTOR;
4040

41-
@property (nonatomic, weak) UIFont *countFont UI_APPEARANCE_SELECTOR;
42-
@property (nonatomic, strong) UIColor *countTextColor UI_APPEARANCE_SELECTOR;
43-
@property (nonatomic, strong) UIColor *selectedCountTextColor UI_APPEARANCE_SELECTOR;
41+
@property (nonatomic, weak, nullable) UIFont *countFont UI_APPEARANCE_SELECTOR;
42+
@property (nonatomic, strong, nullable) UIColor *countTextColor UI_APPEARANCE_SELECTOR;
43+
@property (nonatomic, strong, nullable) UIColor *selectedCountTextColor UI_APPEARANCE_SELECTOR;
4444

45-
@property (nonatomic, strong) UIColor *accessoryColor UI_APPEARANCE_SELECTOR;
46-
@property (nonatomic, strong) UIColor *selectedAccessoryColor UI_APPEARANCE_SELECTOR;
45+
@property (nonatomic, strong, nullable) UIColor *accessoryColor UI_APPEARANCE_SELECTOR;
46+
@property (nonatomic, strong, nullable) UIColor *selectedAccessoryColor UI_APPEARANCE_SELECTOR;
4747

48-
@property (nonatomic, weak) UIColor *selectedBackgroundColor UI_APPEARANCE_SELECTOR;
48+
@property (nonatomic, weak, nullable) UIColor *selectedBackgroundColor UI_APPEARANCE_SELECTOR;
4949

5050

51-
- (instancetype)initWithThumbnailSize:(CGSize)size reuseIdentifier:(NSString *)reuseIdentifier;
52-
- (void)bind:(PHAssetCollection *)collection count:(NSUInteger)count;
51+
- (instancetype)initWithThumbnailSize:(CGSize)size reuseIdentifier:(nullable NSString *)reuseIdentifier;
52+
- (void)bind:(nonnull PHAssetCollection *)collection count:(NSUInteger)count;
5353

5454
@end

CTAssetsPickerController/CTAssetCollectionViewCell.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ - (void)setupPlaceholderImage
123123
for (CTAssetThumbnailView *thumbnailView in self.thumbnailStacks.thumbnailViews)
124124
{
125125
[thumbnailView bind:nil assetCollection:nil];
126-
[thumbnailView setBackgroundImage:image];
126+
thumbnailView.backgroundImage = image;
127127
}
128128
}
129129

@@ -292,12 +292,12 @@ - (void)bind:(PHAssetCollection *)collection count:(NSUInteger)count
292292

293293
[self setupPlaceholderImage];
294294

295-
[self.titleLabel setText:collection.localizedTitle];
295+
self.titleLabel.text = collection.localizedTitle;
296296

297297
if (count != NSNotFound)
298298
{
299299
NSNumberFormatter *nf = [NSNumberFormatter new];
300-
[self.countLabel setText:[nf ctassetsPickerStringFromAssetsCount:count]];
300+
self.countLabel.text = [nf ctassetsPickerStringFromAssetsCount:count];
301301
}
302302

303303
[self setNeedsUpdateConstraints];

CTAssetsPickerController/CTAssetCollectionViewController.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ of this software and associated documentation files (the "Software"), to deal
3232
#import "CTAssetsGridViewController.h"
3333
#import "PHAssetCollection+CTAssetsPickerController.h"
3434
#import "PHAsset+CTAssetsPickerController.h"
35+
#import "PHImageManager+CTAssetsPickerController.h"
3536
#import "NSBundle+CTAssetsPickerController.h"
3637

3738

@@ -308,8 +309,7 @@ - (void)photoLibraryDidChange:(PHChange *)changeInstance
308309
if (!updatedFetchResults)
309310
updatedFetchResults = [self.fetchResults mutableCopy];
310311

311-
[updatedFetchResults replaceObjectAtIndex:[self.fetchResults indexOfObject:fetchResult]
312-
withObject:[changeDetails fetchResultAfterChanges]];
312+
updatedFetchResults[[self.fetchResults indexOfObject:fetchResult]] = changeDetails.fetchResultAfterChanges;
313313
}
314314
}
315315

@@ -440,7 +440,7 @@ - (void)requestThumbnailsForCell:(CTAssetCollectionViewCell *)cell assetCollecti
440440
if (index < assets.count)
441441
{
442442
PHAsset *asset = assets[index];
443-
[self.imageManager requestImageForAsset:asset
443+
[self.imageManager ctassetsPickerRequestImageForAsset:asset
444444
targetSize:targetSize
445445
contentMode:PHImageContentModeAspectFill
446446
options:self.picker.thumbnailRequestOptions

CTAssetsPickerController/CTAssetItemViewController.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,19 @@
2727
#import <UIKit/UIKit.h>
2828
#import <Photos/Photos.h>
2929

30-
30+
NS_ASSUME_NONNULL_BEGIN
3131

3232
@interface CTAssetItemViewController : UIViewController
3333

3434
@property (nonatomic, assign) BOOL allowsSelection;
3535
@property (nonatomic, strong, readonly) PHAsset *asset;
36-
@property (nonatomic, strong, readonly) UIImage *image;
36+
@property (nonatomic, strong, readonly, nullable) UIImage *image;
3737

3838
+ (CTAssetItemViewController *)assetItemViewControllerForAsset:(PHAsset *)asset;
3939

40-
- (void)playAsset:(id)sender;
41-
- (void)pauseAsset:(id)sender;
40+
- (void)playAsset:(nullable id)sender;
41+
- (void)pauseAsset:(nullable id)sender;
42+
43+
@end
4244

43-
@end
45+
NS_ASSUME_NONNULL_END

CTAssetsPickerController/CTAssetItemViewController.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ of this software and associated documentation files (the "Software"), to deal
3131
#import "CTAssetScrollView.h"
3232
#import "NSBundle+CTAssetsPickerController.h"
3333
#import "PHAsset+CTAssetsPickerController.h"
34+
#import "PHImageManager+CTAssetsPickerController.h"
3435

3536

3637

@@ -185,7 +186,7 @@ - (void)requestAssetImage
185186
PHImageRequestOptions *options = [self imageRequestOptions];
186187

187188
self.imageRequestID =
188-
[self.imageManager requestImageForAsset:self.asset
189+
[self.imageManager ctassetsPickerRequestImageForAsset:self.asset
189190
targetSize:targetSize
190191
contentMode:PHImageContentModeAspectFit
191192
options:options
@@ -196,7 +197,7 @@ - (void)requestAssetImage
196197

197198
dispatch_async(dispatch_get_main_queue(), ^{
198199

199-
NSError *error = [info objectForKey:PHImageErrorKey];
200+
NSError *error = info[PHImageErrorKey];
200201

201202
if (error)
202203
[self showRequestImageError:error title:nil];
@@ -241,7 +242,7 @@ - (void)requestAssetPlayerItem:(id)sender
241242
resultHandler:^(AVPlayerItem *playerItem, NSDictionary *info) {
242243
dispatch_async(dispatch_get_main_queue(), ^{
243244

244-
NSError *error = [info objectForKey:PHImageErrorKey];
245+
NSError *error = info[PHImageErrorKey];
245246
NSString * title = CTAssetsPickerLocalizedString(@"Cannot Play Stream Video", nil);
246247

247248
if (error)

CTAssetsPickerController/CTAssetPlayButton.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ - (void)updateConstraints
173173

174174
- (void)setHighlighted:(BOOL)highlighted
175175
{
176-
[super setHighlighted:highlighted];
176+
super.highlighted = highlighted;
177177
self.highlightedView.hidden = !highlighted;
178178
}
179179

CTAssetsPickerController/CTAssetScrollView.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#import "CTAssetSelectionButton.h"
3131

3232

33-
33+
NS_ASSUME_NONNULL_BEGIN
3434

3535
extern NSString * const CTAssetScrollViewDidTapNotification;
3636
extern NSString * const CTAssetScrollViewPlayerWillPlayNotification;
@@ -41,8 +41,8 @@ extern NSString * const CTAssetScrollViewPlayerWillPauseNotification;
4141

4242
@property (nonatomic, assign) BOOL allowsSelection;
4343

44-
@property (nonatomic, strong, readonly) UIImage *image;
45-
@property (nonatomic, strong, readonly) AVPlayer *player;
44+
@property (nonatomic, strong, readonly, nullable) UIImage *image;
45+
@property (nonatomic, strong, readonly, nullable) AVPlayer *player;
4646

4747
@property (nonatomic, strong, readonly) UIImageView *imageView;
4848
@property (nonatomic, strong, readonly) CTAssetPlayButton *playButton;
@@ -54,12 +54,14 @@ extern NSString * const CTAssetScrollViewPlayerWillPauseNotification;
5454

5555
- (void)setProgress:(CGFloat)progress;
5656

57-
- (void)bind:(PHAsset *)asset image:(UIImage *)image requestInfo:(NSDictionary *)info;
58-
- (void)bind:(AVPlayerItem *)playerItem requestInfo:(NSDictionary *)info;
57+
- (void)bind:(PHAsset *)asset image:(nullable UIImage *)image requestInfo:(nullable NSDictionary<NSString*, id> *)info;
58+
- (void)bind:(AVPlayerItem *)playerItem requestInfo:(nullable NSDictionary *)info;
5959

6060
- (void)updateZoomScalesAndZoom:(BOOL)zoom;
6161

6262
- (void)playVideo;
6363
- (void)pauseVideo;
6464

6565
@end
66+
67+
NS_ASSUME_NONNULL_END

CTAssetsPickerController/CTAssetScrollView.m

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,10 @@ - (void)stopActivityAnimating
235235
- (void)setProgress:(CGFloat)progress
236236
{
237237
#if !defined(CT_APP_EXTENSIONS)
238-
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:(progress < 1)];
238+
[UIApplication sharedApplication].networkActivityIndicatorVisible = progress < 1;
239239
#endif
240240
[self.progressView setProgress:progress animated:(progress < 1)];
241-
[self.progressView setHidden:(progress == 1)];
241+
self.progressView.hidden = progress == 1;
242242
}
243243

244244
// To mimic image downloading progress
@@ -311,7 +311,7 @@ - (void)bind:(AVPlayerItem *)playerItem requestInfo:(NSDictionary *)info
311311

312312
CALayer *layer = self.imageView.layer;
313313
[layer addSublayer:playerLayer];
314-
[playerLayer setFrame:layer.bounds];
314+
playerLayer.frame = layer.bounds;
315315

316316
self.player = player;
317317

@@ -487,11 +487,11 @@ - (void)addGestureRecognizers
487487
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapping:)];
488488
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapping:)];
489489

490-
[doubleTap setNumberOfTapsRequired:2.0];
490+
doubleTap.numberOfTapsRequired = 2.0;
491491
[singleTap requireGestureRecognizerToFail:doubleTap];
492492

493-
[singleTap setDelegate:self];
494-
[doubleTap setDelegate:self];
493+
singleTap.delegate = self;
494+
doubleTap.delegate = self;
495495

496496
[self addGestureRecognizer:singleTap];
497497
[self addGestureRecognizer:doubleTap];
@@ -523,7 +523,7 @@ - (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(UIView *
523523

524524
- (void)scrollViewDidZoom:(UIScrollView *)scrollView
525525
{
526-
[self setScrollEnabled:(self.zoomScale != self.perspectiveZoomScale)];
526+
self.scrollEnabled = self.zoomScale != self.perspectiveZoomScale;
527527

528528
if (self.shouldUpdateConstraints)
529529
{
@@ -607,9 +607,9 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
607607
{
608608
if (object == self.player && [keyPath isEqual:@"currentItem.loadedTimeRanges"])
609609
{
610-
NSArray *timeRanges = [change objectForKey:NSKeyValueChangeNewKey];
610+
NSArray *timeRanges = change[NSKeyValueChangeNewKey];
611611

612-
if (timeRanges && [timeRanges count])
612+
if (timeRanges && timeRanges.count)
613613
{
614614
CMTimeRange timeRange = [timeRanges.firstObject CMTimeRangeValue];
615615

CTAssetsPickerController/CTAssetSelectionButton.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ - (void)updateConstraints
112112

113113
- (void)setSelected:(BOOL)selected
114114
{
115-
[super setSelected:selected];
115+
super.selected = selected;
116116
self.checkmark.hidden = !selected;
117117

118118
self.accessibilityLabel = (selected) ? CTAssetsPickerLocalizedString(@"Deselect", nil) : CTAssetsPickerLocalizedString(@"Select", nil);

CTAssetsPickerController/CTAssetSelectionLabel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,6 @@
9494
*
9595
* @param textAttributes The text attributes used to display the label.
9696
*/
97-
- (void)setTextAttributes:(NSDictionary *)textAttributes UI_APPEARANCE_SELECTOR;
97+
- (void)setTextAttributes:(NSDictionary<NSString*, id> *)textAttributes UI_APPEARANCE_SELECTOR;
9898

9999
@end

0 commit comments

Comments
 (0)