Skip to content

Instantly share code, notes, and snippets.

View FilipeLipan's full-sized avatar
🎯
Focusing

Filipe Schmidt FilipeLipan

🎯
Focusing
  • Curitiba Paraná
View GitHub Profile
package com.github.filipelipan.composebuss
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
class TestSchedulerRule : TestRule {
val testScheduler = TestScheduler()
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
override fun apply(base: Statement, d: Description): Statement {
return object : Statement() {
@Throws(Throwable::class)
override fun evaluate() {
viewModelScope.launch {
runWithExecutor(
asyncFunction = async { getSupportedCountriesUseCase.execute(UseCase.None()) },
contextExecutor = coroutinesDispatcherProvider.io) {
it.fold(::showError, ::showCountries)
}
}
abstract class UseCase<out Type, in Params> where Type : Any {
abstract suspend fun executeOperation(params: Params): Either<Failure, Type>
suspend operator fun invoke(scope: CoroutineScope, params: Params, onResult: (Either<Failure, Type>) -> Unit = {}) = scope.launch {
val job = executeOperation(params)
withContext(Dispatchers.Main) {
onResult(job)
}
}
abstract class UseCase<out Type, in Params> where Type : Any? {
abstract suspend fun run(params: Params): Either<Failure, Type>
suspend operator fun invoke(params: Params, coroutinesDispatcherProvider: CoroutinesDispatcherProvider, onResult: (Either<Failure, Type>) -> Unit = {}) {
val result = run(params)
withContext(coroutinesDispatcherProvider.main) {
onResult(result)
}
}
package com.ebanx.go.app.feature_signup
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import com.ebanx.go.app.shared_kotlin.functional.Either
import com.ebanx.go.domain.interactor.GetSupportedCountriesUseCase
import com.ebanx.go.domain.model.Country
import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.given
import junit.framework.Assert.assertEquals
import kotlinx.coroutines.Dispatchers
@FilipeLipan
FilipeLipan / gist:c91e7b0dac601e24eb73669e308bf613
Created March 11, 2020 14:16
charles main in the middle notes
network details
Proxy manual
Help - ssl proxying - device proxying
Install Charles proxy
Copiar ip e portas
Para o emulador - proxy manual
@FilipeLipan
FilipeLipan / gist:adcd0de81530ec6b48380e2802d97dd9
Created October 29, 2019 20:20
a lot of diferrent types of cryptos
package com.ebanx.congo.app
import android.content.Context
import android.security.KeyPairGeneratorSpec
import android.security.keystore.KeyGenParameterSpec
import android.security.keystore.KeyProperties
import android.security.keystore.KeyProperties.KEY_ALGORITHM_RSA
import android.util.Base64
import androidx.security.crypto.MasterKeys
import com.ebanx.congo.BuildConfig
package br.com.botpag.ui.payment
import android.Manifest
import android.content.Intent
import android.content.pm.PackageManager
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
package br.com.avon.common.repository.remote.util;
import java.io.IOException;
import javax.annotation.Nullable;
import br.com.avon.common.BuildConfig;
import br.com.avon.common.entity.response.mobile_commerce.RenewTokenResponse;
import br.com.avon.common.infrastructure.MyApplication;
import br.com.avon.common.repository.remote.RestApi;