Skip to content

Instantly share code, notes, and snippets.

View txusballesteros's full-sized avatar
💭
Transformer

Txus Ballesteros txusballesteros

💭
Transformer
View GitHub Profile
@txusballesteros
txusballesteros / Demo.kt
Created October 8, 2019 09:15
Higher Kinded Types with Arrow
import arrow.Kind
import arrow.core.ForEither
import arrow.core.Option
import com.txusballesteros.codelabs.billboard.api.movie.MovieApi
import com.txusballesteros.codelabs.billboard.core.domain.mapper.map
import com.txusballesteros.codelabs.billboard.core.domain.model.Movie
internal class MovieCloudDataSource<F>(
private val api: MovieApi
@txusballesteros
txusballesteros / FP Data Flow
Created May 9, 2019 10:56 — forked from raulraja/di.kt
Simple Kotlin DI
package com.fortyseven.fptraining
import arrow.core.Either
import arrow.core.right
import arrow.effects.IO
import arrow.effects.extensions.io.fx.fx
data class Account(val balance: Int)
data class AccountEntity(val balance: Int)
import android.animation.ValueAnimator
import android.content.Context
import android.graphics.*
import android.util.AttributeSet
import android.util.TypedValue
import android.view.View
import android.view.animation.DecelerateInterpolator
class OnboardingPageIndicatorView @JvmOverloads constructor(
context: Context,
package com.txusballesteros.mytaxi.core.domain.repository
import com.pholser.junit.quickcheck.generator.GenerationStatus
import com.pholser.junit.quickcheck.generator.Generator
import com.pholser.junit.quickcheck.random.SourceOfRandomness
import com.txusballesteros.mytaxi.core.domain.model.MapState
class MapStatePropertyGenerator: Generator<MapState>(MapState::class.java) {
companion object {
private val MINIMUM_VALUE = 0
class NowPlayingCloudDataSourceTest : UnitTest() {
companion object {
private const val PAGE = 123
private val MODEL = MovieApiModel(
1,
"originalTitle",
"en",
"title",
"overview",
"2017-08-23",
@txusballesteros
txusballesteros / four_segments_dynamic_layout.xml
Last active October 24, 2017 06:10
4 Segments ConstraintLayout
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#b2ebf2">
<android.support.constraint.ConstraintLayout
android:layout_width="110dp"
@txusballesteros
txusballesteros / RecyclerViewAssertion.kt
Created October 15, 2017 15:54
Espresso RecyclerView Assertions
package com.txusballesteros.instrumentacion.assertion
import android.support.test.espresso.EspressoException
import android.support.test.espresso.ViewAssertion
import android.support.test.espresso.matcher.ViewMatchers.assertThat
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.View.FIND_VIEWS_WITH_TEXT
import android.widget.TextView
import org.hamcrest.Matchers.greaterThan
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.View.GONE
import android.view.View.VISIBLE
fun RecyclerView.setEmptyView(view: View) {
adapter?.apply {
val observer = object: RecyclerView.AdapterDataObserver() {
override fun onChanged() {
view.visibility = if (adapter.isEmpty()) VISIBLE else GONE
machine:
environment:
_JAVA_OPTIONS: "-Xms512m -Xmx1024m"
ANDROID_HOME: /usr/local/android-sdk-linux
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"'
dependencies:
pre:
- echo y | android update sdk --no-ui --all --filter tools,platform-tools,android-25
- echo y | android update sdk --no-ui --all --filter build-tools-25.0.2
@txusballesteros
txusballesteros / PulseDrawable.java
Last active December 17, 2022 08:52
Pulse Drawable for Android
/*
* Copyright Txus Ballesteros 2015 (@txusballesteros)
*
* This file is part of some open source application.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the