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
abstract class UseCase<Params, out Type> where Type: Any { | |
// dispatchers | |
private val UI = Dispatchers.Main | |
private val BG = Dispatchers.IO | |
// type for empty parameter | |
class None | |
// parameters |
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
sealed class NetworkResponse<T>( | |
val data: T? = null, | |
val message: String? = null | |
) { | |
class Success<T>(data: T) : NetworkResponse<T>(data) | |
class Error<T>(message: String?, data: T? = null) : NetworkResponse<T>(data, message) | |
class Loading<T> : NetworkResponse<T>() | |
} |
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
abstract class Mapper<F, T> { | |
abstract fun map(from: F): T | |
abstract fun reverse(to: T): F | |
fun map(fromList: List<F>): List<T> = | |
ArrayList<T>(fromList.size).apply { | |
fromList.forEach { | |
add(map(it)) | |
} |
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
// converts Dp to Pixels | |
val Number.toPixels get() = TypedValue.applyDimension( | |
TypedValue.COMPLEX_UNIT_DIP, | |
this.toFloat(), | |
Resources.getSystem().displayMetrics) |
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
abstract class FilterableListAdapter<T, VH : RecyclerView.ViewHolder>( | |
diffCallback: DiffUtil.ItemCallback<T> | |
) : ListAdapter<T, VH>(diffCallback), Filterable { | |
private var originalList: List<T> = currentList.toList() | |
override fun getFilter(): Filter { | |
return object : Filter() { | |
override fun performFiltering(constraint: CharSequence?): FilterResults { | |
return FilterResults().apply { |
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.edenledger.fanvestor.utils | |
/* | |
* Copyright 2017 Google Inc. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* |
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
from Tovar import * | |
tovari = [ | |
Tovar("Хлеб", 9, 20), | |
Tovar("Молоко", 3, 29), | |
Tovar("Чай", 6, 45), | |
Tovar("Кефир", 8, 37), | |
Tovar("Конфеты", 5, 120), | |
] |