-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathRSSGridViewController.m
More file actions
84 lines (67 loc) · 2.1 KB
/
Copy pathRSSGridViewController.m
File metadata and controls
84 lines (67 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//
// RSSGridViewController.m
// CernVM Co-Pilot
//
// Created by Eamon Ford on 8/9/12.
// Copyright (c) 2012 The Byte Factory. All rights reserved.
//
#import "RSSGridViewController.h"
#import "MBProgressHUD.h"
@interface RSSGridViewController ()
@end
@implementation RSSGridViewController
- (id)initWithCoder:(NSCoder *)aDecoder {
if (self = [super initWithCoder:aDecoder]) {
self.aggregator = [[RSSAggregator alloc] init];
self.aggregator.delegate = self;
self.gridView.separatorStyle = AQGridViewCellSeparatorStyleNone;
self.gridView.backgroundColor = [UIColor whiteColor];
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// When we call self.view this will reload the view after a didReceiveMemoryWarning.
self.view.backgroundColor = [UIColor whiteColor];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
return YES;
else
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (void)refresh
{
if (self.aggregator.feeds.count) {
[_noConnectionHUD hide:YES];
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
[self.aggregator refreshAllFeeds];
}
}
#pragma mark - MBProgressHUDDelegate methods
- (void)hudWasTapped:(MBProgressHUD *)hud
{
[self refresh];
}
#pragma mark - RSSAggregatorDelegate methods
- (void)allFeedsDidLoadForAggregator:(RSSAggregator *)aggregator
{
[MBProgressHUD hideHUDForView:self.view animated:YES];
}
- (void)aggregator:(RSSAggregator *)aggregator didFailWithError:(NSError *)error
{
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
_noConnectionHUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
_noConnectionHUD.delegate = self;
_noConnectionHUD.mode = MBProgressHUDModeText;
_noConnectionHUD.labelText = @"No internet connection";
_noConnectionHUD.removeFromSuperViewOnHide = YES;
}
@end