This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fr.francetv.francetvsport.arch.presentation.base | |
import android.view.View | |
import android.widget.Toast | |
class DebouncingOnClickListener( | |
private val intervalMillis: Long, | |
private val doClick: ((View) -> Unit) | |
) : View.OnClickListener { | |
private var enabled = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fr.francetv.francetvsport.arch.presentation.main.navigations | |
import java.io.IOException | |
import java.util.* | |
import java.util.stream.Collectors | |
object GroupByDemoInJava8 { | |
@Throws(IOException::class) | |
@JvmStatic |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fr.francetv.francetvsport.arch.infrastructure.data.source.remote.pic | |
//You are going to be given a word. Your job is to return the middle character of the word. If the word's length is odd, return the middle character. If the word's length is even, return the middle 2 characters. | |
fun getMiddle(word: String): String { | |
val middleIndex = word.length / 2 | |
return if (word.length.isEven()) { | |
word.substring((middleIndex - 1)..middleIndex) | |
} else { | |
word[middleIndex].toString() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fr.francetv.francetvsport.arch.infrastructure.data.source.remote.pic | |
//Your task is to split the chocolate bar of given dimension n x m into small squares. | |
//Each square is of size 1x1 and unbreakable. Implement a function that will return minimum number of breaks needed. | |
// | |
//For example, if you are given a chocolate bar of size 2 x 1 you can split it to single squares in just one break, but for size 3 x 1 you must perform two breaks. | |
// | |
//If input data is invalid you should return 0 (as in no breaks are needed if we do not have any chocolate to split). Input will always be a non-negative integer. | |
fun breakChocolate(n: Int, m: Int): Int = if ((n in 0..1) && (m in 0..1)) { | |
0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fr.francetv.francetvsport.arch.infrastructure.data.source.remote.pic | |
//You are given an array (which will have a length of at least 3, but could be very large) containing integers. The array is either entirely comprised of odd integers or entirely comprised of even integers except for a single integer N. Write a method that takes the array as an argument and returns this "outlier" N. | |
fun find(integers: Array<Int>): Int { | |
var outlierInteger: Int = 0 | |
val oddIntegers = mutableListOf<Int>() | |
val evenIntegers = mutableListOf<Int>() | |
var i = 0 | |
while (i <= integers.lastIndex) { | |
val integer = integers[i] | |
if (integer.isEven()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlinx.coroutines.async | |
import kotlinx.coroutines.delay | |
import kotlinx.coroutines.runBlocking | |
fun main() { | |
runBlocking { | |
val doIt1 = doIt1() | |
val doIt2 = doIt2() | |
val doIt3 = doIt3() | |
println("result ${doIt1 + doIt2 + doIt3}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fr.francetv.francetvsport.arch.presentation.videodetail | |
import kotlinx.coroutines.* | |
fun main() = runBlocking { | |
val parentJob = launch { | |
launch { | |
println("start launch child") | |
while (isActive) { | |
delay(500) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.raywenderlich.kotlin.coroutines | |
import androidx.arch.core.executor.testing.InstantTaskExecutorRule | |
import androidx.lifecycle.* | |
import kotlinx.coroutines.* | |
import kotlinx.coroutines.test.runBlockingTest | |
import kotlinx.coroutines.test.setMain | |
import org.junit.Assert.assertEquals | |
import org.junit.Rule | |
import org.junit.Test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.raywenderlich.kotlin.coroutines | |
import androidx.arch.core.executor.ArchTaskExecutor | |
import androidx.arch.core.executor.TaskExecutor | |
import androidx.lifecycle.* | |
import kotlinx.coroutines.* | |
import kotlin.coroutines.CoroutineContext | |
@ExperimentalCoroutinesApi | |
class Main3 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fr.francetv.francetvsport.arch.application | |
import kotlinx.coroutines.* | |
import kotlinx.coroutines.channels.awaitClose | |
import kotlinx.coroutines.flow.Flow | |
import kotlinx.coroutines.flow.MutableStateFlow | |
import kotlinx.coroutines.flow.channelFlow | |
import kotlinx.coroutines.flow.collect | |
fun main() = runBlocking { |