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
@file:JvmName("TransactionUtils") | |
@file:JvmMultifileClass | |
val Transaction.formattedTransactionTime: String | |
get() = SomeFormattings(this.transactionTime) | |
fun Transaction.getFormattedTransactionTime() : String { | |
return SomeFormattings(this.transactionTime) | |
} |
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
@file:JvmName("TransactionUtils") | |
val Transaction.formattedTransactionTime: String | |
get() = SomeFormattings(this.transactionTime) | |
fun Transaction.getFormattedTransactionTime() : String { | |
return SomeFormattings(this.transactionTime) | |
} |
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
val Transaction.formattedTransactionTime: String | |
get() = SomeFormattings(this.transactionTime) | |
fun Transaction.getFormattedTransactionTime() : String { | |
return SomeFormattings(this.transactionTime) | |
} |
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
public final class TransactionUtils { | |
public static String getTransactionWithFormattedTime(final Transaction transaction) { | |
String transactionTime = transaction.getTransactionTime(); | |
return SomeFormattings(transactionTime); | |
} | |
} | |
//Lets say we are in the ViewHolder of a RecyclerView.Adapter | |
public void onBindViewHolder(...){ |
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
Transaction transaction = transactions.get(0) | |
TransactionUtils.getTransactionWithFormattedTime(transaction); | |
// I call the same method again for the same instance of the transaction | |
TransactionUtils.getTransactionWithFormattedTime(transaction); | |
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
public final class TransactionUtils { | |
public static void getTransactionWithFormattedTime(Transaction transaction) { | |
String oldTransationTime = transaction.getTransactionTime(); | |
transaction.setTransactionTime(SomeFormattings!!!) ; | |
} | |
} | |
//Lets say we are in the ViewHolder of a RecyclerView.Adapter | |
public void onBindViewHolder(...){ |
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
inline fun <T> ViewModel.useCase( | |
noinline call: suspend () -> Result<T>, | |
noinline onError: (suspend (exception: Throwable) -> Unit)? = null, | |
noinline onSuccess: (suspend (data: T) -> Unit)? = null | |
) { | |
flow { | |
when (val response = call()) { | |
is Result.Success -> emit(response.data) | |
is Result.Error -> throw response.exception | |
} |
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
data class Account(val iban: String) | |
val Account.formattedIban:String | |
get(){ | |
... | |
} |
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
class Account(val iban: String) | |
val Account.formattedIban:String | |
get(){ | |
... | |
} |
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
class Account(val iban: String) { | |
fun getFormattedIban():String { | |
val sb = StringBuilder() | |
for (i in 0..15) { | |
if (i % 4 == 0) sb.append(" ") | |
sb.append(iban[i]) | |
} | |
return sb.toString() | |
} |
NewerOlder