View UserScopeModule.kt
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
module("user_scope") { | |
single("endpoint") { Endpoint() } | |
... | |
} | |
// when user switches account, we simply do this: | |
release("user_scope") |
View UnitTest.kt
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
declare { // It is provided in koin-test utilities | |
single("draftStorage") { | |
FakeStorage() as Storage | |
} | |
} |
View DummyFragment.kt
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 DummyFragment : Fragment() { | |
private val draftStorage: Storage by inject("draftStorage") | |
} |
View DummyFragment.kt
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 DummyFragment : Fragment() { | |
@Inject | |
@Named("draftStorage") | |
lateinit var draftStorage: Storage | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
(activity as BaseActivity).component().inject(this) | |
} |
View OffsetsWithDirection.kt
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
/* | |
* Here we want to get the appbar offset changes paired with the direction it's moving and | |
* using RxBinding's great `offsetChanges` API to make an rx Observable of this. The first | |
* part buffers two while skipping one at a time and emits "scroll direction" enums. Second | |
* part is just a simple map to pair the offset with the resolved scroll direction comparing | |
* to the previous offset. This gives us a nice stream of (offset, direction) emissions. | |
* | |
* Note that the filter() is important if you manipulate child views of the ABL. If any child | |
* view requests layout again, it will trigger an emission from the offset listener with the | |
* same value as before, potentially causing measure/layout/draw thrashing if your logic |
View ErrorHandlerExtensions.kt
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
/** | |
* Creates a new instance of [ErrorHandler] | |
* Passing a lambda is optional | |
*/ | |
fun Throwable.handleIsolated(func: ErrorHandler.() -> Unit = {}) { | |
val errorHandler = ErrorHandler.createIsolated() | |
func(errorHandler) | |
errorHandler.handle(this) | |
} |
View record-gif.sh
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
#!/bin/bash | |
adb shell screenrecord --bit-rate=20M "/sdcard/recording.mp4" & | |
PID=$! | |
echo "Recording.. ($PID)" | |
read -n1 -r -p "Press any key to stop" key | |
kill -SIGHUP $PID | |
sleep 1 | |
adb pull "/sdcard/recording.mp4" | |
echo "Gififying..." | |
gifify -r 60 "recording.mp4" |