mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Adding pull on Feed detail page in iphone app to forc ea refresh of the feed. Doesn't quite work yet.
This commit is contained in:
parent
cddc591be4
commit
183a6d00ab
5 changed files with 34 additions and 5 deletions
|
@ -2,7 +2,7 @@
|
|||
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
|
||||
<data>
|
||||
<int key="IBDocument.SystemTarget">1024</int>
|
||||
<string key="IBDocument.SystemVersion">11A511</string>
|
||||
<string key="IBDocument.SystemVersion">11B26</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">1617</string>
|
||||
<string key="IBDocument.AppKitVersion">1138</string>
|
||||
<string key="IBDocument.HIToolboxVersion">566.00</string>
|
||||
|
@ -106,7 +106,7 @@
|
|||
</object>
|
||||
<object class="NSColor" key="IBUIHighlightedColor">
|
||||
<int key="NSColorSpace">1</int>
|
||||
<bytes key="NSRGB">MC44NzQ4NjczMjAxIDAuODc0NzA4OTUwNSAwLjg5NzYyOTk3NjMAA</bytes>
|
||||
<bytes key="NSRGB">MC45Mzk5NzgyNDE5IDAuOTM4OTkxNjY1OCAwLjk3NDUzMTExNDEAA</bytes>
|
||||
</object>
|
||||
<object class="NSColor" key="IBUIShadowColor">
|
||||
<int key="NSColorSpace">1</int>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
@class NewsBlurAppDelegate;
|
||||
|
||||
@interface FeedDetailViewController : UIViewController
|
||||
<UITableViewDelegate, UITableViewDataSource> {
|
||||
<UITableViewDelegate, UITableViewDataSource, PullToRefreshViewDelegate> {
|
||||
NewsBlurAppDelegate *appDelegate;
|
||||
|
||||
NSArray * stories;
|
||||
|
|
|
@ -438,12 +438,25 @@
|
|||
|
||||
// called when the user pulls-to-refresh
|
||||
- (void)pullToRefreshViewShouldRefresh:(PullToRefreshView *)view {
|
||||
// [self fetchFeedList:NO];
|
||||
NSString *urlString = @"http://www.newsblur.com/reader/mark_feed_as_read";
|
||||
NSURL *url = [NSURL URLWithString:urlString];
|
||||
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
|
||||
[request setPostValue:[appDelegate.activeFeed objectForKey:@"id"] forKey:@"feed_id"];
|
||||
[request setDelegate:nil];
|
||||
[request setDidFinishSelector:@selector(markedAsRead)];
|
||||
[request setDidFailSelector:@selector(markedAsRead)];
|
||||
[request startAsynchronous];
|
||||
[appDelegate markActiveFeedAllRead];
|
||||
[appDelegate.navigationController
|
||||
popToViewController:[appDelegate.navigationController.viewControllers
|
||||
objectAtIndex:0]
|
||||
animated:YES];
|
||||
}
|
||||
|
||||
// called when the date shown needs to be updated, optional
|
||||
- (NSDate *)pullToRefreshViewLastUpdated:(PullToRefreshView *)view {
|
||||
// return self.lastUpdate;
|
||||
return [[[NSDate alloc] initWithTimeIntervalSinceNow:-30*30] autorelease];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
@class NewsBlurAppDelegate;
|
||||
|
||||
@interface NewsBlurViewController : UIViewController
|
||||
<UITableViewDelegate, UITableViewDataSource>
|
||||
<UITableViewDelegate, UITableViewDataSource, PullToRefreshViewDelegate>
|
||||
{
|
||||
NewsBlurAppDelegate *appDelegate;
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
|||
IBOutlet UIBarButtonItem * sitesButton;
|
||||
}
|
||||
|
||||
- (void)returnToApp;
|
||||
- (void)fetchFeedList:(BOOL)showLoader;
|
||||
- (IBAction)doLogoutButton;
|
||||
- (IBAction)selectIntelligence;
|
||||
|
|
|
@ -61,6 +61,12 @@ blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
|
|||
pull = [[PullToRefreshView alloc] initWithScrollView:self.feedTitlesTable];
|
||||
[pull setDelegate:self];
|
||||
[self.feedTitlesTable addSubview:pull];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(returnToApp)
|
||||
name:UIApplicationWillEnterForegroundNotification
|
||||
object:nil];
|
||||
|
||||
[super viewDidLoad];
|
||||
}
|
||||
|
||||
|
@ -144,6 +150,15 @@ blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
|
|||
#pragma mark -
|
||||
#pragma mark Initialization
|
||||
|
||||
- (void)returnToApp {
|
||||
NSDate *decayDate = [[NSDate alloc] initWithTimeIntervalSinceNow:(-10*60)];
|
||||
NSLog(@"Last Update: %@ - %f", self.lastUpdate, [self.lastUpdate timeIntervalSinceDate:decayDate]);
|
||||
if ([self.lastUpdate timeIntervalSinceDate:decayDate] < 0) {
|
||||
[self fetchFeedList:NO];
|
||||
}
|
||||
[decayDate release];
|
||||
}
|
||||
|
||||
- (void)fetchFeedList:(BOOL)showLoader {
|
||||
if (showLoader) {
|
||||
MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
||||
|
|
Loading…
Add table
Reference in a new issue