mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-28 06:47:15 +00:00
Added SVProgressHUD for progress visualization
This commit is contained in:
1 parent
f7cf1e08a9
commit
2b0c2085c7
4 files changed
+36
-23
No files matched your search
@@ -34,6 +34,7 @@ class CheckInController : NSObject {
|
||||
// MARK: - Start check-in
|
||||
|
||||
func startCheckIn() {
|
||||
self.delegate.checkInDidStart(self)
|
||||
self.checkInRequestManager.getEvent(checkInData.eventID,
|
||||
success: { (operation, responseObject) -> Void in self.eventSucceed(responseObject) },
|
||||
failure: { (operation, error) -> Void in self.eventFailed(error) })
|
||||
@@ -43,7 +44,7 @@ class CheckInController : NSObject {
|
||||
|
||||
private func eventSucceed(eventResponseObject: AnyObject) {
|
||||
self.checkInData.eventDictionary = eventResponseObject as? [String: AnyObject]
|
||||
self.checkInRequestManager.getLeaderboard(checkInData!.leaderboardName,
|
||||
self.checkInRequestManager.getLeaderboard(checkInData.leaderboardName,
|
||||
success: { (operation, responseObject) -> Void in self.leaderboardSucceed(responseObject) },
|
||||
failure: { (operation, error) -> Void in self.leaderboardFailed(error) })
|
||||
}
|
||||
@@ -58,7 +59,7 @@ class CheckInController : NSObject {
|
||||
self.checkInDidEnd(withSuccess: false)
|
||||
}
|
||||
alertController.addAction(cancelAction)
|
||||
self.delegate.showCheckInAlert(self, alertController: alertController)
|
||||
self.showCheckInAlert(alertController)
|
||||
}
|
||||
|
||||
// MARK: - Leaderboard
|
||||
@@ -80,7 +81,7 @@ class CheckInController : NSObject {
|
||||
self.checkInDidEnd(withSuccess: false)
|
||||
}
|
||||
alertController.addAction(cancelAction)
|
||||
self.delegate.showCheckInAlert(self, alertController: alertController)
|
||||
self.showCheckInAlert(alertController)
|
||||
}
|
||||
|
||||
// MARK: - Competitor
|
||||
@@ -101,7 +102,7 @@ class CheckInController : NSObject {
|
||||
self.checkInDidEnd(withSuccess: false)
|
||||
}
|
||||
alertController.addAction(cancelAction)
|
||||
self.delegate.showCheckInAlert(self, alertController: alertController)
|
||||
self.showCheckInAlert(alertController)
|
||||
}
|
||||
|
||||
// MARK: - Team
|
||||
@@ -125,12 +126,13 @@ class CheckInController : NSObject {
|
||||
self.checkInOnServer()
|
||||
}
|
||||
alertController.addAction(okAction)
|
||||
self.delegate.showCheckInAlert(self, alertController: alertController)
|
||||
self.showCheckInAlert(alertController)
|
||||
}
|
||||
|
||||
// MARK: - Check-in on server
|
||||
|
||||
private func checkInOnServer() {
|
||||
SVProgressHUD.show()
|
||||
checkInRequestManager.checkIn(checkInData.dictionaryLeaderboardName(),
|
||||
competitorID: checkInData!.dictionaryCompetitorId(),
|
||||
deviceUUID: DeviceUDIDManager.UDID,
|
||||
@@ -183,19 +185,28 @@ class CheckInController : NSObject {
|
||||
self.checkInDidEnd(withSuccess: false)
|
||||
}
|
||||
alertController.addAction(cancelAction)
|
||||
self.delegate.showCheckInAlert(self, alertController: alertController)
|
||||
self.showCheckInAlert(alertController)
|
||||
}
|
||||
|
||||
// MARK: - Controller
|
||||
|
||||
private func checkInDidStart() {
|
||||
UIApplication.sharedApplication().beginIgnoringInteractionEvents()
|
||||
delegate.checkInDidStart(self)
|
||||
SVProgressHUD.show()
|
||||
self.delegate.checkInDidStart(self)
|
||||
}
|
||||
|
||||
private func checkInDidEnd(withSuccess succeed: Bool) {
|
||||
UIApplication.sharedApplication().endIgnoringInteractionEvents()
|
||||
delegate.checkInDidEnd(self, withSuccess: succeed)
|
||||
SVProgressHUD.popActivity()
|
||||
self.delegate.checkInDidEnd(self, withSuccess: succeed)
|
||||
}
|
||||
|
||||
private func showCheckInAlert(alertController: UIAlertController) {
|
||||
SVProgressHUD.popActivity()
|
||||
self.delegate.showCheckInAlert(self, alertController: alertController)
|
||||
}
|
||||
|
||||
private func checkInAlertDismissed() {
|
||||
SVProgressHUD.show()
|
||||
}
|
||||
|
||||
// MARK: - Helper
|
||||
|
||||
@@ -41,29 +41,33 @@ class CheckInRequestManager: NSObject {
|
||||
|
||||
// MARK: - Event
|
||||
|
||||
func getEvent(eventId: String!, success: (AFHTTPRequestOperation!, AnyObject!) -> Void, failure: (AFHTTPRequestOperation!, AnyObject!) -> Void) {
|
||||
let urlString = "\(baseURLString)/events/\(eventId)"
|
||||
func getEvent(eventID: String!, success: (AFHTTPRequestOperation!, AnyObject!) -> Void, failure: (AFHTTPRequestOperation!, AnyObject!) -> Void) {
|
||||
let encodedEventID = eventID.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLPathAllowedCharacterSet()) ?? ""
|
||||
let urlString = "\(baseURLString)/events/\(encodedEventID)"
|
||||
manager.GET(urlString, parameters: nil, success: success, failure: failure)
|
||||
}
|
||||
|
||||
// MARK: - Leaderboard
|
||||
|
||||
func getLeaderboard(leaderboardName: String!, success: (AFHTTPRequestOperation!, AnyObject!) -> Void, failure: (AFHTTPRequestOperation!, AnyObject!) -> Void) {
|
||||
let urlString = "\(baseURLString)/leaderboards/\(leaderboardName.stringByAddingPercentEncodingWithAllowedCharacters(_:))"
|
||||
let encodedLeaderboardName = leaderboardName.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLPathAllowedCharacterSet()) ?? ""
|
||||
let urlString = "\(baseURLString)/leaderboards/\(encodedLeaderboardName)"
|
||||
manager!.GET(urlString, parameters: nil, success: success, failure: failure)
|
||||
}
|
||||
|
||||
// MARK: - Competitor
|
||||
|
||||
func getCompetitor(competitorId: String!, success: (AFHTTPRequestOperation!, AnyObject!) -> Void, failure: (AFHTTPRequestOperation!, AnyObject!) -> Void) {
|
||||
let urlString = "\(baseURLString)/competitors/\(competitorId)"
|
||||
func getCompetitor(competitorID: String!, success: (AFHTTPRequestOperation!, AnyObject!) -> Void, failure: (AFHTTPRequestOperation!, AnyObject!) -> Void) {
|
||||
let encodedCompetitorID = competitorID.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLPathAllowedCharacterSet())
|
||||
let urlString = "\(baseURLString)/competitors/\(encodedCompetitorID)"
|
||||
manager!.GET(urlString, parameters: nil, success: success, failure: failure)
|
||||
}
|
||||
|
||||
// MARK: - Team
|
||||
|
||||
func getTeam(competitorId: String!, success: (AFHTTPRequestOperation!, AnyObject!) -> Void, failure: (AFHTTPRequestOperation!, AnyObject!) -> Void) {
|
||||
let urlString = "\(baseURLString)/competitors/\(competitorId)/team"
|
||||
func getTeam(competitorID: String!, success: (AFHTTPRequestOperation!, AnyObject!) -> Void, failure: (AFHTTPRequestOperation!, AnyObject!) -> Void) {
|
||||
let encodedCompetitorID = competitorID.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLPathAllowedCharacterSet())
|
||||
let urlString = "\(baseURLString)/competitors/\(encodedCompetitorID)/team"
|
||||
manager!.GET(urlString, parameters: nil, success: success, failure: failure)
|
||||
}
|
||||
|
||||
|
||||
@@ -16,18 +16,15 @@ class CheckInViewController: UIViewController, CheckInControllerDelegate {
|
||||
}
|
||||
|
||||
func checkInDidStart(checkInController: CheckInController) {
|
||||
UIApplication.sharedApplication().beginIgnoringInteractionEvents()
|
||||
|
||||
}
|
||||
|
||||
func checkInDidEnd(checkInController: CheckInController, withSuccess succeed: Bool) {
|
||||
UIApplication.sharedApplication().endIgnoringInteractionEvents()
|
||||
|
||||
}
|
||||
|
||||
func showCheckInAlert(checkInController: CheckInController, alertController: UIAlertController) {
|
||||
UIApplication.sharedApplication().endIgnoringInteractionEvents()
|
||||
self.presentViewController(alertController, animated: true) {
|
||||
UIApplication.sharedApplication().beginIgnoringInteractionEvents()
|
||||
}
|
||||
self.presentViewController(alertController, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#import <AFNetworking/AFNetworking.h>
|
||||
#import <TSMarkdownParser/TSMarkdownParser.h>
|
||||
#import <SVProgressHUD/SVProgressHUD.h>
|
||||
#import "UIImageView+AFNetworking.h"
|
||||
#import "Appearance.h"
|
||||
|
||||
|
||||
Reference in new issue
Block a user