Commit c271db9b authored by Felix Paul Kühne's avatar Felix Paul Kühne
Browse files

playlist table: improve reliability for folder reordering

parent 164af11c
......@@ -17,6 +17,13 @@
#import "VLCThumbnailsCache.h"
#import <MediaLibraryKit/MLAlbum.h>
@interface VLCPlaylistTableViewCell ()
{
UILongPressGestureRecognizer *_longPress;
}
@end
@implementation VLCPlaylistTableViewCell
+ (VLCPlaylistTableViewCell *)cellWithReuseIdentifier:(NSString *)ident
......@@ -94,6 +101,15 @@
{
[super setEditing:editing animated:animated];
[self _updatedDisplayedInformationForKeyPath:@"editing"];
if (editing) {
if (_longPress)
[self removeGestureRecognizer:_longPress];
} else {
if (!_longPress)
_longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longTouchGestureAction:)];
[self addGestureRecognizer:_longPress];
}
}
- (void)_updatedDisplayedInformationForKeyPath:(NSString *)keyPath
......@@ -278,4 +294,24 @@
}
}
- (void)longTouchGestureAction:(UIGestureRecognizer *)recognizer
{
CGRect frame = self.frame;
if (frame.size.height > 90.)
frame.size.height = 90.;
else if (recognizer.state == UIGestureRecognizerStateBegan)
frame.size.height = 180;
void (^animationBlock)() = ^() {
self.frame = frame;
};
void (^completionBlock)(BOOL finished) = ^(BOOL finished) {
self.frame = frame;
};
NSTimeInterval animationDuration = .2;
[UIView animateWithDuration:animationDuration animations:animationBlock completion:completionBlock];
}
@end
......@@ -81,11 +81,6 @@ static NSString *kDisplayedFirstSteps = @"Did we display the first steps tutoria
_tableView.dataSource = self;
_tableView.opaque = YES;
self.view = _tableView;
if (SYSTEM_RUNS_IOS7_OR_LATER) {
UILongPressGestureRecognizer *gestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(tableViewLongTouchGestureAction:)];
[self.view addGestureRecognizer:gestureRecognizer];
}
} else {
_folderLayout = [[VLCFolderCollectionViewFlowLayout alloc] init];
_collectionView = [[UICollectionView alloc] initWithFrame:[UIScreen mainScreen].bounds collectionViewLayout:_folderLayout];
......@@ -540,30 +535,6 @@ static NSString *kDisplayedFirstSteps = @"Did we display the first steps tutoria
}
#pragma mark - table view gestures
- (void)tableViewLongTouchGestureAction:(UIGestureRecognizer *)recognizer
{
NSIndexPath *path = [(UITableView *)self.view indexPathForRowAtPoint:[recognizer locationInView:self.view]];
UITableViewCell *cell = [(UITableView *)self.view cellForRowAtIndexPath:path];
CGRect frame = cell.frame;
if (frame.size.height > 90.)
frame.size.height = 90.;
else if (recognizer.state == UIGestureRecognizerStateBegan)
frame.size.height = 180;
void (^animationBlock)() = ^() {
cell.frame = frame;
};
void (^completionBlock)(BOOL finished) = ^(BOOL finished) {
cell.frame = frame;
[self.tableView scrollToRowAtIndexPath:path atScrollPosition:UITableViewScrollPositionNone animated:YES];
};
NSTimeInterval animationDuration = .2;
[UIView animateWithDuration:animationDuration animations:animationBlock completion:completionBlock];
}
- (void)swipeRightGestureAction:(UIGestureRecognizer *)recognizer
{
if ([[self.editButtonItem title] isEqualToString:NSLocalizedString(@"BUTTON_CANCEL",@"")])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment