Skip to content

Commit 911f88a

Browse files
Michael BeattieAlfredo Uribe
authored andcommitted
[#67863352] added ability to remove feeds and added header comments
1 parent ab38b50 commit 911f88a

9 files changed

Lines changed: 48 additions & 33 deletions

EasyReader/Application/Api/CSFakedDataRequestor.m

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,21 @@ - (NSDictionary *) feedItemsResponse
149149
@"created_at": @"2014-03-05T22:32:41+00:00",
150150
@"updated_at": @"2014-03-05T22:32:41+00:00",
151151
@"published_at": @"2014-03-04T19:52:21+00:00"}, nil];
152-
153-
NSRange subarrayRange;
154-
if ( !self.requestCounter ) self.requestCounter = 1;
155-
if ( self.requestCounter == 1 ){
156-
subarrayRange = NSMakeRange(0,4);
157-
} else {
158-
subarrayRange = NSMakeRange(self.requestCounter*2,2);
159-
}
160-
self.requestCounter++;
161-
162-
return @{@"feed_items": [items subarrayWithRange:subarrayRange]};
152+
153+
NSRange subarrayRange;
154+
if ( !self.requestCounter ) self.requestCounter = 1;
155+
if ( self.requestCounter == 1 ){
156+
subarrayRange = NSMakeRange(0,4);
157+
} else {
158+
if( self.requestCounter*2 < [items count]){
159+
subarrayRange = NSMakeRange(self.requestCounter*2,2);
160+
} else {
161+
subarrayRange = NSMakeRange(8,2);
162+
}
163+
}
164+
self.requestCounter++;
165+
166+
return @{@"feed_items": [items subarrayWithRange:subarrayRange]};
163167
}
164168

165169

EasyReader/Application/Api/CSFeedSearcher.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
@interface CSFeedSearcher : NSObject
1212

13+
/**
14+
* API requestor for feeds similar to user input
15+
*/
1316
- (void)feedsLike:(NSString *)name;
1417

1518
@end

EasyReader/Application/Api/CSFeedSearcher.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@implementation CSFeedSearcher
1313

1414
/**
15-
* API requestor for feeds similar to user input
15+
* Returns a set of Feeds and associated FeedItems
1616
*/
1717
- (void)feedsLike:(NSString *)name
1818
{

EasyReader/Application/Controllers/CSRootViewController.m

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
3838
return self;
3939
}
4040

41-
- (void) viewWillAppear:(BOOL)animated
42-
{
43-
[super viewWillAppear:animated];
44-
CSAppDelegate *delegate = (CSAppDelegate *)[UIApplication sharedApplication].delegate;
45-
delegate.container.panMode = MFSideMenuPanModeNone;
46-
}
47-
4841
/**
4942
* If the left menu is open, it closes it
5043
* Otherwise it opens to the left menu

EasyReader/Application/Controllers/Menu/CSMenuLeftViewController.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#import "UIImageView+AFNetworking.h"
1313

1414
#import "Feed.h"
15+
#import "FeedItem.h"
1516
#import "User.h"
1617
#import "CSAppDelegate.h"
1718
#import "CSRootViewController.h"
@@ -135,7 +136,7 @@ - (void)menuStateEventOccurred:(NSNotification *)notification {
135136
case MFSideMenuStateEventMenuDidClose:
136137
weakSelf.textField_searchInput.text = @"";
137138
[weakSelf.tableView_feeds setEditing:NO animated:YES];
138-
weakSelf.menuContainerViewController.panMode = MFSideMenuPanModeDefault;
139+
weakSelf.menuContainerViewController.panMode = MFSideMenuPanModeNone;
139140

140141
// Reset to the users feeds
141142
weakSelf.tableView_feeds.dataSource = userFeedDataSource;

EasyReader/Application/Controllers/Menu/MenuDataSources/CSMenuSearchFeedDataSource.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,17 @@
1010

1111
@interface CSMenuSearchFeedDataSource : NSObject<UITableViewDataSource>
1212

13+
#pragma mark - Properties
14+
/**
15+
* Feeds used to populate the menu table
16+
*/
1317
@property (nonatomic, retain) NSMutableSet *feeds;
1418

19+
20+
#pragma mark - Methods
21+
/**
22+
* Updates the list of feeds used to populate the menu table
23+
*/
1524
- (void)updateWithFeeds:(NSMutableSet *)feeds;
1625

1726
@end

EasyReader/Application/Controllers/Menu/MenuDataSources/CSMenuSearchFeedDataSource.m

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#import "CSMenuSearchFeedDataSource.h"
1010
#import "CSUserFeedCell.h"
1111
#import "Feed.h"
12+
#import "FeedItem.h"
1213
#import "UIImageView+AFNetworking.h"
1314

1415
@implementation CSMenuSearchFeedDataSource
@@ -30,7 +31,8 @@ - (id)init
3031
}
3132

3233
/**
33-
* Sets the feeds to those returned by the search
34+
* Sets the feeds to those returned by the search API or
35+
* The custom feed being created by the user
3436
*/
3537
- (void)updateWithFeeds:(NSMutableSet *)feeds
3638
{
@@ -107,6 +109,10 @@ - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEd
107109
{
108110
Feed *toDelete = [self.feeds allObjects][indexPath.row];
109111

112+
[self.feeds removeObject:toDelete];
113+
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
114+
115+
for( FeedItem *item in toDelete.feedItems ) [item deleteEntity];
110116
[toDelete deleteEntity];
111117

112118
[[NSManagedObjectContext defaultContext] saveToPersistentStoreAndWait];
@@ -118,12 +124,7 @@ - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEd
118124
*/
119125
- (UITableViewCellEditingStyle) tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
120126
{
121-
if (!tableView.isEditing)
122-
{
123-
return UITableViewCellEditingStyleNone;
124-
}
125-
126-
if (indexPath.section == 0 && indexPath.row == [self tableView:tableView numberOfRowsInSection:0] - 1)
127+
if ( indexPath.row == [_feeds count] )
127128
{
128129
return UITableViewCellEditingStyleInsert;
129130
}

EasyReader/Application/Controllers/Menu/MenuDataSources/CSMenuUserFeedDataSource.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,17 @@
1010

1111
@interface CSMenuUserFeedDataSource : NSObject<UITableViewDataSource>
1212

13+
#pragma mark - Properties
14+
/**
15+
* Feeds used to populate the menu table
16+
*/
1317
@property (nonatomic, retain) NSMutableSet *feeds;
1418

19+
20+
#pragma mark - Methods
21+
/**
22+
* Updates the list of feeds used to populate the menu table
23+
*/
1524
- (void)updateWithFeeds:(NSMutableSet *)feeds;
1625

1726
@end

EasyReader/Application/Controllers/Menu/MenuDataSources/CSMenuUserFeedDataSource.m

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,7 @@ - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEd
117117
*/
118118
- (UITableViewCellEditingStyle) tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
119119
{
120-
if (!tableView.isEditing)
121-
{
122-
return UITableViewCellEditingStyleNone;
123-
}
124-
125-
if (indexPath.section == 0 && indexPath.row == [self tableView:tableView numberOfRowsInSection:0] - 1)
120+
if ( indexPath.row == [_feeds count] )
126121
{
127122
return UITableViewCellEditingStyleInsert;
128123
}

0 commit comments

Comments
 (0)