Subversion Repository Public Repository

Nextrek

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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
//
//  ChannelsVC_iPad.m
//  PocketVision
//
//  Created by Fabrizio on 11/02/13.
//  Copyright (c) 2013 Odyssey. All rights reserved.
//

#import "ChannelsVC_iPad.h"
#import "TargetConfig.h"
#import "ChannelsTVCelliPad.h"
#import "ProgrammazioneTVCelliPad.h"
#import "Channel.h"
#import "Programma.h"
#import "UIImageView+AFNetworking.h"
#import "NetService.h"

@interface ChannelsVC_iPad () {
    Channel *channelForEpg;
}

@end

@implementation ChannelsVC_iPad

@synthesize listOfChannels;
@synthesize programsForChannel;
@synthesize listaCanaliTV;
@synthesize programmazioneTV;
@synthesize nomeCanale;

- (void)dealloc {
    
    [draggableTab removeGestureRecognizer:panGesture];
    [draggableTab removeGestureRecognizer:tapGesture];
    
    [arrowImageView release];
    
    [super dealloc];
}

- (void)viewDidUnload {
    [arrowImageView release];
    arrowImageView = nil;
    
    [super viewDidUnload];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)];
    tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)];
    
    [draggableTab addGestureRecognizer:panGesture];
    [draggableTab addGestureRecognizer:tapGesture];
    
    [tapGesture setCancelsTouchesInView:NO];
    
    [panGesture release];
    [tapGesture release];
    
    [self createTableItems];
}

- (void) createTableItems {
    
    listOfChannels = [NSMutableArray array];
    listOfChannels = DATAMANAGER.allChannels;
    
    programsForChannel = [[NSMutableArray alloc]initWithCapacity:0];
}

- (void)handleTapGesture:(UITapGestureRecognizer *)sender {
    if (sender.state == UIGestureRecognizerStateEnded){
        if (isViewOpen) {
            [[NSNotificationCenter defaultCenter] postNotificationName:@"MsgGoAllMinimizedStatus" object:nil];
        }
        else {
            [[NSNotificationCenter defaultCenter] postNotificationName:@"MsgGoTimelineStatus" object:nil];
        }
    }
    else if (sender.state == UIGestureRecognizerStateBegan){
        
    }
}

- (void)handlePanGesture:(UIPanGestureRecognizer *)sender {
    
    CGPoint translate = [sender translationInView:self.view.superview];
    
    //LOG_INFO_X (@"translate %f %f", translate.x, translate.y)
    //CGPoint velocity = [sender velocityInView:self.view.superview];
    
    switch ([sender state]) {
        case UIGestureRecognizerStateBegan:{
            //[APPDEL hideDetailPopup];
            panBegan = YES;
            draggingStartPosition = self.view.frame.origin.x;
            
            break;
        }
        case UIGestureRecognizerStateChanged:{
            //LOG_INFO_X (@"translate CHANGED %f %f", translate.x, translate.y)
            
            CGRect f = self.view.frame;
            float minLimit = EAST_SHOWED_POINT_IPAD.x;
            float maxLimit = EAST_MINIMIZED_POINT.x;
            f.origin.x = MAX ( draggingStartPosition + translate.x, minLimit);
            f.origin.x = MIN (f.origin.x, maxLimit);
            self.view.frame = f;
            
            if (translate.x < 0 && panBegan) {
                panBegan = NO;
                [[NSNotificationCenter defaultCenter] postNotificationName:@"MsgHideAllExceptThis" object:self];
            }
            
            break;
        }
            
        default:{
            panBegan = NO;
            
            if (abs(translate.x) > SCREEN_FRAME.size.width*MINIMUM_PAN_PERCENTAGE_TO_OPEN){
                if (translate.x<0 && !isViewOpen) {
                    [[NSNotificationCenter defaultCenter] postNotificationName:@"MsgGoTimelineStatus" object:nil];
                }
                else if (translate.x>0 && isViewOpen) {
                    [[NSNotificationCenter defaultCenter] postNotificationName:@"MsgGoAllMinimizedStatus" object:nil];
                }
            }
            else {
                
                [[NSNotificationCenter defaultCenter] postNotificationName:(isViewOpen ? @"MsgGoTimelineStatus" : @"MsgGoAllMinimizedStatus") object:nil];
            }
            
        }
            break;
    }
}

#pragma mark - HANDLE NETWORK REQUESTS

- (void) doEPGCheck:(id)sender {
    UIButton *epgButton = (UIButton*)sender;
    
    UITableViewCell *cell = (UITableViewCell *)epgButton.superview.superview;
    [ActivityViewVC showActivityWithSuperView:(UITableViewCell *)epgButton.superview];
    
    NSIndexPath *indexPath = [listaCanaliTV indexPathForCell:cell];
    
    Channel *channel = [listOfChannels objectAtIndex:indexPath.row];
    [[NetService getInstance] getEpgForChannel:self channel:channel];
    
    channelForEpg = channel;
}

- (void)getEpgForChannelRequestDone:(ASIHTTPRequest *)request {
	LOG_INFO_X(@"REQUEST PERFORMED - RESPONSE STATUS CODE: %d", [request responseStatusCode]);
    
    [ActivityViewVC hideActivityView];
    
    programsForChannel = [[DataManager getInstance] parseEpgChannelResponse:[request responseData]];
    
    if([programsForChannel count] == 0) {
        LOG_INFO(@"NO EPG FOR CHANNEL");
    }
    else {
        [programmazioneTV reloadData];
        [self showGuidaTV];
        
        nomeCanale.text = channelForEpg.nome;
    }
}

