No longer clearing story when opening original view. Also fixing rotation issues when returning to story detail from rotated original view.

This commit is contained in:
Samuel Clay 2015-11-30 18:12:10 -08:00
parent 3ee9703d2f
commit 0117bbc815
3 changed files with 32 additions and 15 deletions

View file

@ -2904,7 +2904,7 @@
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW,
(unsigned long)NULL), ^(void) {
[self.database inDatabase:^(FMDatabase *db) {
NSLog(@"Saving scroll %ld in %@-%@", position, [story objectForKey:@"story_hash"], [story objectForKey:@"story_title"]);
// NSLog(@"Saving scroll %ld in %@-%@", position, [story objectForKey:@"story_hash"], [story objectForKey:@"story_title"]);
[db executeUpdate:@"INSERT INTO story_scrolls (story_feed_id, story_hash, story_timestamp, scroll) VALUES (?, ?, ?, ?)",
[story objectForKey:@"story_feed_id"],
[story objectForKey:@"story_hash"],

View file

@ -216,7 +216,8 @@
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
if (!appDelegate.showingSafariViewController) {
if (!appDelegate.showingSafariViewController &&
appDelegate.navigationController.visibleViewController != (UIViewController *)appDelegate.originalStoryViewController) {
[self clearStory];
}
}
@ -262,8 +263,8 @@
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
scrollPct = self.webView.scrollView.contentOffset.y / self.webView.scrollView.contentSize.height;
NSLog(@"Current scroll is %2.2f%% (offset %.0f - height %.0f)", scrollPct*100, self.webView.scrollView.contentOffset.y,
self.webView.scrollView.contentSize.height);
// NSLog(@"Current scroll is %2.2f%% (offset %.0f - height %.0f)", scrollPct*100, self.webView.scrollView.contentOffset.y,
// self.webView.scrollView.contentSize.height);
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
_orientation = [UIApplication sharedApplication].statusBarOrientation;
@ -275,12 +276,24 @@
}
- (void)viewWillLayoutSubviews {
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
[super viewWillLayoutSubviews];
[appDelegate.storyPageControl layoutForInterfaceOrientation:orientation];
[self changeWebViewWidth];
[self drawFeedGradient];
NSLog(@"viewWillLayoutSubviews: %.2f", self.webView.scrollView.bounds.size.width);
}
- (void)layoutForInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (interfaceOrientation != _orientation) {
_orientation = interfaceOrientation;
[self changeWebViewWidth];
[self drawFeedGradient];
[self drawStory];
}
}
#pragma mark -
#pragma mark Story setup
@ -2120,13 +2133,12 @@ shouldStartLoadWithRequest:(NSURLRequest *)request
- (void)fetchTextView {
if (!self.activeStoryId || !self.activeStory) return;
self.inTextView = YES;
// NSLog(@"Fetching Text: %@", [self.activeStory objectForKey:@"story_title"]);
dispatch_async(dispatch_get_main_queue(), ^{
// [MBProgressHUD hideHUDForView:self.webView animated:YES];
// MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.webView animated:YES];
// HUD.labelText = @"Fetching text...";
[self.appDelegate.storyPageControl showFetchingTextNotifier];
});
NSLog(@"Fetching Text: %@", [self.activeStory objectForKey:@"story_title"]);
if (self.activeStory == appDelegate.storyPageControl.currentPage.activeStory) {
dispatch_async(dispatch_get_main_queue(), ^{
[self.appDelegate.storyPageControl showFetchingTextNotifier];
});
}
NSString *urlString = [NSString stringWithFormat:@"%@/rss_feeds/original_text",
NEWSBLUR_URL];
@ -2143,7 +2155,9 @@ shouldStartLoadWithRequest:(NSURLRequest *)request
- (void)failedFetchText:(ASIHTTPRequest *)request {
[self.appDelegate.storyPageControl hideNotifier];
[MBProgressHUD hideHUDForView:self.webView animated:YES];
[self informError:@"Could not fetch text"];
if (self.activeStory == appDelegate.storyPageControl.currentPage.activeStory) {
[self informError:@"Could not fetch text"];
}
self.inTextView = NO;
[appDelegate.storyPageControl setTextButton:self];
}

View file

@ -292,7 +292,8 @@
// self.subscribeButton.tintColor = UIColorFromRGB(0x0a6720);
}
appDelegate.isTryFeedView = NO;
[self applyNewIndex:previousPage.pageIndex pageController:previousPage];
[self reorientPages];
// [self applyNewIndex:previousPage.pageIndex pageController:previousPage];
previousPage.view.hidden = NO;
}
@ -324,11 +325,12 @@
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
_orientation = [UIApplication sharedApplication].statusBarOrientation;
[self layoutForInterfaceOrientation:orientation];
[self adjustDragBar:orientation];
[self reorientPages];
} completion:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
NSLog(@"Story page control did re-orient.");
}];
}
@ -531,7 +533,8 @@
pageController.view.hidden = YES;
pageController.view.frame = pageFrame;
}
NSLog(@"---> Story page control orient page: %@ (%d)", NSStringFromCGRect(self.view.bounds), suppressRedraw);
if (suppressRedraw) return;
// NSInteger wasIndex = pageController.pageIndex;