Skip to content

Instantly share code, notes, and snippets.

Implementing common sense

Vasilis Charalampakis charbgr

Implementing common sense
Block or report user

Report or block charbgr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
charbgr / UserScopeModule.kt
Last active Aug 13, 2018
Releasing dependencies in Koin
View UserScopeModule.kt
module("user_scope") {
single("endpoint") { Endpoint() }
// when user switches account, we simply do this:
charbgr / UnitTest.kt
Last active Aug 13, 2018
Mocking dependencies in unit-test using Koin
View UnitTest.kt
declare { // It is provided in koin-test utilities
single("draftStorage") {
FakeStorage() as Storage
charbgr / DummyFragment.kt
Last active Aug 13, 2018
Injection with Koin
View DummyFragment.kt
class DummyFragment : Fragment() {
private val draftStorage: Storage by inject("draftStorage")
charbgr / DummyFragment.kt
Last active Aug 13, 2018
Inject with Dagger
View DummyFragment.kt
class DummyFragment : Fragment() {
lateinit var draftStorage: Storage
override fun onCreate(savedInstanceState: Bundle?) {
(activity as BaseActivity).component().inject(this)
charbgr / OffsetsWithDirection.kt
Created Aug 17, 2017 — forked from ZacSweers/OffsetsWithDirection.kt
Observable stream of AppBarLayout offsets + scroll direction
View OffsetsWithDirection.kt
* 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
charbgr / ErrorHandlerExtensions.kt
Last active Oct 27, 2016
ErrorHandler Kotlin Extension
View ErrorHandlerExtensions.kt
* Creates a new instance of [ErrorHandler]
* Passing a lambda is optional
fun Throwable.handleIsolated(func: ErrorHandler.() -> Unit = {}) {
val errorHandler = ErrorHandler.createIsolated()
charbgr /
Last active Oct 26, 2016
Android - Gif Recording Device
adb shell screenrecord --bit-rate=20M "/sdcard/recording.mp4" &
echo "Recording.. ($PID)"
read -n1 -r -p "Press any key to stop" key
sleep 1
adb pull "/sdcard/recording.mp4"
echo "Gififying..."
gifify -r 60 "recording.mp4"
import android.view.ViewGroup;
public abstract class HeaderFooterRecyclerViewAdapter<
ContentViewHolder extends RecyclerView.ViewHolder,
HeaderViewHolder extends RecyclerView.ViewHolder,
FooterViewHolder extends RecyclerView.ViewHolder>
extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
You can’t perform that action at this time.