VLCLocalPlexFolderListViewController.m 20.4 KB
Newer Older
1
2
3
4
/*****************************************************************************
 * VLCLocalPlexFolderListViewController.m
 * VLC for iOS
 *****************************************************************************
5
 * Copyright (c) 2014-2015 VideoLAN. All rights reserved.
6
7
8
9
10
11
12
13
 *
 * Authors: Felix Paul Kühne <fkuehne # videolan.org>
 *          Pierre SAGASPE <pierre.sagaspe # me.com>
 *
 * Refer to the COPYING file of the official project for license.
 *****************************************************************************/

#import "VLCLocalPlexFolderListViewController.h"
14
#import "VLCPlexMediaInformationViewController.h"
15
#import "VLCPlexParser.h"
16
#import "VLCPlexWebAPI.h"
17
#import "VLCNetworkListCell.h"
18
#import "VLCPlaybackController.h"
19
20
21
22
#import "VLCPlaylistViewController.h"
#import "VLCDownloadViewController.h"
#import "NSString+SupportedMedia.h"
#import "VLCStatusLabel.h"
23
#import "UIDevice+VLC.h"
24

Felix Paul Kühne's avatar
Felix Paul Kühne committed
25
@interface VLCLocalPlexFolderListViewController () <UITableViewDataSource, UITableViewDelegate, VLCNetworkListCellDelegate, UISearchBarDelegate, UISearchDisplayDelegate>
26
{
27
    NSArray *_globalObjectList;
28
    NSCache *_imageCache;
29
30
31
32
33

    NSString *_PlexServerName;
    NSString *_PlexServerAddress;
    NSString *_PlexServerPort;
    NSString *_PlexServerPath;
34
35
    NSString *_PlexAuthentification;

36
    VLCPlexParser *_PlexParser;
37
    VLCPlexWebAPI *_PlexWebAPI;
38
39
40
41

    NSMutableArray *_searchData;
    UISearchBar *_searchBar;
    UISearchDisplayController *_searchDisplayController;
42
    UIRefreshControl *_refreshControl;
43
    UIBarButtonItem *_menuButton;
44
    UITapGestureRecognizer *_tapTwiceGestureRecognizer;
45
46
47
48
49
}
@end

@implementation VLCLocalPlexFolderListViewController

50
51
52
53
54
- (void)dealloc
{
    [_tapTwiceGestureRecognizer removeTarget:self action:NULL];
}

55
56
57
- (void)loadView
{
    _tableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
58
    _tableView.backgroundColor = [UIColor VLCDarkBackgroundColor];
59
60
    _tableView.delegate = self;
    _tableView.dataSource = self;
Felix Paul Kühne's avatar
Felix Paul Kühne committed
61
    _tableView.rowHeight = [VLCNetworkListCell heightOfCell];
62
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
63
    _tableView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
64
65
66
    self.view = _tableView;
}

