diff --git a/RedmineMobile/RedmineMobile/Models/OZLConstants.h b/RedmineMobile/RedmineMobile/Models/OZLConstants.h index 4417e24..555b29c 100644 --- a/RedmineMobile/RedmineMobile/Models/OZLConstants.h +++ b/RedmineMobile/RedmineMobile/Models/OZLConstants.h @@ -27,7 +27,7 @@ // THE SOFTWARE. #import -extern const NSString* NOTIFICATION_REDMINE_ACCOUNT_CHANGED; +extern NSString* NOTIFICATION_REDMINE_ACCOUNT_CHANGED; @interface OZLConstants : NSObject diff --git a/RedmineMobile/RedmineMobile/Models/OZLConstants.m b/RedmineMobile/RedmineMobile/Models/OZLConstants.m index 99e80b1..0f402ab 100644 --- a/RedmineMobile/RedmineMobile/Models/OZLConstants.m +++ b/RedmineMobile/RedmineMobile/Models/OZLConstants.m @@ -27,7 +27,7 @@ // THE SOFTWARE. #import "OZLConstants.h" -const NSString* NOTIFICATION_REDMINE_ACCOUNT_CHANGED = @"NOTIFICATION_REDMINE_ACCOUNT_CHANGED"; +NSString* NOTIFICATION_REDMINE_ACCOUNT_CHANGED = @"NOTIFICATION_REDMINE_ACCOUNT_CHANGED"; @implementation OZLConstants diff --git a/RedmineMobile/RedmineMobile/Utils/OZLSingleton.h b/RedmineMobile/RedmineMobile/Utils/OZLSingleton.h index b895d91..9307f86 100644 --- a/RedmineMobile/RedmineMobile/Utils/OZLSingleton.h +++ b/RedmineMobile/RedmineMobile/Utils/OZLSingleton.h @@ -46,6 +46,12 @@ //app status @property(nonatomic) int lastProjectID;// last viewed project id +// app data +@property (strong, nonatomic) NSArray* trackerList; +@property (strong, nonatomic) NSArray* priorityList; +@property (strong, nonatomic) NSArray* statusList; +@property (strong, nonatomic) NSArray* userList; +@property (strong, nonatomic) NSArray* timeEntryActivityList; @end diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.m index f9f3b95..6088eb3 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueCreateViewController.m @@ -34,6 +34,7 @@ #import "OZLModelUser.h" #import "OZLModelIssueStatus.h" #import "MLTableAlert.h" +#import "OZLSingleton.h" @interface OZLIssueCreateViewController () { @@ -66,6 +67,12 @@ { [super viewDidLoad]; + OZLSingleton* singleton = [OZLSingleton sharedInstance]; + _trackerList = singleton.trackerList; + _statusList = singleton.statusList; + _userList = singleton.userList; + _priorityList = singleton.priorityList; + UIBarButtonItem* cancelBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(onCancel:)]; [self.navigationItem setLeftBarButtonItem:cancelBtn]; UIBarButtonItem* saveBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(onSave:)]; diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m index a91eaeb..c29be83 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueDetailViewController.m @@ -29,6 +29,7 @@ #import "OZLIssueDetailViewController.h" #import "OZLIssueHistoryViewController.h" #import "OZLIssueLogtimeViewController.h" +#import "OZLSingleton.h" @interface OZLIssueDetailViewController () @@ -58,6 +59,8 @@ { [super viewDidLoad]; + _timeEntryActivityList = [[OZLSingleton sharedInstance] timeEntryActivityList]; + _subject.text = _issueData.subject; _description.text = _issueData.description; _progressbar.progress = _issueData.doneRatio/100; @@ -94,7 +97,6 @@ case 2:{//logtime UIStoryboard *tableViewStoryboard = [UIStoryboard storyboardWithName:@"OZLIssueLogtimeViewController" bundle:nil]; OZLIssueLogtimeViewController* creator = [tableViewStoryboard instantiateViewControllerWithIdentifier:@"OZLIssueLogtimeViewController"]; - [creator setTimeEntryActivityList:_timeEntryActivityList]; [creator setIssueData:_issueData]; [self.navigationController pushViewController:creator animated:YES]; }break; diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueFilterViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueFilterViewController.m index 4a6124c..7f94766 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueFilterViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueFilterViewController.m @@ -78,7 +78,6 @@ { OZLSingleton* singleton =[OZLSingleton sharedInstance]; - [singleton setIssueListFilterType:_checkedCell[0]]; [singleton setIssueListSortType:_checkedCell[1]]; [singleton setIssueListSortAscending:_checkedCell[2]]; diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueLogtimeViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueLogtimeViewController.m index 375accb..1e6f82d 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueLogtimeViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLIssueLogtimeViewController.m @@ -10,6 +10,7 @@ #import "MBProgressHUD.h" #import "MLTableAlert.h" #import "OZLNetwork.h" +#import "OZLSingleton.h" @interface OZLIssueLogtimeViewController () { MBProgressHUD* _HUD; @@ -35,6 +36,7 @@ // initialize data _hourValue = 0; _entry = [[OZLModelTimeEntries alloc] init]; + _timeEntryActivityList = [[OZLSingleton sharedInstance] timeEntryActivityList]; UIBarButtonItem* cancelBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(onCancel:)]; [self.navigationItem setLeftBarButtonItem:cancelBtn]; diff --git a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m index 75ef8e5..99ad4fd 100644 --- a/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m +++ b/RedmineMobile/RedmineMobile/ViewControllers/OZLProjectViewController.m @@ -148,70 +148,85 @@ { _issueListOption = [[NSMutableDictionary alloc] init]; - static int doneCount = 0; - const int totalCount = 5; - [OZLNetwork getTrackerListWithParams:nil andBlock:^(NSArray *result, NSError *error) { - if (!error) { - _trackerList = result; - }else { - NSLog(@"get tracker list error : %@",error.description); - } - doneCount ++; - if (doneCount == totalCount) { - [self loadProjectDetail]; - doneCount = 0; - } - }]; + OZLSingleton* singleton = [OZLSingleton sharedInstance]; + if (singleton.userList != nil) { + _trackerList = singleton.trackerList; + _statusList = singleton.statusList; + _userList = singleton.userList; + _priorityList = singleton.priorityList; + _timeEntryActivityList = singleton.timeEntryActivityList; + [self loadProjectDetail]; + }else { + static int doneCount = 0; + const int totalCount = 5; + [OZLNetwork getTrackerListWithParams:nil andBlock:^(NSArray *result, NSError *error) { + if (!error) { + _trackerList = result; + singleton.trackerList = _trackerList; + }else { + NSLog(@"get tracker list error : %@",error.description); + } + doneCount ++; + if (doneCount == totalCount) { + [self loadProjectDetail]; + doneCount = 0; + } + }]; - [OZLNetwork getIssueStatusListWithParams:nil andBlock:^(NSArray *result, NSError *error) { - if (!error) { - _statusList = result; - }else { - NSLog(@"get issue status list error : %@",error.description); - } - doneCount ++; - if (doneCount == totalCount) { - [self loadProjectDetail]; - doneCount = 0; - } - }]; - [OZLNetwork getPriorityListWithParams:nil andBlock:^(NSArray *result, NSError *error) { - if (!error) { - _priorityList = result; - }else { - NSLog(@"get priority list error : %@",error.description); - } - doneCount ++; - if (doneCount == totalCount) { - [self loadProjectDetail]; - doneCount = 0; - } - }]; - [OZLNetwork getUserListWithParams:nil andBlock:^(NSArray *result, NSError *error) { - if (!error) { - _userList = result; - }else { - NSLog(@"get user list error : %@",error.description); - } - doneCount ++; - if (doneCount == totalCount) { - [self loadProjectDetail]; - doneCount = 0; - } - }]; + [OZLNetwork getIssueStatusListWithParams:nil andBlock:^(NSArray *result, NSError *error) { + if (!error) { + _statusList = result; + singleton.statusList = _statusList; + }else { + NSLog(@"get issue status list error : %@",error.description); + } + doneCount ++; + if (doneCount == totalCount) { + [self loadProjectDetail]; + doneCount = 0; + } + }]; + [OZLNetwork getPriorityListWithParams:nil andBlock:^(NSArray *result, NSError *error) { + if (!error) { + _priorityList = result; + singleton.priorityList = _priorityList; + }else { + NSLog(@"get priority list error : %@",error.description); + } + doneCount ++; + if (doneCount == totalCount) { + [self loadProjectDetail]; + doneCount = 0; + } + }]; + [OZLNetwork getUserListWithParams:nil andBlock:^(NSArray *result, NSError *error) { + if (!error) { + _userList = result; + singleton.userList = _userList; + }else { + NSLog(@"get user list error : %@",error.description); + } + doneCount ++; + if (doneCount == totalCount) { + [self loadProjectDetail]; + doneCount = 0; + } + }]; - [OZLNetwork getTimeEntryListWithParams:nil andBlock:^(NSArray *result, NSError *error) { - if (!error) { - _timeEntryActivityList = result; - }else { - NSLog(@"get user list error : %@",error.description); - } - doneCount ++; - if (doneCount == totalCount) { - [self loadProjectDetail]; - doneCount = 0; - } - }]; + [OZLNetwork getTimeEntryListWithParams:nil andBlock:^(NSArray *result, NSError *error) { + if (!error) { + _timeEntryActivityList = result; + singleton.timeEntryActivityList = _timeEntryActivityList; + }else { + NSLog(@"get user list error : %@",error.description); + } + doneCount ++; + if (doneCount == totalCount) { + [self loadProjectDetail]; + doneCount = 0; + } + }]; + } } @@ -307,45 +322,6 @@ return cell; } -/* - // Override to support conditional editing of the table view. - - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath - { - // Return NO if you do not want the specified item to be editable. - return YES; - } - */ - -/* - // Override to support editing the table view. - - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath - { - if (editingStyle == UITableViewCellEditingStyleDelete) { - // Delete the row from the data source - [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; - } - else if (editingStyle == UITableViewCellEditingStyleInsert) { - // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view - } - } - */ - -/* - // Override to support rearranging the table view. - - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath - { - } - */ - -/* - // Override to support conditional rearranging of the table view. - - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath - { - // Return NO if you do not want the item to be re-orderable. - return YES; - } - */ - #pragma mark - Table view delegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath @@ -354,7 +330,6 @@ UIStoryboard *tableViewStoryboard = [UIStoryboard storyboardWithName:@"OZLIssueDetailViewController" bundle:nil]; OZLIssueDetailViewController* detail = [tableViewStoryboard instantiateViewControllerWithIdentifier:@"OZLIssueDetailViewController"]; [detail setIssueData:[_issuesList objectAtIndex:indexPath.row]]; - [detail setTimeEntryActivityList:_timeEntryActivityList]; [self.navigationController pushViewController:detail animated:YES]; } @@ -363,10 +338,6 @@ UIStoryboard *tableViewStoryboard = [UIStoryboard storyboardWithName:@"OZLIssueCreateViewController" bundle:nil]; OZLIssueCreateViewController* creator = [tableViewStoryboard instantiateViewControllerWithIdentifier:@"OZLIssueCreateViewController"]; [creator setParentProject:_projectData]; - creator.userList = _userList; - creator.trackerList = _trackerList; - creator.priorityList = _priorityList; - creator.statusList = _statusList; //[self.navigationController presentModalViewController:creator animated:YES]; [self.navigationController pushViewController:creator animated:YES]; }