aboutsummaryrefslogtreecommitdiffstats
path: root/iBean
diff options
context:
space:
mode:
Diffstat (limited to 'iBean')
-rw-r--r--iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstatebin43058 -> 43341 bytes
-rw-r--r--iBean/iBean.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist91
-rw-r--r--iBean/iBean/AppDelegate+Storage.h3
-rw-r--r--iBean/iBean/AppDelegate+Storage.m79
-rw-r--r--iBean/iBean/AppDelegate.h1
-rw-r--r--iBean/iBean/EditBeanViewController.h2
-rw-r--r--iBean/iBean/SettingsViewController.m8
-rw-r--r--iBean/iBean/ThresholdListViewController.m35
8 files changed, 160 insertions, 59 deletions
diff --git a/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate b/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate
index 673cad7..bd3354c 100644
--- a/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate
+++ b/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate
Binary files differ
diff --git a/iBean/iBean.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist b/iBean/iBean.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist
index d07f366..e4eeaa6 100644
--- a/iBean/iBean.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist
+++ b/iBean/iBean.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist
@@ -33,19 +33,6 @@
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
- filePath = "iBean/AppDelegate+Storage.m"
- timestampString = "381268321.748787"
- startingColumnNumber = "9223372036854775807"
- endingColumnNumber = "9223372036854775807"
- startingLineNumber = "288"
- endingLineNumber = "288"
- landmarkName = "-createTimer::::"
- landmarkType = "5">
- </FileBreakpoint>
- <FileBreakpoint
- shouldBeEnabled = "No"
- ignoreCount = "0"
- continueAfterRunningActions = "No"
filePath = "iBean/ThresholdViewController.m"
timestampString = "381271322.430192"
startingColumnNumber = "9223372036854775807"
@@ -68,5 +55,83 @@
landmarkName = "-tableView:commitEditingStyle:forRowAtIndexPath:"
landmarkType = "5">
</FileBreakpoint>
+ <FileBreakpoint
+ shouldBeEnabled = "No"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ filePath = "iBean/AppDelegate+Storage.m"
+ timestampString = "381432910.18618"
+ startingColumnNumber = "9223372036854775807"
+ endingColumnNumber = "9223372036854775807"
+ startingLineNumber = "145"
+ endingLineNumber = "145"
+ landmarkName = "-incrementExtractionCount"
+ landmarkType = "5">
+ </FileBreakpoint>
+ <FileBreakpoint
+ shouldBeEnabled = "No"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ filePath = "iBean/AppDelegate+Storage.m"
+ timestampString = "381493109.294413"
+ startingColumnNumber = "9223372036854775807"
+ endingColumnNumber = "9223372036854775807"
+ startingLineNumber = "163"
+ endingLineNumber = "163"
+ landmarkName = "-processThresholds"
+ landmarkType = "5">
+ </FileBreakpoint>
+ <FileBreakpoint
+ shouldBeEnabled = "No"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ filePath = "iBean/AppDelegate+Storage.m"
+ timestampString = "381432960.601612"
+ startingColumnNumber = "9223372036854775807"
+ endingColumnNumber = "9223372036854775807"
+ startingLineNumber = "136"
+ endingLineNumber = "136"
+ landmarkName = "-setExtractionCount:"
+ landmarkType = "5">
+ </FileBreakpoint>
+ <FileBreakpoint
+ shouldBeEnabled = "No"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ filePath = "iBean/AppDelegate+Storage.m"
+ timestampString = "381503070.601476"
+ startingColumnNumber = "9223372036854775807"
+ endingColumnNumber = "9223372036854775807"
+ startingLineNumber = "170"
+ endingLineNumber = "170"
+ landmarkName = "-processThresholds"
+ landmarkType = "5">
+ </FileBreakpoint>
+ <FileBreakpoint
+ shouldBeEnabled = "Yes"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ filePath = "iBean/AppDelegate.m"
+ timestampString = "381511651.662976"
+ startingColumnNumber = "9223372036854775807"
+ endingColumnNumber = "9223372036854775807"
+ startingLineNumber = "54"
+ endingLineNumber = "54"
+ landmarkName = "-applicationWillTerminate:"
+ landmarkType = "5">
+ </FileBreakpoint>
+ <FileBreakpoint
+ shouldBeEnabled = "No"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ filePath = "iBean/AppDelegate+Storage.m"
+ timestampString = "381513161.061541"
+ startingColumnNumber = "9223372036854775807"
+ endingColumnNumber = "9223372036854775807"
+ startingLineNumber = "200"
+ endingLineNumber = "200"
+ landmarkName = "-processThresholds"
+ landmarkType = "5">
+ </FileBreakpoint>
</FileBreakpoints>
</Bucket>
diff --git a/iBean/iBean/AppDelegate+Storage.h b/iBean/iBean/AppDelegate+Storage.h
index f668396..abaef29 100644
--- a/iBean/iBean/AppDelegate+Storage.h
+++ b/iBean/iBean/AppDelegate+Storage.h
@@ -17,7 +17,7 @@
methods etc. in one area. Just to keep it clean.
*/
-@interface AppDelegate (Storage)
+@interface AppDelegate (Storage) <UIAlertViewDelegate>
#pragma mark - Common storage related methods
- (NSError*) save;
@@ -36,6 +36,7 @@
//Thresholds methods
- (void) processThresholds;
+- (void) processActiveThreshold;
- (Threshold*) createThreshold;
diff --git a/iBean/iBean/AppDelegate+Storage.m b/iBean/iBean/AppDelegate+Storage.m
index fe62969..8448f3e 100644
--- a/iBean/iBean/AppDelegate+Storage.m
+++ b/iBean/iBean/AppDelegate+Storage.m
@@ -9,6 +9,7 @@
#import "AppDelegate+Storage.h"
#import "Configuration+Interface.h"
#import "BeanCollection.h"
+#include "Threshold.h"
@implementation AppDelegate (Storage)
@@ -130,6 +131,10 @@
cancelButtonTitle:@"OK" otherButtonTitles: nil];
[setExtractionCountAlert show];
}
+ else
+ {
+ [self processThresholds];
+ }
}
return error;
@@ -143,9 +148,8 @@
{
if ([c.countExtractions boolValue] == YES)
{
- if ([self setExtractionCount:[NSNumber numberWithInteger:([c.extractionCount integerValue] + 1)]] != nil)
+ if ([self setExtractionCount:[NSNumber numberWithInteger:([c.extractionCount integerValue] + 1)]] == nil)
{
- [self processThresholds];
return c.extractionCount;
}
}
@@ -155,9 +159,65 @@
- (void) processThresholds
{
-#warning TODO - Implement this
- //Simply go through the thresholds array and alert on those that are enabled and "active".
- //Find out how to make the list of thresholds sorted on the value.
+ //First out, lets sort the thresholds
+ Configuration *configuration = [self getConfiguration];
+
+ if (configuration != nil)
+ {
+ if ([configuration.useThresholds boolValue] == YES)
+ {
+ self.activeThresholdsToProcess = [[NSMutableArray alloc] init];
+ NSArray *sortedThresholds = [configuration.thresholds sortedArrayUsingComparator:
+ ^NSComparisonResult(id obj1, id obj2)
+ {
+ Threshold* t1 = obj1;
+ Threshold* t2 = obj2;
+
+ if ([[t1 value] integerValue] > [[t2 value] integerValue])
+ {
+ return (NSComparisonResult)NSOrderedDescending;
+ }
+
+ if ([[t1 value] integerValue] < [[t2 value] integerValue])
+ {
+ return (NSComparisonResult)NSOrderedAscending;
+ }
+
+ return (NSComparisonResult)NSOrderedSame;
+ }];
+
+ //Time to go through all thresholds and se which one(s) that are hit!
+ for (Threshold *t in sortedThresholds)
+ {
+ if ([configuration.extractionCount integerValue] >= [t.value integerValue] && [t.enabled boolValue] == YES)
+ {
+ NSLog(@"Threshold %@ active (%@ >= %@)", t.name, configuration.extractionCount, t.value);
+ [self.activeThresholdsToProcess addObject:t];
+ }
+ }
+
+ //Now, let's go through all active thresholds.
+ [self processActiveThreshold];
+ }
+ }
+}
+
+- (void) processActiveThreshold
+{
+ if (self.activeThresholdsToProcess != nil)
+ {
+ if (self.activeThresholdsToProcess.count > 0)
+ {
+ Threshold *t = [self.activeThresholdsToProcess objectAtIndex:0];
+ [self.activeThresholdsToProcess removeObject:t];
+ UIAlertView *thresholdAlert = [[UIAlertView alloc] initWithTitle:@"Threshold reached!" message:t.name delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
+ [thresholdAlert show];
+ }
+ else
+ {
+ self.activeThresholdsToProcess = nil;
+ }
+ }
}
- (Threshold*) createThreshold
@@ -317,7 +377,14 @@
}
}
-
+#pragma mark - UIAlertView delegate
+- (void) alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
+{
+ if (self.activeThresholdsToProcess != nil)
+ {
+ [self processActiveThreshold];
+ }
+}
@end
diff --git a/iBean/iBean/AppDelegate.h b/iBean/iBean/AppDelegate.h
index b09db3e..b2f867d 100644
--- a/iBean/iBean/AppDelegate.h
+++ b/iBean/iBean/AppDelegate.h
@@ -14,6 +14,7 @@
@property (nonatomic, strong) id timerCallbackTarget;
@property (nonatomic, strong) NSTimer *timer;
+@property (nonatomic, strong) NSMutableArray* activeThresholdsToProcess;
@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
diff --git a/iBean/iBean/EditBeanViewController.h b/iBean/iBean/EditBeanViewController.h
index 7d0d8fd..83d7ac9 100644
--- a/iBean/iBean/EditBeanViewController.h
+++ b/iBean/iBean/EditBeanViewController.h
@@ -14,7 +14,7 @@
@property (nonatomic, assign) NSUInteger editBeanIndex;
/* Utility methods */
-- (void) initWithModeAndBeanCollectionAndBeanIndex:(BOOL)editMode: (BeanCollection*) bc: (NSUInteger) beanIndex;
+- (void) initWithModeAndBeanCollectionAndBeanIndex:(BOOL)editMode: (BeanCollection*)bc: (NSUInteger) beanIndex;
- (void) initViewController;
/* UI Outlets */
diff --git a/iBean/iBean/SettingsViewController.m b/iBean/iBean/SettingsViewController.m
index 242bee1..4b8f723 100644
--- a/iBean/iBean/SettingsViewController.m
+++ b/iBean/iBean/SettingsViewController.m
@@ -127,10 +127,8 @@
{
if (self.configuration != nil)
{
- self.configuration.extractionCount = [NSNumber numberWithDouble:self.extractionCountStepper.value];
-
+ NSError *error = [(AppDelegate*) [[UIApplication sharedApplication] delegate] setExtractionCount:[NSNumber numberWithDouble:self.extractionCountStepper.value]];
self.extractionCountLabel.text = [self.configuration.extractionCount stringValue];
- NSError *error = [(AppDelegate*) [[UIApplication sharedApplication] delegate] save];
if (error != nil)
{
UIAlertView *setExtractionCountAlert = [[UIAlertView alloc]
@@ -140,6 +138,10 @@
cancelButtonTitle:@"OK" otherButtonTitles: nil];
[setExtractionCountAlert show];
}
+ else
+ {
+ self.extractionCountLabel.text = [self.configuration.extractionCount stringValue];
+ }
}
}
diff --git a/iBean/iBean/ThresholdListViewController.m b/iBean/iBean/ThresholdListViewController.m
index 57db263..18f087a 100644
--- a/iBean/iBean/ThresholdListViewController.m
+++ b/iBean/iBean/ThresholdListViewController.m
@@ -158,40 +158,5 @@
}
}
-// 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;
-}
-
-// Override to support rearranging the table view.
-//http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/tableview_iphone/ManageReorderRow/ManageReorderRow.html
-- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
-{
- if (self.configuration != nil && fromIndexPath.row != toIndexPath.row)
- {
- NSLog(@"From: %d, To: %d", fromIndexPath.row, toIndexPath.row);
- if (toIndexPath.row < (self.configuration.thresholds.count - 1))
- {
- NSMutableIndexSet *thresholdIndexes = [NSMutableIndexSet indexSetWithIndex:fromIndexPath.row];
- [thresholdIndexes addIndex:toIndexPath.row];
- NSArray *thresholds = [NSArray arrayWithObjects:[self.configuration.thresholds objectAtIndex:fromIndexPath.row], [self.configuration.thresholds objectAtIndex:toIndexPath.row], nil];
- [self.configuration replaceThresholdsAtIndexes:thresholdIndexes withThresholds:thresholds];
-
- //Commit change
- if ([(AppDelegate*) [[UIApplication sharedApplication] delegate] save] != nil)
- {
- UIAlertView *deleteRowAlert = [[UIAlertView alloc] initWithTitle:@"Configuration error!" message:@"iBean was unable to move threshold!\nPlease try again." delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
- [deleteRowAlert show];
-
- //Rollback and reload table view
- [(AppDelegate*) [[UIApplication sharedApplication] delegate] rollback];
- [self.thresholdListTableView reloadData];
- }
- }
- }
-}
-
@end