67
- (id)initWithPlexServer:(NSString *)serverName serverAddress:(NSString *)serverAddress portNumber:(NSString *)portNumber atPath:(NSString *)path authentification:(NSString *)auth
68
69
70
71
72
73
74
75
{
    self = [super init];
    if (self) {
        _PlexServerName = serverName;
        _PlexServerAddress = serverAddress;
        _PlexServerPort = portNumber;
        _PlexServerPath = path;

76
77
        _PlexAuthentification = auth;

78
        _globalObjectList = [[NSArray alloc] init];
79
80
        _imageCache = [[NSCache alloc] init];
        [_imageCache setCountLimit:50];
81
82
83
84
85
86
87
88
89
90

        _PlexParser = [[VLCPlexParser alloc] init];
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

91
92
    self.tableView.separatorColor = [UIColor VLCDarkBackgroundColor];
    self.view.backgroundColor = [UIColor VLCDarkBackgroundColor];
93

94
95
    _PlexWebAPI = [[VLCPlexWebAPI alloc] init];

96
    self.title = _PlexServerName;
97
98

    _searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
99
    UINavigationBar *navBar = self.navigationController.navigationBar;
Felix Paul Kühne's avatar
Felix Paul Kühne committed
100
    _searchBar.barTintColor = navBar.barTintColor;
101
102
103
    _searchBar.tintColor = navBar.tintColor;
    _searchBar.translucent = navBar.translucent;
    _searchBar.opaque = navBar.opaque;
104
105
106
107
    _searchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:_searchBar contentsController:self];
    _searchDisplayController.delegate = self;
    _searchDisplayController.searchResultsDataSource = self;
    _searchDisplayController.searchResultsDelegate = self;
Felix Paul Kühne's avatar
Felix Paul Kühne committed
108
    _searchDisplayController.searchBar.searchBarStyle = UIBarStyleBlack;
109
110
    _searchDisplayController.searchResultsTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    _searchDisplayController.searchResultsTableView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
111
    _searchBar.delegate = self;
112
    _searchBar.hidden = YES;
113
114
115
    //self.tableView.tableHeaderView = _searchBar;
    //self.tableView.contentOffset = CGPointMake(0, CGRectGetHeight(_searchBar.frame)); // -> hide search bar to load

116
117
118
    _tapTwiceGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self  action:@selector(tapTwiceGestureAction:)];
    [_tapTwiceGestureRecognizer setNumberOfTapsRequired:2];
    [self.navigationController.navigationBar addGestureRecognizer:_tapTwiceGestureRecognizer];
119

Pierre SAGASPE's avatar
Pierre SAGASPE committed
120
    // Active le Pull down to refresh
121
122
123
    _refreshControl = [[UIRefreshControl alloc] init];
    _refreshControl.backgroundColor = [UIColor VLCDarkBackgroundColor];
    _refreshControl.tintColor = [UIColor whiteColor];
Pierre SAGASPE's avatar
Pierre SAGASPE committed
124
    // Call the refresh function
125
126
    [_refreshControl addTarget:self action:@selector(handleRefresh) forControlEvents:UIControlEventValueChanged];
    [self.tableView addSubview:_refreshControl];
Pierre SAGASPE's avatar
Pierre SAGASPE committed
127

128
129
130
    _menuButton = [UIBarButtonItem themedRevealMenuButtonWithTarget:self andSelector:@selector(menuButtonAction:)];
    self.navigationItem.rightBarButtonItem = _menuButton;

131
    _globalObjectList = [[NSArray alloc] init];
132
    _searchData = [[NSMutableArray alloc] init];
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154

    [self performSelectorInBackground:@selector(loadContents) withObject:nil];
}

- (void)loadContents
{
    _globalObjectList = [_PlexParser PlexMediaServerParser:_PlexServerAddress port:_PlexServerPort navigationPath:_PlexServerPath authentification:_PlexAuthentification];
    NSDictionary *firstObject = [_globalObjectList firstObject];

    if (_globalObjectList.count == 0 || firstObject == nil)
        _PlexAuthentification = @"";
    else
        _PlexAuthentification = [firstObject objectForKey:@"authentification"];

    NSString *titleValue;
    if ([_PlexServerPath isEqualToString:@""] || _globalObjectList.count == 0 || firstObject == nil)
        titleValue = _PlexServerName;
    else
        titleValue = [firstObject objectForKey:@"libTitle"];
    self.title = titleValue;

    [self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
155
156
157
158
159
160
161
162
163
164
}

- (BOOL)shouldAutorotate
{
    UIInterfaceOrientation toInterfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
        return NO;
    return YES;
}

165
166
- (IBAction)menuButtonAction:(id)sender
{
167
    [[VLCSidebarController sharedInstance] toggleSidebar];
168
169
170
171
172

    if (self.isEditing)
        [self setEditing:NO animated:YES];
}

173
174
175
176
177
178
179
180
181
182
183
184
#pragma mark - Table view data source

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

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView == self.searchDisplayController.searchResultsTableView)
        return _searchData.count;
    else
