Skip to content

Commit

Permalink
See #30. Show “Loading…” for fields until initial load has completed.
Browse files Browse the repository at this point in the history
Removed all console logging to speed up app performance.
  • Loading branch information
Glavin001 committed Aug 22, 2014
1 parent c713bbe commit 63f70b7
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ pod "Streamlyne-Cocoa-SDK", :git => '[email protected]:Streamlyne/Cocoa-SDK.git'
pod 'PKRevealController'
pod 'MBProgressHUD', '~> 0.8'
# Misc
pod 'PromiseKit', '<= 0.9.14'
pod 'CocoaLumberjack'
pod 'PromiseKit'
pod 'ReactiveCocoa'
pod 'TestFlightSDK'
pod 'FontAwesomeIconFactory'
Expand Down
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ DEPENDENCIES:
- FontAwesomeIconFactory
- MBProgressHUD (~> 0.8)
- PKRevealController
- PromiseKit
- PromiseKit (<= 0.9.14)
- ReactiveCocoa
- Streamlyne-Cocoa-SDK (from `[email protected]:Streamlyne/Cocoa-SDK.git`)
- TestFlightSDK
Expand Down
34 changes: 22 additions & 12 deletions Streamlyne/Controllers/SLMetricsSheetViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,28 @@ - (void)didReceiveMemoryWarning

- (void) handleRefresh:(UIRefreshControl *)refreshControl
{
// Request
[self.refreshControl beginRefreshing];
[self.attributeCollection reloadRecord]
//[SLAttributeCollection findById:attributeCollection.nid]
.then(^(SLAttributeCollection *record) {
NSLog(@"attributeCollection: %@", record);
self.attributeCollection = record;
[self.tableView reloadData];
[self.refreshControl endRefreshing];
})
.catch(^(NSError *error) {
DDLogInfo(@"Error: %@", error);
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){

// Request
[self.refreshControl beginRefreshing];
[self.attributeCollection reloadRecord]
//[SLAttributeCollection findById:attributeCollection.nid]
.then(^(SLAttributeCollection *record) {
NSLog(@"attributeCollection: %@", record);
self.attributeCollection = record;
[self.tableView reloadData];
[self.refreshControl endRefreshing];
})
.catch(^(NSError *error) {
DDLogInfo(@"Error: %@", error);
});


//Background Thread
dispatch_async(dispatch_get_main_queue(), ^(void){
//Run UI Updates
});

});
}

Expand Down
6 changes: 3 additions & 3 deletions Streamlyne/Storyboards/iPad/Metrics_iPad.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@
<rect key="frame" x="0.0" y="0.0" width="768" height="99"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" misplaced="YES" text="Asset Name" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VZ4-R8-zOf">
<rect key="frame" x="20" y="15" width="235" height="21"/>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" misplaced="YES" text="Loading Asset Name..." lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VZ4-R8-zOf">
<rect key="frame" x="20" y="20" width="235" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="17"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Assset description.." lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="235" translatesAutoresizingMaskIntoConstraints="NO" id="YXA-fB-Nk3">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Loading Assset description.." lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="235" translatesAutoresizingMaskIntoConstraints="NO" id="YXA-fB-Nk3">
<rect key="frame" x="20" y="39" width="235" height="48"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="15"/>
Expand Down
9 changes: 5 additions & 4 deletions Streamlyne/Storyboards/iPad/en.lproj/Main_iPad.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<color key="textColor" red="0.94205659643644557" green="0.98907773363968832" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vvF-BP-dBU">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vvF-BP-dBU">
<rect key="frame" x="265" y="754" width="238" height="66"/>
<color key="backgroundColor" red="0.38823533058166504" green="0.74117648601531982" blue="0.82745105028152466" alpha="1" colorSpace="deviceRGB"/>
<constraints>
Expand All @@ -47,7 +47,7 @@
<action selector="loginBtnPressed:" destination="JR7-An-Jel" eventType="touchUpInside" id="Xkg-0o-shn"/>
</connections>
</button>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Email" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="AcL-9i-d85">
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="[email protected]" placeholder="Email" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="AcL-9i-d85">
<rect key="frame" x="159" y="489" width="451" height="69"/>
<color key="backgroundColor" red="0.1098039299249649" green="0.21960785984992981" blue="0.24313727021217346" alpha="1" colorSpace="deviceRGB"/>
<constraints>
Expand All @@ -58,7 +58,7 @@
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="22"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" keyboardType="emailAddress" returnKeyType="next"/>
</textField>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Password" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="EKL-aX-RSr">
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="streamlyne" placeholder="Password" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="EKL-aX-RSr">
<rect key="frame" x="159" y="583" width="451" height="69"/>
<color key="backgroundColor" red="0.1098039299" green="0.2196078598" blue="0.24313727020000001" alpha="1" colorSpace="deviceRGB"/>
<constraints>
Expand All @@ -68,7 +68,7 @@
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="22"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" returnKeyType="next" secureTextEntry="YES"/>
</textField>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Organization" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="pGv-0w-M5f">
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="nevis" placeholder="Organization" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="pGv-0w-M5f">
<rect key="frame" x="159" y="668" width="451" height="69"/>
<color key="backgroundColor" red="0.1098039299" green="0.2196078598" blue="0.24313727020000001" alpha="1" colorSpace="deviceRGB"/>
<constraints>
Expand All @@ -92,6 +92,7 @@
<constraint firstItem="pGv-0w-M5f" firstAttribute="leading" secondItem="EKL-aX-RSr" secondAttribute="leading" id="3S4-YR-GUW"/>
<constraint firstItem="AcL-9i-d85" firstAttribute="leading" secondItem="EKL-aX-RSr" secondAttribute="leading" id="8zy-TN-Imc"/>
<constraint firstItem="pGv-0w-M5f" firstAttribute="trailing" secondItem="EKL-aX-RSr" secondAttribute="trailing" id="FtD-EN-TMt"/>
<constraint firstItem="EKL-aX-RSr" firstAttribute="centerX" secondItem="AN6-HC-XFm" secondAttribute="centerX" id="N5r-mW-fwI"/>
<constraint firstItem="2a9-im-Juc" firstAttribute="leading" secondItem="lZ1-cy-6BG" secondAttribute="trailing" constant="8" id="Yz3-C5-i8d"/>
<constraint firstItem="2a9-im-Juc" firstAttribute="top" secondItem="Pbe-mH-bBd" secondAttribute="bottom" constant="234" id="ZPS-h7-Y2x"/>
<constraint firstItem="lZ1-cy-6BG" firstAttribute="top" secondItem="Pbe-mH-bBd" secondAttribute="bottom" constant="238" id="eXw-Oi-OnY"/>
Expand Down
19 changes: 11 additions & 8 deletions Streamlyne/Supporting Files/Streamlyne-Prefix.pch
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@
#import <CoreData/CoreData.h>

