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 scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) { | |
if scrollView == suggestionsTableView { | |
let cellHeight = CGFloat(60.0) | |
let y = targetContentOffset.pointee.y + scrollView.contentInset.top + (cellHeight / 2) | |
let cellIndex = floor(y / cellHeight) | |
targetContentOffset.pointee.y = cellIndex * cellHeight - scrollView.contentInset.top | |
} | |
} |
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
data class BackKeyPressedTimePair(val prev: Long, val curr: Long) | |
private var backSubject = PublishSubject.create<Boolean>() | |
// onBackPressed() | |
backSubject.throttleFirst(100, TimeUnit.MILLISECONDS) | |
.observeOn(uiScheduler) | |
.filter { isAvailable } | |
.map { | |
// if there is BottomSheet, hide that. |
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 Item { | |
Item({this.itemId}); | |
final String itemId; | |
StreamController<Item> _controller = StreamController<Item>.broadcast(); | |
Stream<Item> get onChanged => _controller.stream; | |
String _status; | |
String get status => _status; | |
set status(String 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
override fun onCreateWindow(view: WebView?, isDialog: Boolean, | |
isUserGesture: Boolean, resultMsg: Message?): Boolean { | |
val context = view?.context ?: return false | |
val transport = resultMsg?.obj as? WebViewTransport | |
val newWebView = WebView(context) | |
view.addView(newWebView) | |
transport?.webView = newWebView | |
resultMsg?.sendToTarget() | |
newWebView.webViewClient = object : WebViewClient() { |
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
// activity with android:windowSoftInputMode="stateHidden" | |
private fun showPasswordDialog() { | |
val context = this.context ?: return | |
val editText = EditText(context) | |
editText.inputType = InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_VARIATION_PASSWORD | |
editText.filters = arrayOf(InputFilter.LengthFilter(4)) | |
val frame = FrameLayout(context) | |
frame.addView(editText) |
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
// Hugo Elias Water 2D Effect | |
let COLUMNS = 40; | |
let ROWS = 40; | |
let BLOCKS = COLUMNS * ROWS; | |
let LEVEL = 50; | |
let HIGH_LEVEL = LEVEL * 2; | |
let HUE = 210; | |
let SATU = 95; |
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 fetchCoachingRoom(complete: @escaping (Error?) -> Void) { | |
refreshCoachingRoomStatus = .working | |
cancellableCoachingRoom?.cancel() | |
cancellableCoachingRoom = apiService.stream(Api.getCoachingRoom()) | |
.map({ (res) -> [AClass] in | |
return res.userClassList | |
}) | |
.receive(on: DispatchQueue.main) | |
.map { [weak self] list -> [Int] in | |
self?.coachingRoomClasses = list |
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
Scheduler scheduler = Schedulers.immediate(); | |
Scheduler.Worker worker = scheduler.createWorker(); | |
worker.schedule(() -> result += "action"); | |
Assert.assertTrue(result.equals("action")); |
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
Scheduler scheduler = Schedulers.newThread(); | |
Scheduler.Worker worker = scheduler.createWorker(); | |
worker.schedule(() -> { | |
result += "First_Action"; | |
worker.unsubscribe(); | |
}); | |
worker.schedule(() -> result += "Second_Action"); | |
Assert.assertTrue(result.equals("First_Action")); |
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 NSObjectProtocol where Self: NSObject { | |
func observe<Value>(_ keyPath: KeyPath<Self, Value>, | |
onChange: @escaping (Value?) -> Void) -> NSKeyValueObservation { | |
return observe(keyPath, options: [.initial, .new]) { _, change in | |
onChange(change.newValue) | |
} | |
} | |
func bind<Value, Target>(_ sourceKeyPath: KeyPath<Self, Value>, |