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 balance = userHandler.user | |
.switchMap { user -> | |
Log.d("myLog", "switchMap: $user") | |
pusherManager.getUpdateBalancesLiveData(user) | |
} | |
.mapSuspended(context = BackgroundDispatcher) { unit -> | |
Log.d("myLog", "gettingBalance") | |
val balance = getBalance() // suspend fun | |
balance | |
} |
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
interface HasX { | |
val x: Int | |
companion object | |
} | |
enum class A(override val x: Int) : HasX { ONE(1), TWO(2) } | |
enum class B(override val x: Int, val w: String) : HasX { AB(2, "ab"), CDE(3, "cde") } | |
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
fun Dispensary.currentDayStatus(): DispensaryTimeStatus? { | |
val currentDayKey = when (Calendar.getInstance().dayOfWeek) { | |
Calendar.MONDAY -> Dispensary.MONDAY_KEY | |
Calendar.TUESDAY -> Dispensary.TUESDAY_KEY | |
Calendar.WEDNESDAY -> Dispensary.WEDNESDAY_KEY | |
Calendar.THURSDAY -> Dispensary.THURSDAY_KEY | |
Calendar.FRIDAY -> Dispensary.FRIDAY_KEY | |
Calendar.SATURDAY -> Dispensary.SATURDAY_KEY | |
Calendar.SUNDAY -> Dispensary.SUNDAY_KEY |
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
suspend fun apiIsOutdated(): Boolean = try { | |
val appApiVersionInfo = apiMeta.apiVersion | |
val realApiVersionInfo = getApiInfo() | |
.map(ApiInfo::version) | |
.fold( | |
onSuccess = ::identity, | |
onFailure = { appApiVersionInfo } | |
) | |
fun String.getVersions() = split(".").map(String::toInt) |
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 SummaryItem : IdEntity<Long> { | |
companion object { | |
fun wrap(meta: TransactionMeta): SummaryItem = | |
if (meta.transaction.isInvoiceItem()) | |
SummaryInvoice(meta) else SummaryPayment(meta) | |
} | |
} | |
fun Transaction.isInvoiceItem() = isMyInvoice() or isMyRequest() |
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
data class Transaction( | |
override val id: Long, | |
val blockchainUrl: String?, | |
val type: Type, | |
val status: Status, | |
val castAs: CastAs, | |
val senderAddress: String?, | |
val receiverAddress: String?, | |
val senderMessage: String?, | |
val receiverMessage: String?, |
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
data class TransactionMeta( | |
val transaction: Transaction, | |
val color: Color, | |
val title: String, | |
val time: Timestamp, | |
val message: String?, | |
val address: String, | |
val amount: String, | |
val isSpace: Boolean, | |
val isCancelable: Boolean, |
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 TransactionViewHolder( | |
view: View | |
) : BaseRecyclerViewHolder(view) { | |
val expansionLayout: ExpansionLayout = transactionSummaryLayout | |
private val timeFormatter = DefaultLocaleDateFormat("MMMM d yyyy - hh:mm a") | |
private var onViewDetailsListener: OnActionListener? = 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
class InvoiceActivity : BaseActivity(), HasBottomBar, HasToolbar { | |
private val paymentId: Long by longExtra(PAYMENT_ID) | |
private val viewModel by viewModel<InvoiceViewModel> { | |
parametersOf(paymentId) | |
} | |
private val paymentViewBinder by lazy { PaymentViewBinder(layoutInvoice) } | |
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
override fun bind(data: ActiveSession) { | |
val device = data.device | |
val deviceStr = device.device.takeIf(String::isNotBlank) | |
val platform = device.platform.takeIf(String::isNotBlank) | |
title = when { | |
deviceStr != null && platform != null -> "$deviceStr, $platform" | |
deviceStr != null && platform == null -> deviceStr | |
deviceStr == null && platform != null -> platform |
OlderNewer