From c8bcec75c5d7436690cc510e7acfe136cc1574f5 Mon Sep 17 00:00:00 2001 From: Paul Young Date: Thu, 11 Jul 2013 23:20:33 -0400 Subject: Work in progress for #132: Added message preview to iOS example. * Operations are not yet cancelled at any point. * There is a visible delay when the detail text of table cells are updated after a delay as cells are re-used. --- .../ios/iOS UI Test/iOS UI Test/MasterViewController.m | 7 +++++++ .../iOS UI Test/en.lproj/MainStoryboard.storyboard | 15 ++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'example') diff --git a/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m b/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m index 5bbc0d53..1b2528d1 100644 --- a/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m +++ b/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m @@ -171,6 +171,13 @@ finishedRefreshWithFetcher:(GTMHTTPFetcher *)fetcher MCOIMAPMessage *message = self.messages[indexPath.row]; cell.textLabel.text = message.header.subject; + + MCOIMAPMessageRenderingOperation * op = [self.imapSession plainTextBodyRenderingOperationWithMessage:message + folder:@"INBOX"]; + + [op start:^(NSString * htmlString, NSError * error) { + cell.detailTextLabel.text = htmlString; + }]; return cell; } diff --git a/example/ios/iOS UI Test/iOS UI Test/en.lproj/MainStoryboard.storyboard b/example/ios/iOS UI Test/iOS UI Test/en.lproj/MainStoryboard.storyboard index 63190886..ce2aec94 100644 --- a/example/ios/iOS UI Test/iOS UI Test/en.lproj/MainStoryboard.storyboard +++ b/example/ios/iOS UI Test/iOS UI Test/en.lproj/MainStoryboard.storyboard @@ -1,5 +1,5 @@ - + @@ -28,20 +28,25 @@ - + - -- cgit v1.2.3 From 9da381504d06076274d893b6a73dd270b703e8aa Mon Sep 17 00:00:00 2001 From: Paul Young Date: Fri, 12 Jul 2013 00:18:02 -0400 Subject: Restored table view cell style to subtitle. * Lost in the merge conflict. --- .../iOS UI Test/en.lproj/MainStoryboard.storyboard | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'example') diff --git a/example/ios/iOS UI Test/iOS UI Test/en.lproj/MainStoryboard.storyboard b/example/ios/iOS UI Test/iOS UI Test/en.lproj/MainStoryboard.storyboard index 72b2d274..91422073 100644 --- a/example/ios/iOS UI Test/iOS UI Test/en.lproj/MainStoryboard.storyboard +++ b/example/ios/iOS UI Test/iOS UI Test/en.lproj/MainStoryboard.storyboard @@ -1,16 +1,15 @@ - + - + - @@ -31,20 +30,25 @@ - + - @@ -57,7 +61,6 @@ - @@ -84,4 +87,4 @@ - + \ No newline at end of file -- cgit v1.2.3 From ba30d5c850b2712d0a5530ecc09b8616e55a40ba Mon Sep 17 00:00:00 2001 From: Paul Young Date: Sun, 14 Jul 2013 15:51:15 -0400 Subject: Associating message rendering operation with table view cell. * Added custom table view cell. * Cancelling operation on cell reuse. --- .../iOS UI Test/iOS UI Test.xcodeproj/project.pbxproj | 6 ++++++ example/ios/iOS UI Test/iOS UI Test/MCTTableViewCell.h | 16 ++++++++++++++++ example/ios/iOS UI Test/iOS UI Test/MCTTableViewCell.m | 13 +++++++++++++ .../ios/iOS UI Test/iOS UI Test/MasterViewController.m | 11 +++++++---- .../iOS UI Test/en.lproj/MainStoryboard.storyboard | 5 ++++- 5 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 example/ios/iOS UI Test/iOS UI Test/MCTTableViewCell.h create mode 100644 example/ios/iOS UI Test/iOS UI Test/MCTTableViewCell.m (limited to 'example') diff --git a/example/ios/iOS UI Test/iOS UI Test.xcodeproj/project.pbxproj b/example/ios/iOS UI Test/iOS UI Test.xcodeproj/project.pbxproj index e9cd3797..d8972256 100644 --- a/example/ios/iOS UI Test/iOS UI Test.xcodeproj/project.pbxproj +++ b/example/ios/iOS UI Test/iOS UI Test.xcodeproj/project.pbxproj @@ -35,6 +35,7 @@ C6D71951178BB8B4008ED15F /* GTMOAuth2ViewControllerTouch.m in Sources */ = {isa = PBXBuildFile; fileRef = C6D71947178BA812008ED15F /* GTMOAuth2ViewControllerTouch.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; C6D71952178BB8B4008ED15F /* GTMOAuth2ViewTouch.xib in Resources */ = {isa = PBXBuildFile; fileRef = C6D71948178BA812008ED15F /* GTMOAuth2ViewTouch.xib */; }; C6D71954178BB91E008ED15F /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C6D71953178BB91E008ED15F /* SystemConfiguration.framework */; }; + DA9AD477179331A600743873 /* MCTTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = DA9AD476179331A600743873 /* MCTTableViewCell.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -126,6 +127,8 @@ C6D71947178BA812008ED15F /* GTMOAuth2ViewControllerTouch.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GTMOAuth2ViewControllerTouch.m; sourceTree = ""; }; C6D71948178BA812008ED15F /* GTMOAuth2ViewTouch.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = GTMOAuth2ViewTouch.xib; sourceTree = ""; }; C6D71953178BB91E008ED15F /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; + DA9AD475179331A600743873 /* MCTTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCTTableViewCell.h; sourceTree = ""; }; + DA9AD476179331A600743873 /* MCTTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MCTTableViewCell.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -222,6 +225,8 @@ AB9EAE3517036FD700D750C7 /* SettingsViewController.xib */, AB9EAE0C170368F000D750C7 /* Supporting Files */, AB665BC917134336007F2151 /* common */, + DA9AD475179331A600743873 /* MCTTableViewCell.h */, + DA9AD476179331A600743873 /* MCTTableViewCell.m */, ); path = "iOS UI Test"; sourceTree = ""; @@ -408,6 +413,7 @@ C6D7194F178BB8B4008ED15F /* GTMOAuth2Authentication.m in Sources */, B12AAA3417322654003551C7 /* MCOMessageView.mm in Sources */, B12AAA3517322654003551C7 /* MCTMsgViewController.mm in Sources */, + DA9AD477179331A600743873 /* MCTTableViewCell.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/example/ios/iOS UI Test/iOS UI Test/MCTTableViewCell.h b/example/ios/iOS UI Test/iOS UI Test/MCTTableViewCell.h new file mode 100644 index 00000000..0d680415 --- /dev/null +++ b/example/ios/iOS UI Test/iOS UI Test/MCTTableViewCell.h @@ -0,0 +1,16 @@ +// +// MCTTableViewCell.h +// iOS UI Test +// +// Created by Paul Young on 14/07/2013. +// Copyright (c) 2013 AppJon. All rights reserved. +// + +#import +#import + +@interface MCTTableViewCell : UITableViewCell + +@property (nonatomic, strong) MCOIMAPMessageRenderingOperation * messageRenderingOperation; + +@end diff --git a/example/ios/iOS UI Test/iOS UI Test/MCTTableViewCell.m b/example/ios/iOS UI Test/iOS UI Test/MCTTableViewCell.m new file mode 100644 index 00000000..21d22e38 --- /dev/null +++ b/example/ios/iOS UI Test/iOS UI Test/MCTTableViewCell.m @@ -0,0 +1,13 @@ +// +// MCTTableViewCell.m +// iOS UI Test +// +// Created by Paul Young on 14/07/2013. +// Copyright (c) 2013 AppJon. All rights reserved. +// + +#import "MCTTableViewCell.h" + +@implementation MCTTableViewCell + +@end diff --git a/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m b/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m index 1b2528d1..c05fdd9a 100644 --- a/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m +++ b/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m @@ -11,6 +11,7 @@ #import "FXKeychain.h" #import "MCTMsgViewController.h" #import "GTMOAuth2ViewControllerTouch.h" +#import "MCTTableViewCell.h" #define CLIENT_ID @"the-client-id" #define CLIENT_SECRET @"the-client-secret" @@ -167,15 +168,17 @@ finishedRefreshWithFetcher:(GTMHTTPFetcher *)fetcher } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; + MCTTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; MCOIMAPMessage *message = self.messages[indexPath.row]; cell.textLabel.text = message.header.subject; - MCOIMAPMessageRenderingOperation * op = [self.imapSession plainTextBodyRenderingOperationWithMessage:message - folder:@"INBOX"]; + [cell.messageRenderingOperation cancel]; - [op start:^(NSString * htmlString, NSError * error) { + cell.messageRenderingOperation = [self.imapSession plainTextBodyRenderingOperationWithMessage:message + folder:@"INBOX"]; + + [cell.messageRenderingOperation start:^(NSString * htmlString, NSError * error) { cell.detailTextLabel.text = htmlString; }]; diff --git a/example/ios/iOS UI Test/iOS UI Test/en.lproj/MainStoryboard.storyboard b/example/ios/iOS UI Test/iOS UI Test/en.lproj/MainStoryboard.storyboard index 91422073..2e9d223f 100644 --- a/example/ios/iOS UI Test/iOS UI Test/en.lproj/MainStoryboard.storyboard +++ b/example/ios/iOS UI Test/iOS UI Test/en.lproj/MainStoryboard.storyboard @@ -30,7 +30,7 @@ - + @@ -75,6 +75,9 @@ + + + -- cgit v1.2.3 From 58fc7bb84a0bb5b053a63857dc5e81b732c4cf8b Mon Sep 17 00:00:00 2001 From: Paul Young Date: Sun, 14 Jul 2013 22:36:52 -0400 Subject: Setting the rendering operation to nil when the complete. --- example/ios/iOS UI Test/iOS UI Test/MasterViewController.m | 1 + 1 file changed, 1 insertion(+) (limited to 'example') diff --git a/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m b/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m index c05fdd9a..0e9e0536 100644 --- a/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m +++ b/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m @@ -180,6 +180,7 @@ finishedRefreshWithFetcher:(GTMHTTPFetcher *)fetcher [cell.messageRenderingOperation start:^(NSString * htmlString, NSError * error) { cell.detailTextLabel.text = htmlString; + cell.messageRenderingOperation = nil; }]; return cell; -- cgit v1.2.3 From 7f7e86d9a24a9849a6d854073640ab3e95cb2168 Mon Sep 17 00:00:00 2001 From: Paul Young Date: Sun, 14 Jul 2013 22:37:49 -0400 Subject: Renamed block parameter. --- example/ios/iOS UI Test/iOS UI Test/MasterViewController.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'example') diff --git a/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m b/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m index 0e9e0536..accd9040 100644 --- a/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m +++ b/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m @@ -178,8 +178,8 @@ finishedRefreshWithFetcher:(GTMHTTPFetcher *)fetcher cell.messageRenderingOperation = [self.imapSession plainTextBodyRenderingOperationWithMessage:message folder:@"INBOX"]; - [cell.messageRenderingOperation start:^(NSString * htmlString, NSError * error) { - cell.detailTextLabel.text = htmlString; + [cell.messageRenderingOperation start:^(NSString * plainTextBodyString, NSError * error) { + cell.detailTextLabel.text = plainTextBodyString; cell.messageRenderingOperation = nil; }]; -- cgit v1.2.3 From 94a1a8bc8eb5a43d4e7bcd3576e32aab034ef4a5 Mon Sep 17 00:00:00 2001 From: Paul Young Date: Sun, 14 Jul 2013 23:18:09 -0400 Subject: Cancelling ay previous rendering operation ASAP. --- example/ios/iOS UI Test/iOS UI Test/MasterViewController.m | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'example') diff --git a/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m b/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m index accd9040..40aa791f 100644 --- a/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m +++ b/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m @@ -169,12 +169,11 @@ finishedRefreshWithFetcher:(GTMHTTPFetcher *)fetcher - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { MCTTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; - + [cell.messageRenderingOperation cancel]; + MCOIMAPMessage *message = self.messages[indexPath.row]; cell.textLabel.text = message.header.subject; - [cell.messageRenderingOperation cancel]; - cell.messageRenderingOperation = [self.imapSession plainTextBodyRenderingOperationWithMessage:message folder:@"INBOX"]; -- cgit v1.2.3 From 1ee4a022d831bd256f1ecc535864e1ba6c4885f1 Mon Sep 17 00:00:00 2001 From: Paul Young Date: Sun, 14 Jul 2013 23:18:59 -0400 Subject: Clearing previous cell subtitle on reuse. --- example/ios/iOS UI Test/iOS UI Test/MasterViewController.m | 1 + 1 file changed, 1 insertion(+) (limited to 'example') diff --git a/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m b/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m index 40aa791f..9e6f49df 100644 --- a/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m +++ b/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m @@ -170,6 +170,7 @@ finishedRefreshWithFetcher:(GTMHTTPFetcher *)fetcher - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { MCTTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; [cell.messageRenderingOperation cancel]; + cell.detailTextLabel.text = @" "; MCOIMAPMessage *message = self.messages[indexPath.row]; cell.textLabel.text = message.header.subject; -- cgit v1.2.3 From f789d411c42d14ab9403470b06dc2c8b905018c3 Mon Sep 17 00:00:00 2001 From: Paul Young Date: Sun, 14 Jul 2013 23:36:39 -0400 Subject: Added prepareForReuse * Moved cancellation of rendering operation and resetting of subtitle. --- example/ios/iOS UI Test/iOS UI Test/MCTTableViewCell.m | 6 ++++++ example/ios/iOS UI Test/iOS UI Test/MasterViewController.m | 5 +---- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'example') diff --git a/example/ios/iOS UI Test/iOS UI Test/MCTTableViewCell.m b/example/ios/iOS UI Test/iOS UI Test/MCTTableViewCell.m index 21d22e38..bf0df5fb 100644 --- a/example/ios/iOS UI Test/iOS UI Test/MCTTableViewCell.m +++ b/example/ios/iOS UI Test/iOS UI Test/MCTTableViewCell.m @@ -10,4 +10,10 @@ @implementation MCTTableViewCell +- (void)prepareForReuse +{ + [self.messageRenderingOperation cancel]; + self.detailTextLabel.text = @" "; +} + @end diff --git a/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m b/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m index 9e6f49df..b6a2206e 100644 --- a/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m +++ b/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m @@ -169,12 +169,9 @@ finishedRefreshWithFetcher:(GTMHTTPFetcher *)fetcher - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { MCTTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; - [cell.messageRenderingOperation cancel]; - cell.detailTextLabel.text = @" "; - MCOIMAPMessage *message = self.messages[indexPath.row]; - cell.textLabel.text = message.header.subject; + cell.textLabel.text = message.header.subject; cell.messageRenderingOperation = [self.imapSession plainTextBodyRenderingOperationWithMessage:message folder:@"INBOX"]; -- cgit v1.2.3 From 739398c238744901170a3800bd3d19f3ad584911 Mon Sep 17 00:00:00 2001 From: Paul Young Date: Mon, 15 Jul 2013 00:10:22 -0400 Subject: Registered a class for cell reuse. --- example/ios/iOS UI Test/iOS UI Test/MCTTableViewCell.m | 6 ++++++ example/ios/iOS UI Test/iOS UI Test/MasterViewController.m | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'example') diff --git a/example/ios/iOS UI Test/iOS UI Test/MCTTableViewCell.m b/example/ios/iOS UI Test/iOS UI Test/MCTTableViewCell.m index bf0df5fb..1c45b0ec 100644 --- a/example/ios/iOS UI Test/iOS UI Test/MCTTableViewCell.m +++ b/example/ios/iOS UI Test/iOS UI Test/MCTTableViewCell.m @@ -10,6 +10,12 @@ @implementation MCTTableViewCell +- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier +{ + self = [super initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseIdentifier]; + return self; +} + - (void)prepareForReuse { [self.messageRenderingOperation cancel]; diff --git a/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m b/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m index b6a2206e..7540eee8 100644 --- a/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m +++ b/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m @@ -168,7 +168,10 @@ finishedRefreshWithFetcher:(GTMHTTPFetcher *)fetcher } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - MCTTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; + NSString * cellIdentifier = @"Cell"; + [tableView registerClass:[MCTTableViewCell class] forCellReuseIdentifier:cellIdentifier]; + + MCTTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath]; MCOIMAPMessage *message = self.messages[indexPath.row]; cell.textLabel.text = message.header.subject; -- cgit v1.2.3