-
Notifications
You must be signed in to change notification settings - Fork 1
/
ELIDMovieTableViewController.m
65 lines (54 loc) · 2.42 KB
/
ELIDMovieTableViewController.m
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
//
// ELIDMovieTableViewController.m
// MovieMood
//
// Created by Eric Lee on 9/21/14.
// Copyright (c) 2014 Eric Lee Productions. All rights reserved.
//
#import "ELIDMovieTableViewController.h"
#import "ELActivityIndicator.h"
#import "ELMovieRequests.h"
@interface ELIDMovieTableViewController ()
@property (nonatomic, retain) ELActivityIndicator *activityIndicator;
@end
@implementation ELIDMovieTableViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
-(void) reloadTable {
if(_movieIDs) {
CGSize size = self.view.bounds.size;
CGSize activityViewSize = CGSizeMake(size.width * .2, size.width * .2);
_activityIndicator = [[ELActivityIndicator alloc] initWithFrame:CGRectMake((size.width - activityViewSize.width) / 2,
(size.height - activityViewSize.height) / 2,
activityViewSize.width,
activityViewSize.height)];
_activityIndicator.activityIndicator.color = self.navigationController.navigationBar.tintColor;
[_activityIndicator.activityIndicator startAnimating];
[self.parentViewController.view addSubview: _activityIndicator];
[ELMovieRequests getMoviesWithIDs:_movieIDs successCallback:^(id responesMovies) {
self.movieSource = responesMovies;
[self.tableView reloadData];
[_activityIndicator fadeOutView];
[UIView commitAnimations];
} failCallback:^(NSError *error) {
UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:@"Uh oh!"
message:@"There was an error retrieving your favorite movies! Please try again soon"
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles: nil];
_activityIndicator.alpha = 0.f;
[errorAlert show];
}];
}
}
@end