@@ -39,6 +39,16 @@ - (void)viewDidLoad {
39
39
else
40
40
self.iconSize = 40 ;
41
41
42
+ if (_refreshHeaderView == nil ) {
43
+
44
+ EGORefreshTableHeaderView *view = [[EGORefreshTableHeaderView alloc ] initWithFrame: CGRectMake (0 .0f , 0 .0f - self .tableView.bounds.size.height, self .view.frame.size.width, self .tableView.bounds.size.height)];
45
+ view.delegate = self;
46
+ [self .tableView addSubview: view];
47
+ _refreshHeaderView = view;
48
+ }
49
+
50
+ // update the last update date
51
+ [_refreshHeaderView refreshLastUpdatedDate ];
42
52
}
43
53
44
54
- (void )viewDidUnload {
@@ -72,7 +82,6 @@ - (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfa
72
82
73
83
#pragma mark - Table view data source
74
84
75
-
76
85
// Customize the number of sections in the table view.
77
86
- (NSInteger )numberOfSectionsInTableView : (UITableView *) tableView {
78
87
return 1 ;
@@ -158,7 +167,7 @@ - (void) folder: (SSFolder *) folder itemsLoaded: (NSArray *) items {
158
167
}
159
168
}
160
169
[SVProgressHUD dismiss ];
161
- [self dataSourceDidFinishLoadingNewData ];
170
+ [self doneLoadingTableViewData ];
162
171
}
163
172
164
173
- (void ) reloadOneItem : (SSFolderItem *) item {
@@ -171,8 +180,7 @@ - (void) reloadOneItem: (SSFolderItem *) item {
171
180
172
181
- (void ) folderLoadingFailed : (SSFolder *) folder {
173
182
[SVProgressHUD dismissWithError: @" Folder data loading failed" ];
174
- [self dataSourceDidFinishLoadingNewData ];
175
-
183
+ [self doneLoadingTableViewData ];
176
184
}
177
185
178
186
- (void ) folder : (SSFolder *) folder countLoaded : (int ) count {
@@ -192,7 +200,7 @@ - (void) folderInfoLoadingFailed: (SSFolder *) folder {
192
200
193
201
- (void ) file : (SSFile *) file contentLoaded : (NSData *) content {
194
202
FilePreview *filePreview = [[FilePreview alloc ] initWithFile: file];
195
-
203
+
196
204
FileViewController *newFileViewController = [[FileViewController alloc ] initWithFilePreview: filePreview filename: file.name];
197
205
[SVProgressHUD dismiss ];
198
206
[self .navigationController pushViewController: newFileViewController animated: YES ];
@@ -208,8 +216,53 @@ - (void) fileContentLoadingFailed: (SSFile *) file {
208
216
209
217
- (void ) reloadTableViewDataSource
210
218
{
219
+ _reloading = YES ;
211
220
[self .folder loadItems ];
212
221
}
213
222
223
+ - (void )doneLoadingTableViewData
224
+ {
225
+ _reloading = NO ;
226
+ [_refreshHeaderView egoRefreshScrollViewDataSourceDidFinishedLoading: self .tableView];
227
+ }
228
+
229
+ #pragma mark -
230
+ #pragma mark UIScrollViewDelegate Methods
231
+
232
+ - (void )scrollViewDidScroll : (UIScrollView *)scrollView {
233
+
234
+ [_refreshHeaderView egoRefreshScrollViewDidScroll: scrollView];
235
+
236
+ }
237
+
238
+ - (void )scrollViewDidEndDragging : (UIScrollView *)scrollView willDecelerate : (BOOL )decelerate {
239
+
240
+ [_refreshHeaderView egoRefreshScrollViewDidEndDragging: scrollView];
241
+
242
+ }
243
+
244
+
245
+ #pragma mark -
246
+ #pragma mark EGORefreshTableHeaderDelegate Methods
247
+
248
+ - (void )egoRefreshTableHeaderDidTriggerRefresh : (EGORefreshTableHeaderView*)view {
249
+
250
+ [self reloadTableViewDataSource ];
251
+ [self performSelector: @selector (doneLoadingTableViewData ) withObject: nil afterDelay: 3.0 ];
252
+
253
+ }
254
+
255
+ - (BOOL )egoRefreshTableHeaderDataSourceIsLoading : (EGORefreshTableHeaderView*)view {
256
+
257
+ return _reloading; // should return if data source model is reloading
258
+
259
+ }
260
+
261
+ - (NSDate *)egoRefreshTableHeaderDataSourceLastUpdated : (EGORefreshTableHeaderView*)view {
262
+
263
+ return [NSDate date ]; // should return date data source was last changed
264
+
265
+ }
266
+
214
267
215
268
@end
0 commit comments