Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework strategy to select/deselect items #1237

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 14 additions & 23 deletions XBMC Remote/DetailViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1507,6 +1507,7 @@ - (void)viewChild:(NSIndexPath*)indexPath item:(NSDictionary*)item displayPoint:
else {
[self addPlayback:item indexPath:indexPath position:indexPath.row shuffle:NO];
}
[self deselectAtIndexPath:indexPath];
return;
}
else {
Expand Down Expand Up @@ -1550,6 +1551,7 @@ - (void)viewChild:(NSIndexPath*)indexPath item:(NSDictionary*)item displayPoint:
}

- (void)didSelectItemAtIndexPath:(NSIndexPath*)indexPath item:(NSDictionary*)item displayPoint:(CGPoint)point {
[self selectAtIndexPath:indexPath];
mainMenu *menuItem = [self getMainMenu:item];
int activeTab = [self getActiveTab:item];
NSDictionary *methods = menuItem.subItem.mainMethod[activeTab];
Expand Down Expand Up @@ -1606,6 +1608,7 @@ - (void)didSelectItemAtIndexPath:(NSIndexPath*)indexPath item:(NSDictionary*)ite
NSString *message = [NSString stringWithFormat:@"%@ (type = '%@')", LOCALIZED_STR(@"Cannot do that"), item[@"type"]];
[Utilities showMessage:message color:[Utilities getSystemRed:0.95]];
}
[self deselectAtIndexPath:indexPath];
}
else if (methods[@"method"] != nil && ![parameters[@"forceActionSheet"] boolValue] && !stackscrollFullscreen) {
// There is a child and we want to show it (only when not in fullscreen)
Expand All @@ -1625,6 +1628,7 @@ - (void)didSelectItemAtIndexPath:(NSIndexPath*)indexPath item:(NSDictionary*)ite
else {
[self addPlayback:item indexPath:indexPath position:indexPath.row shuffle:NO];
}
[self deselectAtIndexPath:indexPath];
}
}
}
Expand Down Expand Up @@ -2847,7 +2851,6 @@ - (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)
int rectOriginX = cell.frame.origin.x + cell.frame.size.width / 2;
int rectOriginY = cell.frame.origin.y + cell.frame.size.height / 2 - offsetPoint.y;
[self didSelectItemAtIndexPath:indexPath item:item displayPoint:CGPointMake(rectOriginX, rectOriginY)];
return;
}

- (NSUInteger)indexOfObjectWithSeason:(NSString*)seasonNumber inArray:(NSArray*)array {
Expand Down Expand Up @@ -3213,6 +3216,15 @@ - (id)getCell:(NSIndexPath*)indexPath {
return cell;
}

- (void)selectAtIndexPath:(NSIndexPath*)indexPath {
if (enableCollectionView) {
[collectionView selectItemAtIndexPath:indexPath animated:NO scrollPosition:UICollectionViewScrollPositionNone];
}
else {
[dataList selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
}
}

- (void)deselectAtIndexPath:(NSIndexPath*)indexPath {
if (enableCollectionView) {
[collectionView deselectItemAtIndexPath:indexPath animated:NO];
Expand Down Expand Up @@ -3284,18 +3296,6 @@ - (void)handleLongPress:(UILongPressGestureRecognizer*)activeRecognizer {
selectedIndexPath = indexPath;

NSDictionary *item = [self getItemFromIndexPath:indexPath];

if ([self doesShowSearchResults]) {
[dataList selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
}
else {
if (enableCollectionView) {
[collectionView selectItemAtIndexPath:indexPath animated:NO scrollPosition:UICollectionViewScrollPositionNone];
}
else {
[dataList selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
}
}
mainMenu *menuItem = [self getMainMenu:item];
int activeTab = [self getActiveTab:item];
NSMutableArray *sheetActions = [menuItem.sheetActions[activeTab] mutableCopy];
Expand Down Expand Up @@ -3351,7 +3351,6 @@ - (void)showActionSheetOptions:(NSString*)title options:(NSArray*)sheetActions r

UIAlertAction *action_cancel = [UIAlertAction actionWithTitle:LOCALIZED_STR(@"Cancel") style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
forceMusicAlbumMode = NO;
[self deselectAtIndexPath:selectedIndexPath];
}];

for (NSString *actionName in sheetActions) {
Expand Down Expand Up @@ -3525,7 +3524,6 @@ - (void)actionSheetHandler:(NSString*)actiontitle origin:(CGPoint)origin fromvie

UIAlertAction *action_cancel = [UIAlertAction actionWithTitle:LOCALIZED_STR(@"Cancel") style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
forceMusicAlbumMode = NO;
[self deselectAtIndexPath:selectedIndexPath];
}];

for (NSString *actiontitle in sheetActions) {
Expand Down Expand Up @@ -4071,7 +4069,6 @@ - (void)deleteTimer:(NSDictionary*)item indexPath:(NSIndexPath*)indexPath {
withParameters:parameters
onCompletion:^(NSString *methodName, NSInteger callId, id methodResult, DSJSONRPCError *methodError, NSError *error) {
[cellActivityIndicator stopAnimating];
[self deselectAtIndexPath:indexPath];
if (error == nil && methodError == nil) {
[self.searchController setActive:NO];
[Utilities AnimView:activeLayoutView AnimDuration:0.3 Alpha:1.0 XPos:viewWidth];
Expand Down Expand Up @@ -4118,7 +4115,6 @@ - (void)recordChannel:(NSDictionary*)item indexPath:(NSIndexPath*)indexPath {
withParameters:parameters
onCompletion:^(NSString *methodName, NSInteger callId, id methodResult, DSJSONRPCError *methodError, NSError *error) {
[cellActivityIndicator stopAnimating];
[self deselectAtIndexPath:indexPath];
if (error == nil && methodError == nil) {
id cell = [self getCell:indexPath];
UIImageView *timerView = (UIImageView*)[cell viewWithTag:EPG_VIEW_CELL_RECORDING_ICON];
Expand Down Expand Up @@ -5473,14 +5469,9 @@ - (void)viewWillAppear:(BOOL)animated {
self.slidingViewController.anchorLeftRevealAmount = 0;
}
NSIndexPath *selection = [dataList indexPathForSelectedRow];
if (selection) {
[dataList deselectRowAtIndexPath:selection animated:NO];
}
selection = [dataList indexPathForSelectedRow];
if (selection) {
[dataList deselectRowAtIndexPath:selection animated:YES];
[dataList deselectRowAtIndexPath:selection animated:NO];
}

for (selection in [collectionView indexPathsForSelectedItems]) {
[collectionView deselectItemAtIndexPath:selection animated:YES];
}
Expand Down
2 changes: 0 additions & 2 deletions XBMC Remote/iPad/StackScrollViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ - (id)init {
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanFrom:)];
panRecognizer.delegate = self;
panRecognizer.maximumNumberOfTouches = 1;
panRecognizer.delaysTouchesBegan = YES;
panRecognizer.delaysTouchesEnded = YES;
panRecognizer.cancelsTouchesInView = YES;
[self.view addGestureRecognizer:panRecognizer];
[self.view addSubview:slideViews];
Expand Down