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.example | |
import com.squareup.moshi.JsonAdapter | |
import com.squareup.moshi.JsonAdapter.Factory | |
import com.squareup.moshi.JsonReader | |
import com.squareup.moshi.JsonWriter | |
import com.squareup.moshi.Types | |
import com.squareup.moshi.rawType | |
import kotlinx.collections.immutable.ImmutableList |
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.BufferedWriter | |
import java.io.File | |
import java.io.FileWriter | |
import java.io.Writer | |
import kotlin.random.Random | |
val weekOffset = 5 | |
val holidays = setOf(8, 16) | |
val month = 4 | |
val year = 1402 |
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 | |
val importPattern = "import com\\.squareup\\.moshi\\.JsonClass".toRegex() | |
val jsonAttrPattern = "^(.*)\\@Json\\(name \\= (\".*\")\\)".toRegex() | |
val jsonClassPattern = "^(.*)\\@JsonClass\\(generateAdapter \\= true\\)".toRegex() | |
val root = File("/Users/farhad/Projects/Otgahak/Host") | |
root.walkTopDown() | |
.filter { it.extension == "kt" } | |
.filter { it.readText().contains(importPattern) } |
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 StateModel( | |
val detail: ViewResource<Entity1>, | |
val something: Entity2?, | |
val error: Event<String>? | |
) { | |
companion object { | |
val initial = StateModel( | |
detail = ViewResource.NotAvailable, | |
something = null, | |
error = 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
@Module | |
interface DataModule { | |
@Binds | |
fun bindSessionProvider(sessionProvider: SessionProviderImpl): SessionProvider | |
} | |
@Singleton | |
class SessionProviderImpl @Inject constructor( | |
private val application: Application | |
) : SessionProvider |
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
/* | |
expected functionality: | |
// 1002.0 -> 1,002 | |
// 1002.1 -> 1,002.10 | |
// 1002.666 -> 1,002.66 | |
*/ | |
fun legacyFormatPrice(value: Double) { | |
return if (this.rem(1) == 0.0) | |
String.format("%,.0f", value) | |
else |
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 SampleValidator( | |
val balance: Long?, | |
val amount: Long?, | |
val acceptedTerms: Boolean? | |
) : Validator<SampleValidator> { | |
override fun validate(): Validation<SampleValidator> { | |
return when { | |
balance ?: 0 <= 0 -> Validation.Invalid("بالانس شما کافی نیست") | |
amount ?: 0 <= 0 -> Validation.Invalid("مبلغ وارد شده صحیح نیست") | |
amount ?: 0 > balance ?: 0 -> Validation.Invalid("مبلغ وارد شده بیشتر از بالانس شماست") |
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
^(?!(chatty|ConfigStore|system_server|OpenGLRenderer|girad.threadin|EGL_emulation)) |
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 kotlin.Metadata; | |
import kotlin.jvm.internal.Intrinsics; | |
import org.jetbrains.annotations.NotNull; | |
public final class Test { | |
public final void s() { | |
RequestProvider.Production production1 = new FoodStore(); | |
RequestProvider.Production production2 = new FastFoodStore(); | |
RequestProvider.Production production3 = new InOutBurger(); | |
} |
NewerOlder