Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Removing UIKit to prepare the way to support OS X with this library #36

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions DeskAPIClient/DeskAPIClient/DSAPINetworkIndicatorController.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
// POSSIBILITY OF SUCH DAMAGE.
//

#import <Foundation/Foundation.h>
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#endif

@interface DSAPINetworkIndicatorController : NSObject

Expand Down
15 changes: 14 additions & 1 deletion DeskAPIClient/DeskAPIClient/DSAPINetworkIndicatorController.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,28 @@ - (instancetype)init

- (void)networkActivityDidStart
{
#if TARGET_OS_IPHONE
NSAssert([NSThread isMainThread], @"Altering network activity indicator state can only be done on the main thread.");
self.activityCount++;
[self updateIndicatorVisibility];
#endif
}

- (void)networkActivityDidEnd
{
#if TARGET_OS_IPHONE
NSAssert([NSThread isMainThread], @"Altering network activity indicator state can only be done on the main thread.");
NSAssert(self.activityCount > 0, @"networkActivityDidEnd before matching networkActivityDidStart");
self.activityCount--;
[self updateIndicatorVisibility];
#endif
}

#pragma mark - Private

- (void)updateIndicatorVisibility
{
#if TARGET_OS_IPHONE
if (self.activityCount > 0) {
[self showIndicator];
} else {
Expand All @@ -92,31 +96,40 @@ - (void)updateIndicatorVisibility
*/
[self createTimerToHideIndicator];
}
#endif
}

- (void)createTimerToHideIndicator
{
#if TARGET_OS_IPHONE
self.timer = [NSTimer scheduledTimerWithTimeInterval:0.75 target:self selector:@selector(timerFireMethod:) userInfo:nil repeats:NO];
self.timer.tolerance = 0.5;
#endif
}

- (void)timerFireMethod:(NSTimer *)timer
{
#if TARGET_OS_IPHONE
[self hideIndicator];
#endif
}

- (void)showIndicator
{
#if TARGET_OS_IPHONE
[self.timer invalidate];
self.timer = nil;
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
#endif
}

- (void)hideIndicator
{
#if TARGET_OS_IPHONE
[self.timer invalidate];
self.timer = nil;
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
#endif
}


Expand Down
2 changes: 1 addition & 1 deletion DeskAPIClient/DeskAPIClientTests/DSAPIBrandTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
// POSSIBILITY OF SUCH DAMAGE.
//

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "DSAPITestCase.h"

@interface DSAPIBrandTests : DSAPITestCase
Expand Down
2 changes: 1 addition & 1 deletion DeskAPIClient/DeskAPIClientTests/DSAPIListProviderTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
// POSSIBILITY OF SUCH DAMAGE.
//

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <XCTest/XCTest.h>
#import "DSAPIResource+Testing.h"
#import "DSAPIListProvider.h"
Expand Down
2 changes: 1 addition & 1 deletion DeskAPIClient/DeskAPIClientTests/DSAPIPermissionTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright (c) 2015 Desk.com. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "DSAPITestCase.h"
#import "DSAPIETagCache.h"

Expand Down
2 changes: 1 addition & 1 deletion DeskAPIClient/DeskAPIClientTests/DSAPISiteTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
// POSSIBILITY OF SUCH DAMAGE.
//

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "DSAPITestCase.h"

@interface DSAPISiteTests : DSAPITestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//

#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#define EXP_SHORTHAND YES
#import "Expecta.h"
Expand Down