185
        return _globalObjectList.count;
186
187
188
189
190
191
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"PlexCellDetail";

192
    VLCNetworkListCell *cell = (VLCNetworkListCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
193
194

    if (cell == nil)
195
        cell = [VLCNetworkListCell cellWithReuseIdentifier:CellIdentifier];
196

197
    NSDictionary *cellObject;
198
199

    if (tableView == self.searchDisplayController.searchResultsTableView)
200
        cellObject = _searchData[indexPath.row];
201
    else
202
        cellObject = _globalObjectList[indexPath.row];
203

204
    [cell setTitle:cellObject[@"title"]];
205
    [cell setIcon:[UIImage imageNamed:@"blank"]];
206

207
    NSString *thumbPath = cellObject[@"thumb"];
208
    if (thumbPath) {
209
        dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0);
210
        dispatch_async(queue, ^{
211
            UIImage *img = [self getCachedImage:[self _urlAuth:thumbPath]];
212
            dispatch_async(dispatch_get_main_queue(), ^{
213
214
215
216
                if (!img)
                    [cell setIcon:[UIImage imageNamed:@"blank"]];
                else
                    [cell setIcon:img];
217
218
219
            });
        });
    }
220

221
    if ([cellObject[@"container"] isEqualToString:@"item"]) {
222
223
224
        UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRightGestureAction:)];
        [swipeRight setDirection:(UISwipeGestureRecognizerDirectionRight)];
        [cell addGestureRecognizer:swipeRight];
Felix Paul Kühne's avatar
Felix Paul Kühne committed
225
226
        UILongPressGestureRecognizer *longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longTouchGestureAction:)];
        [cell addGestureRecognizer:longPressGestureRecognizer];
227
        NSInteger size = [cellObject[@"size"] integerValue];
228
        NSString *mediaSize = [NSByteCountFormatter stringFromByteCount:size countStyle:NSByteCountFormatterCountStyleFile];
229
        NSString *durationInSeconds = cellObject[@"duration"];
230
231
232
233
234
235
        [cell setIsDirectory:NO];
        [cell setSubtitle:[NSString stringWithFormat:@"%@ (%@)", mediaSize, durationInSeconds]];
        [cell setIsDownloadable:YES];
        [cell setDelegate:self];
    } else {
        [cell setIsDirectory:YES];
236
        if (!thumbPath)
237
            [cell setIcon:[UIImage imageNamed:@"folder"]];
238
239
240
241
    }
    return cell;
}

242
- (UIImage *)getCachedImage:(NSString *)url
243
244
245
246
247
248
{
    UIImage *image = [_imageCache objectForKey:url];
    if ((image != nil) && [image isKindOfClass:[UIImage class]]) {
        return image;
    } else {
        NSData *imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:url]];
249
250
        if (imageData) {
            image = [[UIImage alloc] initWithData:imageData];
Felix Paul Kühne's avatar
Felix Paul Kühne committed
251
252
            if (image)
                [_imageCache setObject:image forKey:url];
253
        }
254
255
256
257
        return image;
    }
}

258
259
#pragma mark - Table view delegate

