@@ -54,9 +54,6 @@ @interface EZRHomeViewController()
5454// / The social sharing toolbar
5555@property (nonatomic , weak ) IBOutlet CLDSocialShareToolbar *socialShareToolbar;
5656
57- // / The up indicator displayed over the web view to assist in navigating to the top of the page
58- @property (nonatomic , strong ) UIImageView *upIndicatorView;
59-
6057@end
6158
6259
@@ -90,11 +87,43 @@ @implementation EZRHomeViewController
9087 Feed *lastSelectedFeed;
9188}
9289
90+ #pragma mark - Public Methods
91+
92+ - (void )loadURLForFeedItem : (FeedItem *)feedItem
93+ {
94+ NSURL *url = [NSURL URLWithString: feedItem.url];
95+ NSURLRequest *request = [NSURLRequest requestWithURL: url cachePolicy: NSURLRequestReturnCacheDataElseLoad timeoutInterval: 30.0 ];
96+
97+ [self .webView_feedItem loadRequest: request];
98+ }
99+
100+ - (void )resetWebView
101+ {
102+ [self .webView_feedItem stopLoading ];
103+
104+ NSString *blankHTML = @" <html><head></head><body style=\" background-color: #000000;\" ></body></html>" ;
105+ [self .webView_feedItem loadHTMLString: blankHTML
106+ baseURL: nil ];
107+ }
108+
109+ - (void )hideUpInidicator {
110+ [UIView animateWithDuration: 0 .5f animations: ^{
111+ [self .upIndicatorView setAlpha: 0 .0f ];
112+ }];
113+ }
114+
115+ - (void )showUpInidicator {
116+ [UIView animateWithDuration: 0 .5f animations: ^{
117+ [self .upIndicatorView setAlpha: 1 .0f ];
118+ }];
119+ }
120+
93121- (FeedItem *)currentFeedItem
94122{
95123 return self.collectionView_feedItems .currentFeedItem ;
96124}
97125
126+
98127#pragma mark - UIViewController Methods
99128
100129/* *
@@ -263,12 +292,7 @@ -(void)setUpWebView
263292 [self .upIndicatorView addGestureRecognizer: tapRecognizer];
264293}
265294
266- /* *
267- * Scrolls the main containing scroll view to the top (animated)
268- */
269- - (void ) scrollToTop {
270- [self .scrollView_vertical setContentOffset: CGPointMake (0 ,0 ) animated: YES ];
271- }
295+
272296
273297
274298#pragma mark - Observations
@@ -328,7 +352,7 @@ - (void) visibleFeedItemsDidChange:(EZRCurrentFeedsProvider *)currentFeedService
328352}
329353
330354
331- #pragma mark - IBActions
355+ #pragma mark - Actions
332356
333357// Receives left menu link click
334358- (IBAction )buttonLeftMenu_touchUpInside_goToMenu : (id )sender {
@@ -356,6 +380,15 @@ - (void)scrollToFeedItem:(FeedItem *)feedItem
356380 [_collectionView_feedItems scrollToItemAtIndexPath: indexPath atScrollPosition: UICollectionViewScrollPositionCenteredHorizontally animated: NO ];
357381}
358382
383+ /* *
384+ * Scrolls the main containing scroll view to the top (animated)
385+ */
386+ - (void ) scrollToTop {
387+ [self .scrollView_vertical setContentOffset: CGPointMake (0 ,0 ) animated: YES ];
388+ }
389+
390+ #pragma mark - Prefetching
391+
359392/* *
360393 * Fetches the current feed item image, then prefetches after
361394 */
@@ -388,33 +421,9 @@ - (void)prefetchImagesNearIndex:(NSInteger)currentPageIndex count:(NSInteger)cou
388421 NSArray *itemsToPrefetch = [self .currentFeedsProvider.visibleFeedItems subarrayWithRange: fetchRange];
389422
390423 [[EZRFeedImageService shared ] prefetchImagesForFeedItems: itemsToPrefetch];
391-
392424}
393425
394- /* *
395- * Loads the url for the new feed item in the web view
396- *
397- * @param feedItem The feed item to
398- */
399- - (void ) loadURLForFeedItem : (FeedItem *)feedItem
400- {
401- NSURL *url = [NSURL URLWithString: feedItem.url];
402- NSURLRequest *request = [NSURLRequest requestWithURL: url cachePolicy: NSURLRequestReturnCacheDataElseLoad timeoutInterval: 30.0 ];
403426
404- [self .webView_feedItem loadRequest: request];
405- }
406-
407- /* *
408- * Resets the content of the web view
409- */
410- - (void )resetWebView
411- {
412- [self .webView_feedItem stopLoading ];
413-
414- NSString *blankHTML = @" <html><head></head><body style=\" background-color: #000000;\" ></body></html>" ;
415- [self .webView_feedItem loadHTMLString: blankHTML
416- baseURL: nil ];
417- }
418427
419428@end
420429
0 commit comments