2010-06-25 18:36:01 -04:00
|
|
|
//
|
|
|
|
// StoryDetailViewController.m
|
|
|
|
// NewsBlur
|
|
|
|
//
|
|
|
|
// Created by Samuel Clay on 6/24/10.
|
|
|
|
// Copyright 2010 __MyCompanyName__. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "StoryDetailViewController.h"
|
|
|
|
#import "NewsBlurAppDelegate.h"
|
2011-09-05 22:06:31 -07:00
|
|
|
#import "FeedDetailViewController.h"
|
2010-11-22 10:44:52 -05:00
|
|
|
#import "ASIHTTPRequest.h"
|
|
|
|
#import "ASIFormDataRequest.h"
|
2011-09-05 22:06:31 -07:00
|
|
|
#import "Base64.h"
|
2011-10-17 09:37:16 -07:00
|
|
|
#import "Utilities.h"
|
2010-06-25 18:36:01 -04:00
|
|
|
|
|
|
|
@implementation StoryDetailViewController
|
|
|
|
|
2011-08-14 00:16:25 -07:00
|
|
|
@synthesize activeStoryId;
|
2010-06-25 18:36:01 -04:00
|
|
|
@synthesize appDelegate;
|
2011-07-26 08:37:10 -07:00
|
|
|
@synthesize progressView;
|
2010-06-27 19:35:17 -04:00
|
|
|
@synthesize webView;
|
2011-02-13 19:01:01 -05:00
|
|
|
@synthesize toolbar;
|
|
|
|
@synthesize buttonNext;
|
|
|
|
@synthesize buttonPrevious;
|
2011-09-05 22:06:31 -07:00
|
|
|
@synthesize activity;
|
|
|
|
@synthesize loadingIndicator;
|
2011-10-30 20:24:12 -07:00
|
|
|
@synthesize feedTitleGradient;
|
2010-06-25 18:36:01 -04:00
|
|
|
|
|
|
|
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
|
|
|
|
2011-03-09 18:23:55 -05:00
|
|
|
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
|
2010-06-25 18:36:01 -04:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2011-08-14 00:16:25 -07:00
|
|
|
- (void)dealloc {
|
|
|
|
[activeStoryId release];
|
|
|
|
[appDelegate release];
|
|
|
|
[progressView release];
|
|
|
|
[webView release];
|
|
|
|
[toolbar release];
|
|
|
|
[buttonNext release];
|
|
|
|
[buttonPrevious release];
|
2011-09-05 22:06:31 -07:00
|
|
|
[activity release];
|
|
|
|
[loadingIndicator release];
|
2011-10-30 20:24:12 -07:00
|
|
|
[feedTitleGradient release];
|
2011-08-14 00:16:25 -07:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2011-08-24 10:24:02 -07:00
|
|
|
- (void)viewDidLoad {
|
|
|
|
UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
backBtn.frame = CGRectMake(0, 0, 51, 31);
|
|
|
|
[backBtn setImage:[UIImage imageNamed:@"nav_btn_back.png"] forState:UIControlStateNormal];
|
|
|
|
[backBtn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
UIBarButtonItem *back = [[[UIBarButtonItem alloc] initWithCustomView:backBtn] autorelease];
|
|
|
|
self.navigationItem.backBarButtonItem = back;
|
2011-09-05 22:06:31 -07:00
|
|
|
self.loadingIndicator = [[[UIActivityIndicatorView alloc]
|
|
|
|
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite]
|
|
|
|
autorelease];
|
|
|
|
|
2011-08-24 10:24:02 -07:00
|
|
|
[super viewDidLoad];
|
|
|
|
}
|
|
|
|
|
2010-06-25 18:36:01 -04:00
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
2011-08-24 10:24:02 -07:00
|
|
|
// NSLog(@"Stories; %@ -- %@ (%d)", self.activeStoryId, [appDelegate.activeStory objectForKey:@"id"], self.activeStoryId == [appDelegate.activeStory objectForKey:@"id"]);
|
2011-08-22 18:25:33 -07:00
|
|
|
id storyId = [appDelegate.activeStory objectForKey:@"id"];
|
|
|
|
if (self.activeStoryId != storyId) {
|
|
|
|
[appDelegate pushReadStory:storyId];
|
2011-08-14 00:16:25 -07:00
|
|
|
[self setActiveStory];
|
|
|
|
[self showStory];
|
|
|
|
[self markStoryAsRead];
|
|
|
|
[self setNextPreviousButtons];
|
|
|
|
self.webView.scalesPageToFit = YES;
|
|
|
|
}
|
2011-09-05 22:06:31 -07:00
|
|
|
[self.loadingIndicator stopAnimating];
|
2011-07-25 09:08:20 -07:00
|
|
|
|
2010-11-22 10:44:52 -05:00
|
|
|
[super viewWillAppear:animated];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewDidAppear:(BOOL)animated {
|
2011-08-14 00:16:25 -07:00
|
|
|
UIBarButtonItem *originalButton = [[UIBarButtonItem alloc]
|
|
|
|
initWithTitle:@"Original"
|
|
|
|
style:UIBarButtonItemStyleBordered
|
|
|
|
target:self
|
|
|
|
action:@selector(showOriginalSubview:)
|
|
|
|
];
|
|
|
|
self.navigationItem.rightBarButtonItem = originalButton;
|
|
|
|
[originalButton release];
|
2010-11-22 10:44:52 -05:00
|
|
|
[super viewDidAppear:animated];
|
|
|
|
}
|
|
|
|
|
2011-08-14 10:22:26 -07:00
|
|
|
- (void)viewDidDisappear:(BOOL)animated {
|
|
|
|
Class viewClass = [appDelegate.navigationController.visibleViewController class];
|
|
|
|
if (viewClass == [appDelegate.feedDetailViewController class] ||
|
|
|
|
viewClass == [appDelegate.feedsViewController class]) {
|
|
|
|
self.activeStoryId = nil;
|
|
|
|
[webView loadHTMLString:@"" baseURL:[NSURL URLWithString:@""]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-25 09:08:20 -07:00
|
|
|
- (void)setNextPreviousButtons {
|
|
|
|
int nextIndex = [appDelegate indexOfNextStory];
|
2011-09-05 22:06:31 -07:00
|
|
|
int unreadCount = [appDelegate unreadCount];
|
|
|
|
if (nextIndex == -1 && unreadCount > 0) {
|
|
|
|
[buttonNext setStyle:UIBarButtonItemStyleBordered];
|
|
|
|
[buttonNext setTitle:@"Next Unread"];
|
|
|
|
} else if (nextIndex == -1) {
|
|
|
|
[buttonNext setStyle:UIBarButtonItemStyleDone];
|
2011-07-25 09:08:20 -07:00
|
|
|
[buttonNext setTitle:@"Done"];
|
|
|
|
} else {
|
2011-09-05 22:06:31 -07:00
|
|
|
[buttonNext setStyle:UIBarButtonItemStyleBordered];
|
2011-07-25 09:08:20 -07:00
|
|
|
[buttonNext setTitle:@"Next Unread"];
|
|
|
|
}
|
|
|
|
|
2011-08-22 18:25:33 -07:00
|
|
|
int readStoryCount = [appDelegate.readStories count];
|
|
|
|
if (readStoryCount == 0 ||
|
|
|
|
(readStoryCount == 1 &&
|
|
|
|
[appDelegate.readStories lastObject] == [appDelegate.activeStory objectForKey:@"id"])) {
|
2011-09-05 22:06:31 -07:00
|
|
|
|
|
|
|
[buttonPrevious setStyle:UIBarButtonItemStyleDone];
|
2011-07-25 09:08:20 -07:00
|
|
|
[buttonPrevious setTitle:@"Done"];
|
|
|
|
} else {
|
2011-09-05 22:06:31 -07:00
|
|
|
[buttonPrevious setStyle:UIBarButtonItemStyleBordered];
|
2011-07-25 09:08:20 -07:00
|
|
|
[buttonPrevious setTitle:@"Previous"];
|
|
|
|
}
|
2011-07-26 08:37:10 -07:00
|
|
|
|
|
|
|
float unreads = [appDelegate unreadCount];
|
2011-08-09 17:58:43 -07:00
|
|
|
float total = [appDelegate originalStoryCount];
|
2011-07-26 08:37:10 -07:00
|
|
|
float progress = (total - unreads) / total;
|
2011-08-14 00:16:25 -07:00
|
|
|
// NSLog(@"Total: %f / %f = %f", unreads, total, progress);
|
2011-07-26 08:37:10 -07:00
|
|
|
[progressView setProgress:progress];
|
2011-07-25 09:08:20 -07:00
|
|
|
}
|
|
|
|
|
2010-11-22 10:44:52 -05:00
|
|
|
- (void)markStoryAsRead {
|
2011-07-24 21:47:58 -07:00
|
|
|
if ([[appDelegate.activeStory objectForKey:@"read_status"] intValue] != 1) {
|
|
|
|
[appDelegate markActiveStoryRead];
|
|
|
|
|
2011-08-24 10:24:02 -07:00
|
|
|
NSString *urlString = [NSString stringWithFormat:@"http://%@/reader/mark_story_as_read",
|
|
|
|
NEWSBLUR_URL];
|
2011-07-24 21:47:58 -07:00
|
|
|
NSURL *url = [NSURL URLWithString:urlString];
|
|
|
|
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
|
2011-08-14 00:16:25 -07:00
|
|
|
[request setPostValue:[appDelegate.activeStory
|
|
|
|
objectForKey:@"id"]
|
|
|
|
forKey:@"story_id"];
|
2011-10-26 20:09:28 -07:00
|
|
|
[request setPostValue:[appDelegate.activeStory
|
|
|
|
objectForKey:@"story_feed_id"]
|
2011-08-14 00:16:25 -07:00
|
|
|
forKey:@"feed_id"];
|
2011-08-01 09:43:13 -07:00
|
|
|
[request setDidFinishSelector:@selector(markedAsRead)];
|
|
|
|
[request setDidFailSelector:@selector(markedAsRead)];
|
2011-07-24 21:47:58 -07:00
|
|
|
[request setDelegate:self];
|
|
|
|
[request startAsynchronous];
|
|
|
|
}
|
2010-11-22 10:44:52 -05:00
|
|
|
}
|
|
|
|
|
2011-08-01 09:43:13 -07:00
|
|
|
- (void)markedAsRead {
|
2010-11-22 10:44:52 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)showStory {
|
2011-06-15 11:21:55 -04:00
|
|
|
// NSLog(@"Loaded Story view: %@", appDelegate.activeStory);
|
2010-07-15 23:32:37 -04:00
|
|
|
NSString *imgCssString = [NSString stringWithFormat:@"<style>"
|
|
|
|
"body {"
|
|
|
|
" line-height: 18px;"
|
|
|
|
" font-size: 13px;"
|
|
|
|
" font-family: 'Lucida Grande',Helvetica, Arial;"
|
|
|
|
" text-rendering: optimizeLegibility;"
|
2010-11-22 10:44:52 -05:00
|
|
|
" margin: 0;"
|
2010-07-15 23:32:37 -04:00
|
|
|
"}"
|
2011-08-09 17:58:43 -07:00
|
|
|
"h1, h2, h3, h4, h5, h6, div, table, span, pre, code {"
|
|
|
|
" max-width: 300px;"
|
|
|
|
"}"
|
2010-07-15 23:32:37 -04:00
|
|
|
"img {"
|
|
|
|
" max-width: 300px;"
|
|
|
|
" width: auto;"
|
|
|
|
" height: auto;"
|
|
|
|
"}"
|
|
|
|
"blockquote {"
|
|
|
|
" background-color: #F0F0F0;"
|
|
|
|
" border-left: 1px solid #9B9B9B;"
|
|
|
|
" padding: .5em 2em;"
|
|
|
|
" margin: 0px;"
|
|
|
|
"}"
|
2010-11-22 10:44:52 -05:00
|
|
|
".NB-header {"
|
|
|
|
" font-size: 14px;"
|
|
|
|
" font-weight: bold;"
|
|
|
|
" background-color: #E0E0E0;"
|
|
|
|
" border-bottom: 1px solid #A0A0A0;"
|
2011-07-20 21:08:57 -07:00
|
|
|
" padding: 8px 8px 6px;"
|
2010-11-22 10:44:52 -05:00
|
|
|
" text-shadow: 1px 1px 0 #EFEFEF;"
|
2011-07-20 21:08:57 -07:00
|
|
|
" overflow: hidden;"
|
2011-08-09 17:58:43 -07:00
|
|
|
" max-width: none;"
|
2010-11-22 10:44:52 -05:00
|
|
|
"}"
|
|
|
|
".NB-story {"
|
2011-07-18 09:56:48 -07:00
|
|
|
" margin: 12px 8px;"
|
2010-11-22 10:44:52 -05:00
|
|
|
"}"
|
2011-06-13 10:44:17 -04:00
|
|
|
".NB-story-author {"
|
|
|
|
" color: #969696;"
|
|
|
|
" font-size: 10px;"
|
|
|
|
" text-transform: uppercase;"
|
2011-07-20 21:08:57 -07:00
|
|
|
" margin: 2px 8px 0px 0;"
|
2011-06-13 10:44:17 -04:00
|
|
|
" text-shadow: 0 1px 0 #F9F9F9;"
|
|
|
|
" float: left;"
|
|
|
|
"}"
|
|
|
|
".NB-story-tags {"
|
|
|
|
" overflow: hidden;"
|
|
|
|
" line-height: 12px;"
|
|
|
|
" height: 14px;"
|
2011-07-20 21:08:57 -07:00
|
|
|
" padding: 5px 0 0 0;"
|
2011-06-13 10:44:17 -04:00
|
|
|
" text-transform: uppercase;"
|
|
|
|
"}"
|
|
|
|
".NB-story-tag {"
|
|
|
|
" float: left;"
|
|
|
|
" font-weight: normal;"
|
|
|
|
" font-size: 9px;"
|
2011-06-14 10:35:33 -04:00
|
|
|
" padding: 0px 4px 0px;"
|
|
|
|
" margin: 0 4px 2px 0;"
|
|
|
|
" background-color: #C6CBC3;"
|
|
|
|
" color: #505050;"
|
|
|
|
" text-shadow: 0 1px 0 #E7E7E7;"
|
2011-06-13 10:44:17 -04:00
|
|
|
" border-radius: 4px;"
|
|
|
|
" -moz-border-radius: 4px;"
|
|
|
|
" -webkit-border-radius: 4px;"
|
|
|
|
"}"
|
|
|
|
".NB-story-date {"
|
|
|
|
" font-size: 11px;"
|
2011-08-09 17:58:43 -07:00
|
|
|
" color: #454D6C;"
|
2011-06-13 10:44:17 -04:00
|
|
|
"}"
|
|
|
|
".NB-story-title {"
|
|
|
|
" clear: left;"
|
2011-07-20 21:08:57 -07:00
|
|
|
" margin: 4px 0 4px;"
|
2011-06-13 10:44:17 -04:00
|
|
|
"}"
|
2011-08-09 17:58:43 -07:00
|
|
|
"ins {"
|
|
|
|
" text-decoration: none;"
|
|
|
|
"}"
|
|
|
|
"del {"
|
|
|
|
" display: none;"
|
|
|
|
"}"
|
|
|
|
"</style>"
|
|
|
|
"<meta name=\"viewport\" content=\"width=320\"/>"];
|
2011-06-13 10:44:17 -04:00
|
|
|
NSString *story_author = @"";
|
|
|
|
if ([appDelegate.activeStory objectForKey:@"story_authors"]) {
|
2011-08-14 00:16:25 -07:00
|
|
|
NSString *author = [NSString stringWithFormat:@"%@",
|
|
|
|
[appDelegate.activeStory objectForKey:@"story_authors"]];
|
2011-06-14 10:35:33 -04:00
|
|
|
if (author && ![author isEqualToString:@"<null>"]) {
|
|
|
|
story_author = [NSString stringWithFormat:@"<div class=\"NB-story-author\">%@</div>",author];
|
|
|
|
}
|
2011-06-13 10:44:17 -04:00
|
|
|
}
|
|
|
|
NSString *story_tags = @"";
|
|
|
|
if ([appDelegate.activeStory objectForKey:@"story_tags"]) {
|
|
|
|
NSArray *tag_array = [appDelegate.activeStory objectForKey:@"story_tags"];
|
|
|
|
if ([tag_array count] > 0) {
|
2011-08-14 00:16:25 -07:00
|
|
|
story_tags = [NSString
|
|
|
|
stringWithFormat:@"<div class=\"NB-story-tags\">"
|
|
|
|
"<div class=\"NB-story-tag\">"
|
|
|
|
"%@</div></div>",
|
2011-06-14 10:35:33 -04:00
|
|
|
[tag_array componentsJoinedByString:@"</div><div class=\"NB-story-tag\">"]];
|
2011-06-13 10:44:17 -04:00
|
|
|
}
|
|
|
|
}
|
2010-11-22 10:44:52 -05:00
|
|
|
NSString *storyHeader = [NSString stringWithFormat:@"<div class=\"NB-header\">"
|
2011-06-13 10:44:17 -04:00
|
|
|
"<div class=\"NB-story-date\">%@</div>"
|
|
|
|
"<div class=\"NB-story-title\">%@</div>"
|
|
|
|
"%@"
|
2011-07-20 21:08:57 -07:00
|
|
|
"%@"
|
2011-06-13 10:44:17 -04:00
|
|
|
"</div>",
|
2011-08-14 00:16:25 -07:00
|
|
|
[story_tags length] ?
|
|
|
|
[appDelegate.activeStory
|
|
|
|
objectForKey:@"long_parsed_date"] :
|
|
|
|
[appDelegate.activeStory
|
|
|
|
objectForKey:@"short_parsed_date"],
|
2011-06-13 10:44:17 -04:00
|
|
|
[appDelegate.activeStory objectForKey:@"story_title"],
|
2011-07-20 21:08:57 -07:00
|
|
|
story_author,
|
2011-06-13 10:44:17 -04:00
|
|
|
story_tags];
|
2010-11-22 10:44:52 -05:00
|
|
|
NSString *htmlString = [NSString stringWithFormat:@"%@ %@ <div class=\"NB-story\">%@</div>",
|
|
|
|
imgCssString, storyHeader,
|
|
|
|
[appDelegate.activeStory objectForKey:@"story_content"]];
|
2011-10-27 19:05:38 -07:00
|
|
|
NSString *feed_link = [[appDelegate.dictFeeds objectForKey:[NSString stringWithFormat:@"%@",
|
|
|
|
[appDelegate.activeStory
|
|
|
|
objectForKey:@"story_feed_id"]]]
|
|
|
|
objectForKey:@"feed_link"];
|
|
|
|
|
2010-07-15 23:32:37 -04:00
|
|
|
[webView loadHTMLString:htmlString
|
2011-10-27 09:44:58 -07:00
|
|
|
baseURL:[NSURL URLWithString:feed_link]];
|
2011-10-27 19:05:38 -07:00
|
|
|
|
|
|
|
NSDictionary *feed = [appDelegate.dictFeeds objectForKey:[NSString stringWithFormat:@"%@",
|
|
|
|
[appDelegate.activeStory
|
|
|
|
objectForKey:@"story_feed_id"]]];
|
2011-10-30 20:24:12 -07:00
|
|
|
[self.feedTitleGradient addSubview:[appDelegate makeFeedTitleGradient:feed
|
|
|
|
withRect:CGRectMake(-1, -21, self.webView.frame.size.width, 21)]];
|
|
|
|
|
2011-10-27 19:05:38 -07:00
|
|
|
for (NSObject *aSubView in [self.webView subviews]) {
|
|
|
|
if ([aSubView isKindOfClass:[UIScrollView class]]) {
|
|
|
|
UIScrollView * theScrollView = (UIScrollView *)aSubView;
|
2011-10-28 10:51:03 -07:00
|
|
|
if (appDelegate.isRiverView) {
|
2011-10-30 18:53:10 -07:00
|
|
|
theScrollView.contentInset = UIEdgeInsetsMake(19, 0, 0, 0);
|
2011-10-28 10:51:03 -07:00
|
|
|
} else {
|
2011-10-30 20:24:12 -07:00
|
|
|
theScrollView.contentInset = UIEdgeInsetsMake(9, 0, 0, 0);
|
2011-10-28 10:51:03 -07:00
|
|
|
}
|
2011-10-28 18:29:33 -07:00
|
|
|
feedTitleGradient.tag = 12; // Not attached yet. Remove old gradients, first.
|
2011-10-30 20:24:12 -07:00
|
|
|
// for (UIView *subview in theScrollView.subviews) {
|
|
|
|
// if (subview.tag == 12) {
|
|
|
|
// [subview removeFromSuperview];
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// [self.view addSubview:feedTitleGradient];
|
2011-10-28 10:51:03 -07:00
|
|
|
break;
|
2011-10-27 19:05:38 -07:00
|
|
|
}
|
|
|
|
}
|
2010-06-25 18:36:01 -04:00
|
|
|
}
|
|
|
|
|
2011-06-14 10:35:33 -04:00
|
|
|
- (IBAction)doNextUnreadStory {
|
2011-06-15 11:21:55 -04:00
|
|
|
int nextIndex = [appDelegate indexOfNextStory];
|
2011-09-05 22:06:31 -07:00
|
|
|
int unreadCount = [appDelegate unreadCount];
|
|
|
|
[self.loadingIndicator stopAnimating];
|
|
|
|
|
|
|
|
if (nextIndex == -1 && unreadCount > 0 &&
|
|
|
|
self.appDelegate.feedDetailViewController.feedPage < 50 &&
|
|
|
|
!self.appDelegate.feedDetailViewController.pageFinished &&
|
|
|
|
!self.appDelegate.feedDetailViewController.pageFetching) {
|
|
|
|
// Fetch next page and see if it has the unreads.
|
|
|
|
[self.loadingIndicator startAnimating];
|
|
|
|
self.activity.customView = self.loadingIndicator;
|
|
|
|
[self.appDelegate.feedDetailViewController fetchNextPage:^() {
|
|
|
|
[self doNextUnreadStory];
|
|
|
|
}];
|
|
|
|
} else if (nextIndex == -1) {
|
2011-08-14 00:16:25 -07:00
|
|
|
[appDelegate.navigationController
|
|
|
|
popToViewController:[appDelegate.navigationController.viewControllers
|
|
|
|
objectAtIndex:0]
|
|
|
|
animated:YES];
|
2011-06-15 11:21:55 -04:00
|
|
|
} else {
|
2011-08-14 00:16:25 -07:00
|
|
|
[appDelegate setActiveStory:[[appDelegate activeFeedStories]
|
|
|
|
objectAtIndex:nextIndex]];
|
2011-08-22 18:25:33 -07:00
|
|
|
[appDelegate pushReadStory:[appDelegate.activeStory objectForKey:@"id"]];
|
2011-08-14 00:16:25 -07:00
|
|
|
[self setActiveStory];
|
2011-06-15 11:21:55 -04:00
|
|
|
[self showStory];
|
2011-07-24 21:47:58 -07:00
|
|
|
[self markStoryAsRead];
|
2011-07-25 09:08:20 -07:00
|
|
|
[self setNextPreviousButtons];
|
2011-07-24 21:47:58 -07:00
|
|
|
|
2011-06-15 11:21:55 -04:00
|
|
|
[UIView beginAnimations:nil context:nil];
|
|
|
|
[UIView setAnimationDuration:.5];
|
|
|
|
[UIView setAnimationBeginsFromCurrentState:NO];
|
2011-08-14 00:16:25 -07:00
|
|
|
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp
|
|
|
|
forView:self.view
|
|
|
|
cache:NO];
|
2011-06-15 11:21:55 -04:00
|
|
|
[UIView commitAnimations];
|
|
|
|
}
|
2011-06-14 10:35:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)doPreviousStory {
|
2011-09-05 22:06:31 -07:00
|
|
|
[self.loadingIndicator stopAnimating];
|
2011-08-22 18:25:33 -07:00
|
|
|
id previousStoryId = [appDelegate popReadStory];
|
|
|
|
if (!previousStoryId || previousStoryId == [appDelegate.activeStory objectForKey:@"id"]) {
|
2011-08-14 00:16:25 -07:00
|
|
|
[appDelegate.navigationController
|
|
|
|
popToViewController:[appDelegate.navigationController.viewControllers
|
|
|
|
objectAtIndex:0]
|
|
|
|
animated:YES];
|
2011-06-15 11:21:55 -04:00
|
|
|
} else {
|
2011-08-22 18:25:33 -07:00
|
|
|
int previousIndex = [appDelegate locationOfStoryId:previousStoryId];
|
|
|
|
if (previousIndex == -1) {
|
|
|
|
return [self doPreviousStory];
|
|
|
|
}
|
2011-08-14 00:16:25 -07:00
|
|
|
[appDelegate setActiveStory:[[appDelegate activeFeedStories]
|
|
|
|
objectAtIndex:previousIndex]];
|
|
|
|
[self setActiveStory];
|
2011-06-15 11:21:55 -04:00
|
|
|
[self showStory];
|
2011-07-24 21:47:58 -07:00
|
|
|
[self markStoryAsRead];
|
2011-07-25 09:08:20 -07:00
|
|
|
[self setNextPreviousButtons];
|
2011-06-15 11:21:55 -04:00
|
|
|
|
|
|
|
[UIView beginAnimations:nil context:nil];
|
|
|
|
[UIView setAnimationDuration:.5];
|
|
|
|
[UIView setAnimationBeginsFromCurrentState:NO];
|
2011-08-14 00:16:25 -07:00
|
|
|
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown
|
|
|
|
forView:self.view
|
|
|
|
cache:NO];
|
2011-06-15 11:21:55 -04:00
|
|
|
[UIView commitAnimations];
|
|
|
|
}
|
2011-06-14 10:35:33 -04:00
|
|
|
}
|
|
|
|
|
2010-11-13 18:32:43 -05:00
|
|
|
- (void)showOriginalSubview:(id)sender {
|
|
|
|
NSURL *url = [NSURL URLWithString:[appDelegate.activeStory
|
|
|
|
objectForKey:@"story_permalink"]];
|
|
|
|
[appDelegate showOriginalStory:url];
|
|
|
|
}
|
|
|
|
|
2011-08-14 00:16:25 -07:00
|
|
|
- (void)setActiveStory {
|
2011-08-24 19:36:03 -07:00
|
|
|
self.activeStoryId = [appDelegate.activeStory objectForKey:@"id"];
|
|
|
|
|
2011-10-26 08:40:31 -07:00
|
|
|
NSString *feedIdStr = [NSString stringWithFormat:@"%@", [appDelegate.activeStory objectForKey:@"story_feed_id"]];
|
2011-10-28 10:51:03 -07:00
|
|
|
UIImage *titleImage = appDelegate.isRiverView ?
|
|
|
|
[UIImage imageNamed:@"folder.png"] :
|
|
|
|
[Utilities getImage:feedIdStr];
|
2011-08-24 19:36:03 -07:00
|
|
|
UIImageView *titleImageView = [[UIImageView alloc] initWithImage:titleImage];
|
|
|
|
titleImageView.frame = CGRectMake(0.0, 2.0, 16.0, 16.0);
|
|
|
|
self.navigationItem.titleView = titleImageView;
|
|
|
|
[titleImageView release];
|
2011-08-14 00:16:25 -07:00
|
|
|
}
|
|
|
|
|
2010-06-25 18:36:01 -04:00
|
|
|
- (void)didReceiveMemoryWarning {
|
|
|
|
// Releases the view if it doesn't have a superview.
|
|
|
|
[super didReceiveMemoryWarning];
|
2011-08-18 09:56:52 -07:00
|
|
|
self.activeStoryId = nil;
|
2010-06-25 18:36:01 -04:00
|
|
|
// Release any cached data, images, etc that aren't in use.
|
|
|
|
}
|
|
|
|
|
2011-08-14 00:16:25 -07:00
|
|
|
- (BOOL)webView:(UIWebView *)webView
|
|
|
|
shouldStartLoadWithRequest:(NSURLRequest *)request
|
|
|
|
navigationType:(UIWebViewNavigationType)navigationType {
|
2010-11-13 18:32:43 -05:00
|
|
|
if (navigationType == UIWebViewNavigationTypeLinkClicked) {
|
|
|
|
NSURL *url = [request URL];
|
|
|
|
[appDelegate showOriginalStory:url];
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2011-02-13 19:01:01 -05:00
|
|
|
- (void)webViewDidStartLoad:(UIWebView *)webView {
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)webViewDidFinishLoad:(UIWebView *)webView {
|
|
|
|
}
|
|
|
|
|
2010-06-25 18:36:01 -04:00
|
|
|
@end
|