- (void)getEpgForChannelRequestWentWrong:(ASIHTTPRequest *)request {
    LOG_INFO_X(@"RESPONSE WRONG:%@", [request responseString]);
    
    [ActivityViewVC hideActivityView];
    
}

#pragma mark - Animations

- (void) show {
    [panGesture setEnabled:YES];
    [tapGesture setEnabled:YES];
    [UIView beginAnimations:@"show" context:nil];
    [UIView setAnimationDuration:0.30];
    [UIView setAnimationDelegate:self];
    
    CGRect f = self.view.frame;
    f.origin = EAST_SHOWED_POINT_IPAD;
    self.view.frame = f;
    
    [UIView commitAnimations];
    [arrowImageView setImage:[UIImage imageNamed:@"close_iPad.png"]];
}


- (void) minimize {
    [panGesture setEnabled:YES];
    [tapGesture setEnabled:YES];
    [UIView beginAnimations:@"minimize" context:nil];
    [UIView setAnimationDuration:0.30];
    [UIView setAnimationDelegate:self];
    
    CGRect f = self.view.frame;
    f.origin = EAST_MINIMIZED_POINT_IPAD;
    self.view.frame = f;
    
    [UIView commitAnimations];
    [arrowImageView setImage:[UIImage imageNamed:@"open_iPad.png"]];
}


- (void) hide {
    [panGesture setEnabled:NO];
    [tapGesture setEnabled:NO];
    [UIView beginAnimations:@"hide" context:nil];
    [UIView setAnimationDuration:0.05];
    [UIView setAnimationDelegate:self];
    
    CGRect f = self.view.frame;
    f.origin = EAST_HIDDEN_POINT;
    self.view.frame = f;
    
    [UIView commitAnimations];
    [arrowImageView setImage:[UIImage imageNamed:@"open_iPad.png"]];
}

- (void) showGuidaTV {
    [panGesture setEnabled:YES];
    [tapGesture setEnabled:YES];
    [UIView beginAnimations:@"showGuidaTV" context:nil];
    [UIView setAnimationDuration:0.70];
    [UIView setAnimationDelegate:self];
    
    CGRect f = self.view.frame;
    f.origin = EAST_SHOWED_POINT_GUIDA_IPAD;
    self.view.frame = f;
    
    [UIView commitAnimations];
    [arrowImageView setImage:[UIImage imageNamed:@"close_iPad.png"]];
}

- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
	if (finished) {
        
        if ([@"minimize" isEqualToString:animationID]) {
            isViewOpen = NO;
        }
        else if ([@"hide" isEqualToString:animationID]) {
            isViewOpen = NO;
        }
        else if ([@"show" isEqualToString:animationID]) {
            isViewOpen = YES;
        }
    }
}

#pragma mark - Change Channel methods

- (void) doChangeChannel:(id)sender {
    
    UIButton *channelButton = (UIButton*)sender;
    
    UITableViewCell *cell = (UITableViewCell *)channelButton.superview.superview;
    
    NSIndexPath *indexPath = [listaCanaliTV indexPathForCell:cell];
    
    Channel *channel = [listOfChannels objectAtIndex:indexPath.row];
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"PlayChannel_iPad" object:channel];
}


#pragma mark - Table view methods

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    int rowsCount = 0;
    
    if(tableView == listaCanaliTV) {
        rowsCount = [listOfChannels count];
    }
    else if (tableView == programmazioneTV) {
        rowsCount = [programsForChannel count];
    }
    
    return  rowsCount;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if(tableView == listaCanaliTV) {
        return 75;
    }
    else if (tableView == programmazioneTV) {
        return 65;
    }
    
    return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if(tableView == listaCanaliTV) {
        static NSString *MyIdentifier = @"ChannelsTVCelliPad";
        
        ChannelsTVCelliPad *cell = (ChannelsTVCelliPad *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
        if (cell == nil)	{
            NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:MyIdentifier owner:self options:nil];
            cell = [topLevelObjects objectAtIndex:0];
        }
        
        Channel *channel = [listOfChannels objectAtIndex:indexPath.row];
        
        cell.titleLabel.text = channel.nome;
        cell.guidaTvBtn.hidden = !channel.hasEPG;
        [cell.channelBtn addTarget:self action:@selector(doChangeChannel:) forControlEvents:UIControlEventTouchUpInside];
        [cell.guidaTvBtn addTarget:self action:@selector(doEPGCheck:) forControlEvents:UIControlEventTouchUpInside];
        
        [cell.imageView setImageWithURL:channel.logoURL placeholderImage:nil];
        
        return cell;
    }
    else if(tableView == programmazioneTV) {
        static NSString *MyIdentifier = @"ProgrammazioneTVCelliPad";
        
        ProgrammazioneTVCelliPad *cell = (ProgrammazioneTVCelliPad *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
        if (cell == nil)	{
            NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:MyIdentifier owner:self options:nil];
            cell = [topLevelObjects objectAtIndex:0];
        }
        
        Programma *programma = [programsForChannel objectAtIndex:indexPath.row];
        
        cell.titleLabel.text = programma.titolo;
        cell.subTitleLabel.text = [programma.tipo capitalizedString];
        cell.dateLabel.text = programma.timestamp;
        
        return cell;
    }
    
    return nil;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
}



@end

Commits for Nextrek/iOS/PocketVision/PocketVision/VC/iPad/ChannelsVC_iPad.m

Diff revisions: vs.
Revision Author Commited Message
62 FAquili picture FAquili Sat 18 Jan, 2014 16:39:26 +0000

PocketVision 1.0