Merge branch 'mkirk/avoid-double-layout'

pull/1/head
Michael Kirk 8 years ago
commit 2230f01d47

@ -4461,7 +4461,16 @@ typedef enum : NSUInteger {
// Snapshot the scroll state by measuring the "distance from top of view to
// bottom of content"; if the mapping's "window" size grows, it will grow
// _upward_.
CGFloat viewTopToContentBottom = self.safeContentHeight - self.collectionView.contentOffset.y;
CGFloat viewTopToContentBottom = 0;
OWSAssert([self.collectionView.collectionViewLayout isKindOfClass:[ConversationViewLayout class]]);
ConversationViewLayout *conversationViewLayout
= (ConversationViewLayout *)self.collectionView.collectionViewLayout;
// To avoid laying out the collection view during initial view
// presentation, don't trigger layout here (via safeContentHeight)
// until layout has been done at least once.
if (conversationViewLayout.hasEverHadLayout) {
viewTopToContentBottom = self.safeContentHeight - self.collectionView.contentOffset.y;
}
NSUInteger oldCellCount = [self.messageMappings numberOfItemsInGroup:self.thread.uniqueId];

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
NS_ASSUME_NONNULL_BEGIN
@ -37,7 +37,8 @@ typedef NS_ENUM(NSInteger, ConversationViewLayoutAlignment) {
@interface ConversationViewLayout : UICollectionViewLayout
@property (nonatomic, weak) id<ConversationViewLayoutDelegate> delegate;
@property (nonatomic, readonly) BOOL hasLayout;
@property (nonatomic, readonly) BOOL hasEverHadLayout;
@property (nonatomic, readonly) int contentWidth;
@end

@ -19,6 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
// layout without incurring any of the (great) expense of performing an
// unnecessary layout pass.
@property (nonatomic) BOOL hasLayout;
@property (nonatomic) BOOL hasEverHadLayout;
@property (nonatomic) int contentWidth;
@ -37,6 +38,15 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
- (void)setHasLayout:(BOOL)hasLayout
{
_hasLayout = hasLayout;
if (hasLayout) {
self.hasEverHadLayout = YES;
}
}
- (void)invalidateLayout
{
[super invalidateLayout];

Loading…
Cancel
Save