260
- (void)tableView:(UITableView *)tableView willDisplayCell:(VLCNetworkListCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
261
{
262
    UIColor *color = (indexPath.row % 2 == 0)? [UIColor blackColor]: [UIColor VLCDarkBackgroundColor];
263
264
265
266
267
    cell.contentView.backgroundColor = cell.titleLabel.backgroundColor = cell.folderTitleLabel.backgroundColor = cell.subtitleLabel.backgroundColor =  color;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
268
    NSArray *objectList;
269
270
271
    NSString *newPath = nil;

    if (tableView == self.searchDisplayController.searchResultsTableView)
272
        objectList = [_searchData copy];
273
    else
274
275
276
        objectList = _globalObjectList;

    NSDictionary *rowObject = objectList[indexPath.row];
277

278
    NSString *keyValue = [rowObject objectForKey:@"key"];
279
280
281
282
283
284

    if ([keyValue rangeOfString:@"library"].location == NSNotFound)
        newPath = [_PlexServerPath stringByAppendingPathComponent:keyValue];
    else
        newPath = keyValue;

285
286
    if ([rowObject[@"container"] isEqualToString:@"item"]) {
        objectList = [_PlexParser PlexMediaServerParser:_PlexServerAddress port:_PlexServerPort navigationPath:newPath authentification:_PlexAuthentification];
287
288
        NSString *URLofSubtitle = nil;

289
290
291
292
293
294
295
296
        NSDictionary *firstObject = [objectList firstObject];
        if (!firstObject)
            return;

        if ([firstObject objectForKey:@"keySubtitle"])
            URLofSubtitle = [_PlexWebAPI getFileSubtitleFromPlexServer:firstObject modeStream:YES];

        NSURL *itemURL = [NSURL URLWithString:[self _urlAuth:firstObject[@"keyMedia"]]];
297
        if (itemURL) {
298
299
            VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
            [vpc playURL:itemURL subtitlesFilePath:URLofSubtitle];
300
301
        }
    } else {
302
        VLCLocalPlexFolderListViewController *targetViewController = [[VLCLocalPlexFolderListViewController alloc] initWithPlexServer:_PlexServerName serverAddress:_PlexServerAddress portNumber:_PlexServerPort atPath:newPath authentification:_PlexAuthentification];
303
304
305
306
307
308
309
        [[self navigationController] pushViewController:targetViewController animated:YES];
    }
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
}

#pragma mark - Specifics

310
311
312
313
314
- (NSString *)_urlAuth:(NSString *)url
{
    return [_PlexWebAPI urlAuth:url autentification:_PlexAuthentification];
}

315
- (void)_playMediaItem:(NSDictionary *)mediaObject
316
317
{
    NSString *newPath = nil;
318
    NSString *keyValue = [mediaObject objectForKey:@"key"];
319
320
321
322
323
324

    if ([keyValue rangeOfString:@"library"].location == NSNotFound)
        newPath = [_PlexServerPath stringByAppendingPathComponent:keyValue];
    else
        newPath = keyValue;

325
326
    if ([[mediaObject objectForKey:@"container"] isEqualToString:@"item"]) {
        NSArray *mediaList = [_PlexParser PlexMediaServerParser:_PlexServerAddress port:_PlexServerPort navigationPath:newPath authentification:_PlexAuthentification];
327
        NSString *URLofSubtitle = nil;
328
329
330
        NSDictionary *firstObject = [mediaList firstObject];
        if (!firstObject)
            return;
331

332
333
334
335
        if ([firstObject objectForKey:@"keySubtitle"])
            URLofSubtitle = [_PlexWebAPI getFileSubtitleFromPlexServer:firstObject modeStream:YES];

        NSURL *itemURL = [NSURL URLWithString:[self _urlAuth:[firstObject objectForKey:@"keyMedia"]]];
336
        if (itemURL) {
337
338
            VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
            [vpc playURL:itemURL subtitlesFilePath:URLofSubtitle];
339
340
341
342
        }
    }
}

343
- (void)_downloadFileFromMediaItem:(NSDictionary *)mediaObject
344
{
345
346
347
348
    if (!mediaObject)
        return;

    NSURL *itemURL = [NSURL URLWithString:[mediaObject objectForKey:@"keyMedia"]];
349
350

    if (![[itemURL absoluteString] isSupportedFormat]) {
351
352
353
354
355
        VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"FILE_NOT_SUPPORTED", nil)
                                                         message:[NSString stringWithFormat:NSLocalizedString(@"FILE_NOT_SUPPORTED_LONG", nil), [itemURL absoluteString]]
                                                         delegate:self
                                                cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", nil)
                                                otherButtonTitles:nil];
356
357
        [alert show];
    } else if (itemURL) {
358
        NSString *fileName = [mediaObject objectForKey:@"namefile"];
359
        [[VLCDownloadViewController sharedInstance] addURLToDownloadList:itemURL fileNameOfMedia:fileName];
360
361
362
    }
}

