This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // call Google Places Autocomplete | |
| try { | |
| AutocompleteFilter autocompleteFilter = new AutocompleteFilter.Builder() | |
| .setTypeFilter(Place.TYPE_COUNTRY) | |
| .setCountry("GH") | |
| .build(); | |
| Intent intent = | |
| new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY) | |
| .setFilter(autocompleteFilter) | |
| .build(AddressActivity.this); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var orientationLock = UIInterfaceOrientationMask.portrait | |
| func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { | |
| return self.orientationLock | |
| } | |
| struct AppUtility { | |
| static func lockOrientation(_ orientation: UIInterfaceOrientationMask) { | |
| if let delegate = UIApplication.shared.delegate as? AppDelegate { | |
| delegate.orientationLock = orientation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| class FirstFruitsViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import Alamofire | |
| public class APIManager { | |
| private let manager: Session | |
| init(manager: Session = Session.default) { | |
| self.manager = manager |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Observable<T> { | |
| var value: T { | |
| didSet { | |
| listener?(value) | |
| } | |
| } | |
| private var listener: ((T) -> Void)? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import Alamofire | |
| protocol ObservableViewModelProtocol { | |
| func fetchEmployees() | |
| func setError(_ message: String) | |
| var employees: Observable<[Employee]> { get set } //1 | |
| var errorMessage: Observable<String?> { get set } | |
| var error: Observable<Bool> { get set } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| open class EventBus { | |
| struct Static { | |
| static let instance = EventBus() | |
| static let queue = DispatchQueue(label: "EventBus", attributes: []) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| class EmployeesEvent: NSObject { | |
| var error: Bool | |
| var errorMessage: String? | |
| var employees: [Employee]? | |
| init(error: Bool, errorMessage: String? = nil, employees: [Employee]? = nil) { | |
| self.error = error | |
| self.errorMessage = errorMessage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func callEvent() { | |
| //Post Event (Publish Event) | |
| EventBus.post("fetchEmployees", sender: EmployeesEvent(error: error, errorMessage: errorMessage, employees: employees)) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func setupEventBusSubscriber() { | |
| _ = EventBus.onMainThread(self, name: "fetchEmployees") { result in | |
| if let event = result!.object as? EmployeesEvent { | |
| if event.employees != nil { | |
| self.showTableView() | |
| } else if let message = event.errorMessage { | |
| self.showAlert(title: "Error", message: message) | |
| } | |
| } | |
| } |
OlderNewer