Skip to content

Instantly share code, notes, and snippets.

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 March 13, 2020 12:32
Controller view lifecycle
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 February 3, 2020 11:01
material-dialogs files crash due to missing Dispatchers.Main
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 July 10, 2019 13:44
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
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
@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
@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