363
364
365
366
367
- (void)swipeRightGestureAction:(UIGestureRecognizer *)recognizer
{
    NSIndexPath *swipedIndexPath = [self.tableView indexPathForRowAtPoint:[recognizer locationInView:self.tableView]];
    UITableViewCell *swipedCell = [self.tableView cellForRowAtIndexPath:swipedIndexPath];

368
    VLCNetworkListCell *cell = (VLCNetworkListCell *)[[self tableView] cellForRowAtIndexPath:swipedIndexPath];
369

370
    NSDictionary *cellObject = _globalObjectList[[self.tableView indexPathForCell:swipedCell].row];
371

372
373
    NSString *ratingKey = cellObject[@"ratingKey"];
    NSString *tag = cellObject[@"state"];
374
375
    NSString *cellStatusLbl = nil;

376
    NSInteger status = [_PlexWebAPI MarkWatchedUnwatchedMedia:_PlexServerAddress port:_PlexServerPort videoRatingKey:ratingKey state:tag authentification:_PlexAuthentification];
377
378
379
380

    if (status == 200) {
        if ([tag isEqualToString:@"watched"]) {
            tag = @"unwatched";
381
            cellStatusLbl = NSLocalizedString(@"PLEX_UNWATCHED", nil);
382
383
        } else if ([tag isEqualToString:@"unwatched"]) {
            tag = @"watched";
384
            cellStatusLbl = NSLocalizedString(@"PLEX_WATCHED", nil);
385
386
        }
    } else
387
        cellStatusLbl = NSLocalizedString(@"PLEX_ERROR_MARK", nil);
388
389
390

    [cell.statusLabel showStatusMessage:cellStatusLbl];

391
    [_globalObjectList[[self.tableView indexPathForCell:swipedCell].row] setObject:tag forKey:@"state"];
392
393
}

Pierre SAGASPE's avatar
Pierre SAGASPE committed
394
395
- (void)reloadTableViewPlex
{
396
    _globalObjectList = [_PlexParser PlexMediaServerParser:_PlexServerAddress port:_PlexServerPort navigationPath:_PlexServerPath authentification:_PlexAuthentification];
Pierre SAGASPE's avatar
Pierre SAGASPE committed
397
398
399
    [self.tableView reloadData];
}

Felix Paul Kühne's avatar
Felix Paul Kühne committed
400
#pragma mark - VLCNetworkListCell delegation
401

402
- (void)triggerDownloadForCell:(VLCNetworkListCell *)cell
403
{
404
    NSDictionary *cellObject;
405
406

    if ([self.searchDisplayController isActive])
407
        cellObject = _searchData[[self.searchDisplayController.searchResultsTableView indexPathForCell:cell].row];
408
    else
409
410
411
        cellObject = _globalObjectList[[self.tableView indexPathForCell:cell].row];

    NSString *path = cellObject[@"key"];
412

413
414
    NSArray *mediaList = [_PlexParser PlexMediaServerParser:_PlexServerAddress port:_PlexServerPort navigationPath:path authentification:_PlexAuthentification];
    NSDictionary *firstObject = [mediaList firstObject];
415

416
    NSInteger size = [[firstObject objectForKey:@"size"] integerValue];
417
    if (size  < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
418
419
        if ([firstObject objectForKey:@"keySubtitle"])
            [_PlexWebAPI getFileSubtitleFromPlexServer:firstObject modeStream:NO];
420

421
        [self _downloadFileFromMediaItem:firstObject];
422
423
        [cell.statusLabel showStatusMessage:NSLocalizedString(@"DOWNLOADING", nil)];
    } else {
424
        VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"DISK_FULL", nil)
425
                                                          message:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), [firstObject objectForKey:@"title"], [[UIDevice currentDevice] model]]
