Skip to content

Instantly share code, notes, and snippets.

@felipepedroso
felipepedroso / LifecycleLogger.kt
Last active May 18, 2020 11:15
Some classes to help debugging LifeCycle and RxJava subscriptions.
import android.util.Log
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent
class LifecycleLogger(private val lifecycleName: String) : LifecycleObserver {
@OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
fun onCreate() = logLifecycleEvent(Lifecycle.Event.ON_CREATE.name)
{"items":[{"id":1,"sku":"a19cf5409c8dc86f55b0cab6213e64d7c4a8e1fbd860f240f0f86ae3ad9f9436","name":"ante ipsum primis in faucibus","price":{"current":2.22,"original":136.68,"currency":"RUB"},"brand":"Anderson, Ferry and Kuhic","image":"http://dummyimage.com/104x150.png/dddddd/000000","published_at":"2019-01-28T05:26:05Z","is_active":false},
{"id":2,"sku":"192ce5928e91b9265744e22db561cddf9164cbab3dcffd622346a7fa40098a23","name":"faucibus accumsan odio curabitur convallis duis consequat","price":{"current":84.52,"original":101.29,"currency":"CHF"},"brand":"Abshire Group","image":"http://dummyimage.com/108x208.png/ff4444/ffffff","published_at":"2019-01-03T18:27:34Z","is_active":true},
{"id":3,"sku":"f534afd7b2b123d6f826a6ef33569a795e4eb6e16b0dc5ae7d3e5980e4cef578","name":"nulla sed vel enim sit amet","price":{"current":50.01,"original":107.47,"currency":"CNY"},"brand":"Willms, Crooks and Haley","image":"http://dummyimage.com/247x194.png/5fa2dd/ffffff","published_at":"2019-02-08T15:11:18Z","is_active":true},
{"id"
@felipepedroso
felipepedroso / droidcon-berlin-19-highlights.md
Last active August 27, 2019 09:26
Droidcon Berlin 2019 - Highlights
fun main(args: Array<String>) {
val callbacksList = mutableListOf<(HttpResponse) -> Unit>()
// Adicionando um método estático
callbacksList.add(::printResponse)
// Adicionando um callback anônimo
val anonymousCallback = { httpResponse: HttpResponse ->
println("Response code from anonymous callback: ${httpResponse.code}")
/*
* Copyright (C) 2014 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software