-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUsersAudioViewController.m
95 lines (74 loc) · 2.05 KB
/
UsersAudioViewController.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//
// UsersAudioViewController.m
// VKMusic
//
// Created by Evgeniy Kirpichenko on 1/4/13.
// Copyright (c) 2013 Evgeniy Kirpichenko. All rights reserved.
//
#import "UsersAudioViewController.h"
#import "AudioGetApiRequest.h"
#import "AudioCell.h"
#import "UITableView+CellCreation.h"
@interface UsersAudioViewController ()
@end
@implementation UsersAudioViewController
#pragma mark -
#pragma mark life cycle
- (id)init
{
if (self = [super init]) {
[self registerForNotificationNamed:kUserSignedIn selector:@selector(userSignedIn)];
[self registerForNotificationNamed:kUserSignedOut selector:@selector(userSignedOut)];
}
return self;
}
- (void) dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
#pragma mark -
#pragma mark load view
- (void) viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if ([[SettingsManager sharedInstance] isUserAuthorized] &&
[[self audioRecordsFull] count] == 0)
{
[self loadAudio];
}
}
#pragma mark -
#pragma mark notifications
- (void) registerForNotificationNamed:(NSString *) name selector:(SEL) selector
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:selector
name:name
object:nil];
}
- (void) userSignedIn
{
[self loadAudio];
}
- (void) userSignedOut
{
NSLog(@"signed out");
}
#pragma mark -
#pragma mark UITableViewDataSource
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
AudioCell *cell = (AudioCell *)[super tableView:tableView cellForRowAtIndexPath:indexPath];
[cell setDelegate:self];
return cell;
}
#pragma mark -
#pragma mark requests
- (AudioGetApiRequest *)audioApiRequest
{
AudioGetApiRequest *model = [[AudioGetApiRequest alloc] init];
[model setUserID:[[[SettingsManager sharedInstance] signedUser] userID]];
[model setAlbumID:[self albumID]];
return model;
}
@end