426
427
428
                                                         delegate:self
                                                cancelButtonTitle:NSLocalizedString(@"BUTTON_OK", nil)
                                                otherButtonTitles:nil];
429
430
        [alert show];
    }
431
432
433
434
435
436
437
438
}

#pragma mark - Search Display Controller Delegate

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
    [_searchData removeAllObjects];

439
440
    NSUInteger count = _globalObjectList.count;
    for (NSUInteger i = 0; i < count; i++) {
441
        NSRange nameRange;
442
        nameRange = [[_globalObjectList[i] objectForKey:@"title"] rangeOfString:searchString options:NSCaseInsensitiveSearch];
443
        if (nameRange.location != NSNotFound)
444
            [_searchData addObject:_globalObjectList[i]];
445
446
447
448
449
450
451
452
453
454
455
456
457
458
    }
    return YES;
}

- (void)searchDisplayController:(UISearchDisplayController *)controller didLoadSearchResultsTableView:(UITableView *)tableView
{
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
        tableView.rowHeight = 80.0f;
    else
        tableView.rowHeight = 68.0f;

    tableView.backgroundColor = [UIColor blackColor];
}

Pierre SAGASPE's avatar
Pierre SAGASPE committed
459
460
461
462
463
#pragma mark - Refresh

-(void)handleRefresh
{
    //set the title while refreshing
464
    _refreshControl.attributedTitle = [[NSAttributedString alloc]initWithString:NSLocalizedString(@"LOCAL_SERVER_REFRESH", nil)];
Pierre SAGASPE's avatar
Pierre SAGASPE committed
465
    //set the date and time of refreshing
466
    NSDateFormatter *formattedDate = [[NSDateFormatter alloc]init];
Pierre SAGASPE's avatar
Pierre SAGASPE committed
467
    [formattedDate setDateFormat:@"MMM d, h:mm a"];
468
    NSString *lastupdated = [NSString stringWithFormat:NSLocalizedString(@"LOCAL_SERVER_LAST_UPDATE", nil),[formattedDate stringFromDate:[NSDate date]]];
469
470
    NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName];
    _refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:lastupdated attributes:attrsDictionary];
Pierre SAGASPE's avatar
Pierre SAGASPE committed
471
    //end the refreshing
472
    [_refreshControl endRefreshing];
Pierre SAGASPE's avatar
Pierre SAGASPE committed
473
474
475
    [self performSelector:@selector(reloadTableViewPlex) withObject:nil];
}

476
477
478
479
480
481
482
483
484
485
486
487
488
#pragma mark - Gesture Action

- (void)tapTwiceGestureAction:(UIGestureRecognizer *)recognizer
{
    _searchBar.hidden = !_searchBar.hidden;
    if (_searchBar.hidden)
        self.tableView.tableHeaderView = nil;
    else
        self.tableView.tableHeaderView = _searchBar;

    [self.tableView setContentOffset:CGPointMake(0.0f, -self.tableView.contentInset.top) animated:NO];
}

489
490
491
492
493
- (void)longTouchGestureAction:(UIGestureRecognizer *)recognizer
{
    if (recognizer.state == UIGestureRecognizerStateBegan) {
        NSIndexPath *swipedIndexPath = [self.tableView indexPathForRowAtPoint:[recognizer locationInView:self.tableView]];
        UITableViewCell *swipedCell = [self.tableView cellForRowAtIndexPath:swipedIndexPath];
494
        NSDictionary *cellObject = _globalObjectList[[self.tableView indexPathForCell:swipedCell].row];
495

Felix Paul Kühne's avatar
Felix Paul Kühne committed
496
497
        VLCPlexMediaInformationViewController *targetViewController = [[VLCPlexMediaInformationViewController alloc] initPlexMediaInformation:cellObject serverAddress:_PlexServerAddress portNumber:_PlexServerPort atPath:_PlexServerPath authentification:_PlexAuthentification];
        [[self navigationController] pushViewController:targetViewController animated:YES];
498
499
500
    }
}

501
@end