Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilHardwick committed Sep 10, 2014
2 parents 0ce773b + 47e9e25 commit 386be35
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 24 deletions.
7 changes: 4 additions & 3 deletions pinpoint2/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5056" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="FmE-h9-rSq">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6245" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="FmE-h9-rSq">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
<deployment defaultVersion="1808" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6238"/>
</dependencies>
<scenes>
<!--Card Collection View Controller-->
Expand All @@ -26,7 +27,7 @@
<rect key="frame" x="0.0" y="0.0" width="300" height="300"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<webView contentMode="scaleAspectFit" allowsInlineMediaPlayback="NO" mediaPlaybackRequiresUserAction="NO" mediaPlaybackAllowsAirPlay="NO" keyboardDisplayRequiresUserAction="NO" id="51c-Ut-dBs">
<webView userInteractionEnabled="NO" contentMode="scaleAspectFit" allowsInlineMediaPlayback="NO" mediaPlaybackRequiresUserAction="NO" mediaPlaybackAllowsAirPlay="NO" keyboardDisplayRequiresUserAction="NO" id="51c-Ut-dBs">
<rect key="frame" x="0.0" y="0.0" width="300" height="300"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
Expand Down
4 changes: 4 additions & 0 deletions pinpoint2/PPAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ @implementation PPAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Ignores the Unused expression result errors.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-value"
[[PPJobCardProvider alloc] initWithCardService:[PPCardService sharedInstance]];
[[PPWorkingFuturesCardProvider alloc] initWithCardService:[PPCardService sharedInstance]];
[[PPUnemploymentCardProvider alloc] initWithCardService:[PPCardService sharedInstance]];
[[PPPayRegionCardProvider alloc] initWithCardService:[PPCardService sharedInstance]];
#pragma clang diagnostic pop
[[UINavigationBar appearance] setBackgroundColor:[UIColor orangeColor]];

[[NSUserDefaults standardUserDefaults] removePersistentDomainForName:[NSBundle mainBundle].bundleIdentifier];
Expand Down
3 changes: 3 additions & 0 deletions pinpoint2/PPCard.m
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,7 @@ - (bool)cardCanBeOutOfDate {
return NO;
}

- (void)handleLike {}
- (void)handleDislike {}

@end
9 changes: 5 additions & 4 deletions pinpoint2/PPCardCollectionViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ - (void)panGestureRecognizerDidChange:(UIPanGestureRecognizer *)panGestureRecogn
CGAffineTransform transform = CGAffineTransformConcat(moveTransform, rotateTransform) ;

// Apply the transformation to the content view
[[self contentView] setTransform:transform];
[self setTransform:transform];

