From ac77879caba3acf6947b671f0d1adf6a97ed2d61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A6=99=E9=A2=A8=E6=99=BA=E4=B9=83?= Date: Thu, 25 Oct 2018 11:36:21 -0400 Subject: [PATCH] 1.0.1 - Add refreshing check so when the user presses a cell, it doesn't load information and possibly causes the app to crash. Fix character roles for the character section in the staff detail. --- .../AtarashiiAPIListFormatAniList.m | 3 +- .../Backend/Constants/AniListConstants.m | 6 +- Shukofukurou-IOS/Info.plist | 4 +- .../View Controllers/AiringViewController.m | 41 +-- .../CharacterDetailViewController.m | 8 +- .../View Controllers/ListViewController.m | 233 ++++++++++-------- .../View Controllers/SeasonsViewController.m | 41 +-- 7 files changed, 185 insertions(+), 151 deletions(-) diff --git a/Shukofukurou-IOS/Backend/AtarashiiDataFormatters/AtarashiiAPIListFormatAniList.m b/Shukofukurou-IOS/Backend/AtarashiiDataFormatters/AtarashiiAPIListFormatAniList.m index e2414c60..376f513e 100644 --- a/Shukofukurou-IOS/Backend/AtarashiiDataFormatters/AtarashiiAPIListFormatAniList.m +++ b/Shukofukurou-IOS/Backend/AtarashiiDataFormatters/AtarashiiAPIListFormatAniList.m @@ -440,6 +440,7 @@ + (NSDictionary *)AniListPersontoAtarashii:(NSDictionary *)person { vaobj.characterid = ((NSNumber *)characterrole[@"node"][@"id"]).intValue; vaobj.name = characterrole[@"node"][@"name"][@"last"] != [NSNull null] && ((NSString *)characterrole[@"node"][@"name"][@"last"]).length > 0 ? [NSString stringWithFormat:@"%@, %@",characterrole[@"node"][@"name"][@"last"],characterrole[@"node"][@"name"][@"first"]] : characterrole[@"node"][@"name"][@"first"]; vaobj.image_url = characterrole[@"node"][@"image"] != [NSNull null] && characterrole[@"node"][@"image"][@"large"] ? characterrole[@"node"][@"image"][@"large"] : @""; + vaobj.main_role = [(NSString *)characterrole[@"role"] isEqualToString:@"MAIN"]; for (NSDictionary *anime in characterrole[@"media"]) { vaobj.anime = @{@"id" : anime[@"id"], @"title" : anime[@"title"][@"romaji"]}; [characterroles addObject:vaobj.NSDictionaryRepresentation]; @@ -469,7 +470,7 @@ + (NSDictionary *)AniListCharactertoAtarashii:(NSDictionary *)person { for (NSDictionary *va in media[@"voiceActors"]) { @autoreleasepool { if ([voiceactors filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"id == %@", va[@"id"]]].count == 0) { - [voiceactors addObject:@{@"id" : va[@"id"], @"name" : va[@"name"][@"last"] != [NSNull null] ? [NSString stringWithFormat:@"%@, %@", va[@"name"][@"last"], va[@"name"][@"first"]] : va[@"name"][@"first"], @"image" : va[@"image"] != [NSNull null] && va[@"image"][@"medium"] ? va[@"image"][@"medium"] : @"" , @"language" : ((NSString *)va[@"language"]).lowercaseString.capitalizedString}]; + [voiceactors addObject:@{@"id" : va[@"id"], @"name" : va[@"name"][@"last"] != [NSNull null] && ((NSString *)va[@"name"][@"last"]).length > 0 ? [NSString stringWithFormat:@"%@, %@",va[@"name"][@"last"],va[@"name"][@"first"]] : va[@"name"][@"first"], @"image" : va[@"image"] != [NSNull null] && va[@"image"][@"medium"] ? va[@"image"][@"medium"] : @"" , @"language" : ((NSString *)va[@"language"]).lowercaseString.capitalizedString}]; } } } diff --git a/Shukofukurou-IOS/Backend/Constants/AniListConstants.m b/Shukofukurou-IOS/Backend/Constants/AniListConstants.m index 69529ba2..42dca230 100644 --- a/Shukofukurou-IOS/Backend/Constants/AniListConstants.m +++ b/Shukofukurou-IOS/Backend/Constants/AniListConstants.m @@ -27,6 +27,9 @@ @implementation AniListConstants NSString *const kAnilistUserProfileByUsername = @"query ($name: String) {\n User (name: $name) {\n id\n name\n about # (asHtml: true)\n donatorTier\n isFollowing\n mediaListOptions {\n scoreFormat\n }\n avatar {\n large\n medium\n }\n updatedAt\n }\n}"; NSString *const kAniListSeason = @"query ($season: MediaSeason, $seasonYear: Int, $page: Int) {\n Page (page : $page) {\n media(season: $season, seasonYear: $seasonYear, type: ANIME) {\n id\n idMal\n isAdult\n coverImage {\n large\n medium\n }\n title {\n romaji\n english\n native\n userPreferred\n }\n format\n }\n pageInfo {\n total\n currentPage\n lastPage\n hasNextPage\n perPage\n }\n }\n}"; NSString *const kAniListAiring = @"query ($page: Int) {\n Page (page : $page) {\n media(status: RELEASING, type: ANIME) {\n id\n idMal\n isAdult\n title {\n romaji\n english\n native\n userPreferred\n }\n episodes\n format\n meanScore\n description\n coverImage {\n large\n medium\n }\n nextAiringEpisode {\n id\n airingAt\n }\n }\n pageInfo {\n total\n currentPage\n lastPage\n hasNextPage\n perPage\n }\n }\n}"; +NSString *const kAnilistRetrieveListTitleIdsOnly = @"query ($id : Int!, $page: Int, $type : MediaType) {\n List: Page (page: $page) {\n mediaList(userId: $id, type: $type) {\n id :media{id, idMal}\n }\n pageInfo {\n total\n currentPage\n lastPage\n hasNextPage\n perPage\n }\n }\n}"; +NSString *const kAnilistCharacterSearch = @"query ($query : String) {\n Page(perPage: 50) {\n characters(search: $query) {\n id\n name {\n first\n last\n native\n }\n image {\n large\n medium\n }\n }\n } \n}"; +NSString *const kAniListStaffSearch = @"query ($query: String) {\n Page(perPage: 50) {\n staff(search: $query) {\n id\n name {\n first\n last\n native\n }\n image {\n large\n medium\n }\n }\n }\n}"; #pragma mark mutations NSString *const kAnilistAddAnimeListEntry = @"mutation ($mediaid : Int, $progress : Int, $status : MediaListStatus, $score : Int) {\n SaveMediaListEntry(mediaId: $mediaid, progress: $progress, status: $status, scoreRaw: $score) {\n id\n progress\n status\n score(format: POINT_100)\n }\n}"; NSString *const kAnilistAddMangaListEntry = @"mutation ($mediaid : Int, $progress : Int, $progressVolumes : Int, $status : MediaListStatus, $score : Int) {\n SaveMediaListEntry(mediaId: $mediaid, progress: $progress, progressVolumes: $progressVolumes,status: $status, scoreRaw: $score) {\n id\n progress\n progressVolumes\n status\n score(format: POINT_100)\n }\n}"; @@ -36,7 +39,4 @@ @implementation AniListConstants NSString *const kAnilistUpdateMangaListEntryAdvanced = @"mutation ($id : Int, $progress : Int, $progressVolumes : Int, $status : MediaListStatus, $score : Int, $notes : String, $private : Boolean, $startedAt : FuzzyDateInput, $completedAt : FuzzyDateInput, $reconsumeCount : Int) {\n SaveMediaListEntry(id: $id, progress: $progress, progressVolumes: $progressVolumes, status: $status, scoreRaw: $score, notes: $notes, private: $private, startedAt: $startedAt, completedAt: $completedAt, repeat: $reconsumeCount) {\n id\n progress\n progressVolumes\n status\n score(format: POINT_100)\n notes\n private\n startedAt {\n year\n month\n day\n }\n completedAt {\n year\n month\n day\n }\n }\n}"; NSString *const kAnilistDeleteListEntry = @"mutation ($id : Int) {\n DeleteMediaListEntry (id: $id) {\n deleted\n }\n}"; NSString *const kAnilistModifyCustomLists = @"mutation ($id : Int, $custom_lists : [String] ) {\n SaveMediaListEntry(id: $id, customLists : $custom_lists) {\n id\n customLists(asArray:true)\n }\n}"; -NSString *const kAnilistRetrieveListTitleIdsOnly = @"query ($id : Int!, $page: Int, $type : MediaType) {\n List: Page (page: $page) {\n mediaList(userId: $id, type: $type) {\n id :media{id, idMal}\n }\n pageInfo {\n total\n currentPage\n lastPage\n hasNextPage\n perPage\n }\n }\n}"; -NSString *const kAnilistCharacterSearch = @"query ($query : String) {\n Page(perPage: 50) {\n characters(search: $query) {\n id\n name {\n first\n last\n native\n }\n image {\n large\n medium\n }\n }\n } \n}"; -NSString *const kAniListStaffSearch = @"query ($query: String) {\n Page(perPage: 50) {\n staff(search: $query) {\n id\n name {\n first\n last\n native\n }\n image {\n large\n medium\n }\n }\n }\n}"; @end diff --git a/Shukofukurou-IOS/Info.plist b/Shukofukurou-IOS/Info.plist index 07260e7a..aea5d039 100644 --- a/Shukofukurou-IOS/Info.plist +++ b/Shukofukurou-IOS/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0 + 1.0.1 CFBundleURLTypes @@ -32,7 +32,7 @@ CFBundleVersion - 20181024 + 20181025 LSRequiresIPhoneOS UIBackgroundModes diff --git a/Shukofukurou-IOS/View Controllers/AiringViewController.m b/Shukofukurou-IOS/View Controllers/AiringViewController.m index caf5bbfe..76211dd5 100644 --- a/Shukofukurou-IOS/View Controllers/AiringViewController.m +++ b/Shukofukurou-IOS/View Controllers/AiringViewController.m @@ -119,24 +119,29 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - NSDictionary *entry = _airinglist[indexPath.row]; - switch ([listservice getCurrentServiceID]) { - case 1: - if (entry[@"idMal"] != [NSNull null]) { - [self showTitleView:((NSNumber *)entry[@"idMal"]).intValue]; - } - break; - case 2: - if (entry[@"idMal"] != [NSNull null]) { - [TitleIdConverter getKitsuIDFromMALId:((NSNumber *)entry[@"idMal"]).intValue withTitle:entry[@"title"] titletype:entry[@"type"] withType:0 completionHandler:^(int kitsuid) { - [self showTitleView:kitsuid]; - } error:^(NSError *error) { - }]; - } - break; - case 3: - [self showTitleView:((NSNumber *)entry[@"id"]).intValue]; - break; + if (!self.tableView.refreshControl.refreshing) { + NSDictionary *entry = _airinglist[indexPath.row]; + switch ([listservice getCurrentServiceID]) { + case 1: + if (entry[@"idMal"] != [NSNull null]) { + [self showTitleView:((NSNumber *)entry[@"idMal"]).intValue]; + } + break; + case 2: + if (entry[@"idMal"] != [NSNull null]) { + [TitleIdConverter getKitsuIDFromMALId:((NSNumber *)entry[@"idMal"]).intValue withTitle:entry[@"title"] titletype:entry[@"type"] withType:0 completionHandler:^(int kitsuid) { + [self showTitleView:kitsuid]; + } error:^(NSError *error) { + }]; + } + break; + case 3: + [self showTitleView:((NSNumber *)entry[@"id"]).intValue]; + break; + } + } + else { + [[tableView cellForRowAtIndexPath:indexPath] setSelected:NO animated:NO]; } } diff --git a/Shukofukurou-IOS/View Controllers/CharacterDetailViewController.m b/Shukofukurou-IOS/View Controllers/CharacterDetailViewController.m index 96fd961d..527fd186 100644 --- a/Shukofukurou-IOS/View Controllers/CharacterDetailViewController.m +++ b/Shukofukurou-IOS/View Controllers/CharacterDetailViewController.m @@ -141,10 +141,14 @@ - (void)populateCharacterData:(NSDictionary *)data { } }); if (data[@"description"]) { - [detailsArray addObject:@{@"title" : @"Details", @"value" : data[@"description"], @"type" : @"longdetail"}]; + if (((NSString *)data[@"description"]).length > 0) { + [detailsArray addObject:@{@"title" : @"Details", @"value" : data[@"description"], @"type" : @"longdetail"}]; + } } else { - [detailsArray addObject:@{@"title" : @"Details", @"value" : data[@"more_details"], @"type" : @"longdetail"}]; + if (((NSString *)data[@"more_details"]).length > 0) { + [detailsArray addObject:@{@"title" : @"Details", @"value" : data[@"more_details"], @"type" : @"longdetail"}]; + } } if (data[@"favorited_count"] && ((NSNumber *)data[@"favorited_count"]).intValue > 0) { [detailsArray addObject:@{@"title" : @"Favorited", @"value" : ((NSNumber *)data[@"favorited_count"]).stringValue, @"type" : @"detail"}]; diff --git a/Shukofukurou-IOS/View Controllers/ListViewController.m b/Shukofukurou-IOS/View Controllers/ListViewController.m index f45b9c8f..3b5d0867 100644 --- a/Shukofukurou-IOS/View Controllers/ListViewController.m +++ b/Shukofukurou-IOS/View Controllers/ListViewController.m @@ -133,10 +133,12 @@ - (void)setViewTitle { - (void)refreshListWithCompletionHandler:(void (^)(bool success)) completionHandler { NSLog(@"Refreshing List"); + [_refreshcontrol beginRefreshing]; [self retrieveList:true completion:^(bool success) { NSLog(@"Refreshed: %i", success); [self.tableView reloadData]; [self.listselector generateLists:[self retrieveEntriesWithType:self.listtype withFilterPredicate:nil] withListType:self.listtype]; + [self.refreshControl endRefreshing]; completionHandler(success); }]; } @@ -149,14 +151,16 @@ - (void)retrieveList:(bool)refresh completion:(void (^)(bool success)) completio completionHandler(true); } else { - __weak ListViewController *weakSelf = self; + [_refreshcontrol beginRefreshing]; [listservice retrieveownListWithType:_listtype completion:^(id responseObject) { - [weakSelf saveEntriesWithDictionary:responseObject withType:weakSelf.listtype]; + [self saveEntriesWithDictionary:responseObject withType:self.listtype]; // populate list [self reloadList]; + [self.refreshControl endRefreshing]; completionHandler(true); } error:^(NSError *error) { NSLog(@"%@", error.userInfo); + [self.refreshControl endRefreshing]; completionHandler(false); }]; } @@ -408,127 +412,144 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } - (UITableViewCell *)generateAnimeEntryCellAtIndexPath:(NSIndexPath *)indexPath tableView:(UITableView *)tableView { - NSDictionary *entry = _filteredlist[indexPath.row]; - AnimeEntryTableViewCell *aentrycell = [tableView dequeueReusableCellWithIdentifier:@"animeentrycell"]; - if (aentrycell == nil && tableView != self.tableView) { - aentrycell = [self.tableView dequeueReusableCellWithIdentifier:@"animeentrycell"]; - } - aentrycell.title.text = entry[@"title"]; - aentrycell.progress.text = [NSString stringWithFormat:@"Episode: %@/%@", entry[@"watched_episodes"], entry[@"episodes"]]; - NSString *score = @""; - switch ([listservice getCurrentServiceID]) { - case 1: - score = entry[@"score"]; - break; - case 2: - score = [RatingTwentyConvert convertRatingTwentyToActualScore:((NSNumber *)entry[@"score"]).intValue scoretype:(int)[NSUserDefaults.standardUserDefaults integerForKey:@"kitsu-ratingsystem"]]; - break; - case 3: - score = [AniListScoreConvert convertAniListScoreToActualScore:((NSNumber *)entry[@"score"]).intValue withScoreType:[NSUserDefaults.standardUserDefaults valueForKey:@"anilist-scoreformat"]]; - break; - default: - break; - } - aentrycell.score.text = [NSString stringWithFormat:@"Score: %@",score]; - [aentrycell loadimage:entry[@"image_url"]]; - aentrycell.active.hidden = ![(NSString *)entry[@"status"] isEqualToString:@"currently airing"]; - // Geneerate Swipe Cells - // Left - __weak ListViewController *weakSelf = self; - aentrycell.leftButtons = @[[MGSwipeButton buttonWithTitle:@"Delete" backgroundColor:UIColor.redColor callback:^BOOL(MGSwipeTableCell * _Nonnull cell) { - NSDictionary *entry = weakSelf.filteredlist[indexPath.row]; - [weakSelf deleteTitle:((NSNumber *)entry[@"id"]).intValue withInfo:entry]; - return true; - }]]; - aentrycell.leftSwipeSettings.transition = MGSwipeTransitionDrag; - - //Right - NSMutableArray *rightbuttons = [NSMutableArray new]; - [rightbuttons addObject:[MGSwipeButton buttonWithTitle:@"Options" backgroundColor:UIColor.grayColor callback:^BOOL(MGSwipeTableCell * _Nonnull cell) { - NSDictionary *entry = weakSelf.filteredlist[indexPath.row]; - [weakSelf showOtherOptions:entry withIndexPath:indexPath]; - return true; - }]]; - if ([self canIncrement:entry]) { - [rightbuttons addObject:[MGSwipeButton buttonWithTitle:@"Ep +" backgroundColor:[UIColor colorWithRed:0.33 green:0.84 blue:0.41 alpha:1.0] callback:^BOOL(MGSwipeTableCell * _Nonnull cell) { + if (indexPath.row < _filteredlist.count) { + NSDictionary *entry = _filteredlist[indexPath.row]; + AnimeEntryTableViewCell *aentrycell = [tableView dequeueReusableCellWithIdentifier:@"animeentrycell"]; + if (aentrycell == nil && tableView != self.tableView) { + aentrycell = [self.tableView dequeueReusableCellWithIdentifier:@"animeentrycell"]; + } + aentrycell.title.text = entry[@"title"]; + aentrycell.progress.text = [NSString stringWithFormat:@"Episode: %@/%@", entry[@"watched_episodes"], entry[@"episodes"]]; + NSString *score = @""; + switch ([listservice getCurrentServiceID]) { + case 1: + score = entry[@"score"]; + break; + case 2: + score = [RatingTwentyConvert convertRatingTwentyToActualScore:((NSNumber *)entry[@"score"]).intValue scoretype:(int)[NSUserDefaults.standardUserDefaults integerForKey:@"kitsu-ratingsystem"]]; + break; + case 3: + score = [AniListScoreConvert convertAniListScoreToActualScore:((NSNumber *)entry[@"score"]).intValue withScoreType:[NSUserDefaults.standardUserDefaults valueForKey:@"anilist-scoreformat"]]; + break; + default: + break; + } + aentrycell.score.text = [NSString stringWithFormat:@"Score: %@",score]; + [aentrycell loadimage:entry[@"image_url"]]; + aentrycell.active.hidden = ![(NSString *)entry[@"status"] isEqualToString:@"currently airing"]; + // Geneerate Swipe Cells + // Left + __weak ListViewController *weakSelf = self; + aentrycell.leftButtons = @[[MGSwipeButton buttonWithTitle:@"Delete" backgroundColor:UIColor.redColor callback:^BOOL(MGSwipeTableCell * _Nonnull cell) { NSDictionary *entry = weakSelf.filteredlist[indexPath.row]; - [weakSelf incrementProgress:entry]; + [weakSelf deleteTitle:((NSNumber *)entry[@"id"]).intValue withInfo:entry]; return true; }]]; + aentrycell.leftSwipeSettings.transition = MGSwipeTransitionDrag; + + //Right + NSMutableArray *rightbuttons = [NSMutableArray new]; + [rightbuttons addObject:[MGSwipeButton buttonWithTitle:@"Options" backgroundColor:UIColor.grayColor callback:^BOOL(MGSwipeTableCell * _Nonnull cell) { + NSDictionary *entry = weakSelf.filteredlist[indexPath.row]; + [weakSelf showOtherOptions:entry withIndexPath:indexPath]; + return true; + }]]; + if ([self canIncrement:entry]) { + [rightbuttons addObject:[MGSwipeButton buttonWithTitle:@"Ep +" backgroundColor:[UIColor colorWithRed:0.33 green:0.84 blue:0.41 alpha:1.0] callback:^BOOL(MGSwipeTableCell * _Nonnull cell) { + NSDictionary *entry = weakSelf.filteredlist[indexPath.row]; + [weakSelf incrementProgress:entry]; + return true; + }]]; + } + aentrycell.rightButtons = rightbuttons.copy; + aentrycell.rightSwipeSettings.transition = MGSwipeTransitionDrag; + return aentrycell; + } + else { + return [UITableViewCell new]; } - aentrycell.rightButtons = rightbuttons.copy; - aentrycell.rightSwipeSettings.transition = MGSwipeTransitionDrag; - return aentrycell; } - (UITableViewCell *)generateMangaEntryCellAtIndexPath:(NSIndexPath *)indexPath tableView:(UITableView *)tableView { - NSDictionary *entry = _filteredlist[indexPath.row]; - MangaEntryTableViewCell *mentrycell = [tableView dequeueReusableCellWithIdentifier:@"mangaentrycell"]; - if (mentrycell == nil && tableView != self.tableView) { - mentrycell = [self.tableView dequeueReusableCellWithIdentifier:@"mangaentrycell"]; - } - mentrycell.title.text = entry[@"title"]; - mentrycell.progress.text = [NSString stringWithFormat:@"Chapters: %@/%@", entry[@"chapters_read"], entry[@"chapters"]]; - mentrycell.progressVolumes.text = [NSString stringWithFormat:@"Volumes: %@/%@", entry[@"volumes_read"], entry[@"volumes"]]; - NSString *score = @""; - switch ([listservice getCurrentServiceID]) { - case 1: - score = entry[@"score"]; - break; - case 2: - score = [RatingTwentyConvert convertRatingTwentyToActualScore:((NSNumber *)entry[@"score"]).intValue scoretype:(int)[NSUserDefaults.standardUserDefaults integerForKey:@"kitsu-ratingsystem"]]; - break; - case 3: - score = [AniListScoreConvert convertAniListScoreToActualScore:((NSNumber *)entry[@"score"]).intValue withScoreType:[NSUserDefaults.standardUserDefaults valueForKey:@"anilist-scoreformat"]]; - break; - default: - break; - } - mentrycell.score.text = [NSString stringWithFormat:@"Score: %@",score]; - [mentrycell loadimage:entry[@"image_url"]]; - mentrycell.active.hidden = ![(NSString *)entry[@"status"] isEqualToString:@"publishing"]; - - // Geneerate Swipe Cells - // Left - __weak ListViewController *weakSelf = self; - mentrycell.leftButtons = @[[MGSwipeButton buttonWithTitle:@"Delete" backgroundColor:UIColor.redColor callback:^BOOL(MGSwipeTableCell * _Nonnull cell) { - NSDictionary *entry = weakSelf.filteredlist[indexPath.row]; - [weakSelf deleteTitle:((NSNumber *)entry[@"id"]).intValue withInfo:entry]; - return true; - }]]; - mentrycell.leftSwipeSettings.transition = MGSwipeTransitionDrag; - - //Right - NSMutableArray *rightbuttons = [NSMutableArray new]; - [rightbuttons addObject:[MGSwipeButton buttonWithTitle:@"Options" backgroundColor:UIColor.grayColor callback:^BOOL(MGSwipeTableCell * _Nonnull cell) { - NSDictionary *entry = weakSelf.filteredlist[indexPath.row]; - [weakSelf showOtherOptions:entry withIndexPath:indexPath]; - return true; - }]]; - if ([self canIncrement:entry]) { - [rightbuttons addObject:[MGSwipeButton buttonWithTitle:@"Vol +" backgroundColor:[UIColor colorWithRed:0.37 green:0.79 blue:0.97 alpha:1.0] callback:^BOOL(MGSwipeTableCell * _Nonnull cell) { + if (indexPath.row < _filteredlist.count) { + NSDictionary *entry = _filteredlist[indexPath.row]; + MangaEntryTableViewCell *mentrycell = [tableView dequeueReusableCellWithIdentifier:@"mangaentrycell"]; + if (mentrycell == nil && tableView != self.tableView) { + mentrycell = [self.tableView dequeueReusableCellWithIdentifier:@"mangaentrycell"]; + } + mentrycell.title.text = entry[@"title"]; + mentrycell.progress.text = [NSString stringWithFormat:@"Chapters: %@/%@", entry[@"chapters_read"], entry[@"chapters"]]; + mentrycell.progressVolumes.text = [NSString stringWithFormat:@"Volumes: %@/%@", entry[@"volumes_read"], entry[@"volumes"]]; + NSString *score = @""; + switch ([listservice getCurrentServiceID]) { + case 1: + score = entry[@"score"]; + break; + case 2: + score = [RatingTwentyConvert convertRatingTwentyToActualScore:((NSNumber *)entry[@"score"]).intValue scoretype:(int)[NSUserDefaults.standardUserDefaults integerForKey:@"kitsu-ratingsystem"]]; + break; + case 3: + score = [AniListScoreConvert convertAniListScoreToActualScore:((NSNumber *)entry[@"score"]).intValue withScoreType:[NSUserDefaults.standardUserDefaults valueForKey:@"anilist-scoreformat"]]; + break; + default: + break; + } + mentrycell.score.text = [NSString stringWithFormat:@"Score: %@",score]; + [mentrycell loadimage:entry[@"image_url"]]; + mentrycell.active.hidden = ![(NSString *)entry[@"status"] isEqualToString:@"publishing"]; + + // Geneerate Swipe Cells + // Left + __weak ListViewController *weakSelf = self; + mentrycell.leftButtons = @[[MGSwipeButton buttonWithTitle:@"Delete" backgroundColor:UIColor.redColor callback:^BOOL(MGSwipeTableCell * _Nonnull cell) { NSDictionary *entry = weakSelf.filteredlist[indexPath.row]; - [weakSelf performMangaIncrement:entry volumeIncrement:YES]; + [weakSelf deleteTitle:((NSNumber *)entry[@"id"]).intValue withInfo:entry]; return true; }]]; - [rightbuttons addObject:[MGSwipeButton buttonWithTitle:@"Ch +" backgroundColor:[UIColor colorWithRed:0.33 green:0.84 blue:0.41 alpha:1.0] callback:^BOOL(MGSwipeTableCell * _Nonnull cell) { + mentrycell.leftSwipeSettings.transition = MGSwipeTransitionDrag; + + //Right + NSMutableArray *rightbuttons = [NSMutableArray new]; + [rightbuttons addObject:[MGSwipeButton buttonWithTitle:@"Options" backgroundColor:UIColor.grayColor callback:^BOOL(MGSwipeTableCell * _Nonnull cell) { NSDictionary *entry = weakSelf.filteredlist[indexPath.row]; - [weakSelf performMangaIncrement:entry volumeIncrement:NO]; + [weakSelf showOtherOptions:entry withIndexPath:indexPath]; return true; }]]; + if ([self canIncrement:entry]) { + [rightbuttons addObject:[MGSwipeButton buttonWithTitle:@"Vol +" backgroundColor:[UIColor colorWithRed:0.37 green:0.79 blue:0.97 alpha:1.0] callback:^BOOL(MGSwipeTableCell * _Nonnull cell) { + NSDictionary *entry = weakSelf.filteredlist[indexPath.row]; + [weakSelf performMangaIncrement:entry volumeIncrement:YES]; + return true; + }]]; + [rightbuttons addObject:[MGSwipeButton buttonWithTitle:@"Ch +" backgroundColor:[UIColor colorWithRed:0.33 green:0.84 blue:0.41 alpha:1.0] callback:^BOOL(MGSwipeTableCell * _Nonnull cell) { + NSDictionary *entry = weakSelf.filteredlist[indexPath.row]; + [weakSelf performMangaIncrement:entry volumeIncrement:NO]; + return true; + }]]; + } + mentrycell.rightButtons = rightbuttons.copy; + mentrycell.rightSwipeSettings.transition = MGSwipeTransitionDrag; + return mentrycell; + } + else { + return [UITableViewCell new]; } - mentrycell.rightButtons = rightbuttons.copy; - mentrycell.rightSwipeSettings.transition = MGSwipeTransitionDrag; - return mentrycell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - NSDictionary *entry = _filteredlist[indexPath.row]; - int titleid = ((NSNumber *)entry[@"id"]).intValue; - TitleInfoViewController *titleinfovc = (TitleInfoViewController *)[[UIStoryboard storyboardWithName:@"InfoView" bundle:nil] instantiateViewControllerWithIdentifier:@"TitleInfo"]; - [self.navigationController pushViewController:titleinfovc animated:YES]; - [titleinfovc loadTitleInfo:titleid withType:_listtype]; - + id cell = [tableView cellForRowAtIndexPath:indexPath]; + if ([cell isKindOfClass:[AnimeEntryTableViewCell class]] || [cell isKindOfClass:[MangaEntryTableViewCell class]]) { + if (indexPath.row < _filteredlist.count && !_refreshcontrol.refreshing) { + NSDictionary *entry = _filteredlist[indexPath.row]; + int titleid = ((NSNumber *)entry[@"id"]).intValue; + TitleInfoViewController *titleinfovc = (TitleInfoViewController *)[[UIStoryboard storyboardWithName:@"InfoView" bundle:nil] instantiateViewControllerWithIdentifier:@"TitleInfo"]; + [self.navigationController pushViewController:titleinfovc animated:YES]; + [titleinfovc loadTitleInfo:titleid withType:_listtype]; + } + } + else { + [(UITableViewCell *)cell setSelected:NO animated:NO]; + } } - (IBAction)refresh:(UIRefreshControl *)sender { diff --git a/Shukofukurou-IOS/View Controllers/SeasonsViewController.m b/Shukofukurou-IOS/View Controllers/SeasonsViewController.m index 9822ac02..228576a2 100644 --- a/Shukofukurou-IOS/View Controllers/SeasonsViewController.m +++ b/Shukofukurou-IOS/View Controllers/SeasonsViewController.m @@ -141,26 +141,29 @@ - (BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtI } - (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath { - NSDictionary *entry = _seasonlist[indexPath.row]; - switch ([listservice getCurrentServiceID]) { - case 1: - if (entry[@"idMal"] != [NSNull null]) { - [self showTitleView:((NSNumber *)entry[@"idMal"]).intValue]; - } - break; - case 2: - if (entry[@"idMal"] != [NSNull null]) { - [TitleIdConverter getKitsuIDFromMALId:((NSNumber *)entry[@"idMal"]).intValue withTitle:entry[@"title"] titletype:entry[@"type"] withType:0 completionHandler:^(int kitsuid) { - [self showTitleView:kitsuid]; - } error:^(NSError *error) { - }]; - } - break; - case 3: - [self showTitleView:((NSNumber *)entry[@"id"]).intValue]; - break; + if (!self.collectionView.refreshControl.refreshing) { + NSDictionary *entry = _seasonlist[indexPath.row]; + switch ([listservice getCurrentServiceID]) { + case 1: + if (entry[@"idMal"] != [NSNull null]) { + [self showTitleView:((NSNumber *)entry[@"idMal"]).intValue]; + } + break; + case 2: + if (entry[@"idMal"] != [NSNull null]) { + [TitleIdConverter getKitsuIDFromMALId:((NSNumber *)entry[@"idMal"]).intValue withTitle:entry[@"title"] titletype:entry[@"type"] withType:0 completionHandler:^(int kitsuid) { + [self showTitleView:kitsuid]; + } error:^(NSError *error) { + }]; + } + break; + case 3: + [self showTitleView:((NSNumber *)entry[@"id"]).intValue]; + break; + } + return YES; } - return YES; + return NO; }