forked from UNAMMobile/Descarga-Cultura-UNAM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCL.m
265 lines (185 loc) · 8.9 KB
/
CL.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
//
// CL.m
// Esqueleto DCU
//
// Created by julio.guzman on 18/11/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
//Vista Tipo Informacion un solo Elemento
/*
Descripción/Datos que utiliza
Entrada:
Se alimenta de los datos obtenidos en la VISTA ANTERIOR DE INFORMACION DEL TITULO
Acción:
Construye una vista con los Ligas para compartir y audios de un titulo particular
Salida:
Al dar click en el boton de regresar ala informacion REGRESA A LA VISTA DE INFORMACIÓN DETALLADA DEL TITULO
Al dar click en los botones cerca de la imagen para tw y fb nos lleva a una vista con opciones para compartir nos envia el url del titulo para que podamos compartirlo
Al dar click en el boton de mail nos pregunta el remitente y el destinatario.
Al dar click en los los botones de los tracs de audio podemos, dependiendo del boton:
descargar el audio
reproducir e audio
detener el audio
Al dar click en los botones inferiores nos lleva a la vista correcpondiente.
*/
#import "CL.h"
#import "WV.h"
#import "CFT.h"
#define IMAGEURL @"http://www.descargacultura.unam.mx/images/mp3Icons/"
@implementation CL
@synthesize dictionary ;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil dictionary:(NSMutableDictionary *)dictionary1
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
dictionary = dictionary1;
//NSLog(@"DICTIONARY FACETWIT : %@", dictionary);
}
return self;
}
- (IBAction)facebook:(id)sender {
WV *nextPage = [[WV alloc] initWithNibName:@"WV" bundle:nil dictionary:dictionary];
nextPage.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self.view addSubview:nextPage.view];
[self presentModalViewController:nextPage animated:YES];
}
- (IBAction)twitter:(id)sender {
CFT *nextPage = [[CFT alloc] initWithNibName:@"CFT" bundle:nil dictionary:dictionary];
nextPage.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self.view addSubview:nextPage.view];
[self presentModalViewController:nextPage animated:YES];
}
- (void)dealloc
{
[super dealloc];
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
if (rep == nil) {
rep = [[[Player alloc] initWithNibName:@"Player" bundle:nil] retain];
rep.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
}
/*if (stackSongs == nil) {
stackSongs = [[[NSMutableArray alloc] init] retain];
}*/
tracks = [dictionary objectForKey:@"track"];
autores = [dictionary objectForKey:@"autores"];
[activityindicator startAnimating];
[NSThread detachNewThreadSelector:@selector(parse) toTarget:self withObject:nil];
}
-(void)parse{
//NSLog(@"DICTIONARY : %@", dictionary);
//Titulo
label.text = [dictionary objectForKey:@"titulo"];
//Image
[NSThread detachNewThreadSelector:@selector(setImage:) toTarget:image withObject:[UIImage imageWithData:[[NSData alloc] initWithContentsOfURL:[[NSURL alloc] initWithString:[IMAGEURL stringByAppendingString:[dictionary objectForKey:@"image"]]]]]];
//Rating
switch ([(NSString *)[dictionary objectForKey:@"rating"] intValue]) {
case 0:
[star1 performSelectorOnMainThread:@selector(setHidden:) withObject:[NSNumber numberWithBool:YES] waitUntilDone:YES];
[star2 performSelectorOnMainThread:@selector(setHidden:) withObject:[NSNumber numberWithBool:YES] waitUntilDone:YES];
[star3 performSelectorOnMainThread:@selector(setHidden:) withObject:[NSNumber numberWithBool:YES] waitUntilDone:YES];
[star4 performSelectorOnMainThread:@selector(setHidden:) withObject:[NSNumber numberWithBool:YES] waitUntilDone:YES];
[star5 performSelectorOnMainThread:@selector(setHidden:) withObject:[NSNumber numberWithBool:YES] waitUntilDone:YES];
break;
case 1:
[star2 performSelectorOnMainThread:@selector(setHidden:) withObject:[NSNumber numberWithBool:YES] waitUntilDone:YES];
[star3 performSelectorOnMainThread:@selector(setHidden:) withObject:[NSNumber numberWithBool:YES] waitUntilDone:YES];
[star4 performSelectorOnMainThread:@selector(setHidden:) withObject:[NSNumber numberWithBool:YES] waitUntilDone:YES];
[star5 performSelectorOnMainThread:@selector(setHidden:) withObject:[NSNumber numberWithBool:YES] waitUntilDone:YES];
break;
case 2:
[star3 performSelectorOnMainThread:@selector(setHidden:) withObject:[NSNumber numberWithBool:YES] waitUntilDone:YES];
[star4 performSelectorOnMainThread:@selector(setHidden:) withObject:[NSNumber numberWithBool:YES] waitUntilDone:YES];
[star5 performSelectorOnMainThread:@selector(setHidden:) withObject:[NSNumber numberWithBool:YES] waitUntilDone:YES];
break;
case 3:
[star4 performSelectorOnMainThread:@selector(setHidden:) withObject:[NSNumber numberWithBool:YES] waitUntilDone:YES];
[star5 performSelectorOnMainThread:@selector(setHidden:) withObject:[NSNumber numberWithBool:YES] waitUntilDone:YES];
break;
case 4:
[star5 performSelectorOnMainThread:@selector(setHidden:) withObject:[NSNumber numberWithBool:YES] waitUntilDone:YES];
break;
default:
break;
}
[activityindicator setHidesWhenStopped:YES];
[activityindicator stopAnimating];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 115/5;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
UIImageView *background = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,tableView.contentSize.width ,125/5)];
if (indexPath.row % 2 == 0) {
background.image = [UIImage imageNamed:@"fondo-lista-A.png"];
}
else
{
background.image = [UIImage imageNamed:@"fondo-lista-B.png"];
}
[[cell contentView] addSubview:background];
cell.textLabel.backgroundColor=[UIColor clearColor];
cell.textLabel.textColor=[UIColor whiteColor];
NSMutableDictionary *track = [tracks objectAtIndex:indexPath.row];
cell.textLabel.text = [track objectForKey:@"titulo"];
return cell;
}
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
Estados *state = [[Estados alloc] init];
[state initWithDefaultValues];
NSMutableDictionary *track = [tracks objectAtIndex:indexPath.row];
NSMutableDictionary *autor;
@try {
autor = [autores objectAtIndex:0];
}
@catch (NSException *exception) {
autor = [[NSMutableDictionary alloc] initWithObjects:[NSArray arrayWithObject:@""] forKeys:[NSArray arrayWithObject:@"nombre"]];
}
NSString *portada = [[NSString alloc] initWithString:[IMAGEURL stringByAppendingString:[dictionary objectForKey:@"image"]]];
[state initWithTitle:[track objectForKey:@"titulo"] image:portada urlPath:/*@"http://nyanit.com/audio/nyanlooped.mp3"*/[track objectForKey:@"url"] raiting:[(NSString *)[dictionary objectForKey:@"rating"] intValue] length:[track objectForKey:@"duracion"] author:[autor objectForKey:@"nombre"]];
[Player push:state];
/*[stackSongs insertObject:state atIndex:0];
NSLog(@"=======================================");
for (int k = 0; k<stackSongs.count; k++) {
NSLog(@"HEY HEY HEY : %@",[[stackSongs objectAtIndex:k] getTitle]);
}*/
[self.view addSubview:rep.view];
[self presentModalViewController:rep animated:YES];
}
- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return tracks.count;
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (IBAction)reproductor {
if (rep == nil) {
rep = [[[Player alloc] initWithNibName:@"Player" bundle:nil] retain];
rep.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
}
[self.view addSubview:rep.view];
[self presentModalViewController:rep animated:YES];
}
@end