This file contains 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
//app build.gradle | |
apply plugin: 'kotlin-kapt' | |
... | |
dependencies { | |
{ | |
//Moshi Core | |
implementation "com.squareup.moshi:moshi:1.8.0" | |
//Moshi Codegen |
This file contains 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
val li=List(1,2,10,20,30) //> li : List[Int] = List(1, 2, 10, 20, 30) | |
def insert[T](li:List[T],x:T)(implicit cmp:Ordering[T])={ | |
val (first,last)=li.partition {cmp.lteq(_, x) } | |
first:::x::last | |
} //> insert: [T](li: List[T], x: T)(implicit cmp: Ordering[T])List[T] | |
insert(li,11) //> res0: List[Int] = List(1, 2, 10, 11, 20, 30) | |
insert(li,10) //> res1: List[Int] = List(1, 2, 10, 10, 20, 30) | |
insert(li,9) //> res2: List[Int] = List(1, 2, 9, 10, 20, 30) |
This file contains 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 java.io.File; | |
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.Stack; | |
import android.os.FileObserver; | |
/** | |
* A FileObserver that observes all the files/folders within given directory | |
* recursively. It automatically starts/stops monitoring new folders/files |
This file contains 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 java.util.LinkedHashMap; | |
import java.util.Map; | |
import rx.Observer; | |
import rx.Subscription; | |
import rx.subjects.PublishSubject; | |
abstract class Repository<K, V> { | |
private final Cache<K, V> cache; |