Skip to content

Instantly share code, notes, and snippets.

View NinoDLC's full-sized avatar

Nino NinoDLC

  • Lyon, France
View GitHub Profile
// open JaCoCo report after generation
def openReport(htmlOutDir) {
final reportPath = "$htmlOutDir\\index.html"
println "HTML Report: $reportPath"
def os = org.gradle.internal.os.OperatingSystem.current()
if (os.isWindows()) {
exec { commandLine 'cmd', '/c', "start $reportPath" }
} else if (os.isMacOsX()) {
@NinoDLC
NinoDLC / RestaurantDetailsRepository
Created August 23, 2021 20:48
Caching data in RAM
import android.util.LruCache;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import fr.delcey.go4lunch.data.restaurant_details.pojo.RestaurantDetailsResponse;
import fr.delcey.go4lunch.data.restaurant_details.pojo.RestaurantDetailsResponseWrapper;
import retrofit2.Call;
package fr.delcey.pokedexfullflow
import android.location.Location
import androidx.lifecycle.LiveData
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOf
import kotlin.random.Random
class AllInOneRepository {
@ColorRes
fun getTypeColorRes(type: String?): Int? = when (type) {
"normal" -> R.color.type_normal
"fire" -> R.color.type_fire
"water" -> R.color.type_water
"electric" -> R.color.type_electric
"grass" -> R.color.type_grass
"ice" -> R.color.type_ice
"fighting" -> R.color.type_fighting
Intent intent = MeetingDetailActivity.navigate(this, meetingId);
Pair<View, String> imageViewPair = new Pair<>(imageView, imageView.getTransitionName());
Pair<View, String> textViewPair = new Pair<>(textView, textView.getTransitionName());
@SuppressWarnings("unchecked")
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(
this,
imageViewPair,
textViewPair
@NinoDLC
NinoDLC / TestCoroutineRule.kt
Created December 28, 2021 18:28
TestCoroutineRule.kt
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.TestCoroutineDispatcher
import kotlinx.coroutines.test.TestCoroutineScope
import kotlinx.coroutines.test.resetMain
import kotlinx.coroutines.test.runBlockingTest
import kotlinx.coroutines.test.setMain
import org.junit.rules.TestRule
import org.junit.runner.Description
import org.junit.runners.model.Statement
@NinoDLC
NinoDLC / TestCoroutineRule.kt
Created January 10, 2022 17:39
TestCoroutineRule.kt
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.*
import org.junit.rules.TestRule
import org.junit.runner.Description
import org.junit.runners.model.Statement
@ExperimentalCoroutinesApi
class TestCoroutineRule : TestRule {
val testCoroutineDispatcher = UnconfinedTestDispatcher()
@NinoDLC
NinoDLC / InterpolationRepository.kt
Last active May 6, 2022 15:10
InterpolationRepository
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.launch
@NinoDLC
NinoDLC / DataInterpolationRepository.kt
Last active May 6, 2022 15:25
DataInterpolationRepository
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.launch
@NinoDLC
NinoDLC / MultipleDetailsDemo.kt
Created May 6, 2022 07:52
Query multiple details in parallel with coroutines async / awaitAll()
import kotlinx.coroutines.*
import java.io.IOException
object MultipleDetailsDemo {
@JvmStatic
fun main(args: Array<String>) = runBlocking {
val start = System.currentTimeMillis()
val detailEntities: List<DetailEntity> = try {
val ids = listOf(0, 1, 2)