This file contains 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 SystemConfiguration | |
import RxSwift | |
public class Reachability { | |
class func isConnectedToNetwork() -> Bool { | |
var zeroAddress = sockaddr_in(sin_len: 0, sin_family: 0, sin_port: 0, sin_addr: in_addr(s_addr: 0), sin_zero: (0, 0, 0, 0, 0, 0, 0, 0)) | |
zeroAddress.sin_len = UInt8(MemoryLayout.size(ofValue: zeroAddress)) | |
zeroAddress.sin_family = sa_family_t(AF_INET) |
This file contains 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
infix fun Variable<String>.binding(editText: EditText) { | |
var block = false | |
this.observable.subscribe { | |
if (block == false) { | |
block = true | |
editText.setText(it) | |
block = false | |
} | |
} |
This file contains 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 Variable<T>(private val defaultValue: T) { | |
var value: T = defaultValue | |
set(value) { | |
field = value | |
observable.onNext(value) | |
} | |
val observable = BehaviorSubject.createDefault(value) | |
} |
This file contains 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
abstract class BaseController: Controller(), LayoutContainer { | |
private var _containerView: View? = null | |
override val containerView: View? | |
get() = _containerView | |
protected abstract fun inflateView(inflater: LayoutInflater, container: ViewGroup): View | |
var toolbar: Toolbar? = null | |
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup): View { | |
val view = inflateView(inflater, container).also { |