Skip to content

Instantly share code, notes, and snippets.

View AndroidUIThreadDelays.java
private final Handler uiHandler = new Handler(Looper.getMainLooper());
private void startAnimation() {
animateBallRestart(firstBall);
uiHandler.postDelayed(new Runnable() {
@Override
public void run() {
animateBallRestart(secondBall);
@angusholder
angusholder / ControllerLifecycle.kt
Created Mar 13, 2020
Controller view lifecycle
View ControllerLifecycle.kt
package co.mopo.android.ui.base
import android.content.Context
import android.view.View
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LifecycleRegistry
import com.bluelinelabs.conductor.Controller
import com.bluelinelabs.conductor.Controller.LifecycleListener
@angusholder
angusholder / material-dialogs-crash.txt
Created Feb 3, 2020
material-dialogs files crash due to missing Dispatchers.Main
View material-dialogs-crash.txt
02-03 10:50:40.420 18736-18736/com.afollestad.materialdialogs.sample E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.afollestad.materialdialogs.sample, PID: 18736
java.lang.IllegalStateException: Module with the Main dispatcher is missing. Add dependency providing the Main dispatcher, e.g. 'kotlinx-coroutines-android'
at kotlinx.coroutines.internal.MissingMainCoroutineDispatcher.missing(MainDispatchers.kt:90)
at kotlinx.coroutines.internal.MissingMainCoroutineDispatcher.isDispatchNeeded(MainDispatchers.kt:71)
at kotlinx.coroutines.DispatchedKt.resumeCancellable(Dispatched.kt:420)
at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:26)
at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:109)
at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:154)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:54)
@angusholder
angusholder / FixedAndroidSentryClientFactory.kt
Last active Jul 10, 2019
Fixes the slow startup caused by Sentry accessing Java resources on Android. Instead we access files using Android assets. Put your Sentry config in /app/src/main/assets/sentry.properties
View FixedAndroidSentryClientFactory.kt
package com.example
import android.content.Context
import android.util.Log
import io.sentry.SentryUncaughtExceptionHandler
import io.sentry.android.AndroidSentryClientFactory
import io.sentry.buffer.Buffer
import io.sentry.buffer.DiskBuffer
import io.sentry.connection.AsyncConnection
import io.sentry.connection.BufferedConnection
View ControllerCtorInjectionViaComponentFactory.kt
@file:SuppressLint("ValidController")
package co.mopo.android.ui
import android.annotation.SuppressLint
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import co.mopo.android.data.disk.AppDatabase
View ControllerCtorInjectionViaAssistedInject.kt
@file:SuppressLint("ValidController")
package co.mopo.android.ui
import android.annotation.SuppressLint
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import co.mopo.android.data.disk.AppDatabase