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
// we use the RxJava2CallAdapterFactory to wrap all of our retrofit api calls in a | |
// RxJava2 Single | |
public class BoundAPI { | |
private static BoundApi sInstance = null; | |
private final BoundApiService mService; | |
public static BoundApi getInstance(OkHttpProvider okHttpProvider, GsonProvider gsonProvider) { |
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
package radtabinc.radtab.api; | |
import com.google.gson.JsonDeserializationContext; | |
import com.google.gson.JsonDeserializer; | |
import com.google.gson.JsonElement; | |
import com.google.gson.JsonParseException; | |
import com.google.gson.JsonPrimitive; | |
import com.google.gson.JsonSerializationContext; | |
import com.google.gson.JsonSerializer; | |
import com.google.gson.JsonSyntaxException; |
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
extension UIView { | |
class func fromNib<T: UIView>() -> T { | |
return Bundle.main.loadNibNamed(String(describing: T.self), owner: nil, options: nil)![0] as! T | |
} | |
} |
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
/// Optional Assignment, assigns if value exists | |
infix operator ?=: AssignmentPrecedence | |
func ?=<T>(lhs: inout T, rhs: T?) { | |
guard let value = rhs else { return } | |
lhs = value | |
} |
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 UIKit | |
import Cartography | |
class LoadingView: UIView { | |
let activityView = UIActivityIndicatorView(frame: .zero) | |
let overlayView = UIView(frame: .zero) | |
override init(frame: CGRect) { |
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 | |
enum UIViewControllerDismissType { | |
case pop | |
case dismiss | |
} | |
extension UIViewController { | |
func presentAlertWithTitle(title: String = "Oops!", message: String, actions: [UIAlertAction] = [], preferredStyle: UIAlertControllerStyle = .alert, onComplete: ((KeystoneResultSimple) -> Void)? = nil) { |
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 | |
struct Device { | |
let ran: Bool | |
@discardableResult static func whenIphoneX(_ block: () -> Void) -> Device { | |
return runIfTrue(Device.isIphoneX, block: block) | |
} | |
@discardableResult static func whenNotIphoneX(_ block: () -> Void) -> Device { | |
return runIfFalse(Device.isIphoneX, block: block) |
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 CoreData | |
public extension NSManagedObjectContext { | |
@discardableResult func saveToStore() -> NSError? { | |
var currentContext: NSManagedObjectContext? = self | |
var error: NSError? = nil | |
var hasChanges = true | |
while let context = currentContext, (error == nil && hasChanges) { |
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 | |
extension UIStoryboard { | |
static func fromStoryboard(named: String) -> UIViewController? { | |
return UIStoryboard(name: named, bundle: nil).instantiateInitialViewController() | |
} | |
static func fromStoryboard(named: String, get: String) -> UIViewController? { | |
return UIStoryboard(name: named, bundle: nil).instantiateViewController(withIdentifier: get) |
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 | |
extension UIView { | |
var absoluteFrame: CGRect { | |
return self.superview!.convert(self.frame, to: nil) | |
} | |
func convertFrame(toParentView parentView: UIView) -> CGRect { | |
return self.superview!.convert(self.frame, to: parentView) | |
} |
NewerOlder