break;
}
Expand Down Expand Up @@ -117,7 +117,7 @@ - (void)panGestureRecognizerDidChange:(UIPanGestureRecognizer *)panGestureRecogn
// Animate the 'throwing away' of the cell and update the collection view once it's completed
[UIView animateWithDuration:duration
animations:^(){
[[self contentView] setTransform:transform];
[self setTransform:transform];
}
completion:^(BOOL finished){
[self setDeleted:YES];
Expand All @@ -130,15 +130,16 @@ - (void)panGestureRecognizerDidChange:(UIPanGestureRecognizer *)panGestureRecogn

} else {
// The cell shouldn't be deleted: animate the content view back to its original position
[UIView animateWithDuration:1.f animations:^(){
[[self contentView] setTransform:CGAffineTransformIdentity];
[UIView animateWithDuration:.3f animations:^(){
[self setTransform:CGAffineTransformIdentity];
}];
}

break;
}

default: {
NSLog(@"Other case: %ld",[panGestureRecognizer state]);
break;
}
}
Expand Down
6 changes: 3 additions & 3 deletions pinpoint2/PPCardCollectionViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ - (void)cardWasSwipedRight:(PPCardCollectionViewCell *)cardCell {

- (void)getCardsFromCardServiceIfTheresNotEnough {
if (self.cards.count < MIN_NUM_CARDS) {
[self getCardsFromCardService:(MIN_NUM_CARDS - self.cards.count)];
[self getCardsFromCardService:(MIN_NUM_CARDS - (int)self.cards.count)];
}
}

- (void)getCardsFromCardService:(int)numOfCards {
int oldNumOfCards = self.cards.count;
int oldNumOfCards = (int)self.cards.count;
[self.cards addObjectsFromArray:[self.cardService getNumberOfCards:numOfCards]];
int newNumOfCards = self.cards.count;
int newNumOfCards = (int)self.cards.count;
[self.collectionView insertItemsAtIndexPaths:[self getIndexPathsOfNewlyInsertedCardsFromOldNumberOfCards:oldNumOfCards andNewNumOfCards:newNumOfCards]];
if (self.cards.count >= MIN_NUM_CARDS) {
[getCardsTimer invalidate];
Expand Down
7 changes: 5 additions & 2 deletions pinpoint2/PPCardProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,16 @@ - (NSString *)getUnusedSocCodeFromArrayOfPossibles:(NSArray *)socCodes usingNSDe
if (mutableSocCodes.count == 0) {
return nil;
}
NSString *socCode = mutableSocCodes[arc4random_uniform(mutableSocCodes.count)];
NSString *socCode = mutableSocCodes[arc4random_uniform((uint)mutableSocCodes.count)];
NSMutableArray *mutableUsedCodes = [usedCodes mutableCopy];
[mutableUsedCodes addObject:socCode];
[[NSUserDefaults standardUserDefaults] setObject:mutableUsedCodes forKey:keyForUsedCodes];
return socCode;
}


- (PPCard*)provideCardFromUserPreferences:(PPUserPreferences *)userPreferences{
NSAssert(NO, @"This should never be called. You should implement the method provideCardFromUserPreferences: in your subclass.");
return nil;
}

@end
6 changes: 3 additions & 3 deletions pinpoint2/PPCardService.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ - (void)getCardsFromProviders {
for (id<PPCardProviderInterface> cardProvider in cardProviders) {
PPCard *card = [cardProvider provideCardFromUserPreferences:[[PPUserPreferencesStore sharedInstance] getCurrentUserPreferences]];
if ([[card isFinished] boolValue] && ![cardsFinished containsObject:card]) {
[cardsFinished insertObject:card atIndex:arc4random_uniform(cardsFinished.count)];
[cardsFinished insertObject:card atIndex:arc4random_uniform((uint)cardsFinished.count)];
} else if (card) {
[cardsUnfinished addObject:card];
[card addObserver:self forKeyPath:NSStringFromSelector(@selector(isFinished)) options:0 context:NULL];
Expand All @@ -57,7 +57,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
if ([object isKindOfClass:[PPCard class]]) {
if ([keyPath isEqualToString:NSStringFromSelector(@selector(isFinished))]) {
if (![cardsFinished containsObject:object]) {
[cardsFinished insertObject:object atIndex:arc4random_uniform(cardsFinished.count)];
[cardsFinished insertObject:object atIndex:arc4random_uniform((uint)cardsFinished.count)];
}
[cardsUnfinished removeObject:object];
[object removeObserver:self forKeyPath:NSStringFromSelector(@selector(isFinished))];
Expand All @@ -70,7 +70,7 @@ - (bool)userPreferencesAreDifferentToCard:(PPCard *)card {
}

- (bool)weHaveEnoughFinishedCards {
NSLog(@"number of cards ready to go: %d", cardsFinished.count);
NSLog(@"number of cards ready to go: %d", (uint)cardsFinished.count);
return cardsFinished.count > 4;
}

Expand Down
8 changes: 4 additions & 4 deletions pinpoint2/PPCollectionViewFlowLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
}
}
//NSLog(@"%d %d", newAttributes.count, attributes.count);
NSArray *attrsList = [super layoutAttributesForElementsInRect:rect];
// NSArray *attrsList = [super layoutAttributesForElementsInRect:rect];

for (UICollectionViewLayoutAttributes *attrs in attrsList) {
//NSLog(@"%f %f", attrs.frame.origin.x, attrs.frame.origin.y);
}
// for (UICollectionViewLayoutAttributes *attrs in attrsList) {
// NSLog(@"%f %f", attrs.frame.origin.x, attrs.frame.origin.y);
// }
return newAttributes;
}

Expand Down
8 changes: 4 additions & 4 deletions pinpoint2/PPJobCardProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
#import "PPJobCardProvider.h"
#import "PPJobCard.h"

int socs[369]={1115,1116,1121,1122,1123,1131,1132,1133,1134,1135,1136,1139,1150,1161,1162,1171,1172,1173,1181,1184,1190,1211,1213,1221,1223,1224,1225,1226,1241,1242,1251,1252,1253,1254,1255,1259,2111,2112,2113,2114,2119,2121,2122,2123,2124,2126,2127,2129,2133,2134,2135,2136,2137,2139,2141,2142,2150,2211,2212,2213,2214,2215,2216,2217,2218,2219,2221,2222,2223,2229,2231,2232,2311,2312,2314,2315,2316,2317,2318,2319,2412,2413,2419,2421,2423,2424,2425,2426,2429,2431,2432,2433,2434,2435,2436,2442,2443,2444,2449,2451,2452,2461,2462,2463,2471,2472,2473,3111,3112,3113,3114,3115,3116,3119,3121,3122,3131,3132,3213,3216,3217,3218,3219,3231,3233,3234,3235,3239,3311,3312,3313,3314,3315,3319,3411,3412,3413,3414,3415,3416,3417,3421,3422,3441,3442,3443,3511,3512,3513,3520,3531,3532,3533,3534,3535,3536,3537,3538,3539,3541,3542,3543,3544,3545,3546,3550,3561,3562,3563,3564,3565,3567,4112,4113,4114,4121,4122,4123,4124,4129,4131,4132,4133,4134,4135,4138,4151,4159,4161,4162,4211,4212,4213,4214,4215,4216,4217,5111,5112,5113,5114,5119,5211,5212,5213,5214,5215,5216,5221,5222,5223,5224,5225,5231,5232,5234,5235,5236,5237,5241,5242,5244,5245,5249,5250,5311,5312,5313,5314,5315,5316,5319,5321,5322,5323,5330,5411,5412,5413,5414,5419,5421,5422,5423,5431,5432,5433,5434,5435,5436,5441,5442,5443,5449,6121,6122,6123,6125,6126,6131,6132,6139,6141,6142,6143,6144,6145,6146,6147,6148,6211,6212,6214,6215,6219,6221,6222,6231,6232,6240,7111,7112,7113,7114,7115,7121,7122,7123,7124,7125,7129,7130,7211,7213,7214,7215,7219,7220,8111,8112,8113,8114,8115,8116,8117,8118,8119,8121,8122,8123,8124,8125,8126,8127,8129,8131,8132,8133,8134,8135,8137,8139,8141,8142,8143,8149,8211,8212,8213,8214,8215,8221,8222,8223,8229,8231,8232,8233,8234,8239,9111,9112,9119,9120,9132,9134,9139,9211,9219,9231,9232,9233,9234,9235,9236,9239,9241,9242,9244,9249,9251,9259,9260,9271,9272,9273,9274,9275,9279};
int validSOCs[]={1115,1116,1121,1122,1123,1131,1132,1133,1134,1135,1136,1139,1150,1161,1162,1171,1172,1173,1181,1184,1190,1211,1213,1221,1223,1224,1225,1226,1241,1242,1251,1252,1253,1254,1255,1259,2111,2112,2113,2114,2119,2121,2122,2123,2124,2126,2127,2129,2133,2134,2135,2136,2137,2139,2141,2142,2150,2211,2212,2213,2214,2215,2216,2217,2218,2219,2221,2222,2223,2229,2231,2232,2311,2312,2314,2315,2316,2317,2318,2319,2412,2413,2419,2421,2423,2424,2425,2426,2429,2431,2432,2433,2434,2435,2436,2442,2443,2444,2449,2451,2452,2461,2462,2463,2471,2472,2473,3111,3112,3113,3114,3115,3116,3119,3121,3122,3131,3132,3213,3216,3217,3218,3219,3231,3233,3234,3235,3239,3311,3312,3313,3314,3315,3319,3411,3412,3413,3414,3415,3416,3417,3421,3422,3441,3442,3443,3511,3512,3513,3520,3531,3532,3533,3534,3535,3536,3537,3538,3539,3541,3542,3543,3544,3545,3546,3550,3561,3562,3563,3564,3565,3567,4112,4113,4114,4121,4122,4123,4124,4129,4131,4132,4133,4134,4135,4138,4151,4159,4161,4162,4211,4212,4213,4214,4215,4216,4217,5111,5112,5113,5114,5119,5211,5212,5213,5214,5215,5216,5221,5222,5223,5224,5225,5231,5232,5234,5235,5236,5237,5241,5242,5244,5245,5249,5250,5311,5312,5313,5314,5315,5316,5319,5321,5322,5323,5330,5411,5412,5413,5414,5419,5421,5422,5423,5431,5432,5433,5434,5435,5436,5441,5442,5443,5449,6121,6122,6123,6125,6126,6131,6132,6139,6141,6142,6143,6144,6145,6146,6147,6148,6211,6212,6214,6215,6219,6221,6222,6231,6232,6240,7111,7112,7113,7114,7115,7121,7122,7123,7124,7125,7129,7130,7211,7213,7214,7215,7219,7220,8111,8112,8113,8114,8115,8116,8117,8118,8119,8121,8122,8123,8124,8125,8126,8127,8129,8131,8132,8133,8134,8135,8137,8139,8141,8142,8143,8149,8211,8212,8213,8214,8215,8221,8222,8223,8229,8231,8232,8233,8234,8239,9111,9112,9119,9120,9132,9134,9139,9211,9219,9231,9232,9233,9234,9235,9236,9239,9241,9242,9244,9249,9251,9259,9260,9271,9272,9273,9274,9275,9279};

@implementation PPJobCardProvider

- (PPCard *)provideCardFromUserPreferences:(PPUserPreferences *)userPreferences {
if (!userPreferences.jobKeywords) {
return [self provideRandomJobCardAttachedToUserPreferences:userPreferences];
}
NSString *jobKeyword = userPreferences.jobKeywords[arc4random_uniform(userPreferences.jobKeywords.count)];
NSString *jobKeyword = userPreferences.jobKeywords[arc4random_uniform((uint)userPreferences.jobKeywords.count)];
PPJobCard *card = [[PPJobCard alloc] initWithUserPreferences:userPreferences];
[apiClient GET:@"soc/search" parameters:@{@"q":jobKeyword} success:^(AFHTTPRequestOperation *operation, id responseObject){
NSDictionary *socDetails = (NSDictionary *)responseObject[arc4random_uniform(((NSArray *)responseObject).count)];
NSDictionary *socDetails = (NSDictionary *)responseObject[arc4random_uniform((uint)((NSArray *)responseObject).count)];
[card addDataToCard:socDetails];
[card setCardAsFinishedIfDataIsAllPresentAndRenderTheHtml];
[card setCardType:PPCardTypeJob];
Expand All @@ -32,7 +32,7 @@ - (PPCard *)provideCardFromUserPreferences:(PPUserPreferences *)userPreferences

- (PPCard *)provideRandomJobCardAttachedToUserPreferences:(PPUserPreferences *)userPreferences {
PPJobCard *card = [[PPJobCard alloc] initWithUserPreferences:userPreferences];
[apiClient GET:[NSString stringWithFormat:@"soc/code/%d", socs[arc4random_uniform(369)]] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject){
[apiClient GET:[NSString stringWithFormat:@"soc/code/%d", validSOCs[arc4random_uniform(369)]] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject){
NSDictionary *socDetails = (NSDictionary *)responseObject;
[card addDataToCard:socDetails];
[card setCardAsFinishedIfDataIsAllPresentAndRenderTheHtml];
Expand Down
2 changes: 1 addition & 1 deletion pinpoint2/PPPayRegionCardProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ - (NSString *)getRegionNameFromCode:(int)code {
}

- (NSString *)getAnnualPayFromWeeklyPay:(NSString *)weeklyPayString {
int weeklyPay = [weeklyPayString integerValue];
int weeklyPay = (int)[weeklyPayString integerValue];
int annualPay = weeklyPay*52;
return [NSString stringWithFormat:@"%d", annualPay];
}
Expand Down
4 changes: 4 additions & 0 deletions pinpoint2/PPUserPreferencesStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,8 @@ + (instancetype)sharedInstance {
return sharedInstance;
}

- (NSArray*)getArrayOfKeywordsAndPointsOrderedByPoints{
return nil;
}

@end

0 comments on commit 386be35

Please sign in to comment.