Skip to content
Browse files

use objc subscripting

  • Loading branch information...
1 parent 38ab15a commit e0c2e8c9023e95c8d765fbc4d19a154807da5420 @steipete committed Mar 19, 2013
View
14 PSTCollectionView/PSTCollectionView.m
@@ -1664,18 +1664,18 @@ - (void)updateWithItems:(NSArray *)items {
}
NSIndexPath *newIndexPath = newGlobalIndex == NSNotFound ? nil : [_update[@"newModel"] indexPathForItemAtGlobalIndex:newGlobalIndex];
if (newIndexPath) {
-
-
+
+
PSTCollectionViewLayoutAttributes* startAttrs = nil;
PSTCollectionViewLayoutAttributes* finalAttrs = nil;
-
+
startAttrs = [_layout initialLayoutAttributesForAppearingItemAtIndexPath:newIndexPath];
finalAttrs = [_layout layoutAttributesForItemAtIndexPath:newIndexPath];
-
+
NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:@{@"view":view}];
if (startAttrs) dic[@"previousLayoutInfos"] = startAttrs;
if (finalAttrs) dic[@"newLayoutInfos"] = finalAttrs;
-
+
[animations addObject:dic];
PSTCollectionViewItemKey* newKey = [key copy];
[newKey setIndexPath:newIndexPath];
@@ -1691,7 +1691,7 @@ - (void)updateWithItems:(NSArray *)items {
NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:@{@"view":view}];
if (startAttrs) dic[@"previousLayoutInfos"] = startAttrs;
if (finalAttrs) dic[@"newLayoutInfos"] = finalAttrs;
-
+
[animations addObject:dic];
PSTCollectionViewItemKey* newKey = [key copy];
newAllVisibleView[newKey] = view;
@@ -1750,7 +1750,7 @@ - (void)updateWithItems:(NSArray *)items {
// Iterate through all the views previously visible and search for those which are no more visible.
[previouslyVisibleViewsDict enumerateKeysAndObjectsUsingBlock:
^(PSTCollectionViewItemKey *key, PSTCollectionReusableView* view, BOOL *stop) {
- if (![_allVisibleViewsDict objectForKey:key]) {
+ if (!_allVisibleViewsDict[key]) {
// View for this key isn't visible any more, so it should be reused.
if(key.type == PSTCollectionViewItemTypeCell) {
[self reuseCell:(PSTCollectionViewCell *)view];
View
18 PSTCollectionView/PSTCollectionViewFlowLayout.m
@@ -116,7 +116,7 @@ - (id)initWithCoder:(NSCoder *)decoder {
- (void)encodeWithCoder:(NSCoder *)coder
{
[super encodeWithCoder:coder];
-
+
[coder encodeCGSize:self.itemSize forKey:@"UIItemSize"];
[coder encodeFloat:self.minimumInteritemSpacing forKey:@"UIInteritemSpacing"];
[coder encodeFloat:self.minimumLineSpacing forKey:@"UILineSpacing"];
@@ -229,29 +229,29 @@ - (PSTCollectionViewLayoutAttributes *)layoutAttributesForSupplementaryViewOfKin
NSUInteger sectionIndex = indexPath.section;
PSTCollectionViewLayoutAttributes *layoutAttributes = nil;
-
+
if (sectionIndex < _data.sections.count) {
PSTGridLayoutSection *section = _data.sections[sectionIndex];
-
+
CGRect normilazedFrame = CGRectZero;
-
+
if ([kind isEqualToString:PSTCollectionElementKindSectionHeader]) {
normilazedFrame = section.headerFrame;
}
else if ([kind isEqualToString:PSTCollectionElementKindSectionFooter]) {
normilazedFrame = section.footerFrame;
}
-
+
if (!CGRectIsEmpty(normilazedFrame)) {
normilazedFrame.origin.x += section.frame.origin.x;
normilazedFrame.origin.y += section.frame.origin.y;
-
+
layoutAttributes = [[[self class] layoutAttributesClass] layoutAttributesForSupplementaryViewOfKind:kind withIndexPath:[NSIndexPath indexPathForItem:0 inSection:sectionIndex]];
layoutAttributes.frame = normilazedFrame;
-
+
}
-
-
+
+
}
return layoutAttributes;
View
12 PSTCollectionView/PSTCollectionViewLayout.m
@@ -299,9 +299,9 @@ - (void)prepareForCollectionViewUpdates:(NSArray *)updateItems {
for (PSTCollectionReusableView *view in [[_collectionView visibleViewsDict] objectEnumerator]) {
PSTCollectionViewLayoutAttributes *attr = [view.layoutAttributes copy];
if (attr.isCell) {
-
+
NSInteger index = [update[@"oldModel"] globalIndexForItemAtIndexPath:[attr indexPath]];
-
+
if(index != NSNotFound) {
index = [update[@"oldToNewIndexMap"][index] intValue];
if(index != NSNotFound) {
@@ -319,7 +319,7 @@ - (void)prepareForCollectionViewUpdates:(NSArray *)updateItems {
for (PSTCollectionViewLayoutAttributes* attr in [collectionViewData layoutAttributesForElementsInRect:bounds]) {
if (attr.isCell) {
NSInteger index = [collectionViewData globalIndexForItemAtIndexPath:attr.indexPath];
-
+
index = [update[@"newToOldIndexMap"][index] intValue];
if(index != NSNotFound) {
PSTCollectionViewLayoutAttributes* finalAttrs = [attr copy];
@@ -392,7 +392,7 @@ - (PSTCollectionViewLayoutAttributes *)finalLayoutAttributesForDisappearingItemA
- (PSTCollectionViewLayoutAttributes *)initialLayoutAttributesForInsertedSupplementaryElementOfKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)elementIndexPath {
PSTCollectionViewLayoutAttributes* attrs = _initialAnimationLayoutAttributesDict[[PSTCollectionViewItemKey collectionItemKeyForCellWithIndexPath:elementIndexPath]];
-
+
if([_insertedSectionsSet containsIndex:[elementIndexPath section]]) {
attrs = [attrs copy];
[attrs setAlpha:0];
@@ -416,11 +416,11 @@ - (void)finalizeCollectionViewUpdates {
#pragma mark - Registering Decoration Views
- (void)registerClass:(Class)viewClass forDecorationViewOfKind:(NSString *)kind {
- [_decorationViewClassDict setObject:viewClass forKey:kind];
+ _decorationViewClassDict[kind] = viewClass;
}
- (void)registerNib:(UINib *)nib forDecorationViewOfKind:(NSString *)kind {
- [_decorationViewNibDict setObject:nib forKey:kind];
+ _decorationViewNibDict[kind] = nib;
}
///////////////////////////////////////////////////////////////////////////////////////////

0 comments on commit e0c2e8c

Please sign in to comment.
Something went wrong with that request. Please try again.