You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by so...@apache.org on 2017/04/01 06:03:07 UTC

[02/50] [abbrv] incubator-weex git commit: * [ios] fix issue that recycle will crash if header height is zero (no layout attribute but has header will cause crash)

* [ios] fix issue that recycle will crash if header height is zero (no layout attribute but has header will cause crash)


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/0dc2daad
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/0dc2daad
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/0dc2daad

Branch: refs/heads/dev
Commit: 0dc2daadcc252cd3be890361cd052640e76ac3a8
Parents: 014cfc1
Author: \u9690\u98ce <cx...@apache.org>
Authored: Tue Mar 28 00:36:55 2017 +0800
Committer: \u9690\u98ce <cx...@apache.org>
Committed: Tue Mar 28 00:36:55 2017 +0800

----------------------------------------------------------------------
 .../WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.h   | 2 ++
 .../WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.m   | 5 +++--
 .../WeexSDK/Sources/Component/Recycler/WXRecyclerComponent.m   | 5 +++++
 .../Sources/Component/Recycler/WXRecyclerDataController.h      | 2 ++
 .../Sources/Component/Recycler/WXRecyclerDataController.m      | 6 ++++++
 5 files changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/0dc2daad/ios/sdk/WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.h b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.h
index f107db0..34b1f6a 100644
--- a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.h
+++ b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.h
@@ -21,6 +21,8 @@ extern NSString * const kCollectionSupplementaryViewKindHeader;
 
 - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout heightForHeaderInSection:(NSInteger)section;
 
+- (BOOL)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout hasHeaderInSection:(NSInteger)section;
+
 - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout isNeedStickyForHeaderInSection:(NSInteger)section;
 
 @end

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/0dc2daad/ios/sdk/WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.m b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.m
index a959ddc..9a56502 100644
--- a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.m
+++ b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.m
@@ -156,9 +156,10 @@ NSString * const kMultiColumnLayoutCell = @"WXMultiColumnLayoutCell";
     }
     
     for (NSInteger section = 0; section < numberOfSections; section++) {
-        CGFloat headerHeight = [self.delegate collectionView:self.collectionView layout:self heightForHeaderInSection:section];
+        BOOL hasHeader = [self.delegate collectionView:self.collectionView layout:self hasHeaderInSection:section];
         // header
-        if (headerHeight > 0) {
+        if (hasHeader) {
+            CGFloat headerHeight = [self.delegate collectionView:self.collectionView layout:self heightForHeaderInSection:section];
             WXMultiColumnLayoutHeaderAttributes *headerAttributes = [WXMultiColumnLayoutHeaderAttributes layoutAttributesForSupplementaryViewOfKind:kCollectionSupplementaryViewKindHeader withIndexPath:[NSIndexPath indexPathForItem:0 inSection:section]];
             headerAttributes.frame = CGRectMake(insets.left, currentHeight, self.contentWidth - (insets.left + insets.right), headerHeight);
             headerAttributes.isSticky = [self.delegate collectionView:self.collectionView layout:self isNeedStickyForHeaderInSection:section];

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/0dc2daad/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerComponent.m b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerComponent.m
index 91f3d12..b5b5ac8 100644
--- a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerComponent.m
@@ -406,6 +406,11 @@ typedef enum : NSUInteger {
     return headerSize.height;
 }
 
+- (BOOL)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout hasHeaderInSection:(NSInteger)section
+{
+    return [self.dataController hasHeaderInSection:section];
+}
+
 - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout isNeedStickyForHeaderInSection:(NSInteger)section
 {
     return [self.dataController isStickyForHeaderAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:section]];

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/0dc2daad/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDataController.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDataController.h b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDataController.h
index 34e8a10..63391d1 100644
--- a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDataController.h
+++ b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDataController.h
@@ -29,6 +29,8 @@
 
 - (BOOL)isStickyForHeaderAtIndexPath:(NSIndexPath *)indexPath;
 
+- (BOOL)hasHeaderInSection:(NSInteger)section;
+
 - (NSIndexPath *)indexPathForCell:(WXCellComponent *)cell;
 
 - (NSUInteger)indexForHeader:(WXHeaderComponent *)header;

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/0dc2daad/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDataController.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDataController.m b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDataController.m
index 2031837..92875ce 100644
--- a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDataController.m
+++ b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDataController.m
@@ -92,6 +92,12 @@
     return [sectionController sizeForHeaderAtIndex:indexPath.item];
 }
 
+- (BOOL)hasHeaderInSection:(NSInteger)section
+{
+    WXSectionDataController *sectionController = [self dataControllerForSection:section];
+    return sectionController.headerComponent != nil;
+}
+
 - (BOOL)isStickyForHeaderAtIndexPath:(NSIndexPath *)indexPath
 {
     WXSectionDataController *sectionController = [self dataControllerForSection:indexPath.section];