Permalink
Browse files

renames and exposes cellForItemAtIndex (was: itemSubViewForPosition)

  • Loading branch information...
1 parent cd4ea23 commit c8c6b8ea45123f04c8fc14e567ec36accd7b67fd @steipete steipete committed with Dec 14, 2011
Showing with 17 additions and 14 deletions.
  1. +3 −0 GMGridView/API/GMGridView.h
  2. +14 −14 GMGridView/API/GMGridView.m
@@ -79,6 +79,9 @@ typedef enum
// Reusable cells
- (GMGridViewCell *)dequeueReusableCell;
+// Cells
+- (GMGridViewCell *)cellForItemAtIndex:(NSInteger)position;
+
// Actions
- (void)reloadData;
- (void)insertObjectAtIndex:(NSInteger)index;
@@ -106,7 +106,7 @@ - (BOOL)isInTransformingState;
- (void)recomputeSize;
- (void)relayoutItemsAnimated:(BOOL)animated;
- (NSArray *)itemSubviews;
-- (GMGridViewCell *)itemSubViewForPosition:(NSInteger)position;
+- (GMGridViewCell *)cellForItemAtIndex:(NSInteger)position;
- (GMGridViewCell *)newItemSubViewForPosition:(NSInteger)position;
- (NSInteger)positionForItemSubview:(GMGridViewCell *)view;
- (void)setSubviewsCacheAsInvalid;
@@ -574,7 +574,7 @@ - (void)sortingMoveDidStartAtPoint:(CGPoint)point
{
NSInteger position = [self.layoutStrategy itemPositionFromLocation:point];
- GMGridViewCell *item = [self itemSubViewForPosition:position];
+ GMGridViewCell *item = [self cellForItemAtIndex:position];
[_scrollView bringSubviewToFront:item];
_sortMovingItem = item;
@@ -696,7 +696,7 @@ - (void)sortingMoveDidContinueToPoint:(CGPoint)point
{
if (_sortMovingItem)
{
- UIView *v = [self itemSubViewForPosition:position];
+ UIView *v = [self cellForItemAtIndex:position];
v.tag = _sortFuturePosition + kTagOffset;
CGPoint origin = [self.layoutStrategy originForItemAtPosition:_sortFuturePosition];
@@ -883,7 +883,7 @@ - (void)transformingGestureDidBeginWithGesture:(UIGestureRecognizer *)gesture
{
CGPoint locationTouch = [gesture locationOfTouch:0 inView:_scrollView];
NSInteger positionTouch = [self.layoutStrategy itemPositionFromLocation:locationTouch];
- _transformingItem = [self itemSubViewForPosition:positionTouch];
+ _transformingItem = [self cellForItemAtIndex:positionTouch];
CGRect frameInMainView = [_scrollView convertRect:_transformingItem.frame toView:self.mainSuperView];
@@ -1082,7 +1082,7 @@ - (NSArray *)itemSubviews
return subviews;
}
-- (GMGridViewCell *)itemSubViewForPosition:(NSInteger)position
+- (GMGridViewCell *)cellForItemAtIndex:(NSInteger)position
{
GMGridViewCell *view = nil;
@@ -1180,7 +1180,7 @@ - (void)loadRequiredItems
if ((forceLoad || !NSLocationInRange(positionToLoad, loadedPositionsRange)) && positionToLoad < _numberTotalItems)
{
- if (![self itemSubViewForPosition:positionToLoad])
+ if (![self cellForItemAtIndex:positionToLoad])
{
GMGridViewCell *cell = [self newItemSubViewForPosition:positionToLoad];
[_scrollView addSubview:cell];
@@ -1208,7 +1208,7 @@ - (void)cleanupUnseenItems
{
for (int i = self.firstPositionLoaded; i < rangeOfPositions.location; i++)
{
- cell = [self itemSubViewForPosition:i];
+ cell = [self cellForItemAtIndex:i];
if(cell)
{
//NSLog(@"Removing item at position %d", i);
@@ -1225,7 +1225,7 @@ - (void)cleanupUnseenItems
{
for (int i = NSMaxRange(rangeOfPositions); i <= self.lastPositionLoaded; i++)
{
- cell = [self itemSubViewForPosition:i];
+ cell = [self cellForItemAtIndex:i];
if(cell)
{
//NSLog(@"Removing item at position %d", i);
@@ -1303,7 +1303,7 @@ - (void)reloadObjectAtIndex:(NSInteger)index
{
NSAssert((index >= 0 && index < _numberTotalItems), @"Invalid index");
- UIView *currentView = [self itemSubViewForPosition:index];
+ UIView *currentView = [self cellForItemAtIndex:index];
GMGridViewCell *cell = [self newItemSubViewForPosition:index];
CGPoint origin = [self.layoutStrategy originForItemAtPosition:index];
@@ -1382,7 +1382,7 @@ - (void)insertObjectAtIndex:(NSInteger)index
for (int i = index; i < _numberTotalItems; i++)
{
- UIView *oldView = [self itemSubViewForPosition:i];
+ UIView *oldView = [self cellForItemAtIndex:i];
oldView.tag = oldView.tag + 1;
}
@@ -1410,11 +1410,11 @@ - (void)removeObjectAtIndex:(NSInteger)index
{
NSAssert((index >= 0 && index < _numberTotalItems), @"Invalid index specified");
- GMGridViewCell *cell = [self itemSubViewForPosition:index];
+ GMGridViewCell *cell = [self cellForItemAtIndex:index];
for (int i = index + 1; i < _numberTotalItems; i++)
{
- GMGridViewCell *oldView = [self itemSubViewForPosition:i];
+ GMGridViewCell *oldView = [self cellForItemAtIndex:i];
oldView.tag = oldView.tag - 1;
}
@@ -1451,8 +1451,8 @@ - (void)swapObjectAtIndex:(NSInteger)index1 withObjectAtIndex:(NSInteger)index2
NSAssert((index1 >= 0 && index1 < _numberTotalItems), @"Invalid index1 specified");
NSAssert((index2 >= 0 && index2 < _numberTotalItems), @"Invalid index2 specified");
- GMGridViewCell *view1 = [self itemSubViewForPosition:index1];
- GMGridViewCell *view2 = [self itemSubViewForPosition:index2];
+ GMGridViewCell *view1 = [self cellForItemAtIndex:index1];
+ GMGridViewCell *view2 = [self cellForItemAtIndex:index2];
view1.tag = index2 + kTagOffset;
view2.tag = index1 + kTagOffset;

0 comments on commit c8c6b8e

Please sign in to comment.