// Lumberjack Logger
#import <CocoaLumberjack/CocoaLumberjack.h>

#endif

#import <CocoaLumberjack/CocoaLumberjack.h>
#ifdef DEBUG
//static int ddLogLevel = LOG_LEVEL_VERBOSE;
#else
//static int ddLogLevel = LOG_LEVEL_ERROR;
#endif
static int ddLogLevel = LOG_LEVEL_ERROR;

#ifdef DEBUG
static int ddLogLevel = LOG_LEVEL_VERBOSE;
#else
static int ddLogLevel = LOG_LEVEL_ERROR;
#endif

#import <Streamlyne-Cocoa-SDK/StreamlyneSDK.h>
#import <ReactiveCocoa/ReactiveCocoa/ReactiveCocoa.h>
#import <ReactiveCocoa/ReactiveCocoa/ReactiveCocoa.h>

// Disable NSLog
#define NSLog(...);
38 changes: 36 additions & 2 deletions Streamlyne/TableViewCells/SLAttributeDataInputViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ - (void) setAttribute:(SLAttribute *)attribute
_attribute = attribute;
NSLog(@"Set Attribute: %@", attribute);

// Reset UI
self.assetNameLabel.text = @"Loading Asset Name...";
if (self.assetDescriptionLabel != nil)
{
self.assetDescriptionLabel.text = @"Loading Asset Description...";
}
self.attributeNameLabel.text = @"Loading Attribute Name...";
if (self.attributeDescriptionLabel != nil)
{
self.attributeDescriptionLabel.text = @"Loading Attribute Description...";
}


// Bind to new attribute
if (self.attributeDescriptionLabel != nil)
{
Expand All @@ -61,6 +74,12 @@ - (void) setAttribute:(SLAttribute *)attribute
self.attributeDescriptionLabel.text = description;
}];
}
[RACObserve(self.attribute, humanName) subscribeNext:^(NSString *humanName)
{
NSLog(@"Attribute humanName: %@", humanName);
// self.attributeNameLabel.text = humanName;
}];

[RACObserve(self.attribute, name) subscribeNext:^(NSString *name)
{
NSLog(@"Name: %@", name);
Expand All @@ -69,12 +88,18 @@ - (void) setAttribute:(SLAttribute *)attribute

attribute.asset.then(^(SLAsset *asset) {
DDLogInfo(@"Attribute's Asset: %@", asset);
[RACObserve(asset, humanName) subscribeNext:^(NSString *assetName)

[RACObserve(asset, name) subscribeNext:^(NSString *assetName)
{
NSLog(@"assetName: %@", assetName);
self.assetNameLabel.text = assetName;
}];

[RACObserve(asset, humanName) subscribeNext:^(NSString *assetHumanName)
{
NSLog(@"assetHumanName: %@", assetHumanName);
// self.assetNameLabel.text = assetHumanName;
}];

if (self.assetDescriptionLabel != nil)
{
Expand All @@ -85,6 +110,15 @@ - (void) setAttribute:(SLAttribute *)attribute
}];
}
});


dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){
//Background Thread

dispatch_async(dispatch_get_main_queue(), ^(void){
//Run UI Updates
});
});

}

Expand Down

0 comments on commit 63f70b7

Please sign in to comment.