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
//models | |
data class RequestData(val data:String) | |
class BusinessException(val msg:String):Throwable(msg) | |
//Interactor | |
interface IDataRequestInteractor { | |
suspend fun getData(): RequestData | |
} | |
// ViewModel |
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 kotlinx.coroutines.* | |
import kotlin.coroutines.CoroutineContext | |
fun <T> launchAsync(block: suspend () -> T, onComplete: (T) -> Unit = {}, onError: (Throwable) -> Unit = {}, dispatcher: CoroutineDispatcher = Dispatchers.IO, context: CoroutineContext = Dispatchers.Main + SupervisorJob(), onCanceled: () -> Unit = {}): Job { | |
val scope = CoroutineScope(context) | |
return scope.launch { | |
try { | |
val result = withContext(dispatcher) { block.invoke() } | |
onComplete.invoke(result) | |
} catch (e: CancellationException) { |
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
ext.versions = [ | |
'androidPlugin' : '3.4.1', | |
'minSdk' : 16, | |
'targetSdk' : 27, | |
'compileSdk' : 28, | |
'buildTools' : '28.0.3', | |
'supportLibrary' : '28.0.0', | |
'constraint' : '2.0.0-beta1', | |
'kotlin' : '1.3.31', | |
'coroutines' : '1.2.1', |
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
/** | |
* return items from second array wich not includes in first by custom diff by predicate | |
* @param first ArrayList of T | |
* @param second Collection of T | |
* @param predicate function equals | |
*/ | |
fun <T> arraysDiff(first: ArrayList<T>, second: ArrayList<T>, predicate: (firstOf:T, secondOf:T) -> Boolean): ArrayList<T> { | |
val result = arrayListOf<T>() | |
for (f in first) { | |
var equal = false |
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 android.support.annotation.LayoutRes | |
import android.support.v7.util.DiffUtil | |
import android.support.v7.widget.RecyclerView | |
import android.view.LayoutInflater | |
import android.view.ViewGroup | |
import android.widget.Filter | |
abstract class SimpleAbstractAdapter<T>(private var items: ArrayList<T> = arrayListOf()) : RecyclerView.Adapter<SimpleAbstractAdapter.VH>() { | |
protected var listener: OnViewHolderListener<T>? = null | |
private val filter = ArrayFilter() |
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
package com.arny.arnylib.utils; | |
import android.content.Context; | |
import android.content.SharedPreferences; | |
import android.preference.PreferenceManager; | |
import android.support.annotation.NonNull; | |
public class Config { | |
private static SharedPreferences settings = null; |
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
package com.arny.arnylib; | |
import com.arny.arnylib.utils.Stopwatch; | |
import com.arny.arnylib.utils.TestingUtils; | |
import io.reactivex.Observable; | |
import io.reactivex.functions.Function; | |
import io.reactivex.observers.TestObserver; | |
import io.reactivex.plugins.RxJavaPlugins; | |
import io.reactivex.schedulers.Schedulers; | |
import org.junit.Rule; |