path
stringlengths 4
280
| owner
stringlengths 2
39
| repo_id
int64 21.1k
879M
| is_fork
bool 2
classes | languages_distribution
stringlengths 13
1.95k
⌀ | content
stringlengths 7
482k
| issues
int64 0
13.9k
| main_language
stringclasses 121
values | forks
stringlengths 1
5
| stars
int64 0
111k
| commit_sha
stringlengths 40
40
| size
int64 7
482k
| name
stringlengths 1
100
| license
stringclasses 93
values |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
pluto/lib/src/main/java/com/pluto/tool/modules/ruler/internal/RulerFragment.kt | androidPluto | 390,471,457 | false | {"Kotlin": 744352, "Shell": 646} | package com.pluto.tool.modules.ruler.internal
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
internal class RulerFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return RulerScaleView(requireContext()).apply {
id = View.generateViewId()
}
}
}
| 23 | Kotlin | 64 | 657 | 5562cb7065bcbcf18493820e287d87c7726f630b | 476 | pluto | Apache License 2.0 |
kotlin/services/sagemaker/src/main/kotlin/com/kotlin/sage/DescribeTrainingJob.kt | awsdocs | 66,023,605 | false | null | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package com.kotlin.sage
// snippet-start:[sagemaker.kotlin.describe_train_job.import]
import aws.sdk.kotlin.services.sagemaker.SageMakerClient
import aws.sdk.kotlin.services.sagemaker.model.DescribeTrainingJobRequest
import kotlin.system.exitProcess
// snippet-end:[sagemaker.kotlin.describe_train_job.import]
/**
Before running this Kotlin code example, set up your development environment,
including your credentials.
For more information, see the following documentation topic:
https://docs.aws.amazon.com/sdk-for-kotlin/latest/developer-guide/setup.html
*/
suspend fun main(args: Array<String>) {
val usage = """
Usage:
<trainingJobName>
Where:
trainingJobName - The name of the training job.
"""
if (args.size != 1) {
println(usage)
exitProcess(1)
}
val trainingJobName = args[0]
describeTrainJob(trainingJobName)
}
// snippet-start:[sagemaker.kotlin.describe_train_job.main]
suspend fun describeTrainJob(trainingJobNameVal: String?) {
val request =
DescribeTrainingJobRequest {
trainingJobName = trainingJobNameVal
}
SageMakerClient { region = "us-west-2" }.use { sageMakerClient ->
val jobResponse = sageMakerClient.describeTrainingJob(request)
println("The job status is ${jobResponse.trainingJobStatus}")
}
}
// snippet-end:[sagemaker.kotlin.describe_train_job.main]
| 248 | null | 5614 | 9,502 | 3d8f94799b9c661cd7092e03d6673efc10720e52 | 1,516 | aws-doc-sdk-examples | Apache License 2.0 |
koin-test/src/test/kotlin/org/koin/test/core/ContextReleaseTest.kt | snaplucas | 124,597,554 | true | {"Kotlin": 90742, "Shell": 622} | package org.koin.test.core
import org.junit.Assert
import org.junit.Assert.fail
import org.junit.Test
import org.koin.core.scope.Scope
import org.koin.dsl.module.Module
import org.koin.error.NoScopeFoundException
import org.koin.standalone.releaseContext
import org.koin.standalone.startKoin
import org.koin.test.KoinTest
import org.koin.test.ext.junit.*
import org.koin.test.get
class ContextReleaseTest : KoinTest {
class HierarchyContextsModule() : Module() {
override fun context() = applicationContext {
context(name = "A") {
provide { ComponentA() }
context(name = "B") {
provide { ComponentB() }
context(name = "C") {
provide { ComponentC() }
}
}
}
}
}
class ComponentA
class ComponentB
class ComponentC
@Test
fun `should release context - from B`() {
startKoin(listOf(HierarchyContextsModule()))
assertContexts(4)
assertDefinitions(3)
assertDefinedInScope(ComponentA::class, "A")
assertDefinedInScope(ComponentB::class, "B")
assertDefinedInScope(ComponentC::class, "C")
assertScopeParent("B", "A")
assertScopeParent("C", "B")
val a1 = get<ComponentA>()
val b1 = get<ComponentB>()
val c1 = get<ComponentC>()
assertRemainingInstances(3)
assertContextInstances("A", 1)
assertContextInstances("B", 1)
assertContextInstances("C", 1)
releaseContext("B")
assertRemainingInstances(1)
assertContextInstances("A", 1)
assertContextInstances("B", 0)
assertContextInstances("C", 0)
val a2 = get<ComponentA>()
val b2 = get<ComponentB>()
val c2 = get<ComponentC>()
assertRemainingInstances(3)
assertContextInstances("A", 1)
assertContextInstances("B", 1)
assertContextInstances("C", 1)
Assert.assertEquals(a1, a2)
Assert.assertNotEquals(b1, b2)
Assert.assertNotEquals(c1, c2)
}
@Test
fun `should release context - from A`() {
startKoin(listOf(HierarchyContextsModule()))
assertContexts(4)
assertDefinitions(3)
assertDefinedInScope(ComponentA::class, "A")
assertDefinedInScope(ComponentB::class, "B")
assertDefinedInScope(ComponentC::class, "C")
assertScopeParent("B", "A")
assertScopeParent("C", "B")
val a1 = get<ComponentA>()
val b1 = get<ComponentB>()
val c1 = get<ComponentC>()
assertRemainingInstances(3)
assertContextInstances("A", 1)
assertContextInstances("B", 1)
assertContextInstances("C", 1)
releaseContext("A")
assertRemainingInstances(0)
assertContextInstances("A", 0)
assertContextInstances("B", 0)
assertContextInstances("C", 0)
val a2 = get<ComponentA>()
val b2 = get<ComponentB>()
val c2 = get<ComponentC>()
assertRemainingInstances(3)
assertContextInstances("A", 1)
assertContextInstances("B", 1)
assertContextInstances("C", 1)
Assert.assertNotEquals(a1, a2)
Assert.assertNotEquals(b1, b2)
Assert.assertNotEquals(c1, c2)
}
@Test
fun `should release context - from ROOT`() {
startKoin(listOf(HierarchyContextsModule()))
assertContexts(4)
assertDefinitions(3)
assertDefinedInScope(ComponentA::class, "A")
assertDefinedInScope(ComponentB::class, "B")
assertDefinedInScope(ComponentC::class, "C")
assertScopeParent("B", "A")
assertScopeParent("C", "B")
val a1 = get<ComponentA>()
val b1 = get<ComponentB>()
val c1 = get<ComponentC>()
assertRemainingInstances(3)
assertContextInstances("A", 1)
assertContextInstances("B", 1)
assertContextInstances("C", 1)
releaseContext(Scope.ROOT)
assertRemainingInstances(0)
assertContextInstances("A", 0)
assertContextInstances("B", 0)
assertContextInstances("C", 0)
val a2 = get<ComponentA>()
val b2 = get<ComponentB>()
val c2 = get<ComponentC>()
assertRemainingInstances(3)
assertContextInstances("A", 1)
assertContextInstances("B", 1)
assertContextInstances("C", 1)
Assert.assertNotEquals(a1, a2)
Assert.assertNotEquals(b1, b2)
Assert.assertNotEquals(c1, c2)
}
@Test
fun `should release context - from C`() {
startKoin(listOf(HierarchyContextsModule()))
assertContexts(4)
assertDefinitions(3)
assertDefinedInScope(ComponentA::class, "A")
assertDefinedInScope(ComponentB::class, "B")
assertDefinedInScope(ComponentC::class, "C")
assertScopeParent("B", "A")
assertScopeParent("C", "B")
val a1 = get<ComponentA>()
val b1 = get<ComponentB>()
val c1 = get<ComponentC>()
assertRemainingInstances(3)
assertContextInstances("A", 1)
assertContextInstances("B", 1)
assertContextInstances("C", 1)
releaseContext("C")
assertRemainingInstances(2)
assertContextInstances("A", 1)
assertContextInstances("B", 1)
assertContextInstances("C", 0)
val a2 = get<ComponentA>()
val b2 = get<ComponentB>()
val c2 = get<ComponentC>()
assertRemainingInstances(3)
assertContextInstances("A", 1)
assertContextInstances("B", 1)
assertContextInstances("C", 1)
Assert.assertEquals(a1, a2)
Assert.assertEquals(b1, b2)
Assert.assertNotEquals(c1, c2)
}
@Test
fun `should not release context - unknown context`() {
startKoin(listOf(HierarchyContextsModule()))
assertContexts(4)
assertDefinitions(3)
assertDefinedInScope(ComponentA::class, "A")
assertDefinedInScope(ComponentB::class, "B")
assertDefinedInScope(ComponentC::class, "C")
assertScopeParent("B", "A")
assertScopeParent("C", "B")
Assert.assertNotNull(get<ComponentA>())
Assert.assertNotNull(get<ComponentB>())
Assert.assertNotNull(get<ComponentC>())
assertRemainingInstances(3)
assertContextInstances("A", 1)
assertContextInstances("B", 1)
assertContextInstances("C", 1)
try {
releaseContext("D")
fail()
} catch (e: NoScopeFoundException) {
}
assertRemainingInstances(3)
assertContextInstances("A", 1)
assertContextInstances("B", 1)
assertContextInstances("C", 1)
}
} | 0 | Kotlin | 0 | 0 | 8793915f270983c063bee9ffaf0ae75c40c7ac12 | 6,807 | koin | Apache License 2.0 |
app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollPrimaryDescription.kt | vitorpamplona | 587,850,619 | false | {"Kotlin": 3170921, "Shell": 1485, "Java": 921} | package com.vitorpamplona.amethyst.ui.components
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.KeyboardCapitalization
import androidx.compose.ui.text.style.TextDirection
import androidx.compose.ui.unit.dp
import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.ui.actions.NewPostViewModel
import com.vitorpamplona.amethyst.ui.actions.UrlUserTagTransformation
@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun NewPollPrimaryDescription(pollViewModel: NewPostViewModel) {
// initialize focus reference to be able to request focus programmatically
val focusRequester = remember { FocusRequester() }
val keyboardController = LocalSoftwareKeyboardController.current
var isInputValid = true
if (pollViewModel.message.text.isEmpty()) {
isInputValid = false
}
val colorInValid = TextFieldDefaults.outlinedTextFieldColors(
focusedBorderColor = MaterialTheme.colors.error,
unfocusedBorderColor = Color.Red
)
val colorValid = TextFieldDefaults.outlinedTextFieldColors(
focusedBorderColor = MaterialTheme.colors.primary,
unfocusedBorderColor = MaterialTheme.colors.onSurface.copy(alpha = 0.32f)
)
OutlinedTextField(
value = pollViewModel.message,
onValueChange = {
pollViewModel.updateMessage(it)
},
label = {
Text(
text = stringResource(R.string.poll_primary_description),
color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f)
)
},
keyboardOptions = KeyboardOptions.Default.copy(
capitalization = KeyboardCapitalization.Sentences
),
modifier = Modifier
.fillMaxWidth()
.padding(top = 8.dp)
.focusRequester(focusRequester)
.onFocusChanged {
if (it.isFocused) {
keyboardController?.show()
}
},
placeholder = {
Text(
text = stringResource(R.string.poll_primary_description),
color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f)
)
},
colors = if (isInputValid) colorValid else colorInValid,
visualTransformation = UrlUserTagTransformation(MaterialTheme.colors.primary),
textStyle = LocalTextStyle.current.copy(textDirection = TextDirection.Content)
)
}
| 157 | Kotlin | 88 | 981 | 2de3d19a34b97c012e39b203070d9c1c0b1f0520 | 3,024 | amethyst | MIT License |
app/src/main/java/com/pixaby/arpan/arch/mvi/IModel.kt | arpanpeter | 532,363,756 | false | null |
package com.pixaby.arpan.arch.mvi
import androidx.lifecycle.LiveData
import kotlinx.coroutines.channels.Channel
interface IModel<S: IState, I: IAction> {
val actions: Channel<I>
val state: LiveData<S>
} | 0 | Kotlin | 0 | 0 | f10a6d45429a0d27ad58b882961607d35d7b069c | 213 | Pixo | Apache License 2.0 |
src/test/kotlin/core/simulator/ExporterTests.kt | dfialho | 97,379,051 | false | null | package core.simulator
import core.routing.Message
import core.routing.Route
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.greaterThan
import org.jetbrains.spek.api.Spek
import org.jetbrains.spek.api.dsl.given
import org.jetbrains.spek.api.dsl.it
import org.jetbrains.spek.api.dsl.on
import testing.invalidRoute
import testing.node
import testing.someExtender
/**
* Created on 22-07-2017
*
* @author <NAME>
*/
object ExporterTests : Spek({
/**
* Returns a message.
*/
fun message(): Message<Route> {
return Message(node(1), node(2), invalidRoute(), someExtender())
}
given("an exporter using a random delay generator") {
// Change message delay generator to random generator
Engine.messageDelayGenerator = RandomDelayGenerator.with(min = 1, max = 10, seed = 10L)
afterGroup {
Engine.resetToDefaults()
}
val exporter = Exporter<Route>()
on("exporting 100 messages") {
it("keeps the deliver time of each message higher than the previous one") {
var previousDeliverTime = 0
var deliverTime = exporter.export(message())
for (i in 1..99) {
assertThat(deliverTime, greaterThan(previousDeliverTime))
previousDeliverTime = deliverTime
deliverTime = exporter.export(message())
}
}
}
}
})
| 0 | Kotlin | 0 | 0 | 7e637089290bdd568e7401ca8f728ebe9906cb34 | 1,479 | routing-simulator | MIT License |
src/test/kotlin/core/simulator/ExporterTests.kt | dfialho | 97,379,051 | false | null | package core.simulator
import core.routing.Message
import core.routing.Route
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.greaterThan
import org.jetbrains.spek.api.Spek
import org.jetbrains.spek.api.dsl.given
import org.jetbrains.spek.api.dsl.it
import org.jetbrains.spek.api.dsl.on
import testing.invalidRoute
import testing.node
import testing.someExtender
/**
* Created on 22-07-2017
*
* @author David Fialho
*/
object ExporterTests : Spek({
/**
* Returns a message.
*/
fun message(): Message<Route> {
return Message(node(1), node(2), invalidRoute(), someExtender())
}
given("an exporter using a random delay generator") {
// Change message delay generator to random generator
Engine.messageDelayGenerator = RandomDelayGenerator.with(min = 1, max = 10, seed = 10L)
afterGroup {
Engine.resetToDefaults()
}
val exporter = Exporter<Route>()
on("exporting 100 messages") {
it("keeps the deliver time of each message higher than the previous one") {
var previousDeliverTime = 0
var deliverTime = exporter.export(message())
for (i in 1..99) {
assertThat(deliverTime, greaterThan(previousDeliverTime))
previousDeliverTime = deliverTime
deliverTime = exporter.export(message())
}
}
}
}
})
| 0 | Kotlin | 0 | 0 | 7e637089290bdd568e7401ca8f728ebe9906cb34 | 1,485 | routing-simulator | MIT License |
ultron/src/main/java/com/atiurin/ultron/extensions/PerfomOnViewExt.kt | open-tool | 312,407,423 | false | null | package com.atiurin.ultron.extensions
import android.view.View
import androidx.test.espresso.DataInteraction
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.ViewInteraction
import com.atiurin.ultron.core.espresso.UltronEspressoInteraction
import com.atiurin.ultron.custom.espresso.action.CustomEspressoActionType.PERFORM_ON_VIEW
import com.atiurin.ultron.custom.espresso.action.CustomEspressoActionType.PERFORM_ON_VIEW_FORCIBLY
import com.atiurin.ultron.custom.espresso.action.getView
import com.atiurin.ultron.custom.espresso.base.UltronViewFinder
import com.atiurin.ultron.utils.runOnUiThread
import org.hamcrest.Matcher
/**
* Ultron is not responsible for the outcome of these actions.
* If you use this approach, you clearly understand what you are doing.
*/
fun View.performOnView(action: View.() -> Unit) {
runOnUiThread {
action(this)
}
}
/**
* Actual time execution could be timeout*2
* as we are getting view and then perform provided action.
*/
fun <T> UltronEspressoInteraction<T>.performOnView(action: View.() -> Unit) {
val view = this.getView()
executeAction(
operationBlock = { view.performOnView(action) },
name = "Perform on view with '${getInteractionMatcher()}' in root '${getInteractionRootMatcher()}'",
type = PERFORM_ON_VIEW,
description = "${interaction.className()} perform $action on view '$PERFORM_ON_VIEW' of '${getInteractionMatcher()}' with root '${getInteractionRootMatcher()}' during ${getActionTimeout()} ms",
)
}
fun <T> UltronEspressoInteraction<T>.performOnViewForcibly(action: View.() -> Unit) {
executeAction(
operationBlock = { UltronViewFinder(interaction).view.performOnView(action) },
name = "Perform forcibly on view with '${getInteractionMatcher()}' in root '${getInteractionRootMatcher()}'",
type = PERFORM_ON_VIEW_FORCIBLY,
description = "${interaction.className()} perform $action forcibly on view '$PERFORM_ON_VIEW_FORCIBLY' of '${getInteractionMatcher()}' with root '${getInteractionRootMatcher()}' during ${getActionTimeout()} ms",
)
}
/**
* Performs the given [action] on the view matched by this matcher on the MainThread.
*
* Obtaining of the view is based on the common espresso idle state mechanism.
*/
fun Matcher<View>.performOnView(action: View.() -> Unit) = UltronEspressoInteraction(onView(this)).performOnView(action)
fun ViewInteraction.performOnView(action: View.() -> Unit) = UltronEspressoInteraction(this).performOnView(action)
fun DataInteraction.performOnView(action: View.() -> Unit) = UltronEspressoInteraction(this).performOnView(action)
/**
* Performs the given [action] on the view matched by this matcher on the MainThread.
*
* The difference between `performOnViewForcibly()` and `performOnView()` is that in the first method,
* obtaining of the view is not bound to the common espresso idle state mechanism.
*/
fun Matcher<View>.performOnViewForcibly(action: View.() -> Unit) = UltronEspressoInteraction(onView(this)).performOnViewForcibly(action)
fun ViewInteraction.performOnViewForcibly(action: View.() -> Unit) = UltronEspressoInteraction(this).performOnViewForcibly(action)
fun DataInteraction.performOnViewForcibly(action: View.() -> Unit) = UltronEspressoInteraction(this).performOnViewForcibly(action) | 8 | Kotlin | 9 | 44 | d5f8ae5a592aa44c4aa2bb59ec92c9b7e9a66679 | 3,333 | ultron | Apache License 2.0 |
app/src/main/java/com/zobaer53/zedmovies/data/database/source/TvShowDetailsDatabaseDataSource.kt | zobaer53 | 661,586,013 | false | {"Kotlin": 498107, "JavaScript": 344099, "C++": 10825, "CMake": 2160} | package com.zobaer53.zedmovies.data.database.source
import com.zobaer53.zedmovies.data.database.dao.tvshow.TvShowDetailsDao
import com.zobaer53.zedmovies.data.database.model.tvshow.TvShowDetailsEntity
import com.zobaer53.zedmovies.data.database.util.zedMoviesDatabaseTransactionProvider
import javax.inject.Inject
class TvShowDetailsDatabaseDataSource @Inject constructor(
private val tvShowDetailsDao: TvShowDetailsDao,
private val transactionProvider: zedMoviesDatabaseTransactionProvider
) {
fun getById(id: Int) = tvShowDetailsDao.getById(id)
fun getByIds(ids: List<Int>) = tvShowDetailsDao.getByIds(ids)
suspend fun deleteAndInsert(tvShowDetails: TvShowDetailsEntity) =
transactionProvider.runWithTransaction {
tvShowDetailsDao.deleteById(id = tvShowDetails.id)
tvShowDetailsDao.insert(tvShowDetails)
}
suspend fun deleteAndInsertAll(tvShowDetailsList: List<TvShowDetailsEntity>) =
transactionProvider.runWithTransaction {
tvShowDetailsList.forEach { tvShowDetails ->
tvShowDetailsDao.deleteById(id = tvShowDetails.id)
tvShowDetailsDao.insert(tvShowDetails)
}
}
}
| 0 | Kotlin | 3 | 6 | 1e70d46924b711942b573364745fa74ef1f8493f | 1,209 | NoFlix | Apache License 2.0 |
app/src/main/java/ca/hojat/gamehub/core/domain/games/usecases/RefreshMostAnticipatedGamesUseCase.kt | hojat72elect | 574,228,468 | false | {"Kotlin": 912868, "Shell": 539} | package ca.hojat.gamehub.core.domain.games.usecases
import ca.hojat.gamehub.core.domain.common.DispatcherProvider
import ca.hojat.gamehub.core.domain.DomainResult
import ca.hojat.gamehub.core.extensions.onEachSuccess
import ca.hojat.gamehub.core.domain.games.RefreshableGamesUseCase
import ca.hojat.gamehub.core.domain.games.common.RefreshUseCaseParams
import ca.hojat.gamehub.core.domain.games.common.throttling.GamesRefreshingThrottlerTools
import ca.hojat.gamehub.core.domain.games.repository.GamesRepository
import ca.hojat.gamehub.core.domain.entities.Game
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn
import javax.inject.Inject
import javax.inject.Singleton
interface RefreshMostAnticipatedGamesUseCase : RefreshableGamesUseCase
@Singleton
class RefreshMostAnticipatedGamesUseCaseImpl @Inject constructor(
private val gamesRepository: GamesRepository,
private val throttlerTools: GamesRefreshingThrottlerTools,
private val dispatcherProvider: DispatcherProvider,
) : RefreshMostAnticipatedGamesUseCase {
override fun execute(params: RefreshUseCaseParams): Flow<DomainResult<List<Game>>> {
val throttlerKey =
throttlerTools.keyProvider.provideMostAnticipatedGamesKey(params.pagination)
return flow {
if (throttlerTools.throttler.canRefreshGames(throttlerKey)) {
emit(gamesRepository.remote.getMostAnticipatedGames(params.pagination))
}
}
.onEachSuccess { games ->
gamesRepository.local.saveGames(games)
throttlerTools.throttler.updateGamesLastRefreshTime(throttlerKey)
}
.flowOn(dispatcherProvider.main)
}
}
| 0 | Kotlin | 8 | 14 | 0d89fb6e48ea00eb2063b9c415c924730be0a29a | 1,747 | GameHub | MIT License |
src/main/kotlin/com/projectcitybuild/modules/sharedcache/SharedCacheSet.kt | projectcitybuild | 42,997,941 | false | null | package com.projectcitybuild.modules.sharedcache
/**
* Represents a cachable String Set that is shared between all servers.
*
* Anything that conforms to this interface must guarantee that
* regardless of which server it's used from, the underlying
* data will be synchronised.
*/
interface SharedCacheSet {
var key: String
fun has(value: String): Boolean
fun add(value: String)
fun add(values: List<String>)
fun remove(value: String)
fun removeAll()
fun all(): Set<String>
}
| 23 | Kotlin | 0 | 2 | 24c6a86aee15535c3122ba6fb57cc7ca351e32bb | 513 | PCBridge | MIT License |
buildSrc/src/main/kotlin/Deps.kt | S-H-Y-A | 454,439,254 | false | null | object Deps {
const val gson = "com.google.code.gson:gson:_"
const val numberPicker = "com.chargemap.compose:numberpicker:_"
object Project {
const val kotlinDataStore = ":core"
const val dataStoreInitializer = ":initializer"
const val dataStoreEnum = ":enum"
const val dataStoreMoshi = ":moshi"
const val dataStoreGson = ":gson"
const val dataStoreCompose = ":compose"
}
} | 0 | Kotlin | 0 | 4 | 575a5f5b604de0a6f86a08b0ade33bac2fd7b0b4 | 438 | KotlinDataStore | Apache License 2.0 |
app/src/main/java/com/weesnerdevelopment/serialcabinet/components/BasicListItem.kt | adamWeesner | 316,896,304 | false | null | package com.weesnerdevelopment.serialcabinet.components
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.dimensionResource
import com.weesnerdevelopment.serialcabinet.R
@Composable
fun BasicListItem(
name: String,
selected: Boolean,
click: () -> Unit
) {
Column(
modifier = Modifier
.fillMaxWidth()
.clickable(onClick = click)
.background(
if (selected) MaterialTheme.colors.secondary.copy(.8f)
else MaterialTheme.colors.surface
)
) {
Text(
color = if (selected) MaterialTheme.colors.onSecondary else MaterialTheme.colors.onSurface,
text = name,
modifier = Modifier.padding(dimensionResource(R.dimen.space_double))
)
}
}
| 0 | Kotlin | 0 | 0 | eb954995ee9ebe1b9b15dee8163f2b880649b2a7 | 1,178 | Serial-Cabinet | MIT License |
plugins/dependencies/src/main/kotlin/dependencies/_ALL.kt | Splitties | 150,827,271 | false | {"Kotlin": 808317, "Shell": 2793, "Just": 1182, "Java": 89, "Groovy": 24} | // The name of this file starts with an underscore to make it prominent in the file list.
package dependencies
import AndroidX
import COIL
import CashApp
import Firebase
import Google
import Http4k
import JakeWharton
import Kodein
import Koin
import Kotlin
import KotlinX
import Ktor
import Orchid
import RussHWolf
import Splitties
import Spring
import Square
import Testing
import Touchlab
// All top-level objects holding dependency notations shall be added in this list.
internal val ALL_DEPENDENCIES_NOTATIONS = listOf(
AndroidX,
CashApp,
COIL,
Firebase,
Google,
Http4k,
JakeWharton,
Kodein,
Koin,
Kotlin,
KotlinX,
Ktor,
RussHWolf,
Orchid,
Splitties,
Spring,
Square,
Testing,
Touchlab
)
| 81 | Kotlin | 92 | 1,606 | df624c0fb781cb6e0de054a2b9d44808687e4fc8 | 770 | refreshVersions | MIT License |
src/commonTest/kotlin/com.adamratzman/spotify/pub/BrowseApiTest.kt | adamint | 104,819,774 | false | {"Kotlin": 790142, "Shell": 443, "JavaScript": 154} | /* Spotify Web API, Kotlin Wrapper; MIT License, 2017-2022; Original author: <NAME> */
@file:OptIn(ExperimentalCoroutinesApi::class)
package com.adamratzman.spotify.pub
import com.adamratzman.spotify.AbstractTest
import com.adamratzman.spotify.GenericSpotifyApi
import com.adamratzman.spotify.SpotifyException
import com.adamratzman.spotify.endpoints.pub.TuneableTrackAttribute
import com.adamratzman.spotify.runTestOnDefaultDispatcher
import com.adamratzman.spotify.utils.Locale
import com.adamratzman.spotify.utils.Market
import com.adamratzman.spotify.utils.getCurrentTimeMs
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.TestResult
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertNotEquals
import kotlin.test.assertNotNull
import kotlin.test.assertNotSame
import kotlin.test.assertTrue
class BrowseApiTest : AbstractTest<GenericSpotifyApi>() {
@Test
fun testGenreSeeds(): TestResult = runTestOnDefaultDispatcher {
buildApi(::testGenreSeeds.name)
assertTrue(api.browse.getAvailableGenreSeeds().isNotEmpty())
}
@Test
fun testGetCategoryList(): TestResult = runTestOnDefaultDispatcher {
buildApi(::testGetCategoryList.name)
assertNotSame(
api.browse.getCategoryList(locale = Locale.AR_AE).items[0],
api.browse.getCategoryList().items[0]
)
assertTrue(api.browse.getCategoryList(4, 3, market = Market.CA).items.isNotEmpty())
assertTrue(api.browse.getCategoryList(4, 3, locale = Locale.FR_FR, market = Market.CA).items.isNotEmpty())
}
@Test
fun testGetCategory(): TestResult = runTestOnDefaultDispatcher {
buildApi(::testGetCategory.name)
val firstCategoryId = api.browse.getCategoryList(limit = 1, market = Market.FR).first()!!.id
assertNotNull(api.browse.getCategory(firstCategoryId))
assertNotNull(api.browse.getCategory(firstCategoryId, Market.FR))
assertNotNull(api.browse.getCategory(firstCategoryId, Market.FR, locale = Locale.EN_US))
assertNotNull(api.browse.getCategory(firstCategoryId, Market.FR, locale = Locale.SR_ME))
assertFailsWith<SpotifyException.BadRequestException> { api.browse.getCategory("no u", Market.US) }
}
@Test
fun testGetPlaylistsByCategory(): TestResult = runTestOnDefaultDispatcher {
buildApi(::testGetPlaylistsByCategory.name)
assertFailsWith<SpotifyException.BadRequestException> {
api.browse.getPlaylistsForCategory(
"no u",
limit = 4
)
}
assertTrue(
api.browse.getPlaylistsForCategory(
api.browse.getCategoryList(limit = 1).first()!!.id,
10,
0,
Market.FR
).items.isNotEmpty()
)
}
@Test
fun testGetFeaturedPlaylists(): TestResult = runTestOnDefaultDispatcher {
buildApi(::testGetFeaturedPlaylists.name)
assertTrue(
api.browse.getFeaturedPlaylists(
5,
4,
market = Market.US,
timestamp = getCurrentTimeMs() - 10000000
).playlists.total > 0
)
assertTrue(api.browse.getFeaturedPlaylists(offset = 32).playlists.total > 0)
}
@Test
fun testGetNewReleases(): TestResult = runTestOnDefaultDispatcher {
buildApi(::testGetNewReleases.name)
assertTrue(api.browse.getNewReleases(market = Market.CA).items.isNotEmpty())
assertTrue(api.browse.getNewReleases(limit = 1, offset = 3).items.isNotEmpty())
assertTrue(api.browse.getNewReleases(limit = 6, offset = 44, market = Market.US).items.isNotEmpty())
}
@Test
fun testGetRecommendations(): TestResult = runTestOnDefaultDispatcher {
buildApi(::testGetRecommendations.name)
assertFailsWith<SpotifyException.BadRequestException> { api.browse.getTrackRecommendations() }
assertFailsWith<SpotifyException.BadRequestException> {
api.browse.getTrackRecommendations(seedArtists = listOf("abc"))
}
api.browse.getTrackRecommendations(seedArtists = listOf("1kNQXvepPjaPgUfeDAF2h6"))
assertFailsWith<SpotifyException.BadRequestException> {
api.browse.getTrackRecommendations(seedTracks = listOf("abc"))
}
api.browse.getTrackRecommendations(seedTracks = listOf("3Uyt0WO3wOopnUBCe9BaXl")).tracks
api.browse.getTrackRecommendations(
seedTracks = listOf(
"6d9iYQG2JvTTEgcndW81lt",
"3Uyt0WO3wOopnUBCe9BaXl"
)
).tracks
api.browse.getTrackRecommendations(seedGenres = listOf("abc"))
api.browse.getTrackRecommendations(seedGenres = listOf("pop"))
api.browse.getTrackRecommendations(
seedGenres = listOf(
"pop",
"latinx"
)
)
api.browse.getTrackRecommendations(
seedArtists = listOf("2C2sVVXanbOpymYBMpsi89"),
seedTracks = listOf("6d9iYQG2JvTTEgcndW81lt", "3Uyt0WO3wOopnUBCe9BaXl"),
seedGenres = listOf("pop")
)
assertFailsWith<IllegalArgumentException> {
api.browse.getTrackRecommendations(
targetAttributes = listOf(
TuneableTrackAttribute.Acousticness.asTrackAttribute(
3f
)
)
)
}
assertTrue(
api.browse.getTrackRecommendations(
targetAttributes = listOf(
TuneableTrackAttribute.Acousticness.asTrackAttribute(1f)
),
seedGenres = listOf("pop")
).tracks.isNotEmpty()
)
assertFailsWith<IllegalArgumentException> {
api.browse.getTrackRecommendations(
minAttributes = listOf(
TuneableTrackAttribute.Acousticness.asTrackAttribute(
3f
)
)
)
}
assertTrue(
api.browse.getTrackRecommendations(
minAttributes = listOf(
TuneableTrackAttribute.Acousticness.asTrackAttribute(0.5f)
),
seedGenres = listOf("pop")
).tracks.isNotEmpty()
)
assertFailsWith<SpotifyException.BadRequestException> {
api.browse.getTrackRecommendations(
maxAttributes = listOf(
TuneableTrackAttribute.Speechiness.asTrackAttribute(
0.9f
)
)
)
}
assertTrue(
api.browse.getTrackRecommendations(
maxAttributes = listOf(
TuneableTrackAttribute.Acousticness.asTrackAttribute(0.9f),
TuneableTrackAttribute.Danceability.asTrackAttribute(0.9f)
),
seedGenres = listOf("pop")
).tracks.isNotEmpty()
)
assertTrue(TuneableTrackAttribute.values().first().asTrackAttribute(0f).value == 0f)
}
@Test
fun testTuneableTrackAttributeTypes() {
val float1: TuneableTrackAttribute<*> = TuneableTrackAttribute.Speechiness
val float2: TuneableTrackAttribute<*> = TuneableTrackAttribute.Acousticness
val int1: TuneableTrackAttribute<*> = TuneableTrackAttribute.Key
val int2: TuneableTrackAttribute<*> = TuneableTrackAttribute.Popularity
assertEquals(float1.typeClass, float2.typeClass)
assertEquals(int1.typeClass, int2.typeClass)
assertNotEquals(float1.typeClass, int1.typeClass)
}
}
| 6 | Kotlin | 21 | 178 | e047800a69dc80ac00380166076b7b80a3125440 | 7,779 | spotify-web-api-kotlin | MIT License |
app/src/main/java/ru/nightgoat/weather/presentation/list/ListFragmentCallbacks.kt | NightGoat | 255,927,899 | false | {"Kotlin": 101372} | package ru.nightgoat.weather.presentation.list
import ru.nightgoat.weather.data.entity.CityEntity
interface ListFragmentCallbacks {
fun setCurrentCityAndCallCityFragment(cityName: String, cityId: Int)
fun getWeatherIcon(id: Int, dt: Long, sunrise: Long, sunset: Long): String
fun getColor(cityEntity: CityEntity): Int
fun swapPositionWithFirst(city: CityEntity)
fun updateCity(city: CityEntity)
}
| 0 | Kotlin | 0 | 2 | dddb5463ded919f43fd1450bb0fcdffc34a2752e | 419 | WeatherAndroidApp | MIT License |
compiler/src/commonMain/kotlin/com.franzmandl.compiler/ast/ClassSymbol.kt | franzmandl | 512,849,792 | false | null | package com.franzmandl.compiler.ast
import kotlinx.serialization.Serializable
@Serializable
sealed class ClassSymbol
@Serializable
sealed class HasBodySymbol : ClassSymbol() {
abstract val body: Body
} | 0 | Kotlin | 0 | 0 | a5004c6fc8fb717e076441ef55e3f8758efe252f | 205 | visopt | MIT License |
src/main/kotlin/com/waicool20/waicoolutils/Reflection.kt | waicool20 | 135,830,471 | false | null | /*
* The MIT License (MIT)
*
* Copyright (c) waicool20
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.waicool20.waicoolutils
import java.lang.reflect.Field
import java.lang.reflect.ParameterizedType
import kotlin.reflect.KClass
import kotlin.reflect.KProperty
import kotlin.reflect.KType
import kotlin.reflect.full.isSubtypeOf
import kotlin.reflect.full.starProjectedType
import kotlin.reflect.jvm.jvmErasure
/**
* Tries to convert the string to the corresponding data type specified by clazz.
*
* @param clazz Target data type as [java.lang.Class]
*
* @return Converted data type object, null if it failed or the original string if the target
* data type is not supported.
*/
fun String.toObject(clazz: Class<*>): Any? {
return when (clazz) {
Boolean::class.javaObjectType -> toBoolean()
Boolean::class.javaPrimitiveType -> toBoolean()
Byte::class.javaObjectType -> toByteOrNull()
Byte::class.javaPrimitiveType -> toByteOrNull()
Short::class.javaObjectType -> toShortOrNull()
Short::class.javaPrimitiveType -> toShortOrNull()
Int::class.javaObjectType -> toIntOrNull()
Int::class.javaPrimitiveType -> toIntOrNull()
Long::class.javaObjectType -> toLongOrNull()
Long::class.javaPrimitiveType -> toLongOrNull()
Float::class.javaObjectType -> toFloatOrNull()
Float::class.javaPrimitiveType -> toFloatOrNull()
Double::class.javaObjectType -> toDoubleOrNull()
Double::class.javaPrimitiveType -> toDoubleOrNull()
else -> this
}
}
/**
* Tries to convert the string to the corresponding data type specified by clazz.
*
* @param clazz Target data type as [kotlin.reflect.KClass]
*
* @return Converted data type object, null if it failed or the original string if the target
* data type is not supported.
*/
fun String.toObject(clazz: KClass<*>) = toObject(clazz.java)
//<editor-fold desc="JVM Reflection">
/**
* Tries to convert the given [java.lang.Class] from its wrapper form into primitive class form.
*
* @return The converted class if the primitive class for it exists else returns the original class.
*/
fun Class<*>.toPrimitive(): Class<*> {
return when (this) {
Boolean::class.javaObjectType -> Boolean::class.java
Byte::class.javaObjectType -> Byte::class.java
Short::class.javaObjectType -> Short::class.java
Int::class.javaObjectType -> Int::class.java
Long::class.javaObjectType -> Long::class.java
Float::class.javaObjectType -> Float::class.java
Double::class.javaObjectType -> Double::class.java
else -> this
}
}
/**
* Checks if a [java.lang.reflect.Field] is a generic typed field.
*
* @return True if it field is generic.
*/
fun Field.hasGenericType() = genericType is ParameterizedType
/**
* Attempts to retrieve the [java.lang.Class] of generic type of a [java.lang.reflect.Field]
*
* @param level Specifies which generic class should be retrieved, as retrieved classes may also
* have their own generics. Eg. Level 0 will retrieve List from List<List<String>>, but 1 will
* retrieve String. Defaults to 0.
*
* @return The generic class.
*/
fun Field.getGenericClass(level: Int = 0): Class<*> {
var paramType = genericType as ParameterizedType
var objType = paramType.actualTypeArguments[0]
for (i in level downTo 0) {
if (objType is ParameterizedType) {
paramType = objType
objType = paramType.actualTypeArguments[0]
}
}
return objType as Class<*>
}
//</editor-fold>
//<editor-fold desc="Kotlin Reflection">
/**
* Checks if a [kotlin.reflect.KProperty] is a generic typed field.
*
* @return True if it property is generic.
*/
fun KProperty<*>.hasGenericType() = returnType.jvmErasure.typeParameters.isNotEmpty()
/**
* Attempts to retrieve the [kotlin.reflect.KType] of generic class of a [kotlin.reflect.KProperty]
*
* @param level Specifies which generic class should be retrieved, as retrieved classes may also
* have their own generics. Eg. Level 0 will retrieve List from List<List<String>>, but 1 will
* retrieve String. Defaults to 0.
*
* @return The generic type.
*/
fun KProperty<*>.getGenericType(level: Int = 0): KType {
var type = returnType
for (i in level downTo 0) {
type.arguments.firstOrNull()?.type?.let { type = it }
}
return type
}
/**
* Attempts to retrieve the [kotlin.reflect.KClass] of generic class of a [kotlin.reflect.KProperty]
*
* @param level Specifies which generic class should be retrieved, as retrieved classes may also
* have their own generics. Eg. Level 0 will retrieve List from List<List<String>>, but 1 will
* retrieve String. Defaults to 0.
*
* @return The generic class.
*/
fun KProperty<*>.getGenericClass(level: Int = 0) = getGenericType(level).jvmErasure
/**
* Checks if the [kotlin.reflect.KClass] represents an enum value.
*
* @return True if the [kotlin.reflect.KClass] represents an enum value.
*/
fun KClass<*>.isEnum() = starProjectedType.isEnum()
/**
* Checks if the [kotlin.reflect.KType] represents an enum value.
*
* @return True if the [kotlin.reflect.KType] represents an enum value.
*/
fun KType.isEnum() = isSubtypeOf(Enum::class.starProjectedType)
/**
* Attempts to find the enum instance from the given string of the same underlying type that
* this class represents.
*
* @param string Name of enum value
*
* @return The enum instance if it was found else null
*/
fun KClass<*>.enumValueOf(string: String): Any? = java.enumConstants.find {
it.toString().equals(string, true) ||
it.toString().equals(string.replace("_", "-"), true)
}
//</editor-fold>
| 0 | Kotlin | 1 | 1 | 83c675a414800c1662e3dd33a4cde2b8246962b9 | 6,756 | waicoolUtils | MIT License |
androidDesignSystem/src/test/java/by/game/binumbers/design/system/components/button/PauseButtonTest.kt | alexander-kulikovskii | 565,271,232 | false | {"Kotlin": 454229, "Swift": 3274, "Ruby": 2480, "Shell": 622} | package by.game.binumbers.design.system.components.button
import androidx.compose.runtime.Composable
import by.game.binumbers.screenshot.test.tool.BaseComponentTest
class PauseButtonTest : BaseComponentTest() {
override val content: @Composable () -> Unit = { PauseButton() }
}
| 0 | Kotlin | 0 | 10 | 66b1678b47a96a52ebef467111d1d4854a37486a | 284 | 2048-kmm | Apache License 2.0 |
core/network/src/main/java/com/msg/network/datasource/certification/CertificationDataSource.kt | School-of-Company | 700,744,250 | false | {"Kotlin": 724178} | package com.msg.network.datasource.certification
import com.msg.model.remote.request.certification.WriteCertificationRequest
import com.msg.model.remote.response.certification.CertificationListResponse
import kotlinx.coroutines.flow.Flow
import java.util.UUID
interface CertificationDataSource {
fun getCertificationListForTeacher(studentId: UUID): Flow<List<CertificationListResponse>>
fun getCertificationListForStudent(): Flow<List<CertificationListResponse>>
fun writeCertification(body: WriteCertificationRequest): Flow<Unit>
fun editCertification(id: UUID, body: WriteCertificationRequest): Flow<Unit>
} | 6 | Kotlin | 1 | 22 | 358bf40188fa2fc2baf23aa6b308b039cb3fbc8c | 627 | Bitgoeul-Android | MIT License |
kotlin-csstype/src/main/generated/csstype/BreakInside.kt | JetBrains | 93,250,841 | false | null | // Automatically generated - do not modify!
@file:Suppress(
"NAME_CONTAINS_ILLEGAL_CHARS",
"NESTED_CLASS_IN_EXTERNAL_INTERFACE",
)
package csstype
// language=JavaScript
@JsName("""(/*union*/{avoid: 'avoid', avoidColumn: 'avoid-column', avoidPage: 'avoid-page', avoidRegion: 'avoid-region'}/*union*/)""")
sealed external interface BreakInside {
companion object {
val avoid: BreakInside
val avoidColumn: BreakInside
val avoidPage: BreakInside
val avoidRegion: BreakInside
}
}
| 13 | null | 6 | 983 | 7ef1028ba3e0982dc93edcdfa6ee1edb334ddf35 | 527 | kotlin-wrappers | Apache License 2.0 |
glimpse/core/src/commonMain/kotlin/GlimpseDisposableContainer.kt | glimpse-graphics | 319,730,354 | false | null | /*
* Copyright 2020-2022 <NAME>
*
* 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package graphics.glimpse
/**
* A disposable container for disposable Glimpse objects.
*
* After disposed, this container becomes empty and ready to be filled again.
* Thus, [isDisposed] is always `false` for this object.
*
* @since v1.2.0
*/
class GlimpseDisposableContainer : GlimpseDisposable {
private val disposables = mutableSetOf<GlimpseDisposable>()
/**
* Always `false`.
*/
override val isDisposed: Boolean = false
/**
* Adds given [disposable] to this container.
*
* Returns `true` if the disposable was added to this container.
* If the disposable was already in the container before, returns `false`.
*/
fun add(disposable: GlimpseDisposable): Boolean = synchronized(disposables) {
disposables.add(disposable)
}
/**
* Adds all [disposables] from given collection to this container.
*
* Returns `true` if the contents of this container have changed as a result of the operation.
*/
fun addAll(disposables: Collection<GlimpseDisposable>): Boolean = synchronized(disposables) {
this.disposables.addAll(disposables)
}
/**
* Disposes all disposables in this container.
*
* @throws IllegalStateException if any of the disposables in this container has previously been disposed.
*/
override fun dispose(gl: GlimpseAdapter) {
synchronized(disposables) {
for (disposable in disposables) {
disposable.dispose(gl)
}
disposables.clear()
}
}
/**
* Disposes all undisposed disposables in this container.
*/
fun disposeUndisposed(gl: GlimpseAdapter) {
synchronized(disposables) {
for (disposable in disposables) {
if (!disposable.isDisposed) {
disposable.dispose(gl)
}
}
disposables.clear()
}
}
}
| 7 | null | 0 | 6 | e00a9f22db9e10493e7711d5dd8524eb7b06be77 | 2,536 | glimpse | Apache License 2.0 |
roboquant-xchange/src/main/kotlin/org/roboquant/xchange/XChangePollingLiveFeed.kt | neurallayer | 406,929,056 | false | null | /*
* Copyright 2020-2024 Neural Layer
*
* 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
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.roboquant.xchange
import kotlinx.coroutines.delay
import org.knowm.xchange.Exchange
import org.knowm.xchange.currency.CurrencyPair
import org.knowm.xchange.instrument.Instrument
import org.roboquant.common.*
import org.roboquant.feeds.Event
import org.roboquant.feeds.LiveFeed
import org.roboquant.feeds.TradePrice
/**
* Get live-streaming feeds from dozens of bitcoin exchanges. This feed uses the XChange library
* to connect to the different exchanges to get the trade and order book feeds for a currency pair, using polling.
*
* XChange is a Java library providing a streamlined API for interacting with 60+ Bitcoin and Altcoin exchanges,
* providing a consistent interface for trading and accessing market data.
*
* See also https://knowm.org/open-source/xchange/
* @constructor
*
* @param exchange the exchange instance to use. The connection to the provided exchange should already be live.
*/
class XChangePollingLiveFeed(
exchange: Exchange,
) : LiveFeed() {
private val logger = Logging.getLogger(XChangePollingLiveFeed::class)
private val service = exchange.marketDataService
private val exchangeName = exchange.exchangeSpecification?.exchangeName ?: exchange.toString()
private val jobs = ParallelJobs()
/**
* Assets that are available to subscribe to
*/
val availableAssets by lazy {
val symbols = exchange.exchangeInstruments
if (symbols == null) {
logger.warn("No symbols available")
listOf<Asset>()
} else {
symbols.map {
val symbol = "${it.base.currencyCode}_${it.counter.currencyCode}"
Asset(symbol, AssetType.CRYPTO, it.counter.currencyCode, exchangeName)
}
}
}
private val assetMap = mutableMapOf<String, Asset>()
/**
* Assets that are subscribed to
*/
val assets
get() = assetMap.values
/**
* Subscribe to live trade updates from the exchange. The resulting actions will be of the
* type of [TradePrice] events.
*/
fun subscribeTrade(vararg symbols: String, pollingDelayMillis: Int = 60_000) {
for (symbol in symbols) assetMap[symbol] = getAsset(symbol)
jobs.add {
var done = false
while (!done) {
for (symbol in symbols) {
val currencyPair =
symbol.toCurrencyPair() ?: throw RoboquantException("could determine currency pair for $symbol")
val cryptoPair: Instrument =
CurrencyPair(currencyPair.first.currencyCode, currencyPair.second.currencyCode)
val result = service.getTrades(cryptoPair)
for (trade in result.trades) {
println(trade)
val asset = assetMap.getValue(symbol)
val item = TradePrice(asset, trade.price.toDouble(), trade.originalAmount.toDouble())
val now = trade.timestamp.toInstant()
val event = Event(listOf(item), now)
send(event)
}
}
delay(pollingDelayMillis.toLong())
done = !isActive
}
}
}
/**
* Stop all running jobs
*/
override fun close() = jobs.cancelAll()
/**
* Get an asset based on a cryptocurrency pair.
*
* @return
*/
private fun getAsset(symbol: String): Asset {
val currencyPair =
symbol.toCurrencyPair() ?: throw RoboquantException("could determine currency pair for $symbol")
return Asset(symbol, AssetType.CRYPTO, currencyPair.second.currencyCode, exchangeName)
}
}
| 8 | null | 9 | 316 | 769f1aade1e8e95817591866faad4561f7768071 | 4,367 | roboquant | Apache License 2.0 |
character-detail/src/main/java/com/ezike/tobenna/starwarssearch/characterdetail/presentation/CharacterDetailViewStateReducer.kt | Ezike | 294,171,829 | false | {"Kotlin": 190343, "Shell": 657} | package com.ezike.tobenna.starwarssearch.characterdetail.presentation
import com.ezike.tobenna.starwarssearch.characterdetail.mapper.FilmModelMapper
import com.ezike.tobenna.starwarssearch.characterdetail.mapper.PlanetModelMapper
import com.ezike.tobenna.starwarssearch.characterdetail.mapper.SpecieModelMapper
import com.ezike.tobenna.starwarssearch.characterdetail.presentation.CharacterDetailViewResult.CharacterDetail
import com.ezike.tobenna.starwarssearch.characterdetail.presentation.CharacterDetailViewResult.FetchCharacterDetailError
import com.ezike.tobenna.starwarssearch.characterdetail.presentation.viewstate.CharacterDetailViewState
import com.ezike.tobenna.starwarssearch.characterdetail.presentation.viewstate.translateTo
import com.ezike.tobenna.starwarssearch.characterdetail.ui.views.profile.ProfileViewStateFactory
import com.ezike.tobenna.starwarssearch.core.ext.errorMessage
import javax.inject.Inject
internal class CharacterDetailViewStateReducer @Inject constructor(
private val planetModelMapper: PlanetModelMapper,
private val specieModelMapper: SpecieModelMapper,
private val filmModelMapper: FilmModelMapper,
) : CharacterDetailStateReducer {
override fun reduce(
oldState: CharacterDetailViewState,
result: CharacterDetailViewResult
): CharacterDetailViewState {
return when (result) {
is CharacterDetail -> oldState.translateTo {
profileState(
profileViewState = ProfileViewStateFactory.create(model = result.character)
)
}
is FetchCharacterDetailError -> oldState.translateTo {
errorState(
characterName = result.characterName,
error = result.error.errorMessage
)
}
CharacterDetailViewResult.Retrying -> oldState.translateTo { retryState }
is PlanetDetailViewResult -> makePlanetState(result, oldState)
is SpecieDetailViewResult -> makeSpecieState(result, oldState)
is FilmDetailViewResult -> makeFilmState(result, oldState)
}
}
private fun makeFilmState(
result: FilmDetailViewResult,
previous: CharacterDetailViewState
): CharacterDetailViewState {
return when (result) {
is FilmDetailViewResult.Success ->
previous.translateTo {
filmState { Success(filmModelMapper.mapToModelList(result.film)) }
}
is FilmDetailViewResult.Error ->
previous.translateTo { filmState { Error(result.error.errorMessage) } }
FilmDetailViewResult.Loading -> previous.translateTo { filmState { Loading } }
}
}
private fun makeSpecieState(
result: SpecieDetailViewResult,
previous: CharacterDetailViewState
): CharacterDetailViewState {
return when (result) {
is SpecieDetailViewResult.Success ->
previous.translateTo {
specieState { DataLoaded(specieModelMapper.mapToModelList(result.specie)) }
}
is SpecieDetailViewResult.Error ->
previous.translateTo { specieState { Error(result.error.errorMessage) } }
SpecieDetailViewResult.Loading -> previous.translateTo { specieState { Loading } }
}
}
private fun makePlanetState(
result: PlanetDetailViewResult,
previous: CharacterDetailViewState
): CharacterDetailViewState {
return when (result) {
is PlanetDetailViewResult.Success ->
previous.translateTo {
planetState { Success(planetModelMapper.mapToModel(result.planet)) }
}
is PlanetDetailViewResult.Error ->
previous.translateTo { planetState { Error(result.error.errorMessage) } }
PlanetDetailViewResult.Loading -> previous.translateTo { planetState { Loading } }
}
}
}
| 0 | Kotlin | 30 | 198 | f091dc9b19b0a4b5b38d27c5331a4d70388f970d | 4,008 | StarWarsSearch-MVI | Apache License 2.0 |
src/main/kotlin/synchro/Profile.kt | wolfgangasdf | 163,865,648 | false | null | package synchro
import javafx.concurrent.Worker
import mu.KotlinLogging
import store.*
import synchro.Actions.A_CACHEONLY
import synchro.Actions.A_ISEQUAL
import synchro.Actions.A_MERGE
import synchro.Actions.A_RMBOTH
import synchro.Actions.A_RMLOCAL
import synchro.Actions.A_RMREMOTE
import synchro.Actions.A_SKIP
import synchro.Actions.A_SYNCERROR
import synchro.Actions.A_UNCHECKED
import synchro.Actions.A_UNKNOWN
import synchro.Actions.A_USELOCAL
import synchro.Actions.A_USEREMOTE
import util.*
import util.Helpers.dialogOkCancel
import util.Helpers.runUIwait
private val logger = KotlinLogging.logger {}
// subfolder can be single-file entry (for sync single file)
class Profile(private val server: Server, private val sync: Sync, private val subfolder: SubSet) {
var cache = Cache(sync.cacheid.value)
var local: GeneralConnection? = null
var remote: GeneralConnection? = null
private val uiUpdateInterval = 0.5
var profileInitialized = false
fun taskIni() = MyTask {
updateTit("Initialize connections...")
cache.loadCache()
val localproto = Protocol(server, SSP("localproto"), SSP("file://"), SBP(false),
SSP(""), SBP(false),
SSP(sync.localfolder.value), SSP(""), SSP(""), SSP(SettingsStore.tunnelModes[0]))
local = LocalConnection(localproto)
local!!.assignRemoteBasePath("")
val uri = MyURI(server.getProtocol().protocoluri.value)
logger.debug("puri = ${server.getProtocol().protocoluri.value} proto = ${uri.protocol}")
updateProgr(50, 100, "initialize remote connection...")
remote = server.getConnection(sync.remoteFolder.value)
remote!!.permsOverride = sync.permsOverride.value
profileInitialized = true
updateProgr(100, 100, "done!")
}
fun taskCompFiles(useNewFiles: Boolean = false) = MyTask {
logger.info("taskCompFiles: usenewfiles=$useNewFiles server=$server sync=$sync subfolder=$subfolder")
updateTit("CompareFiles...")
val sw = StopWatch() // for timing meas
// reset table
updateProgr(0, 100, "resetting database...")
var cacheall = false
for (sf in subfolder.subfolders) if (sf == "") cacheall = true
// remove cache orphans (happens if user doesn't click synchronize
cache.cache.iterate { iter, _, se -> if (se.cSize == -1L) iter.remove() }
// ini files
cache.cache.iterate { _, path, se ->
var addit = cacheall
if (!cacheall) for (sf in subfolder.subfolders) if (path.startsWith(sf)) addit = true
if (addit) {
se.action = A_UNCHECKED; se.lSize = -1; se.lTime = -1; se.rSize = -1; se.rTime = -1; se.relevant = true
} else {
se.relevant = false
}
}
logger.debug("sw: resetting table: " + sw.getTimeRestart())
updateProgr(50, 100, "Find files local and remote...")
val swUIupdate = StopWatch()
fun acLocRem(vf: VirtualFile, isloc: Boolean, updact: (VirtualFile) -> Unit) {
//logger.debug("aclocrem: isloc=$isloc vf=$vf")
if (swUIupdate.doit(uiUpdateInterval)) updact(vf)
cache.cache.merge(vf.path,
SyncEntry(A_UNCHECKED, if (isloc) vf.modTime else 0, if (isloc) vf.size else -1,
if (!isloc) vf.modTime else 0, if (!isloc) vf.size else -1,
0, 0, -1, vf.isDir(), true)
) { ov, _ ->
if (isloc) {
ov.lTime = vf.modTime
ov.lSize = vf.size
} else {
ov.rTime = vf.modTime
ov.rSize = vf.size
}
ov
}
}
val taskListLocal = MyTask {
updateTit("Find local file")
subfolder.subfolders.forEach {
logger.debug("tasklistlocal: subfolder=$it")
local!!.list(it, sync.excludeFilter.valueSafe, recursive = true, resolveSymlinks = false) { vf -> acLocRem(vf, true) { vf2 -> updateMsg("found ${vf2.path}") } ; !isCancelled }
}
}
val taskListRemote = MyTask {
updateTit("Find remote file")
subfolder.subfolders.forEach {
logger.debug("tasklistremote: subfolder=$it")
remote!!.list(it, sync.excludeFilter.valueSafe, recursive = true, resolveSymlinks = false) { vf -> acLocRem(vf, false) { vf2 -> updateMsg("found ${vf2.path}") } ; !isCancelled }
}
}
taskListLocal.setOnCancelled { logger.debug(" local cancelled!") }
taskListRemote.setOnCancelled { logger.debug(" rem cancelled!") }
taskListLocal.setOnSucceeded { logger.debug(" local succ!") }
taskListRemote.setOnSucceeded { logger.debug(" rem succ!") }
taskListLocal.setOnFailed { error(" local failed!") }
taskListRemote.setOnFailed { logger.debug(" rem failed!") }
tornadofx.runLater { MyWorker.runTask(taskListLocal) }
tornadofx.runLater { MyWorker.runTask(taskListRemote) }
while (!(taskListLocal.isDone && taskListRemote.isDone)) { // ignore exceptions / errors!
Thread.sleep(100)
}
logger.debug("sw: finding files: " + sw.getTimeRestart())
// cache.dumpAll()
val res = runUIwait {
logger.debug("state after list: " + taskListLocal.state + " remote:" + taskListRemote.state)
when {
taskListLocal.state == Worker.State.FAILED -> taskListLocal.exception
taskListRemote.state == Worker.State.FAILED -> taskListRemote.exception
taskListLocal.state == Worker.State.CANCELLED -> InterruptedException("Cancelled local task")
taskListRemote.state == Worker.State.CANCELLED -> InterruptedException("Cancelled remote task")
else -> null
}
}
if (res != null) throw res
// compare entries
updateProgr(76, 100, "comparing...")
sw.restart()
logger.info("*********************** compare sync entries")
val haveChanges = Comparison.compareSyncEntries(cache, useNewFiles)
logger.debug("havechanges1: $haveChanges")
logger.debug("sw: comparing: " + sw.getTimeRestart())
updateProgr(100, 100, "done")
haveChanges
}
fun taskSynchronize() = MyTask {
logger.info("*********************** synchronize")
updateTit("Synchronize")
updateProgr(0, 100, "startup...")
var syncLog = ""
val swUIupdate = StopWatch()
var totalTransferSize = 0.0
var transferredSize = 0.0
cache.cache.iterate { _, _, se ->
if (se.relevant) {
when (se.action) {
A_USELOCAL -> totalTransferSize += se.lSize
A_USEREMOTE -> totalTransferSize += se.rSize
else -> {}
}
}
}
var ignoreErrors = false
fun dosync(path: String, se: SyncEntry) {
var showit = false
val relevantSize = if (se.action == A_USELOCAL) se.lSize else if (se.action == A_USEREMOTE) se.rSize else 0
if (relevantSize > 10000) showit = true
val msg: String
remote!!.onProgress = { progressVal, bytesPerSecond ->
val pv = (100 * progressVal).toInt()
updateMsg(" [${CF.amap[se.action]}]: $path...$pv% (${Helpers.tokMGTPE(bytesPerSecond)}B/s)")
}
if (showit || swUIupdate.doit(uiUpdateInterval)) {
msg = " [${CF.amap[se.action]}]: $path..."
updateProgr(transferredSize, totalTransferSize, msg)
}
try {
when (se.action) {
A_MERGE -> throw UnsupportedOperationException("Merge not implemented yet!")
A_RMLOCAL -> {
local!!.deletefile(path); se.delete = true; se.relevant = false
}
A_RMREMOTE -> {
remote!!.deletefile(path); se.delete = true; se.relevant = false
}
A_RMBOTH -> {
local!!.deletefile(path); remote!!.deletefile(path); se.delete = true; se.relevant = false
}
A_USELOCAL -> {
val nrt = remote!!.putfile(sync.localfolder.value, path, se.lTime)
se.rTime = nrt; se.rSize = se.lSize; se.cSize = se.lSize; se.lcTime = se.lTime; se.rcTime = nrt; se.relevant = false
transferredSize += se.lSize
}
A_USEREMOTE -> {
remote!!.getfile(sync.localfolder.value, path, se.rTime)
se.lTime = se.rTime; se.lSize = se.rSize; se.cSize = se.rSize; se.rcTime = se.rTime; se.lcTime = se.rTime; se.relevant = false
transferredSize += se.rSize
}
A_ISEQUAL -> {
se.cSize = se.rSize; se.lcTime = se.lTime; se.rcTime = se.rTime; se.relevant = false
}
A_SKIP -> {
}
A_CACHEONLY -> se.delete = true
else -> throw UnsupportedOperationException("unknown action: " + se.action)
}
} catch (e: InterruptedException) {
throw e
} catch (e: Exception) {
logger.error("sync exception:", e)
se.action = A_SYNCERROR
se.delete = false
syncLog += (e.message + "[" + path + "]" + "\n")
updateMsg("Failed: $path: $e")
if (!ignoreErrors) {
if (runUIwait {
dialogOkCancel("Error", "Synchronization Error. Press OK to continue ignoring errors, Cancel to abort.",
"File: $path:\n${e.message}")
})
ignoreErrors = true
else
throw Exception("Exception(s) during synchronize:\n$syncLog")
}
// many exceptions are very slow, problem is stacktrace: http://stackoverflow.com/a/569118. Impossible to disable ST via Runtime.getRuntime()
Thread.sleep(600) // to keep sfsync responsive...
}
}
for (state in listOf(1, 2)) {
// delete and add dirs must be done in reverse order!
logger.debug("syncing state = $state")
when (state) {
1 -> // delete
cache.cache.iterate(reversed = true) { _, path, se ->
if (local!!.interrupted.get() || remote!!.interrupted.get()) throw InterruptedException("profile: connections interrupted")
if (se.relevant && listOf(A_RMBOTH, A_RMLOCAL, A_RMREMOTE).contains(se.action)) {
dosync(path, se)
}
}
else -> // put/get and others
cache.cache.iterate { _, path, se ->
if (local!!.interrupted.get() || remote!!.interrupted.get()) throw InterruptedException("profile: connections interrupted")
if (se.relevant) dosync(path, se)
}
}
// update cache: remove removed/cacheonly files
cache.cache.iterate { it, _, se -> if (se.delete) it.remove() }
}
if (syncLog != "") throw Exception("Exception(s) during synchronize:\n$syncLog")
}
fun iniLocalAsRemote() {
cache.cache.iterate { _, _, se ->
if (se.relevant && se.action != A_ISEQUAL) {
se.action = when (se.action) {
A_RMREMOTE -> A_USEREMOTE
A_USELOCAL -> if (se.rSize > -1) A_USEREMOTE else A_RMLOCAL
A_UNKNOWN -> if (se.rSize > -1) A_USEREMOTE else A_RMLOCAL
else -> se.action
}
}
}
}
fun iniRemoteAsLocal() {
cache.cache.iterate { _, _, se ->
if (se.relevant && se.action != A_ISEQUAL) {
se.action = when (se.action) {
A_RMLOCAL -> A_USELOCAL
A_USEREMOTE -> if (se.lSize > -1) A_USELOCAL else A_RMREMOTE
A_UNKNOWN -> if (se.lSize < 0 && se.rSize < 0) A_CACHEONLY else if (se.lSize > -1) A_USELOCAL else A_RMREMOTE
else -> se.action
}
}
}
}
// cleanup (transfers must be stopped before, connection is kept alive here.)
fun taskCleanup() = MyTask {
updateTit("Cleanup profile...")
updateProgr(1, 100, "Save cache...")
cache.saveCache()
updateProgr(50, 100, "Cleanup...")
local?.cleanUp()
local = null
updateProgr(100, 100, "done!")
}
}
| 0 | Kotlin | 0 | 0 | 321f7cda36e582e8ef2e5f0cb66f925e1e815e1f | 13,149 | sfsyncbrowser | MIT License |
decoder/src/commonTest/kotlin/io/github/charlietap/chasm/decoder/decoder/type/vector/VectorTypeDecoderTest.kt | CharlieTap | 743,980,037 | false | null | package io.github.charlietap.chasm.decoder.decoder.type.vector
import com.github.michaelbull.result.Err
import com.github.michaelbull.result.Ok
import io.github.charlietap.chasm.ast.type.VectorType
import io.github.charlietap.chasm.decoder.error.TypeDecodeError
import io.github.charlietap.chasm.decoder.fixture.decoderContext
import io.github.charlietap.chasm.decoder.reader.FakeUByteReader
import kotlin.test.Test
import kotlin.test.assertEquals
class VectorTypeDecoderTest {
@Test
fun `can decode an encoded vector type`() {
val reader = FakeUByteReader { Ok(VECTOR_TYPE_128) }
val context = decoderContext(reader)
val actual = VectorTypeDecoder(context)
assertEquals(Ok(VectorType.V128), actual)
}
@Test
fun `returns an error when the encoded byte doesnt match`() {
val reader = FakeUByteReader { Ok(0u) }
val context = decoderContext(reader)
val actual = VectorTypeDecoder(context)
assertEquals(Err(TypeDecodeError.InvalidVectorType(0x00.toUByte())), actual)
}
}
| 5 | null | 3 | 67 | dd6fa51262510ecc5ee5b03866b3fa5d1384433b | 1,064 | chasm | Apache License 2.0 |
shared/src/commonMain/kotlin/ml/dev/kotlin/openotp/ui/screen/AddProviderScreen.kt | avan1235 | 688,384,879 | false | null | package ml.dev.kotlin.openotp.ui.screen
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Pin
import androidx.compose.material.icons.filled.Update
import androidx.compose.material3.Icon
import androidx.compose.material3.Tab
import androidx.compose.material3.TabRow
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.arkivanov.decompose.extensions.compose.jetbrains.subscribeAsState
import dev.icerock.moko.resources.compose.stringResource
import ml.dev.kotlin.openotp.component.AddHotpProviderComponent
import ml.dev.kotlin.openotp.component.AddOtpProviderComponent
import ml.dev.kotlin.openotp.component.AddTotpProviderComponent
import ml.dev.kotlin.openotp.otp.HmacAlgorithm
import ml.dev.kotlin.openotp.otp.OtpDigits
import ml.dev.kotlin.openotp.otp.OtpType
import ml.dev.kotlin.openotp.otp.OtpType.HOTP
import ml.dev.kotlin.openotp.otp.OtpType.TOTP
import ml.dev.kotlin.openotp.otp.TotpPeriod
import ml.dev.kotlin.openotp.shared.OpenOtpResources
import ml.dev.kotlin.openotp.ui.component.*
import ml.dev.kotlin.openotp.util.SystemBarsScreen
@Composable
internal fun AddProviderScreen(
totpComponent: AddTotpProviderComponent,
hotpComponent: AddHotpProviderComponent,
) {
SystemBarsScreen {
Column(modifier = Modifier.fillMaxWidth()) {
var selected by remember { mutableStateOf(OtpType.entries.first()) }
TabRow(selectedTabIndex = selected.ordinal) {
OtpType.entries.forEach { type ->
Tab(
text = { Text(type.presentableName()) },
selected = type == selected,
onClick = { selected = type },
icon = {
when (type) {
TOTP -> Icon(
imageVector = Icons.Default.Update,
contentDescription = type.presentableName()
)
HOTP -> Icon(
imageVector = Icons.Default.Pin,
contentDescription = type.presentableName()
)
}
}
)
}
}
BoxWithConstraints {
val totpOffset by animateDpAsState(
targetValue = when (selected) {
TOTP -> 0.dp
HOTP -> -maxWidth
}
)
val hotpOffset by animateDpAsState(
targetValue = when (selected) {
TOTP -> maxWidth
HOTP -> 0.dp
}
)
Box(modifier = Modifier.offset(x = totpOffset)) {
AddTotpProviderScreen(totpComponent)
}
Box(modifier = Modifier.offset(x = hotpOffset)) {
AddHotpProviderScreen(hotpComponent)
}
AddProviderFormConfirmButtons(
component = when (selected) {
TOTP -> totpComponent
HOTP -> hotpComponent
}
)
}
}
}
}
@Composable
private fun AddProviderFormConfirmButtons(component: AddOtpProviderComponent) {
SaveCancelFormConfirmButtons(
onSaveClicked = component::onSaveClicked,
onCancelClicked = component::onCancelClicked
)
}
@Composable
private fun AddTotpProviderScreen(component: AddTotpProviderComponent) {
AddOtpProviderScreen(component) {
val selectedAlgorithm by component.algorithm.subscribeAsState()
NamedDropdownMenu(
name = stringResource(OpenOtpResources.strings.algorithm_field_name),
selected = selectedAlgorithm,
anyItems = HmacAlgorithm.entries,
onSelected = component::onAlgorithmSelected,
)
val selectedDigits by component.digits.subscribeAsState()
NamedDropdownMenu(
name = stringResource(OpenOtpResources.strings.digits_field_name),
selected = selectedDigits,
anyItems = OtpDigits.entries,
onSelected = component::onDigitsSelected,
)
val selectedPeriod by component.period.subscribeAsState()
NamedDropdownMenu(
name = stringResource(OpenOtpResources.strings.period_field_name),
selected = selectedPeriod,
anyItems = TotpPeriod.entries,
onSelected = component::onPeriodSelected,
)
}
}
@Composable
private fun AddHotpProviderScreen(component: AddHotpProviderComponent) {
AddOtpProviderScreen(component) {
val counter by component.counter.subscribeAsState()
val counterIsError by component.counterIsError.subscribeAsState()
FormField(
name = stringResource(OpenOtpResources.strings.counter_field_name),
text = counter,
onTextChange = component::onCounterChanged,
isError = counterIsError,
buttonType = FormFieldButtonType.Done,
)
val selectedAlgorithm by component.algorithm.subscribeAsState()
NamedDropdownMenu(
name = stringResource(OpenOtpResources.strings.algorithm_field_name),
selected = selectedAlgorithm,
anyItems = HmacAlgorithm.entries,
onSelected = component::onAlgorithmSelected,
)
val selectedDigits by component.digits.subscribeAsState()
NamedDropdownMenu(
name = stringResource(OpenOtpResources.strings.digits_field_name),
selected = selectedDigits,
anyItems = OtpDigits.entries,
onSelected = component::onDigitsSelected,
)
}
}
@Composable
private fun AddOtpProviderScreen(
component: AddOtpProviderComponent,
advancedSettingsContent: @Composable ColumnScope.() -> Unit,
) {
Box(
modifier = Modifier.fillMaxSize(),
) {
Column(
modifier = Modifier
.verticalScroll(rememberScrollState())
.padding(18.dp),
verticalArrangement = Arrangement.spacedBy(18.dp)
) {
AccountDetails(component)
FormGroup(
groupName = stringResource(OpenOtpResources.strings.advanced_settings_group_name),
content = advancedSettingsContent,
)
Spacer(Modifier.height(48.dp))
}
}
}
@Composable
private fun AccountDetails(component: AddOtpProviderComponent) {
FormGroup(
groupName = stringResource(OpenOtpResources.strings.account_details_group_name)
) {
val issuer by component.issuer.subscribeAsState()
FormField(
name = stringResource(OpenOtpResources.strings.issuer_field_name),
text = issuer,
onTextChange = component::onIssuerChanged,
)
val accountName by component.accountName.subscribeAsState()
FormField(
name = stringResource(OpenOtpResources.strings.account_name_field_name),
text = accountName,
onTextChange = component::onAccountNameChanged,
)
val secret by component.secret.subscribeAsState()
val secretIsError by component.secretIsError.subscribeAsState()
FormField(
name = stringResource(OpenOtpResources.strings.secret_field_name),
text = secret,
isError = secretIsError,
onTextChange = component::onSecretChanged,
buttonType = when (component) {
is AddTotpProviderComponent -> FormFieldButtonType.Done
is AddHotpProviderComponent -> FormFieldButtonType.Next
else -> FormFieldButtonType.Done
},
password = true,
)
}
}
| 2 | null | 3 | 71 | acae3a1e4bdebcfefe549fe5f4fff4ffeed18d51 | 8,283 | open-otp | MIT License |
karibu-dsl-v23/src/main/kotlin/com/github/mvysny/karibudsl/v23/LoginForm.kt | mvysny | 92,477,088 | false | {"Kotlin": 242046, "CSS": 6859, "HTML": 507, "Isabelle": 51} | package com.github.mvysny.karibudsl.v23
import com.github.mvysny.karibudsl.v10.VaadinDsl
import com.vaadin.flow.component.Component
import com.vaadin.flow.component.HasComponents
import com.vaadin.flow.component.login.LoginOverlay
import com.vaadin.flow.dom.Element
@VaadinDsl
public fun (@VaadinDsl LoginOverlay).footer(block: (@VaadinDsl HasComponents).() -> Unit = {}) {
val f = footer
val hc = object : HasComponents {
override fun add(components: MutableCollection<Component>) {
f.add(*components.toTypedArray())
}
override fun getElement(): Element = throw IllegalArgumentException("call add() to add components")
}
hc.block()
}
@VaadinDsl
public fun (@VaadinDsl LoginOverlay).customFormArea(block: (@VaadinDsl HasComponents).() -> Unit = {}) {
val f = customFormArea
val hc = object : HasComponents {
override fun add(components: MutableCollection<Component>) {
f.add(*components.toTypedArray())
}
override fun getElement(): Element = throw IllegalArgumentException("call add() to add components")
}
hc.block()
}
| 7 | Kotlin | 16 | 126 | 26b842b5a5de37050a427e61df2162769d0cda33 | 1,127 | karibu-dsl | MIT License |
app/src/main/java/io/curity/haapidemo/Configuration.kt | curityio | 601,061,534 | false | null | /*
* Copyright (C) 2023 Curity AB
*
* 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.curity.haapidemo
import se.curity.identityserver.haapi.android.driver.HaapiLogger
/**
* Configuration for `HaapiFlowManager`
*
* @property [clientId] A String that represents a clientId. This value is important and needs to match with the curity
* identity server configuration.
* @property [baseURLString] A String that represents a base URL that points to the Curity Identity Server.
* @property [tokenEndpointPath] A String that represents the path to the token endpoint.
* @property [authorizationEndpointPath] A String that represents the path to the authorization endpoint.
* @property [userInfoEndpointPath] A String that represents the path to the user info endpoint.
* @property [redirectURI] A String that represents the redirect URI. This should match the setting for the client in the Curity Identity Server.
* Since HAAPI does not actually use browser redirects, this can be any valid URI.
* @property [scope] A list of strings that represents the scope requested from the authorization server.
* @property [useSSL] Set this to true if you have an instance of the Curity Identity Server with
* TLS certificates that the app can trust (e.g., when exposing the Curity Identity Server with ngrok — see README)
*/
data class Configuration(
var clientId: String,
var baseURLString: String,
var tokenEndpointPath: String,
var authorizationEndpointPath: String,
var userInfoEndpointPath: String,
var redirectURI: String,
var isAutoAuthorizationChallengedEnabled: Boolean = true,
var scope: List<String> = emptyList(),
val useSSL: Boolean,
// To implement HAAPI fallback, customers must define their own DCR related settings
// These will vary depending on the type of credential being used
var dcrTemplateClientId: String? = null,
var dcrClientRegistrationEndpointPath: String? = null,
var deviceSecret: String? = null
) {
val userInfoURI = baseURLString + userInfoEndpointPath
init {
// Set these to `true` if you want the HAAPI SDK to log raw JSON responses.
HaapiLogger.enabled = false
HaapiLogger.isDebugEnabled = false
}
companion object {
fun newInstance(): Configuration =
Configuration(
clientId = "haapi-android-client",
baseURLString = "https://10.0.2.2:8443",
tokenEndpointPath = "/oauth/v2/oauth-token",
authorizationEndpointPath = "/oauth/v2/oauth-authorize",
userInfoEndpointPath = "/oauth/v2/oauth-userinfo",
redirectURI = "app://haapi",
scope = listOf("openid", "profile"),
useSSL = false,
// Uncomment these fields to add support for HAAPI DCR fallback with a simple credential
// dcrTemplateClientId = "haapi-template-client",
// dcrClientRegistrationEndpointPath = "/token-service/oauth-registration",
// deviceSecret = "Password1"
)
}
} | 0 | Kotlin | 0 | 1 | c2384eb3e9fa2efdcd43662a6f7b824a3415cb3f | 3,624 | android-haapi-ui-sdk-demo | Apache License 2.0 |
backend.native/tests/codegen/object/constructor.kt | JetBrains | 58,957,623 | false | null | /*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.`object`.constructor
class A()
class B(val a:Int)
class C(val a:Int, b:Int) | 0 | null | 625 | 7,100 | 9fb0a75ab17e9d8cddd2c3d1802a1cdd83774dfa | 246 | kotlin-native | Apache License 2.0 |
invoice-core/src/commonMain/kotlin/invoice/SenderUtils.kt | aSoft-Ltd | 343,245,386 | false | null | @file:JvmName("SenderUtils")
package invoice
import kotlin.jvm.JvmName
fun Sender.toCreator() = Creator(uid = uid, name = name) | 1 | Kotlin | 1 | 1 | 459df533c067fa3345fe72be85102302a78c4102 | 130 | invoice | MIT License |
app/src/main/java/com/duckduckgo/app/fire/fireproofwebsite/data/FireproofWebsiteRepositoryImpl.kt | duckduckgo | 78,869,127 | false | null | /*
* Copyright (c) 2020 DuckDuckGo
*
* 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.duckduckgo.app.fire.fireproofwebsite.data
import android.net.Uri
import androidx.lifecycle.LiveData
import com.duckduckgo.app.browser.favicon.FaviconManager
import com.duckduckgo.app.fire.FireproofRepository
import com.duckduckgo.app.global.DispatcherProvider
import com.duckduckgo.app.global.UriString
import com.duckduckgo.di.scopes.AppScope
import com.squareup.anvil.annotations.ContributesBinding
import dagger.Lazy
import dagger.SingleInstanceIn
import kotlinx.coroutines.withContext
import javax.inject.Inject
interface FireproofWebsiteRepositoryAPI {
suspend fun fireproofWebsite(domain: String): FireproofWebsiteEntity?
fun getFireproofWebsites(): LiveData<List<FireproofWebsiteEntity>>
fun fireproofWebsitesSync(): List<FireproofWebsiteEntity>
fun isDomainFireproofed(domain: String): Boolean
suspend fun removeFireproofWebsite(fireproofWebsiteEntity: FireproofWebsiteEntity)
suspend fun fireproofWebsitesCountByDomain(domain: String): Int
suspend fun removeAllFireproofWebsites()
}
@ContributesBinding(
scope = AppScope::class,
boundType = FireproofRepository::class
)
@ContributesBinding(
scope = AppScope::class,
boundType = FireproofWebsiteRepositoryAPI::class
)
@SingleInstanceIn(AppScope::class)
class FireproofWebsiteRepository @Inject constructor(
private val fireproofWebsiteDao: FireproofWebsiteDao,
private val dispatchers: DispatcherProvider,
private val faviconManager: Lazy<FaviconManager>
) : FireproofRepository, FireproofWebsiteRepositoryAPI {
override fun fireproofWebsites(): List<String> {
val fireproofWebsites = fireproofWebsiteDao.fireproofWebsitesSync()
return fireproofWebsites.flatMap { entity ->
val acceptedHosts = mutableSetOf<String>()
val host = entity.domain
acceptedHosts.add(host)
host.split(".")
.foldRight(
""
) { next, acc ->
val acceptedHost = ".$next$acc"
acceptedHosts.add(acceptedHost)
acceptedHost
}
acceptedHosts
}.distinct()
}
override suspend fun fireproofWebsite(domain: String): FireproofWebsiteEntity? {
if (!UriString.isValidDomain(domain)) return null
val fireproofWebsiteEntity = FireproofWebsiteEntity(domain = domain)
val id = withContext(dispatchers.io()) {
fireproofWebsiteDao.insert(fireproofWebsiteEntity)
}
return if (id >= 0) {
fireproofWebsiteEntity
} else {
null
}
}
override fun getFireproofWebsites(): LiveData<List<FireproofWebsiteEntity>> = fireproofWebsiteDao.fireproofWebsitesEntities()
override fun fireproofWebsitesSync(): List<FireproofWebsiteEntity> {
return fireproofWebsiteDao.fireproofWebsitesSync()
}
override fun isDomainFireproofed(domain: String): Boolean {
val uri = Uri.parse(domain)
val host = uri.host ?: return false
return fireproofWebsiteDao.getFireproofWebsiteSync(host) != null
}
override suspend fun removeFireproofWebsite(fireproofWebsiteEntity: FireproofWebsiteEntity) {
withContext(dispatchers.io()) {
faviconManager.get().deletePersistedFavicon(fireproofWebsiteEntity.domain)
fireproofWebsiteDao.delete(fireproofWebsiteEntity)
}
}
override suspend fun fireproofWebsitesCountByDomain(domain: String): Int {
return withContext(dispatchers.io()) {
fireproofWebsiteDao.fireproofWebsitesCountByDomain(domain)
}
}
override suspend fun removeAllFireproofWebsites() {
withContext(dispatchers.io()) {
fireproofWebsiteDao.deleteAll()
}
}
}
| 67 | null | 901 | 3,823 | 6415f0f087a11a51c0a0f15faad5cce9c790417c | 4,404 | Android | Apache License 2.0 |
widgetssdk/src/main/java/com/glia/widgets/view/unifiedui/theme/survey/SurveyTheme.kt | salemove | 312,288,713 | false | {"Kotlin": 1795638, "Java": 458170, "Shell": 1802} | package com.glia.widgets.view.unifiedui.theme.survey
import com.glia.widgets.view.unifiedui.theme.base.ButtonTheme
import com.glia.widgets.view.unifiedui.theme.base.LayerTheme
import com.glia.widgets.view.unifiedui.theme.base.TextTheme
internal data class SurveyTheme(
val layer: LayerTheme? = null,
val title: TextTheme? = null,
val submitButton: ButtonTheme? = null,
val cancelButton: ButtonTheme? = null,
val booleanQuestion: SurveyBooleanQuestionTheme? = null,
val scaleQuestion: SurveyScaleQuestionTheme? = null,
val singleQuestion: SurveySingleQuestionTheme? = null,
val inputQuestion: SurveyInputQuestionTheme? = null
)
| 2 | Kotlin | 1 | 6 | b69e7f81bb987d8dabfc450086efd56e2a0ae99d | 661 | android-sdk-widgets | MIT License |
app/src/main/java/com/sinthoras/randograf/cards/CardJoker.kt | SinTh0r4s | 444,149,281 | false | null | package com.sinthoras.randograf.cards
import com.sinthoras.randograf.BlockColors
import com.sinthoras.randograf.structure.StructureGenerator
import com.sinthoras.randograf.R
class CardJoker : Card() {
private val structure = StructureGenerator.generateStructure(1).withColor(BlockColors.ALL)
fun getStructure() = structure
override fun getDuration(): Int {
return 0
}
override fun getTitle(): Int {
return R.string.card_title_joker
}
}
| 1 | null | 1 | 1 | 5319ccb2ebbb9e90f957a065794ad5aebff20459 | 481 | Randograf | MIT License |
app/src/test/java/com/uzias/starwarsshop/core/util/fileFromResource.kt | uziassantosferreira | 108,789,405 | false | null | package com.uzias.starwarsshop.core.util
fun fileFromResource(resource: String, javaClazz: Class<Any>) : String =
javaClazz.classLoader.getResourceAsStream(resource).bufferedReader().use { it.readText() }
| 0 | Kotlin | 1 | 38 | dec2d949a69e870bf37a76c4f22d86c93c12c143 | 215 | Star-Wars-Shop | Apache License 2.0 |
src/main/kotlin/com/gmail/blueboxware/libgdxplugin/ui/LibGDXElementDescriptionProvider.kt | BlueBoxWare | 64,067,118 | false | null | package com.gmail.blueboxware.libgdxplugin.ui
import com.gmail.blueboxware.libgdxplugin.filetypes.atlas.psi.AtlasRegion
import com.gmail.blueboxware.libgdxplugin.filetypes.skin.psi.SkinResource
import com.intellij.psi.ElementDescriptionLocation
import com.intellij.psi.ElementDescriptionProvider
import com.intellij.psi.PsiElement
/*
* Copyright 2017 <NAME>
*
* 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class LibGDXElementDescriptionProvider: ElementDescriptionProvider {
override fun getElementDescription(element: PsiElement, location: ElementDescriptionLocation): String? =
when (element) {
is SkinResource -> element.name
is AtlasRegion -> element.name
else -> null
}
} | 2 | null | 9 | 145 | bcb911e0c3f3e9319bc8ee2d5b6b554c6090fd6c | 1,260 | LibGDXPlugin | Apache License 2.0 |
app/src/main/java/com/scriptsquad/unitalk/Socials_Page/activities/Socials_Gallery_Activity.kt | ST10029788 | 841,892,426 | false | {"Kotlin": 601541, "JavaScript": 1259} | package com.scriptsquad.unitalk.Socials_Page.activities
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.scriptsquad.unitalk.databinding.ActivityGalleryBinding
import com.scriptsquad.unitalk.Socials_Page.fragments.PictureFragment
import com.scriptsquad.unitalk.Socials_Page.fragments.VideoFragment
class Socials_Gallery_Activity : AppCompatActivity() {
// Late-initialized variable for the activity's binding
private lateinit var binding: ActivityGalleryBinding
override fun onCreate(savedInstanceState: Bundle?) {
binding = ActivityGalleryBinding.inflate(layoutInflater)
super.onCreate(savedInstanceState)
setContentView(binding.root)
binding.toolbarBackBtn.setOnClickListener {
onBackPressedDispatcher.onBackPressed()
}
showPicturesFragment()
binding.pictureBtn.setOnClickListener{
showPicturesFragment()
}
binding.videoBtn.setOnClickListener {
showVideoFragment()
}
}
// Show the pictures fragment
private fun showPicturesFragment() {
val fragment = PictureFragment()
val fragmentTransaction = supportFragmentManager.beginTransaction()
fragmentTransaction.replace(binding.fragmentsFl.id, fragment)
fragmentTransaction.commit()
}
// Show the video fragment
private fun showVideoFragment() {
val fragment = VideoFragment()
val fragmentTransaction = supportFragmentManager.beginTransaction()
fragmentTransaction.replace(binding.fragmentsFl.id, fragment)
fragmentTransaction.commit()
}
} | 0 | Kotlin | 0 | 0 | 3ab0d70fb355b7a31f9135810874b28ae069cc4b | 1,653 | UniTalk | MIT License |
code/backend/Odin/src/main/kotlin/pt/isel/odin/http/controllers/department/models/GetAllDepartmentsOutputModel.kt | Rafael4DC | 767,594,795 | false | {"Kotlin": 380088, "TypeScript": 256706, "C#": 13106, "PowerShell": 1924, "JavaScript": 1734, "HTML": 263} | package pt.isel.odin.http.controllers.department.models
import pt.isel.odin.model.Department
/**
* Represents the output model for getting all departments.
*
* @property departments The departments.
*/
data class GetAllDepartmentsOutputModel(
val departments: List<GetDepartmentOutputModel>
)
/**
* Creates a [GetAllDepartmentsOutputModel] from a list of [Department].
*
* @param departments The departments.
*
* @return The [GetAllDepartmentsOutputModel].
*/
fun getAllDepartmentsOutputModel(departments: List<Department>): GetAllDepartmentsOutputModel {
return GetAllDepartmentsOutputModel(
departments.map {
GetDepartmentOutputModel(it)
}
)
}
| 61 | Kotlin | 0 | 2 | 89098f83607781fa838773eae7cef1781cd85a07 | 699 | AssemblyOdin | MIT License |
app/src/main/java/com/example/wordsmemory/di/DbModule.kt | matteofabris | 347,469,835 | false | null | package com.example.wordsmemory.di
import android.content.Context
import com.example.wordsmemory.framework.room.WMDatabase
import com.google.firebase.firestore.ktx.firestore
import com.google.firebase.ktx.Firebase
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import kotlinx.coroutines.InternalCoroutinesApi
@InstallIn(SingletonComponent::class)
@Module
object DbModule {
@InternalCoroutinesApi
@Provides
fun provideDatabase(@ApplicationContext appContext: Context) =
WMDatabase.getInstance(appContext)
@Provides
fun provideVocabularyItemDao(database: WMDatabase) = database.vocabularyItemDao()
@Provides
fun provideCategoryDao(database: WMDatabase) = database.categoryDao()
@Provides
fun provideUserDao(database: WMDatabase) = database.userDao()
@Provides
fun provideFirestoreDb() = Firebase.firestore
} | 0 | Kotlin | 0 | 0 | 8f4d49418ddf046c59f9ada274a94f87149dfb89 | 996 | WordsMemory | MIT License |
core/designsystem/src/main/java/com/eshc/goonersapp/core/designsystem/iconpack/IcPeople.kt | eshc123 | 640,451,475 | false | {"Kotlin": 506530} | package com.eshc.goonersapp.core.designsystem.iconpack
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.PathFillType.Companion.NonZero
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.StrokeCap.Companion.Butt
import androidx.compose.ui.graphics.StrokeJoin.Companion.Miter
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.ImageVector.Builder
import androidx.compose.ui.graphics.vector.path
import androidx.compose.ui.unit.dp
import com.eshc.goonersapp.core.designsystem.IconPack
public val IconPack.IcPeople: ImageVector
get() {
if (_icpeople != null) {
return _icpeople!!
}
_icpeople = Builder(name = "IcPeople", defaultWidth = 18.0.dp, defaultHeight = 20.0.dp,
viewportWidth = 18.0f, viewportHeight = 20.0f).apply {
path(fill = SolidColor(Color(0xFF777777)), stroke = null, strokeLineWidth = 0.0f,
strokeLineCap = Butt, strokeLineJoin = Miter, strokeLineMiter = 4.0f,
pathFillType = NonZero) {
moveTo(9.0f, 9.2574f)
curveTo(7.9393f, 9.2574f, 7.0313f, 8.8416f, 6.2759f, 8.0101f)
curveTo(5.5205f, 7.1787f, 5.1429f, 6.1791f, 5.1429f, 5.0115f)
curveTo(5.1429f, 3.8439f, 5.5205f, 2.8443f, 6.2759f, 2.0128f)
curveTo(7.0313f, 1.1814f, 7.9393f, 0.7656f, 9.0f, 0.7656f)
curveTo(10.0607f, 0.7656f, 10.9688f, 1.1814f, 11.7241f, 2.0128f)
curveTo(12.4795f, 2.8443f, 12.8571f, 3.8439f, 12.8571f, 5.0115f)
curveTo(12.8571f, 6.1791f, 12.4795f, 7.1787f, 11.7241f, 8.0101f)
curveTo(10.9688f, 8.8416f, 10.0607f, 9.2574f, 9.0f, 9.2574f)
close()
moveTo(0.0f, 18.0212f)
verticalLineTo(17.1612f)
curveTo(0.0f, 16.5769f, 0.1545f, 16.0303f, 0.4636f, 15.5213f)
curveTo(0.7727f, 15.0124f, 1.1885f, 14.6173f, 1.711f, 14.336f)
curveTo(2.9242f, 13.6955f, 4.1382f, 13.2151f, 5.353f, 12.8949f)
curveTo(6.5679f, 12.5746f, 7.7835f, 12.4145f, 9.0f, 12.4145f)
curveTo(10.2165f, 12.4145f, 11.4321f, 12.5746f, 12.647f, 12.8949f)
curveTo(13.8618f, 13.2151f, 15.0758f, 13.6955f, 16.289f, 14.336f)
curveTo(16.8115f, 14.6173f, 17.2273f, 15.0124f, 17.5364f, 15.5213f)
curveTo(17.8455f, 16.0303f, 18.0f, 16.5769f, 18.0f, 17.1612f)
verticalLineTo(18.0212f)
curveTo(18.0f, 18.4368f, 17.8718f, 18.7856f, 17.6155f, 19.0677f)
curveTo(17.3592f, 19.3499f, 17.0423f, 19.491f, 16.6649f, 19.491f)
horizontalLineTo(1.3352f)
curveTo(0.9577f, 19.491f, 0.6408f, 19.3499f, 0.3845f, 19.0677f)
curveTo(0.1282f, 18.7856f, 0.0f, 18.4368f, 0.0f, 18.0212f)
close()
moveTo(1.2857f, 18.0756f)
horizontalLineTo(16.7143f)
verticalLineTo(17.1612f)
curveTo(16.7143f, 16.8473f, 16.6224f, 16.5524f, 16.4386f, 16.2766f)
curveTo(16.2548f, 16.0008f, 16.0005f, 15.7677f, 15.6758f, 15.5771f)
curveTo(14.6176f, 15.0128f, 13.5265f, 14.5805f, 12.4025f, 14.2802f)
curveTo(11.2786f, 13.9799f, 10.1444f, 13.8298f, 9.0f, 13.8298f)
curveTo(7.8556f, 13.8298f, 6.7214f, 13.9799f, 5.5975f, 14.2802f)
curveTo(4.4735f, 14.5805f, 3.3824f, 15.0128f, 2.3242f, 15.5771f)
curveTo(1.9995f, 15.7677f, 1.7452f, 16.0008f, 1.5614f, 16.2766f)
curveTo(1.3776f, 16.5524f, 1.2857f, 16.8473f, 1.2857f, 17.1612f)
verticalLineTo(18.0756f)
close()
moveTo(9.0f, 7.8421f)
curveTo(9.7071f, 7.8421f, 10.3125f, 7.5649f, 10.8161f, 7.0106f)
curveTo(11.3196f, 6.4563f, 11.5714f, 5.7899f, 11.5714f, 5.0115f)
curveTo(11.5714f, 4.2331f, 11.3196f, 3.5667f, 10.8161f, 3.0124f)
curveTo(10.3125f, 2.4581f, 9.7071f, 2.1809f, 9.0f, 2.1809f)
curveTo(8.2929f, 2.1809f, 7.6875f, 2.4581f, 7.1839f, 3.0124f)
curveTo(6.6804f, 3.5667f, 6.4286f, 4.2331f, 6.4286f, 5.0115f)
curveTo(6.4286f, 5.7899f, 6.6804f, 6.4563f, 7.1839f, 7.0106f)
curveTo(7.6875f, 7.5649f, 8.2929f, 7.8421f, 9.0f, 7.8421f)
close()
}
}
.build()
return _icpeople!!
}
private var _icpeople: ImageVector? = null
| 2 | Kotlin | 1 | 1 | f80da9068d49ec11403362f538c5d1e903cb2843 | 4,609 | GoonersApp | Apache License 2.0 |
j2k/testData/fileOrElement/tryWithResource/WithReturnInAnonymousClass2.kt | staltz | 93,485,627 | false | null | import java.io.*
interface I {
Throws(IOException::class)
public fun doIt(stream: InputStream): Int
}
public class C {
Throws(IOException::class)
fun foo() {
ByteArrayInputStream(ByteArray(10)).use { stream ->
bar(object : I {
Throws(IOException::class)
override fun doIt(stream: InputStream): Int {
return stream.available()
}
}, stream)
}
}
Throws(IOException::class)
fun bar(i: I, stream: InputStream): Int {
return i.doIt(stream)
}
} | 1 | null | 0 | 1 | 80074c71fa925a1c7173e3fffeea4cdc5872460f | 588 | kotlin | Apache License 2.0 |
CallofProjectAndroid/app/src/main/java/callofproject/dev/androidapp/presentation/project/project_details/ProjectDetailViewModel.kt | CallOfProject | 751,531,328 | false | {"Kotlin": 479159, "Java": 5989} | package callofproject.dev.androidapp.presentation.project.project_details
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import callofproject.dev.androidapp.R
import callofproject.dev.androidapp.domain.use_cases.UseCaseFacade
import callofproject.dev.androidapp.util.Resource
import callofproject.dev.androidapp.util.route.UiEvent
import callofproject.dev.androidapp.util.route.UiText
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.launch
import javax.inject.Inject
@HiltViewModel
class ProjectDetailViewModel @Inject constructor(
private val useCases: UseCaseFacade
) : ViewModel() {
private val _uiEvent = Channel<UiEvent>()
val uiEvent = _uiEvent.receiveAsFlow()
var state by mutableStateOf(ProjectDetailsState())
private set
fun findProjectDetails(projectId: String) {
viewModelScope.launch {
useCases.project.findProjectDetails(projectId).let { result ->
when (result) {
is Resource.Success -> {
state = state.copy(
projectDetailsDTO = result.data!!,
isOwner = true,
isParticipant = true
)
}
is Resource.Error -> {
if (result.message == "You are not the owner or participant of this project") {
state = state.copy(isOwner = false, isParticipant = false)
_uiEvent.send(UiEvent.ShowSnackbar(UiText.StringResource(R.string.msg_notOwnerOfProject)))
}
}
is Resource.Loading -> {
//_uiEvent.send(UiEvent.ShowSnackbar("Loading"))
}
}
}
}
}
} | 0 | Kotlin | 0 | 1 | 5f1f03c80c8ef83bfc4a6609ade55c64bb72458c | 2,108 | Call-Of-Project-Android | MIT License |
app/src/main/java/com/bcassar/nbafantasy/playerstatslist/PlayerGameStatsListFragment.kt | baptistecassar | 557,934,807 | false | null | package com.bcassar.nbafantasy.playerstatslist
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.bcassar.nbafantasy.databinding.FragmentPlayerGameStatsListBinding
import com.bcassar.nbafantasy.utils.argument
import org.koin.androidx.viewmodel.ext.android.viewModel
import org.koin.core.parameter.parametersOf
/**
* Created by bcassar on 30/10/2022
*/
class PlayerGameStatsListFragment : Fragment() {
private var _binding: FragmentPlayerGameStatsListBinding? = null
// This property is only valid between onCreateView and
// onDestroyView.
private val binding get() = _binding!!
// Lazy inject ViewModel
private var date: String by argument()
val viewModel: PlayerGameStatsListViewModel by viewModel { parametersOf(date) }
private val playerGameStatsAdapter = PlayerGameStatsAdapter()
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = FragmentPlayerGameStatsListBinding.inflate(inflater, container, false)
return binding.root
}
override fun onResume() {
super.onResume()
viewModel.fetchPlayerGameStatsList()
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
initLayout()
initObservers()
}
private fun initLayout() {
binding.retryButton.setOnClickListener {
viewModel.fetchPlayerGameStatsList()
}
binding.playerGameStatsList.apply {
layoutManager = LinearLayoutManager(context, RecyclerView.VERTICAL, false)
adapter = playerGameStatsAdapter
}
}
private fun initObservers() {
viewModel.playerGameStatsListEvent.observe(viewLifecycleOwner) { event ->
event.consume()?.let {
when (val playerGameStatsListEvent = it.data) {
PlayerGameStatsListEvent.PlayerGameStatsListFetching -> {
binding.playerGameStatsList.isVisible = false
binding.retryButton.isVisible = false
binding.progress.isVisible = true
}
is PlayerGameStatsListEvent.PlayerGameStatsListFetched -> {
binding.playerGameStatsList.isVisible = true
binding.progress.isVisible = false
playerGameStatsAdapter.submitList(playerGameStatsListEvent.playerGameStatsList.sortedByDescending { it.fantasyPoints })
}
is PlayerGameStatsListEvent.PlayerGameStatsListFetchingFailed -> {
binding.retryButton.isVisible = true
binding.progress.isVisible = false
}
}
}
}
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
companion object {
fun newInstance(date: String): PlayerGameStatsListFragment {
return PlayerGameStatsListFragment().apply {
this.date = date
}
}
}
} | 0 | Kotlin | 0 | 0 | 396491f034852ba294819da74d2461fece148f6a | 3,430 | android-nba-fantasy | MIT License |
kotlin-react-router/src/jsMain/generated/react/router/useLoaderData.kt | JetBrains | 93,250,841 | false | {"Kotlin": 11411371, "JavaScript": 154302} | @file:JsModule("react-router")
package react.router
/**
* Returns the loader data for the nearest ancestor Route loader
*/
external fun useLoaderData(): Any?
| 28 | Kotlin | 173 | 1,250 | 9e9dda28cf74f68b42a712c27f2e97d63af17628 | 163 | kotlin-wrappers | Apache License 2.0 |
kotlin-react-router/src/jsMain/generated/react/router/useLoaderData.kt | JetBrains | 93,250,841 | false | {"Kotlin": 11411371, "JavaScript": 154302} | @file:JsModule("react-router")
package react.router
/**
* Returns the loader data for the nearest ancestor Route loader
*/
external fun useLoaderData(): Any?
| 28 | Kotlin | 173 | 1,250 | 9e9dda28cf74f68b42a712c27f2e97d63af17628 | 163 | kotlin-wrappers | Apache License 2.0 |
src/main/java/com/everis/everledger/util/Util.kt | KKZ | 117,506,559 | false | null | package com.everis.everledger.util
import com.everis.everledger.ifaces.ILPLedgerInfo
import com.google.common.collect.ImmutableList
import io.vertx.core.AsyncResult
import io.vertx.core.Vertx
import io.vertx.core.VertxOptions
import io.vertx.core.json.Json
import io.vertx.core.json.JsonObject
import org.apache.commons.lang3.StringUtils
import org.apache.commons.lang3.math.NumberUtils
import org.interledger.cryptoconditions.PreimageSha256Condition
import org.interledger.cryptoconditions.PreimageSha256Fulfillment
import org.interledger.InterledgerAddress
import org.interledger.InterledgerProtocolException
import org.interledger.ilp.InterledgerProtocolError
// import org.interledger.ledger.money.format.LedgerSpecificDecimalMonetaryAmountFormat
import org.slf4j.LoggerFactory
import java.io.File
import java.io.FileInputStream
import java.io.IOException
import java.lang.Long
import java.net.MalformedURLException
import java.net.URI
import java.net.URL
import java.security.KeyFactory
import java.security.KeyPairGenerator
import java.security.PrivateKey
import java.security.PublicKey
import java.security.spec.PKCS8EncodedKeySpec
import java.security.spec.X509EncodedKeySpec
import java.time.Instant
import java.time.ZoneId
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter
import java.util.*
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
import java.util.function.Consumer
import java.util.function.Supplier
import java.util.regex.Pattern
import javax.money.CurrencyUnit
import javax.money.Monetary
import javax.money.format.MonetaryAmountFormat
import kotlin.collections.ArrayList
class JsonObjectBuilder : Supplier<JsonObject> {
private var beanMap: MutableMap<String, Any> = HashMap<String, Any>()
override fun get(): JsonObject {
return JsonObject(beanMap)
}
// TODO:(1) recheck SuppressWarnings
fun from(value: Any): JsonObjectBuilder {
// TODO:(0) beanMap = Json.mapper.convertValue(value, Map<*, *>::class.java)
return this
}
fun with(vararg pairs: Any): JsonObjectBuilder {
if (pairs.size % 2 != 0) {
throw IllegalArgumentException("Argument pairs must be even! " + pairs.size)
}
var i = 0
while (i < pairs.size) {
put(pairs[i], pairs[i + 1])
i += 2
}
return this
}
fun put(key: Any, value: Any): JsonObjectBuilder {
beanMap.put(key.toString(), value)
return this
}
companion object {
fun create(): JsonObjectBuilder = JsonObjectBuilder()
}
}
object TimeUtils {
val future = ZonedDateTime.ofInstant( Date(Long.MAX_VALUE).toInstant(), ZoneId.of("Europe/Paris"))
val testingDate = ZonedDateTime.parse("2015-06-16T00:00:00.000Z")
var ilpFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSX")
}
object ConversionUtil {
fun toNumber(value: Any): Number = if (value is Number) value else NumberUtils.createNumber(value.toString())
fun fulfillmentToBase64(FF: PreimageSha256Fulfillment): String {
var response = FF.preimage
response = response.substring(0, response.indexOf('='))
return response
}
/**
* Parses a URI formatted crypto-condition
*
* @param uri
* * The crypto-condition formatted as a uri.
* *
* @return
* * The crypto condition
*/
fun parseURI(uri: URI): PreimageSha256Condition {
//based strongly on the five bells implementation at
//https://github.com/interledgerjs/five-bells-condition (7b6a97990cd3a51ee41b276c290e4ae65feb7882)
if ("ni" != uri.scheme) {
throw RuntimeException("Serialized condition must start with 'ni:'")
}
val CONDITION_REGEX_STRICT = "^ni://([A-Za-z0-9_-]?)/sha-256;([a-zA-Z0-9_-]{0,86})\\?(.+)$"
//the regex covers the entire uri format including the 'ni:' scheme
val m = Pattern.compile(CONDITION_REGEX_STRICT).matcher(uri.toString())
if (!m.matches()) {
throw RuntimeException("Invalid condition format")
}
val fingerprint = Base64.getUrlDecoder().decode(m.group(2))
return PreimageSha256Fulfillment(fingerprint).getCondition()
}
fun parseNonEmptyString(input: String) : String {
val result = input.trim()
if ( StringUtils.isEmpty(result) )
throw RuntimeException("Trimmed string is empty")
return result
}
}
object ILPExceptionSupport {
private val selfAddress = InterledgerAddress.builder().value(Config.ilpPrefix).build()
/**
* Well known ILP Errors as defined in the RFCs
* @param errCode
*
* @param data
*/
fun createILPException(httpErrCode: Int, errCode: InterledgerProtocolError.ErrorCode, data: String): HTTPInterledgerException =
HTTPInterledgerException(httpErrCode,
InterledgerProtocolError.builder()
.errorCode(errCode)
.triggeredByAddress(selfAddress)
.forwardedByAddresses(ImmutableList.of(selfAddress))
.triggeredAt(Instant.now())
.data(data.toByteArray())
.build() )
// HTTPInterledgerException(httpErrCode, InterledgerError(errCode, /* triggeredBy */ selfAddress,
// ZonedDateTime.now(), ArrayList<InterledgerAddress>(), /*self Address*/ selfAddress, data))
// Next follow some wrappers arount createILPException, more human-readable.
// ----------- Internal --------------
fun createILPInternalException(data: String): HTTPInterledgerException =
createILPException(500, InterledgerProtocolError.ErrorCode.T00_INTERNAL_ERROR, data)
// ------------ Unauthorized ------------- // TODO:(RFC) Use new ErrorCode.??_UNAUTHORIZED
@JvmOverloads fun createILPUnauthorizedException(data: String = "Unauthorized"): HTTPInterledgerException =
createILPException(401, InterledgerProtocolError.ErrorCode.T00_INTERNAL_ERROR, data)
// ----------- Forbidden --------------// TODO:(RFC) Use new ErrorCode.??_FORBIDDEN
@JvmOverloads fun createILPForbiddenException(data: String = "Forbidden"): HTTPInterledgerException =
createILPException(403, InterledgerProtocolError.ErrorCode.T00_INTERNAL_ERROR, "data")
// ------------ NotFound ------------- // TODO:(ILP) Use new ErrorCode.??_NOT_FOUND
@JvmOverloads fun createILPNotFoundException(data: String = "Not Found"): HTTPInterledgerException =
createILPException(404, InterledgerProtocolError.ErrorCode.T00_INTERNAL_ERROR, data)
// ------------- BadRequest ------------
@JvmOverloads fun createILPBadRequestException(data: String = "Forbidden"): HTTPInterledgerException =
createILPException(400, InterledgerProtocolError.ErrorCode.F00_BAD_REQUEST, data)
// ------------- Unprocessable Entity ------------
@JvmOverloads fun createILPUnprocessableEntityException(data: String = "Unprocessable"): HTTPInterledgerException =
createILPException(422, InterledgerProtocolError.ErrorCode.F00_BAD_REQUEST, data)
}
private data class SimpleLedgerInfo(
private val ilpAddress: InterledgerAddress,
private val precision: Int,
private val scale: Int,
private val currencyUnit: CurrencyUnit,
private val monetaryAmountFormat: MonetaryAmountFormat,
private val conditionSignPublicKey: PublicKey,
private val notificationSignPublicKey: PublicKey) : ILPLedgerInfo {
override fun getAddressPrefix()= ilpAddress
override fun getPrecision() = precision
override fun getScale() = scale
override fun getCurrencyUnit() = currencyUnit
override fun getMonetaryAmountFormat() = monetaryAmountFormat
override fun getConditionSignPublicKey() = conditionSignPublicKey
override fun getNotificationSignPublicKey() = notificationSignPublicKey
override fun getId() = "" // TODO:(?)
}
object Config {
val CONFIG_FILE = "application.conf"
val log = LoggerFactory.getLogger(Config::class.java)
val publicURL: URL
val prop = Properties()
init {
try {
val inputStream = FileInputStream(CONFIG_FILE)
prop.load(inputStream)
val keysEnum = prop.keys()
while (keysEnum.hasMoreElements()) {
val key = keysEnum.nextElement() as String
prop.setProperty(key, prop.getProperty(key).trim { it <= ' ' })
}
} catch (e: Exception) {
throw RuntimeException("Can not set-up ILP config for file " + CONFIG_FILE +
"due to " + e.toString() + "\n")
}
}
val vertxBodyLimit = getInteger("vertx.request.bodyLimit").toLong()
val unitTestsActive = getBoolean("developer.unitTestsActive")
val debug = getBoolean("server.debug")
val ilpPrefix01 = getString("ledger.ilp.prefix")
val ilpPrefix = if (ilpPrefix01.endsWith(".")) ilpPrefix01 else ilpPrefix01+"."
val ledgerCurrencyCode = getString("ledger.currency.code")
val ledgerCurrencySymbol = getString("ledger.currency.symbol")
val ldpauxi01 = getString("ledger.path.prefix")
val ledgerPathPrefix = if(ldpauxi01.endsWith("/")) ldpauxi01.substring(0, ldpauxi01.length - 1) else ldpauxi01
val serverHost = getString("server.host")
val serverPort = getInteger("server.port")
val serverPublicHost = getString("server.public.host")
val serverPublicPort = getString("server.public.port")
val serverUseHTTPS = getBoolean("server.public.use_https")
val ledgerPrecision = getInteger("ledger.precision")
val ledgerScale = getInteger("ledger.scale")
val ledgerVersion = getString("ledger.version")
val tls_key = getString("server.tls_key")
val tls_crt = getString("server.tls_cert")
val ethereum_address_escrow = getString("ethereum.address.escrow")
val test_ethereum_address_escrow = getString("test.ethereum.address.escrow")
val test_ethereum_address_admin = getString("test.ethereum.address.admin")
val test_ethereum_address_ilpconnector = getString("test.ethereum.address.ilpconnector")
val test_ethereum_address_alice = getString("test.ethereum.address.alice")
val test_ethereum_address_bob = getString("test.ethereum.address.bob")
val test_ethereum_address_eve = getString("test.ethereum.address.eve")
// Note: DSAPrivPubKeySupport.main support is used to configure pub/priv.key
// private static final String sConditionSignPrivateKey = getString("ledger.ed25519.conditionSignPrivateKey");
private val sConditionSignPublicKey = getString("ledger.ed25519.conditionSignPublicKey")
// private static final String sNoticificationSignPrivateKey = getString("ledger.ed25519.notificationSignPrivateKey");
private val sNoticificationSignPublicKey = getString("ledger.ed25519.notificationSignPublicKey")
var ilpLedgerInfo: ILPLedgerInfo = SimpleLedgerInfo(
InterledgerAddress.builder().value(ilpPrefix).build(),
ledgerPrecision,
ledgerScale,
Monetary.getCurrency(ledgerCurrencyCode),
LedgerSpecificDecimalMonetaryAmountFormat(
Monetary.getCurrency(ledgerCurrencyCode), ledgerPrecision, ledgerScale) as MonetaryAmountFormat,
DSAPrivPubKeySupport.loadPublicKey(sConditionSignPublicKey),
DSAPrivPubKeySupport.loadPublicKey(sNoticificationSignPublicKey)
)
init {
try {
val inputStream = FileInputStream(CONFIG_FILE)
prop.load(inputStream)
val keysEnum = prop.keys()
while (keysEnum.hasMoreElements()) {
val key = keysEnum.nextElement() as String
prop.setProperty(key, prop.getProperty(key).trim { it <= ' ' })
}
//
val pubSsl = getBoolean("server.public.use_https")
val pubHost = getString("server.public.host")
val pubPort = getInteger("server.public.port")
var prefixUri = getString("ledger.ilp.prefix")
if (!prefixUri.startsWith("/")) {
prefixUri = "/" + prefixUri
} // sanitize
try {
publicURL = URL("http" + if (pubSsl) "s" else "", pubHost, pubPort, ledgerPathPrefix)
} catch (e: MalformedURLException) {
throw RuntimeException("Could NOT create URL with {"
+ "pubHost='" + pubHost + "', "
+ "pubPort='" + pubPort + "', "
+ "prefixUri='" + prefixUri + "'}."
+ " recheck server config")
}
log.info("serverPublicURL: {}", publicURL)
} catch (e: Exception) {
throw RuntimeException("Can not read application.conf due to " + e.toString())
}
}
val indexHandlerMap: MutableMap<String, Any> = HashMap()
init {
indexHandlerMap.put("ilp_prefix", ilpPrefix)
indexHandlerMap.put("currency_code", ledgerCurrencyCode)
indexHandlerMap.put("currency_symbol", ledgerCurrencySymbol)
indexHandlerMap.put("precision", ledgerPrecision)
indexHandlerMap.put("scale", ledgerScale)
indexHandlerMap.put("version", ledgerVersion)
val services = HashMap<String, String>()
// REF:
// - five-bells-ledger/src/controllers/metadata.js
// - plugin.js (REQUIRED_LEDGER_URLS) @ five-bells-plugin
// The conector five-bells-plugin of the js-ilp-connector expect a
// map urls { health:..., transfer: ...,}
val base = publicURL.toString()
// Required by wallet
services.put("health", base + "health")
services.put("accounts", base + "accounts")
services.put("transfer_state", base + "transfers/:id/state")
services.put("account", base + "accounts/:name")
services.put("websocket", base.replace("http://", "ws://")
.replace("https://", "ws://") + "websocket")
// Required by wallet & ilp (ilp-plugin-bells) connector
services.put("transfer", base + "transfers/:id")
services.put("transfer_fulfillment", base + "transfers/:id/fulfillment")
services.put("message", base + "messages")
services.put("auth_token", base + "auth_token")
// services.put("transfer_rejection", base + "not_available") // required by ilp-kit not RFCs
indexHandlerMap.put("urls", services)
indexHandlerMap.put("condition_sign_public_key",
DSAPrivPubKeySupport.savePublicKey(ilpLedgerInfo.conditionSignPublicKey))
/* TODO:(0) Fill connectors with real connected ones */
val connectors = ArrayList<Map<String, String>>()
/* Formato connector ???
ilp: "us.usd.red."
"account":"https://red.ilpdemo.org/ledger/accounts/connector"
"currency":"USD",
...
*/
indexHandlerMap.put("connectors", connectors)
}
private fun getString(key: String): String {
val result = prop.getProperty(key) ?: throw RuntimeException(key + " was not found in " + CONFIG_FILE)
return result.trim()
}
private fun getBoolean(key: String): Boolean {
val auxi = getString(key).toLowerCase()
if (auxi == "false" || auxi == "0") return false
if (auxi == "true" || auxi == "1") return true
throw RuntimeException(key + "defined in " + CONFIG_FILE +
" can not be parsed as boolean. Use true|false or 0|1")
}
private fun getInteger(key: String): Int {
val auxi = getString(key).toLowerCase()
try {
val result = Integer.parseInt(auxi)
return result
} catch (e: Exception) {
throw RuntimeException(key + "defined in " + CONFIG_FILE +
" can not be parsed as integer")
}
}
/**
* Execute this Config.main as java application to check that config is OK!
*/
@JvmStatic fun main(args: Array<String>) { // TODO:(0) Move to Unit tests
println(debug)
}
}
object DSAPrivPubKeySupport {
fun loadPrivateKey(key64: String): PrivateKey {
val clear = Base64.getDecoder().decode(key64)
val keySpec = PKCS8EncodedKeySpec(clear)
try {
val fact = KeyFactory.getInstance("DSA")
val priv = fact.generatePrivate(keySpec)
Arrays.fill(clear, 0.toByte())
return priv
} catch (e: Exception) {
throw RuntimeException(e.toString())
}
}
fun loadPublicKey(stored: String): PublicKey {
val data = Base64.getDecoder().decode(stored)
val spec = X509EncodedKeySpec(data)
try {
val fact = KeyFactory.getInstance("DSA")
return fact.generatePublic(spec)
} catch (e: Exception) {
throw RuntimeException(e.toString())
}
}
fun savePrivateKey(priv: PrivateKey): String {
try {
val fact = KeyFactory.getInstance("DSA")
val spec = fact.getKeySpec(priv,
PKCS8EncodedKeySpec::class.java)
val packed = spec.encoded
val key64 = String(Base64.getEncoder().encode(packed))
Arrays.fill(packed, 0.toByte())
return key64
} catch (e: Exception) {
throw RuntimeException(e.toString())
}
}
fun savePublicKey(publ: PublicKey): String {
// TODO:(0) FIXME:
// It's supposed to return something similar to
// <KEY>
// but it's actually returning something like:
// <KEY>
try {
val fact = KeyFactory.getInstance("DSA")
val spec = fact.getKeySpec(publ,
X509EncodedKeySpec::class.java)
return String(Base64.getEncoder().encode(spec.encoded))
} catch (e: Exception) {
throw RuntimeException(e.toString())
}
}
@Throws(Exception::class)
@JvmStatic fun main(args: Array<String>) { // TODO:(0) Move to UnitTests
val gen = KeyPairGenerator.getInstance("DSA")
val pair = gen.generateKeyPair()
val pubKey = savePublicKey(pair.public)
val privKey = savePrivateKey(pair.private)
println("privKey:" + privKey)
println("pubKey :" + pubKey)
// PublicKey pubSaved = loadPublicKey(pubKey);
// System.out.println(pair.getPublic()+"\n"+pubSaved);
// PrivateKey privSaved = loadPrivateKey(privKey);
// System.out.println(pair.getPrivate()+"\n"+privSaved);
}
}
object VertxRunner {
private val log = LoggerFactory.getLogger(VertxRunner::class.java)
fun run(clazz: Class<*>) {
val verticleID = clazz.name
var baseDir = ""
val options = VertxOptions().setClustered(false)
// Smart cwd detection
// Based on the current directory (.) and the desired directory (baseDir), we try to compute the vertx.cwd
// directory:
try {
// We need to use the canonical file. Without the file name is .
val current = File(".").canonicalFile
if (baseDir.startsWith(current.name) && baseDir != current.name) {
baseDir = baseDir.substring(current.name.length + 1)
}
} catch (e: IOException) {
// Ignore it.
}
System.setProperty("vertx.cwd", baseDir)
val deployLatch = CountDownLatch(1)
val deployHandler = { result : AsyncResult<String> ->
if (result.succeeded()) {
log.info("Deployed verticle {}", result.result())
deployLatch.countDown()
} else {
log.error("Deploying verticle", result.cause())
}
}
val runner = { vertx : io.vertx.core.Vertx ->
try {
vertx.deployVerticle(verticleID, deployHandler)
// Alt: vertx.deployVerticle(verticleID, deploymentOptions, deployHandler);
} catch (e: Throwable) {
log.error("Deploying verticle " + verticleID, e)
throw e
}
}
//DefaultChannelId.newInstance();//Warm up java ipv6 localhost dns
if (options.isClustered) {
Vertx.clusteredVertx(options) { res ->
if (res.succeeded()) {
val vertx = res.result()
// runner.accept(vertx)
runner.invoke(vertx)
} else {
log.error("Deploying clustered verticle " + verticleID, res.cause())
}
}
} else {
val vertx = Vertx.vertx(options)
// runner.accept(vertx)
runner.invoke(vertx)
Runtime.getRuntime().addShutdownHook(object : Thread() {
override fun run() {
log.info("Shutting down")
vertx.close()
}
})
}
while (true) {
try {
if (!deployLatch.await(40, TimeUnit.SECONDS)) {
log.error("Timed out waiting to start")
System.exit(3)
}
break
} catch (e: InterruptedException) {
//ignore
}
}
log.info("Launched")
}
}
/*
* Wrapper class around InterledgerError to store the http error code
*/
// TODO:(0) Change to
// data class HTTPInterledgerException(val httpErrorCode: Int, ILPException: InterledgerProtocolException)
class HTTPInterledgerException(val httpErrorCode: Int, interledgerError: InterledgerProtocolError) :
InterledgerProtocolException(interledgerError)
| 0 | Kotlin | 0 | 0 | 86b585142c2799deac34e8f3f2bb802238cafd82 | 21,832 | interledger-ledger | Apache License 2.0 |
app/src/main/java/com/example/matchmentor/view/CardStackAdapter.kt | RodrigoJrDev | 795,927,508 | false | {"Kotlin": 44434} | package com.example.matchmentor.view
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.example.matchmentor.R
import com.example.matchmentor.model.Item
class CardStackAdapter(
private var items: List<Item>
) : RecyclerView.Adapter<CardStackAdapter.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_card, parent, false)
return ViewHolder(view)
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.bind(items[position])
}
override fun getItemCount(): Int {
return items.size
}
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
private val imageView: ImageView = view.findViewById(R.id.item_image)
private val titleTextView: TextView = view.findViewById(R.id.item_title)
private val subtitleTextView: TextView = view.findViewById(R.id.item_subtitle)
fun bind(item: Item) {
imageView.setImageResource(item.imageResId)
titleTextView.text = item.title
subtitleTextView.text = item.subtitle
}
}
fun setItems(items: List<Item>) {
this.items = items
notifyDataSetChanged()
}
}
| 0 | Kotlin | 0 | 0 | 0e59a878805c88e9ea1c22846e4775c2f7a8cac7 | 1,457 | MatchMentor | MIT License |
src/main/java/uk/gov/justice/hmpps/casenotes/repository/OffenderCaseNoteRepository.kt | ministryofjustice | 195,988,411 | false | {"Kotlin": 252586, "Java": 71311, "Mustache": 1803, "Dockerfile": 1357, "Shell": 580} | package uk.gov.justice.hmpps.casenotes.repository
import org.springframework.data.domain.Pageable
import org.springframework.data.jpa.repository.JpaSpecificationExecutor
import org.springframework.data.jpa.repository.Modifying
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.CrudRepository
import org.springframework.data.repository.PagingAndSortingRepository
import org.springframework.stereotype.Repository
import uk.gov.justice.hmpps.casenotes.model.OffenderCaseNote
import java.time.LocalDateTime
import java.util.UUID
@Repository
interface OffenderCaseNoteRepository :
PagingAndSortingRepository<OffenderCaseNote, UUID>,
JpaSpecificationExecutor<OffenderCaseNote>,
CrudRepository<OffenderCaseNote, UUID> {
@Suppress("FunctionName")
fun findByCaseNoteType_ParentType_TypeInAndModifyDateTimeAfterOrderByModifyDateTime(
types: Set<String>?,
createdDate: LocalDateTime?,
page: Pageable?,
): List<OffenderCaseNote>
fun findByModifyDateTimeBetweenOrderByModifyDateTime(
fromDateTime: LocalDateTime,
toDateTime: LocalDateTime,
): List<OffenderCaseNote>
@Modifying
@Query(
"UPDATE OFFENDER_CASE_NOTE ocn SET offender_identifier = ?2 WHERE ocn.offender_identifier = ?1",
nativeQuery = true,
// see https://github.com/spring-projects/spring-data-jpa/issues/2812. Remove after upgrade past 2.7.9. Not used.
countQuery = "select 1",
)
fun updateOffenderIdentifier(oldOffenderIdentifier: String, newOffenderIdentifier: String): Int
@Modifying
@Query(
value = "DELETE FROM OFFENDER_CASE_NOTE ocn WHERE ocn.offender_identifier = ?1",
nativeQuery = true,
// see https://github.com/spring-projects/spring-data-jpa/issues/2812. Remove after upgrade past 2.7.9. Not used.
countQuery = "select 1",
)
fun deleteOffenderCaseNoteByOffenderIdentifier(offenderIdentifier: String): Int
@Modifying
@Query(
value = "DELETE FROM offender_case_note_amendment ocna where offender_case_note_id in (select offender_case_note_id from offender_case_note where offender_identifier = ?1)",
nativeQuery = true,
// see https://github.com/spring-projects/spring-data-jpa/issues/2812. Remove after upgrade past 2.7.9. Not used.
countQuery = "select 1",
)
fun deleteOffenderCaseNoteAmendmentsByOffenderIdentifier(offenderIdentifier: String): Int
}
| 3 | Kotlin | 1 | 1 | b81955fd2668084f14e5ae26255b13894e54a6e1 | 2,374 | offender-case-notes | MIT License |
compose/src/main/java/com/neeplayer/compose/ArtistsScreen.kt | daugeldauge | 35,284,835 | false | {"Kotlin": 107855, "HTML": 2854} | package com.neeplayer.compose
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import coil.compose.rememberImagePainter
import coil.size.Scale
@Composable
fun ArtistsScreen(artists: List<Artist>, actions: ArtistsActions) {
LazyColumn {
items(artists) {
ArtistItem(artist = it, actions = actions)
}
}
}
@Composable
fun ArtistItem(artist: Artist, actions: ArtistsActions) {
Row(
modifier = Modifier
.clickable(onClick = { actions.goToAlbums(artist) })
.padding(start = 10.dp, end = 10.dp, bottom = 5.dp, top = 5.dp)
.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically
) {
Image(
painter = rememberImagePainter(data = artist.imageUrl.orEmpty()) {
scale(Scale.FILL)
},
contentDescription = null,
modifier = Modifier.size(90.dp),
)
Column(modifier = Modifier.padding(all = 10.dp)) {
Text(text = artist.name, style = MaterialTheme.typography.body1)
Text(text = "${artist.numberOfAlbums} albums, ${artist.numberOfSongs} songs", style = MaterialTheme.typography.body2)
}
}
}
@Preview
@Composable
fun PreviewArtistsScreen() = NeeTheme {
ArtistsScreen(artists = Sample.artists, AppStateContainer())
}
| 0 | Kotlin | 0 | 4 | 48d461a2edcdfa81b80697a796109d6402541a5b | 1,797 | NeePlayer | MIT License |
node-api/src/main/kotlin/net/corda/nodeapi/internal/config/CertificateStore.kt | corda | 70,137,417 | false | null | package net.corda.nodeapi.internal.config
import net.corda.core.crypto.internal.AliasPrivateKey
import net.corda.core.internal.outputStream
import net.corda.nodeapi.internal.crypto.X509KeyStore
import net.corda.nodeapi.internal.crypto.addOrReplaceCertificate
import java.io.InputStream
import java.io.OutputStream
import java.nio.file.OpenOption
import java.nio.file.Path
import java.security.PrivateKey
import java.security.cert.X509Certificate
interface CertificateStore : Iterable<Pair<String, X509Certificate>> {
companion object {
fun of(store: X509KeyStore, password: String, entryPassword: String): CertificateStore = DelegatingCertificateStore(store, password, entryPassword)
fun fromFile(storePath: Path, password: String, entryPassword: String, createNew: Boolean): CertificateStore = DelegatingCertificateStore(X509KeyStore.fromFile(storePath, password, createNew), password, entryPassword)
fun fromInputStream(stream: InputStream, password: String, entryPassword: String): CertificateStore = DelegatingCertificateStore(X509KeyStore.fromInputStream(stream, password), password, entryPassword)
fun fromResource(storeResourceName: String, password: String, entryPassword: String, classLoader: ClassLoader = Thread.currentThread().contextClassLoader): CertificateStore = fromInputStream(classLoader.getResourceAsStream(storeResourceName), password, entryPassword)
}
val value: X509KeyStore
val password: String
val entryPassword: String
fun writeTo(stream: OutputStream) = value.internal.store(stream, password.toCharArray())
fun writeTo(path: Path, vararg options: OpenOption) = path.outputStream(*options)
fun update(action: X509KeyStore.() -> Unit) {
val result = action.invoke(value)
value.save()
return result
}
fun <RESULT> query(action: X509KeyStore.() -> RESULT): RESULT {
return action.invoke(value)
}
operator fun set(alias: String, certificate: X509Certificate) {
update {
internal.addOrReplaceCertificate(alias, certificate)
}
}
override fun iterator(): Iterator<Pair<String, X509Certificate>> {
return query {
aliases()
}.asSequence().map { alias -> alias to get(alias) }.iterator()
}
fun forEach(action: (alias: String, certificate: X509Certificate) -> Unit) {
forEach { (alias, certificate) -> action.invoke(alias, certificate) }
}
fun aliases(): List<String> = value.internal.aliases().toList()
/**
* @throws IllegalArgumentException if no certificate for the alias is found, or if the certificate is not an [X509Certificate].
*/
operator fun get(alias: String): X509Certificate {
return query {
getCertificate(alias)
}
}
operator fun contains(alias: String): Boolean = value.contains(alias)
fun copyTo(certificateStore: CertificateStore) {
certificateStore.update {
[email protected](::setCertificate)
}
}
fun setCertPathOnly(alias: String, certificates: List<X509Certificate>) {
// In case CryptoService and CertificateStore share the same KeyStore (i.e., when BCCryptoService is used),
// extract the existing key from the Keystore and store it again along with the new certificate chain.
// This is because KeyStores do not support updateKeyEntry and thus we cannot update the certificate chain
// without overriding the key entry.
// Note that if the given alias already exists, the keystore information associated with it
// is overridden by the given key (and associated certificate chain).
val privateKey: PrivateKey = if (this.contains(alias)) {
this.value.getPrivateKey(alias, entryPassword)
} else {
AliasPrivateKey(alias)
}
this.value.setPrivateKey(alias, privateKey, certificates, entryPassword)
}
}
private class DelegatingCertificateStore(override val value: X509KeyStore, override val password: String, override val entryPassword: String) : CertificateStore | 62 | null | 1089 | 3,989 | d27aa0e6850d3804d0982024054376d452e7073a | 4,134 | corda | Apache License 2.0 |
compose_material3/src/main/java/dev/vengateshm/compose_material3/side_effects/ProduceStateSample.kt | vengateshm | 670,054,614 | false | {"Kotlin": 1326948, "Java": 33589} | package dev.vengateshm.compose_material3.side_effects
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.produceState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.withContext
import kotlin.time.Duration.Companion.seconds
@Composable
fun ProduceStateSample() {
val post by produceState<Result<Post>?>(initialValue = null) {
value = getPost()
}
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
post
?.onSuccess {
}
?.onFailure {
}
?: CircularProgressIndicator()
}
}
suspend fun getPost(): Result<Post> {
return withContext(Dispatchers.IO) {
delay(3.seconds)
Result.success(Post(id = 1))
}
}
data class Post(
val id: Int,
val title: String = "",
val description: String = ""
) | 0 | Kotlin | 0 | 1 | e697e100a6e012ffee2dcba7644034d9cc2f322f | 1,208 | Android-Kotlin-Jetpack-Compose-Practice | Apache License 2.0 |
implementation/src/main/kotlin/io/github/tomplum/aoc/communication/cpu/MemorySnapshot.kt | TomPlum | 572,260,182 | false | null | package io.github.tomplum.aoc.communication.cpu
/**
* A snapshot of the data in-memory during a single cycle
* of a [ClockCircuit].
* @param xRegister The value of the x register at the [cycle]
* @param cycle The CPU cycle in which the snapshot was captured
*/
data class MemorySnapshot(val xRegister: Int, val cycle: Int) {
companion object {
/**
* Produces the initial snapshot of a [ClockCircuit] buffer.
* The x register initial value is 1.
* The CPU cycles start at 1.
*/
fun initial() = MemorySnapshot(xRegister = 1, cycle = 1)
}
} | 0 | Kotlin | 0 | 0 | 703db17fe02a24d809cc50f23a542d9a74f855fb | 603 | advent-of-code-2022 | Apache License 2.0 |
release/rapid/src/main/kotlin/com/expediagroup/sdk/core/client/HttpHandler.kt | ExpediaGroup | 774,903,007 | false | null | /*
* Copyright (C) 2022 Expedia, 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.expediagroup.sdk.core.client
import io.ktor.client.HttpClient
import io.ktor.client.request.request
import io.ktor.client.request.url
import io.ktor.client.statement.HttpResponse
import io.ktor.http.HttpMethod
internal interface HttpHandler {
suspend fun performGet(
httpClient: HttpClient,
link: String,
): HttpResponse
}
internal class DefaultHttpHandler(
private val environmentProvider: EnvironmentProvider,
) : HttpHandler, EnvironmentProvider by environmentProvider {
override suspend fun performGet(
httpClient: HttpClient,
link: String,
): HttpResponse {
return httpClient.request {
method = HttpMethod.Get
url(link)
appendHeaders()
}
}
}
| 4 | null | 6 | 3 | b286227f8c0710284c8a4496134d44873b58d7c9 | 1,367 | rapid-java-sdk | Apache License 2.0 |
app/src/main/java/com/awscherb/cardkeeper/ui/base/Destination.kt | LateNightProductions | 66,697,395 | false | {"Kotlin": 154044} | package com.awscherb.cardkeeper.ui.base
sealed class Destination(val label: String, val dest: String) {
object Items : Destination("Items", "items")
object Scan : Destination("Scan", "scan")
object Create : Destination("Create", "create")
}
| 1 | Kotlin | 18 | 101 | 609b8a5f9a4161936a3fbf809183a7ece25798fa | 254 | CardKeeper | Apache License 2.0 |
src/test/kotlin/icfp2019/analyzers/MSTAnalyzerTest.kt | godaddy-icfp | 186,746,222 | false | {"JavaScript": 797310, "Kotlin": 116879, "CSS": 9434, "HTML": 5859, "Shell": 70} | package icfp2019.analyzers
import icfp2019.model.*
import icfp2019.toProblem
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
class MSTAnalyzerTest {
@Test
fun testMinimumSpanningTree6Nodes() {
val map3x2 = """
..@
...
""".toProblem()
val gameState = GameState(map3x2)
val spanningTree = MSTAnalyzer.analyze(gameState)(RobotId.first, gameState)
val count = spanningTree.edges.size
Assertions.assertEquals(count, 5)
}
@Test
fun testMinimumSpanningTree9Nodes() {
val map3x3 = """
...
...
...
""".toProblem()
val gameState = GameState(map3x3)
val spanningTree = MSTAnalyzer.analyze(gameState)(RobotId.first, gameState)
val count = spanningTree.edges.size
Assertions.assertEquals(count, 8)
}
}
| 13 | JavaScript | 12 | 0 | a1060c109dfaa244f3451f11812ba8228d192e7d | 906 | icfp-2019 | The Unlicense |
intellij-plugin/educational-core/src/com/jetbrains/edu/learning/EduStartupActivity.kt | JetBrains | 43,696,115 | false | null | package com.jetbrains.edu.learning
import com.intellij.ide.projectView.ProjectView
import com.intellij.ide.util.PropertiesComponent
import com.intellij.notification.BrowseNotificationAction
import com.intellij.notification.NotificationType.WARNING
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.runInEdt
import com.intellij.openapi.application.runWriteAction
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.editor.EditorFactory
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.fileTypes.ExactFileNameMatcher
import com.intellij.openapi.fileTypes.FileTypeManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.startup.StartupActivity
import com.intellij.openapi.startup.StartupManager
import com.intellij.openapi.vfs.VfsUtil
import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.openapi.wm.ToolWindowId
import com.intellij.openapi.wm.ToolWindowManager
import com.jetbrains.edu.coursecreator.CCUtils
import com.jetbrains.edu.coursecreator.SynchronizeTaskDescription
import com.jetbrains.edu.coursecreator.courseignore.CourseIgnoreFileType
import com.jetbrains.edu.coursecreator.framework.SyncChangesStateManager
import com.jetbrains.edu.coursecreator.handlers.CCVirtualFileListener
import com.jetbrains.edu.learning.EduNames.COURSE_IGNORE
import com.jetbrains.edu.learning.EduUtilsKt.isEduProject
import com.jetbrains.edu.learning.EduUtilsKt.isNewlyCreated
import com.jetbrains.edu.learning.EduUtilsKt.isStudentProject
import com.jetbrains.edu.learning.courseFormat.Course
import com.jetbrains.edu.learning.courseFormat.EduFormatNames
import com.jetbrains.edu.learning.courseFormat.FrameworkLesson
import com.jetbrains.edu.learning.courseFormat.TaskFile
import com.jetbrains.edu.learning.courseFormat.checkio.CheckiOCourse
import com.jetbrains.edu.learning.courseFormat.codeforces.CodeforcesCourse
import com.jetbrains.edu.learning.courseFormat.ext.configurator
import com.jetbrains.edu.learning.courseFormat.ext.isPreview
import com.jetbrains.edu.learning.courseFormat.hyperskill.HyperskillCourse
import com.jetbrains.edu.learning.courseFormat.stepik.StepikCourse
import com.jetbrains.edu.learning.courseFormat.tasks.Task
import com.jetbrains.edu.learning.courseFormat.tasks.choice.ChoiceTask
import com.jetbrains.edu.learning.handlers.UserCreatedFileListener
import com.jetbrains.edu.learning.messages.EduCoreBundle
import com.jetbrains.edu.learning.navigation.NavigationUtils
import com.jetbrains.edu.learning.navigation.NavigationUtils.setHighlightLevelForFilesInTask
import com.jetbrains.edu.learning.newproject.coursesStorage.CoursesStorage
import com.jetbrains.edu.learning.notification.EduNotificationManager
import com.jetbrains.edu.learning.projectView.CourseViewPane
import com.jetbrains.edu.learning.statistics.EduCounterUsageCollector
import com.jetbrains.edu.learning.yaml.YamlFormatSynchronizer
import org.jetbrains.annotations.NonNls
import org.jetbrains.annotations.VisibleForTesting
class EduStartupActivity : StartupActivity.DumbAware {
private val YAML_MIGRATED = "Edu.Yaml.Migrate"
override fun runActivity(project: Project) {
if (!project.isEduProject()) return
val manager = StudyTaskManager.getInstance(project)
val connection = ApplicationManager.getApplication().messageBus.connect(manager)
if (!isUnitTestMode) {
val vfsListener = if (project.isStudentProject()) UserCreatedFileListener(project) else CCVirtualFileListener(project, manager)
connection.subscribe(VirtualFileManager.VFS_CHANGES, vfsListener)
if (CCUtils.isCourseCreator(project)) {
EditorFactory.getInstance().eventMulticaster.addDocumentListener(SynchronizeTaskDescription(project), manager)
EditorFactory.getInstance().eventMulticaster.addDocumentListener(CourseIgnoreDocumentListener(project), manager)
}
EduDocumentListener.setGlobalListener(project, manager)
}
ensureCourseIgnoreHasNoCustomAssociation()
StartupManager.getInstance(project).runWhenProjectIsInitialized {
val course = manager.course
if (course == null) {
LOG.warn("Opened project is with null course")
return@runWhenProjectIsInitialized
}
@NonNls val jetBrainsAcademyActionName = "JetBrains Academy"
if (course is CheckiOCourse && !ApplicationManager.getApplication().isUnitTestMode) {
EduNotificationManager.create(
WARNING,
EduFormatNames.CHECKIO,
EduCoreBundle.message("checkio.drop.notifications")
)
.addAction(BrowseNotificationAction(EduFormatNames.CHECKIO, "https://checkio.org/"))
.addAction(BrowseNotificationAction(jetBrainsAcademyActionName, "https://academy.jetbrains.com"))
.setImportant(true)
.notify(project)
}
if (course is CodeforcesCourse && !ApplicationManager.getApplication().isUnitTestMode) {
EduNotificationManager.create(
WARNING,
EduFormatNames.CODEFORCES,
EduCoreBundle.message("codeforces.drop.notification")
)
.addAction(BrowseNotificationAction(EduFormatNames.CODEFORCES, "https://codeforces.com/"))
.addAction(BrowseNotificationAction(jetBrainsAcademyActionName, "https://academy.jetbrains.com"))
.setImportant(true)
.notify(project)
}
val fileEditorManager = FileEditorManager.getInstance(project)
if (!fileEditorManager.hasOpenFiles()) {
NavigationUtils.openFirstTask(course, project)
}
selectProjectView(project, true)
migrateYaml(project, course)
setupProject(project, course)
val coursesStorage = CoursesStorage.getInstance()
val location = project.basePath
if (!coursesStorage.hasCourse(course) && location != null && !course.isPreview) {
coursesStorage.addCourse(course, location)
}
SyncChangesStateManager.getInstance(project).updateSyncChangesState(course)
runWriteAction {
if (project.isStudentProject()) {
course.visitTasks {
setHighlightLevelForFilesInTask(it, project)
}
}
EduCounterUsageCollector.eduProjectOpened(course)
}
}
}
@VisibleForTesting
fun migrateYaml(project: Project, course: Course) {
migratePropagatableYamlFields(project, course)
migrateCanCheckLocallyYaml(project, course)
YamlFormatSynchronizer.saveAll(project)
}
private fun migrateCanCheckLocallyYaml(project: Project, course: Course) {
val propertyComponent = PropertiesComponent.getInstance(project)
if (propertyComponent.getBoolean(YAML_MIGRATED)) return
propertyComponent.setValue(YAML_MIGRATED, true)
if (course !is HyperskillCourse && course !is StepikCourse) return
course.visitTasks {
if (it is ChoiceTask) {
it.canCheckLocally = false
}
}
}
private fun migratePropagatableYamlFields(project: Project, course: Course) {
if (!CCUtils.isCourseCreator(project)) return
val propertiesComponent = PropertiesComponent.getInstance(project)
if (propertiesComponent.getBoolean(YAML_MIGRATED_PROPAGATABLE)) return
propertiesComponent.setValue(YAML_MIGRATED_PROPAGATABLE, true)
var hasPropagatableFlag = false
val nonPropagatableFiles = mutableListOf<TaskFile>()
course.visitTasks { task: Task ->
if (task.lesson is FrameworkLesson) {
for (taskFile in task.taskFiles.values) {
if (!taskFile.isPropagatable) {
hasPropagatableFlag = true
return@visitTasks
}
if (!taskFile.isVisible || !taskFile.isEditable) {
nonPropagatableFiles += taskFile
}
}
}
}
if (hasPropagatableFlag) return
for (taskFile in nonPropagatableFiles) {
taskFile.isPropagatable = false
}
}
private fun ensureCourseIgnoreHasNoCustomAssociation() {
runInEdt {
runWriteAction {
FileTypeManager.getInstance().associate(CourseIgnoreFileType, ExactFileNameMatcher(COURSE_IGNORE))
}
}
}
// In general, it's hack to select proper Project View pane for course projects
// Should be replaced with proper API
private fun selectProjectView(project: Project, retry: Boolean) {
ToolWindowManager.getInstance(project).invokeLater(Runnable {
val toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.PROJECT_VIEW)
// Since 2020.1 project view tool window can be uninitialized here yet
if (toolWindow == null) {
if (retry) {
selectProjectView(project, false)
}
else {
LOG.warn("Failed to show Course View because Project View is not initialized yet")
}
return@Runnable
}
val projectView = ProjectView.getInstance(project)
if (projectView != null) {
val selectedViewId = ProjectView.getInstance(project).currentViewId
if (CourseViewPane.ID != selectedViewId) {
projectView.changeView(CourseViewPane.ID)
}
}
else {
LOG.warn("Failed to select Project View")
}
toolWindow.show()
})
}
private fun setupProject(project: Project, course: Course) {
val configurator = course.configurator
if (configurator == null) {
LOG.warn("Failed to refresh gradle project: configurator for `${course.languageId}` is null")
return
}
if (!isUnitTestMode && project.isNewlyCreated()) {
configurator.courseBuilder.refreshProject(project, RefreshCause.PROJECT_CREATED)
}
// Android Studio creates `gradlew` not via VFS, so we have to refresh project dir
runInBackground(project, EduCoreBundle.message("refresh.course.project.directory"), false) {
VfsUtil.markDirtyAndRefresh(false, true, true, project.courseDir)
}
}
companion object {
@VisibleForTesting
const val YAML_MIGRATED_PROPAGATABLE = "Edu.Yaml.Migrate.Propagatable"
private val LOG = Logger.getInstance(EduStartupActivity::class.java)
}
}
| 7 | null | 49 | 150 | 9cec6c97d896f4485e76cf9a2a95f8a8dd21c982 | 10,084 | educational-plugin | Apache License 2.0 |
app/src/main/java/com/ng/ui/show/view/CtbFragment.kt | jiangzhengnan | 185,233,735 | false | null | package com.ng.ui.show.frag
import android.view.View
import com.ng.ui.R
import kotlinx.android.synthetic.main.fragment_ctb.*
/**
* 描述:
* @author Jzn
* @date 2020-06-12
*/
class CtbFragment : BaseFragment() {
override fun initViewsAndEvents(v: View) {
btn1_mcv.setOnClickListener {
ctt_mcv.isChecked = true
}
btn2_mcv.setOnClickListener {
ctt_mcv.isChecked = false
}
}
override fun getLayoutId(): Int = R.layout.fragment_ctb
} | 0 | null | 68 | 243 | f528f8ad912f89c66ea3622f2e93a31db062cd93 | 502 | NguiLib | Apache License 2.0 |
core/src/main/java/com/infinum/jsonapix/core/discriminators/JsonApiDiscriminator.kt | infinum | 291,043,190 | false | null | @file:SuppressWarnings("TooGenericExceptionCaught")
package com.infinum.jsonapix.core.discriminators
import com.infinum.jsonapix.core.common.JsonApiConstants
import com.infinum.jsonapix.core.common.JsonApiConstants.Prefix.withName
import kotlinx.serialization.json.JsonArray
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonNull
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.jsonObject
/**
* This Discriminator is made specifically to handle JSON API objects. It leverages the functionality
* of [CommonDiscriminator] and handles the whole hierarchy of a JSON API object.
* All child objects or arrays that extend an interface get their discriminator string injected or extracted here
* Discriminator string should always be in the following format:
*
* Root object -> type parameter of the class
* Child objects -> Child prefix + type parameter e.g. Attributes_person where person is the type
* of a class called Person passed as a parameter to JsonApiX annotation.
*/
class JsonApiDiscriminator(
private val rootType: String,
private val rootLinks: String,
private val resourceObjectLinks: String,
relationshipsLinks: String,
meta: String,
error: String
) : BaseJsonApiDiscriminator(rootType, relationshipsLinks, meta, error) {
@SuppressWarnings("SwallowedException", "LongMethod")
override fun inject(jsonElement: JsonElement): JsonElement {
try {
// Current objects
val dataObject = getDataObject(jsonElement)
val relationshipsObject = getRelationshipsObject(jsonElement)
val attributesObject = getAttributesObject(jsonElement)
val rootLinksObject = getLinksObject(jsonElement)
val errorsObject = getErrorsObject(jsonElement)
val resourceLinksObject = dataObject?.let {
getLinksObject(it)
}
val metaObject = getMetaObject(jsonElement)
// Injected objects
val newRootLinksObject = rootLinksObject?.takeIf { it !is JsonNull }?.let {
val resourceLinksDiscriminator = CommonDiscriminator(rootLinks)
resourceLinksDiscriminator.inject(it)
}
val newResourceLinksObject = resourceLinksObject?.takeIf { it !is JsonNull }?.let {
val resourceLinksDiscriminator = CommonDiscriminator(resourceObjectLinks)
resourceLinksDiscriminator.inject(it)
}
val newErrorsArray = errorsObject?.takeIf { it !is JsonNull }?.let {
getNewErrorsArray(it)
}
val newRelationshipsObject = relationshipsObject?.takeIf { it !is JsonNull }?.let {
val relationshipsDiscriminator = CommonDiscriminator(
JsonApiConstants.Prefix.RELATIONSHIPS.withName(rootType)
)
relationshipsDiscriminator.inject(getNewRelationshipsObject(it))
}
val newAttributesObject = attributesObject?.takeIf { it !is JsonNull }?.let {
val attributesDiscriminator =
CommonDiscriminator(JsonApiConstants.Prefix.ATTRIBUTES.withName(rootType))
attributesDiscriminator.inject(it)
}
val newIncludedArray = buildTypeDiscriminatedIncludedArray(jsonElement)
val newDataObject = dataObject?.takeIf { it !is JsonNull }?.let {
val dataDiscriminator = CommonDiscriminator(
JsonApiConstants.Prefix.RESOURCE_OBJECT.withName(rootType)
)
getNewDataObject(
dataDiscriminator.inject(it),
newAttributesObject,
newRelationshipsObject,
newResourceLinksObject
)
}
val newMetaObject = metaObject?.takeIf { it !is JsonNull }?.let { getNewMetaObject(it) }
val newJsonElement = getJsonObjectWithDataDiscriminator(
original = jsonElement,
dataObject = newDataObject,
includedArray = newIncludedArray,
linksObject = newRootLinksObject,
errorsArray = newErrorsArray,
metaObject = newMetaObject
)
return rootDiscriminator.inject(newJsonElement)
} catch (e: Exception) {
// TODO Add Timber and custom exceptions
throw IllegalArgumentException(
"Input must be either JSON object or array with the key type defined",
e.cause
)
}
}
@SuppressWarnings("SwallowedException")
override fun extract(jsonElement: JsonElement): JsonElement {
try {
val dataObject = getDataObject(jsonElement)?.let {
rootDiscriminator.extract(it)
}
val includedArray = buildRootDiscriminatedIncludedArray(jsonElement)
val errorsArray = buildRootDiscriminatedErrorsArray(jsonElement)
val newJsonElement = getJsonObjectWithDataDiscriminator(
original = jsonElement,
includedArray = includedArray,
dataObject = dataObject,
linksObject = null,
errorsArray = errorsArray,
metaObject = null
)
return rootDiscriminator.extract(newJsonElement)
} catch (e: Exception) {
// TODO Add Timber and custom exceptions
throw IllegalArgumentException(
"Input must be either JSON object or array with the key type defined",
e.cause
)
}
}
override fun getRelationshipsObject(jsonElement: JsonElement): JsonElement? =
getDataObject(jsonElement)?.jsonObject?.get(JsonApiConstants.Keys.RELATIONSHIPS)
override fun getAttributesObject(jsonElement: JsonElement): JsonElement? =
getDataObject(jsonElement)?.jsonObject?.get(JsonApiConstants.Keys.ATTRIBUTES)
private fun getJsonObjectWithDataDiscriminator(
original: JsonElement,
dataObject: JsonElement?,
includedArray: JsonArray?,
linksObject: JsonElement?,
errorsArray: JsonArray?,
metaObject: JsonElement?
): JsonObject {
return getDiscriminatedBaseEntries(original, includedArray, linksObject, errorsArray, metaObject).let { entries ->
dataObject?.let { data ->
entries.removeAll { it.key == JsonApiConstants.Keys.DATA }
entries.add(getJsonObjectEntry(JsonApiConstants.Keys.DATA, data))
}
val resultMap = mutableMapOf<String, JsonElement>()
resultMap.putAll(entries.map { Pair(it.key, it.value) })
JsonObject(resultMap)
}
}
}
| 5 | Kotlin | 9 | 28 | 9efad5361759b8dbf48c1bb027ae69fc906066e5 | 6,844 | kotlin-jsonapix | Apache License 2.0 |
components/src/androidMain/kotlin/com/alexrdclement/uiplayground/components/TextField.android.kt | alexrdclement | 661,077,963 | false | {"Kotlin": 224028, "Swift": 900} | package com.alexrdclement.uiplayground.components
import androidx.compose.foundation.text.input.rememberTextFieldState
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import com.alexrdclement.uiplayground.theme.PlaygroundTheme
@Preview
@Composable
private fun Preview() {
PlaygroundTheme {
Surface {
TextField(
state = rememberTextFieldState("text"),
)
}
}
}
| 0 | Kotlin | 0 | 0 | a99ee143215098889afaf4fa97d3399f9dc65383 | 471 | UiPlayground | Apache License 2.0 |
order/listener/src/main/kotlin/com/rarible/protocol/order/listener/service/currency/CurrencyService.kt | NFTDroppr | 418,665,809 | true | {"Kotlin": 2329156, "Scala": 37343, "Shell": 6001, "HTML": 547} | package com.rarible.protocol.order.listener.service.currency
import com.rarible.protocol.order.core.model.Currency
import com.rarible.protocol.order.core.repository.currency.CurrencyRepository
import org.springframework.stereotype.Component
import scalether.domain.Address
@Component
class CurrencyService(
private val repository: CurrencyRepository
) {
suspend fun byAddress(address: Address): Currency? {
return if (address == Address.ZERO()) {
Currency.ETH
} else {
repository.findFirstByAddress(address)
}
}
} | 0 | Kotlin | 0 | 1 | b1efdaceab8be95429befe80ce1092fab3004d18 | 575 | ethereum-indexer | MIT License |
sample/src/main/java/com/chicco/sample/MainActivity.kt | drahovac | 342,925,986 | false | null | package com.chicco.sample
import android.os.Bundle
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import com.chicco.sample.databinding.ActivityMainBinding
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
private val model: MainViewModel by viewModels()
private lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
savePdfStream.setOnClickListener { model.savePdf(saveAsBytes = false) }
savePdfBytes.setOnClickListener { model.savePdf(saveAsBytes = true) }
saveImage.setOnClickListener { model.saveImage() }
saveBitmap.setOnClickListener { model.saveBitmap() }
model.downloadPendingJob.observe(this) { jobPending ->
savePdfStream.isEnabled = !jobPending
if (jobPending) progressBar.show() else progressBar.hide()
}
model.pdfSaveResult.observe(this) {
savePdfResult.text = it
}
model.imageSaveResult.observe(this) {
saveImageResult.text = it
}
model.bitmapSaveResult.observe(this) {
saveBitmapResult.text = it
}
}
}
| 0 | Kotlin | 1 | 2 | ac490dd099347183345e420e1f45a473cb5bde71 | 1,361 | android-file-save | Apache License 2.0 |
longan/src/main/java/com/dylanc/longan/Keyboard.kt | 379107728 | 430,594,612 | false | null | /*
* Copyright (c) 2021. <NAME>
*
* 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("unused")
package com.dylanc.longan
import android.widget.EditText
import androidx.core.view.WindowInsetsCompat.Type
fun EditText.showKeyboard() =
windowInsetsControllerCompat?.show(Type.ime())
fun EditText.hideKeyboard() =
windowInsetsControllerCompat?.hide(Type.ime())
fun EditText.toggleKeyboard() =
if (isKeyboardVisible) hideKeyboard() else showKeyboard()
inline val EditText.isKeyboardVisible: Boolean
get() = rootWindowInsetsCompat?.isVisible(Type.ime()) == true
inline val EditText.keyboardHeight: Int
get() = rootWindowInsetsCompat?.getInsets(Type.ime())?.bottom ?: -1
| 0 | null | 0 | 1 | 602ea1bea3ea2c87185a623204dc17606d0acfc8 | 1,206 | Longan | Apache License 2.0 |
app/src/main/java/com/iamageo/weather/app/WeatherApp.kt | iamageo | 512,027,915 | false | null | package com.plcoding.weatherapp
import android.app.Application
import dagger.hilt.android.HiltAndroidApp
@HiltAndroidApp
class WeatherApp: Application() | 0 | null | 0 | 2 | d9f3f05caa0444de87d99397a35bfb943d4f9dcf | 154 | WeatherApp | MIT License |
app/src/main/java/com/example/fragment/project/ui/my_demo/DatePickerScreen.kt | miaowmiaow | 364,865,870 | false | {"Kotlin": 687499, "Java": 24923, "JavaScript": 10814, "HTML": 5445, "CSS": 60} | package com.example.fragment.project.ui.my_demo
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.ModalBottomSheetLayout
import androidx.compose.material.ModalBottomSheetValue
import androidx.compose.material.Text
import androidx.compose.material.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.fragment.project.R
import com.example.fragment.project.components.DatePicker
import kotlinx.coroutines.launch
@OptIn(ExperimentalMaterialApi::class)
@Composable
fun DatePickerScreen() {
val scope = rememberCoroutineScope()
val sheetState = rememberModalBottomSheetState(
initialValue = ModalBottomSheetValue.Hidden,
)
ModalBottomSheetLayout(
sheetState = sheetState,
sheetContent = {
Row(
Modifier
.fillMaxWidth()
.padding(16.dp),
verticalAlignment = Alignment.CenterVertically
) {
Button(
onClick = { scope.launch { sheetState.hide() } },
modifier = Modifier
.width(50.dp)
.height(25.dp),
elevation = ButtonDefaults.elevation(0.dp, 0.dp, 0.dp),
shape = RoundedCornerShape(5.dp),
border = BorderStroke(1.dp, colorResource(R.color.gray)),
colors = ButtonDefaults.buttonColors(
backgroundColor = colorResource(R.color.gray),
contentColor = colorResource(R.color.text_666)
),
contentPadding = PaddingValues(5.dp, 3.dp, 5.dp, 3.dp)
) {
Text(text = "取消", fontSize = 13.sp)
}
Spacer(Modifier.weight(1f))
Button(
onClick = { scope.launch { sheetState.hide() } },
modifier = Modifier
.width(50.dp)
.height(25.dp),
elevation = ButtonDefaults.elevation(0.dp, 0.dp, 0.dp),
shape = RoundedCornerShape(5.dp),
border = BorderStroke(1.dp, colorResource(R.color.gray)),
colors = ButtonDefaults.buttonColors(
backgroundColor = colorResource(R.color.theme_orange),
contentColor = colorResource(R.color.text_fff)
),
contentPadding = PaddingValues(5.dp, 3.dp, 5.dp, 3.dp)
) {
Text(text = "确定", fontSize = 13.sp)
}
}
Spacer(
Modifier
.background(colorResource(R.color.line))
.fillMaxWidth()
.height(1.dp)
)
DatePicker(
onSelectYear = {
println("year: $it")
},
onSelectMonth = {
println("month: $it")
},
onSelectDay = {
println("day: $it")
}
)
}
) {
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Button(
onClick = {
scope.launch {
sheetState.show()
}
},
modifier = Modifier.height(30.dp),
elevation = ButtonDefaults.elevation(0.dp, 0.dp, 0.dp),
shape = RoundedCornerShape(3.dp),
border = BorderStroke(1.dp, colorResource(R.color.theme_orange)),
colors = ButtonDefaults.buttonColors(
backgroundColor = colorResource(R.color.white),
contentColor = colorResource(R.color.theme_orange)
),
contentPadding = PaddingValues(3.dp, 2.dp, 3.dp, 2.dp)
) {
Text(
text = "日期选择demo",
fontSize = 12.sp
)
}
}
}
} | 0 | Kotlin | 202 | 1,103 | 2279b845e19c85a7d89a4a36fccffddba9e57bd0 | 5,267 | fragmject | Apache License 2.0 |
app/src/main/java/com/an/trailers_compose/data/local/TvDatabase.kt | anitaa1990 | 870,606,866 | false | {"Kotlin": 175839} | package com.an.trailers_compose.data.local
import androidx.room.Database
import androidx.room.RoomDatabase
import androidx.room.TypeConverters
import com.an.trailers_compose.data.local.converter.CreditResponseTypeConverter
import com.an.trailers_compose.data.local.converter.GenreListTypeConverter
import com.an.trailers_compose.data.local.converter.LongListTypeConverter
import com.an.trailers_compose.data.local.converter.TvApiResponseTypeConverter
import com.an.trailers_compose.data.local.converter.VideoResponseTypeConverter
import com.an.trailers_compose.data.local.dao.TvDao
import com.an.trailers_compose.data.local.dao.TvRemoteKeyDao
import com.an.trailers_compose.data.local.entity.TvEntity
import com.an.trailers_compose.data.local.entity.TvRemoteKey
@Database(
entities = [TvEntity::class, TvRemoteKey::class],
version = 1,
exportSchema = false
)
@TypeConverters(
GenreListTypeConverter::class,
LongListTypeConverter::class,
CreditResponseTypeConverter::class,
VideoResponseTypeConverter::class,
TvApiResponseTypeConverter::class
)
abstract class TvDatabase: RoomDatabase() {
abstract val tvDao: TvDao
abstract val remoteKeyDao: TvRemoteKeyDao
} | 0 | Kotlin | 1 | 1 | a93ecd98968f071a174601d807f5d3725c669ff2 | 1,199 | Trailers-Compose | Apache License 2.0 |
app/src/main/java/com/movicom/informativeapplicationcovid19/views/AboutFragment.kt | SebastianRV26 | 289,597,953 | false | null | package com.movicom.informativeapplicationcovid19.views
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.fragment.app.Fragment
import com.movicom.informativeapplicationcovid19.R
import com.squareup.picasso.Picasso
/**
* Controlador de vista: Acerca de.
*/
class AboutFragment : Fragment(), View.OnClickListener {
private var ivDeveloper:ImageView ?= null
private var ivTEC:ImageView ?= null
private var ivMovicom:ImageView ?= null
private var ivGitHub:ImageView ?= null
private var ivLinkedIn:ImageView ?= null
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
val view = inflater.inflate(R.layout.fragment_about, container, false)
ivDeveloper = view.findViewById(R.id.ivDeveloper)
ivTEC = view.findViewById(R.id.ivTEC)
ivMovicom = view.findViewById(R.id.ivMovicom)
ivGitHub = view.findViewById(R.id.ivGitHub)
ivLinkedIn = view.findViewById(R.id.ivLinkedIn)
ivDeveloper!!.loadUrl(getString(R.string.dev_github))
ivTEC!!.setOnClickListener(this)
ivMovicom!!.setOnClickListener(this)
ivGitHub!!.setOnClickListener(this)
ivLinkedIn!!.setOnClickListener(this)
return view
}
override fun onClick(p0: View?) {
when(p0!!.id) {
R.id.ivMovicom -> {
loadUrl("facebook.com/${getString(R.string.movicom)}")
}
R.id.ivTEC -> {
loadUrl(getString(R.string.tec))
}
R.id.ivGitHub -> {
loadUrl("github.com/${getString(R.string.dev_github)}")
}
R.id.ivLinkedIn -> {
loadUrl("linkedin.com/in/${getString(R.string.dev_linkedin)}")
}
}
}
/**
* Intento de abrir una página web.
*
* @param url dirección web.
*/
private fun loadUrl(url:String){
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://www.${url}/"))
startActivity(intent)
}
/**
* Mostrar una imagen de internet con la librería Picasso.
*
* @param url
*/
private fun ImageView.loadUrl(url: String) {
Picasso.with(context).load("https://avatars.githubusercontent.com/$url").into(this)
}
}
| 0 | Kotlin | 0 | 1 | bf3bc1dfc9bdb3cb71a503f81a0cb778240283a2 | 2,538 | Info-COVID-App | MIT License |
hybridAndroid/app/src/main/java/com/liuhc/myapplication/PageFlutterFragmentActivity.kt | ikakaxi | 206,521,040 | false | null | package com.liuhc.myapplication
import android.os.Bundle
import android.util.Log
import io.flutter.app.FlutterFragmentActivity
import io.flutter.plugin.common.MethodChannel
import io.flutter.view.FlutterMain
import org.json.JSONObject
/**
* 描述:
* 作者:liuhc
* 创建日期:2019-09-04 on 21:07
*/
class PageFlutterFragmentActivity : FlutterFragmentActivity() {
private lateinit var methodChannel: MethodChannel
override fun onCreate(savedInstanceState: Bundle?) {
//强烈建议放到Application里初始化,初始化一次即可,放这里只是举个例子
FlutterMain.startInitialization(this)
//intent的参数设置必须在super.onCreate之前,因为super.onCreate里会取这些参数
intent.action = "android.intent.action.RUN"
val channelName = "channelName_PageFlutterFragmentActivity"
val androidMethod = "methodName_PageFlutterFragmentActivity"
val jsonObject = JSONObject()
jsonObject.put("path", "InvokeMethodPage")
jsonObject.put("title", "PageFlutterFragmentActivity")
jsonObject.put("channelName", channelName)
jsonObject.put("androidMethod", androidMethod)
intent.putExtra("route", jsonObject.toString())
super.onCreate(savedInstanceState)
//调用super.onCreate(savedInstanceState)之后flutterView才有值,
//所以如果需要注册插件,则应该放到super.onCreate(savedInstanceState)代码之后才可以
flutterView.enableTransparentBackground()
//如果不需要平台交互的话,只需要上面的代码并在最后加上super.onCreate就可以了
//这里this.registrarFor方法实际调用的是FlutterFragmentActivity里的delegate的registrarFor方法,
//而delegate的registrarFor方法实际调用的是FlutterActivityDelegate里的flutterView.getPluginRegistry().registrarFor方法,
//而FlutterActivityDelegate里的flutterView在调用了这里的super.onCreate(savedInstanceState)才有值,
//所以如果需要注册插件,则应该放到super.onCreate(savedInstanceState)代码之后才可以
val key = "PageFlutterFragmentActivity"
if (this.hasPlugin(key)) return
val registrar = this.registrarFor(key)
methodChannel = MethodChannel(
registrar.messenger(),
channelName
)
methodChannel.setMethodCallHandler { methodCall, result ->
if (methodCall.method == androidMethod) {
Log.e("Android", "接收到了Flutter传递的参数:${methodCall.arguments}")
result.success("$androidMethod ok")
Log.e("Android", "主动调用Flutter的methodInvokeMethodPageState方法")
methodChannel.invokeMethod("methodInvokeMethodPageState", "Android发送给Flutter的参数")
}
}
}
} | 0 | Kotlin | 1 | 5 | 2b8c51cb4941080bb559e99e1f05f693f923dc11 | 2,475 | hybridFlutterAndroid | Apache License 2.0 |
pensjon-brevbaker/src/main/kotlin/no/nav/pensjon/etterlatte/maler/barnepensjon/opphoer/BarnepensjonOpphoer.kt | navikt | 375,334,697 | false | {"Kotlin": 1963048, "TypeScript": 226000, "TeX": 12814, "Shell": 9753, "CSS": 7605, "Python": 4661, "JavaScript": 4236, "Dockerfile": 2406, "HTML": 763} | package no.nav.pensjon.etterlatte.maler.barnepensjon.opphoer
import no.nav.pensjon.brev.template.Language.Bokmal
import no.nav.pensjon.brev.template.Language.English
import no.nav.pensjon.brev.template.Language.Nynorsk
import no.nav.pensjon.brev.template.dsl.createTemplate
import no.nav.pensjon.brev.template.dsl.expression.equalTo
import no.nav.pensjon.brev.template.dsl.expression.expr
import no.nav.pensjon.brev.template.dsl.expression.format
import no.nav.pensjon.brev.template.dsl.expression.not
import no.nav.pensjon.brev.template.dsl.expression.plus
import no.nav.pensjon.brev.template.dsl.helpers.TemplateModelHelpers
import no.nav.pensjon.brev.template.dsl.languages
import no.nav.pensjon.brev.template.dsl.text
import no.nav.pensjon.brev.template.dsl.textExpr
import no.nav.pensjon.brevbaker.api.model.LetterMetadata
import no.nav.pensjon.etterlatte.EtterlatteBrevKode
import no.nav.pensjon.etterlatte.EtterlatteTemplate
import no.nav.pensjon.etterlatte.maler.BrevDTO
import no.nav.pensjon.etterlatte.maler.Element
import no.nav.pensjon.etterlatte.maler.FeilutbetalingType
import no.nav.pensjon.etterlatte.maler.Hovedmal
import no.nav.pensjon.etterlatte.maler.barnepensjon.opphoer.BarnepensjonOpphoerDTOSelectors.bosattUtland
import no.nav.pensjon.etterlatte.maler.barnepensjon.opphoer.BarnepensjonOpphoerDTOSelectors.brukerUnder18Aar
import no.nav.pensjon.etterlatte.maler.barnepensjon.opphoer.BarnepensjonOpphoerDTOSelectors.feilutbetaling
import no.nav.pensjon.etterlatte.maler.barnepensjon.opphoer.BarnepensjonOpphoerDTOSelectors.innhold
import no.nav.pensjon.etterlatte.maler.barnepensjon.opphoer.BarnepensjonOpphoerDTOSelectors.virkningsdato
import no.nav.pensjon.etterlatte.maler.fraser.barnepensjon.BarnepensjonFellesFraser
import no.nav.pensjon.etterlatte.maler.fraser.barnepensjon.BarnepensjonRevurderingFraser
import no.nav.pensjon.etterlatte.maler.konverterElementerTilBrevbakerformat
import no.nav.pensjon.etterlatte.maler.vedlegg.barnepensjon.forhaandsvarselFeilutbetalingBarnepensjonOpphoer
import no.nav.pensjon.etterlatte.maler.vedlegg.klageOgAnke
import java.time.LocalDate
data class BarnepensjonOpphoerDTO(
override val innhold: List<Element>,
val innholdForhaandsvarsel: List<Element>,
val brukerUnder18Aar: Boolean,
val bosattUtland: Boolean,
val virkningsdato: LocalDate,
val feilutbetaling: FeilutbetalingType
) : BrevDTO
@TemplateModelHelpers
object BarnepensjonOpphoer : EtterlatteTemplate<BarnepensjonOpphoerDTO>, Hovedmal {
override val kode: EtterlatteBrevKode = EtterlatteBrevKode.BARNEPENSJON_OPPHOER
override val template = createTemplate(
name = kode.name,
letterDataType = BarnepensjonOpphoerDTO::class,
languages = languages(Bokmal, Nynorsk, English),
letterMetadata = LetterMetadata(
displayTitle = "Vedtak - opphør",
isSensitiv = true,
distribusjonstype = LetterMetadata.Distribusjonstype.VEDTAK,
brevtype = LetterMetadata.Brevtype.VEDTAKSBREV,
),
) {
title {
text(
Bokmal to "Vi har opphørt barnepensjonen din",
Nynorsk to "Vi har avvikla barnepensjonen din",
English to "We have terminated your children's pension",
)
}
outline {
paragraph {
textExpr(
Bokmal to "Barnepensjonen din opphører fra ".expr() + virkningsdato.format() + ".",
Nynorsk to "Barnepensjonen din fell bort frå og med ".expr() + virkningsdato.format() + ".",
English to "Your children's pension will terminate on ".expr() + virkningsdato.format() + ".",
)
}
konverterElementerTilBrevbakerformat(innhold)
showIf(feilutbetaling.equalTo(FeilutbetalingType.FEILUTBETALING_MED_VARSEL)) {
includePhrase(BarnepensjonRevurderingFraser.FeilutbetalingMedVarselOpphoer)
}
includePhrase(BarnepensjonFellesFraser.DuHarRettTilAaKlage)
includePhrase(BarnepensjonFellesFraser.DuHarRettTilInnsyn)
includePhrase(BarnepensjonFellesFraser.HarDuSpoersmaal(brukerUnder18Aar, bosattUtland))
}
// Nasjonal
includeAttachment(klageOgAnke(bosattUtland = false), innhold, bosattUtland.not())
// Bosatt utland
includeAttachment(klageOgAnke(bosattUtland = true), innhold, bosattUtland)
includeAttachment(forhaandsvarselFeilutbetalingBarnepensjonOpphoer, this.argument, feilutbetaling.equalTo(FeilutbetalingType.FEILUTBETALING_MED_VARSEL))
}
}
| 7 | Kotlin | 3 | 1 | b30da6b77c8d2c56d03987031c59373710403d30 | 4,615 | pensjonsbrev | MIT License |
game/plugins/src/main/kotlin/gg/rsmod/plugins/content/npcs/definitions/other/ice_giant_level_53.plugin.kts | 2011Scape | 578,880,245 | false | null | package gg.rsmod.plugins.content.npcs.definitions.other
import gg.rsmod.game.model.combat.SlayerAssignment
import gg.rsmod.game.model.combat.StyleType
import gg.rsmod.plugins.content.drops.DropTableFactory
import gg.rsmod.plugins.content.drops.global.Gems
import gg.rsmod.plugins.content.drops.global.Seeds
val ids = intArrayOf(Npcs.ICE_GIANT, Npcs.ICE_GIANT_3072, Npcs.ICE_GIANT_4685, Npcs.ICE_GIANT_4686, Npcs.ICE_GIANT_4687)
val table = DropTableFactory
val iceGiant = table.build {
guaranteed {
obj(Items.BIG_BONES)
}
main {
total(1024)
obj(Items.IRON_2H_SWORD, slots = 40)
obj(Items.BLACK_KITESHIELD, slots = 32)
obj(Items.STEEL_HATCHET, slots = 32)
obj(Items.STEEL_SWORD, slots = 32)
obj(Items.IRON_PLATELEGS, slots = 8)
obj(Items.MITHRIL_MACE, slots = 8)
obj(Items.MITHRIL_SQ_SHIELD, slots = 8)
obj(Items.ADAMANT_ARROW, quantity = 5, slots = 48)
obj(Items.NATURE_RUNE, quantity = 6, slots = 32)
obj(Items.MIND_RUNE, quantity = 24, slots = 24)
obj(Items.BODY_RUNE, quantity = 37, slots = 24)
obj(Items.LAW_RUNE, quantity = 3, slots = 16)
obj(Items.WATER_RUNE, quantity = 12, slots = 8)
obj(Items.COSMIC_RUNE, quantity = 4, slots = 8)
obj(Items.DEATH_RUNE, quantity = 3, slots = 8)
obj(Items.BLOOD_RUNE, quantity = 2, slots = 8)
table(Seeds.allotmentSeedTable, slots = 64)
obj(Items.COINS_995, quantity = 117, slots = 224)
obj(Items.COINS_995, quantity = 53, slots = 76)
obj(Items.COINS_995, quantity = 196, slots = 72)
obj(Items.COINS_995, quantity = 5, slots = 64)
obj(Items.COINS_995, quantity = 8, slots = 54)
obj(Items.COINS_995, quantity = 2, slots = 48)
obj(Items.COINS_995, quantity = 400, slots = 16)
obj(Items.JUG_OF_WINE, slots = 24)
obj(Items.MITHRIL_ORE, slots = 8)
obj(Items.BANANA, slots = 8)
table(Gems.gemTable, slots = 32)
}
table("Tertiary") {
total(100_000)
obj(Items.LONG_BONE, slots = 250)
obj(Items.CURVED_BONE, slots = 20)
obj(Items.CHAMPIONS_SCROLL_6800, slots = 20)
nothing(99710)
}
}
table.register(iceGiant, *ids)
on_npc_pre_death(*ids) {
val p = npc.damageMap.getMostDamage()!! as Player
p.playSound(Sfx.GIANT_DEATH)
}
on_npc_death(*ids) {
table.getDrop(world, npc.damageMap.getMostDamage()!! as Player, npc.id, npc.tile)
}
ids.forEach {
set_combat_def(it) {
configs {
attackSpeed = 5
respawnDelay = 30
attackStyle = StyleType.SLASH
}
stats {
hitpoints = 700
attack = 40
strength = 40
defence = 40
}
bonuses {
attackBonus = 29
strengthBonus = 31
defenceSlash = 3
defenceCrush = 2
}
anims {
attack = 4672
block = 4671
death = 4673
}
aggro {
radius = 5
}
slayer {
assignment = SlayerAssignment.ICE_GIANT
level = 1
experience = 70.0
}
}
} | 39 | null | 45 | 34 | e5400cc71bfa087164153d468979c5a3abc24841 | 3,220 | game | Apache License 2.0 |
idea/src/org/jetbrains/kotlin/idea/debugger/KotlinPositionManager.kt | msdgwzhy6 | 457,782,179 | false | null | /*
* Copyright 2010-2015 JetBrains s.r.o.
*
* 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.idea.debugger
import com.intellij.debugger.MultiRequestPositionManager
import com.intellij.debugger.NoDataException
import com.intellij.debugger.SourcePosition
import com.intellij.debugger.engine.DebugProcess
import com.intellij.debugger.engine.DebugProcessImpl
import com.intellij.debugger.requests.ClassPrepareRequestor
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.ModalityState
import com.intellij.openapi.progress.ProgressManager
import com.intellij.openapi.project.DumbService
import com.intellij.openapi.roots.libraries.LibraryUtil
import com.intellij.openapi.ui.MessageType
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
import com.intellij.psi.impl.compiled.ClsFileImpl
import com.intellij.psi.search.searches.ReferencesSearch
import com.intellij.psi.util.*
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.util.ThreeState
import com.intellij.xdebugger.frame.XStackFrame
import com.intellij.xdebugger.impl.XDebugSessionImpl
import com.sun.jdi.AbsentInformationException
import com.sun.jdi.Location
import com.sun.jdi.ReferenceType
import com.sun.jdi.request.ClassPrepareRequest
import org.jetbrains.kotlin.codegen.binding.CodegenBinding
import org.jetbrains.kotlin.codegen.inline.InlineCodegenUtil
import org.jetbrains.kotlin.codegen.state.JetTypeMapper
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil
import org.jetbrains.kotlin.fileClasses.NoResolveFileClassesProvider
import org.jetbrains.kotlin.fileClasses.getFileClassInternalName
import org.jetbrains.kotlin.fileClasses.internalNameWithoutInnerClasses
import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils
import org.jetbrains.kotlin.idea.debugger.breakpoints.getLambdasAtLineIfAny
import org.jetbrains.kotlin.idea.debugger.evaluate.KotlinCodeFragmentFactory
import org.jetbrains.kotlin.idea.debugger.evaluate.KotlinDebuggerCaches
import org.jetbrains.kotlin.idea.debugger.evaluate.KotlinDebuggerCaches.Companion.getOrComputeClassNames
import org.jetbrains.kotlin.idea.debugger.evaluate.KotlinDebuggerCaches.ComputedClassNames.CachedClassNames
import org.jetbrains.kotlin.idea.debugger.evaluate.KotlinDebuggerCaches.ComputedClassNames.NonCachedClassNames
import org.jetbrains.kotlin.idea.decompiler.classFile.KtClsFile
import org.jetbrains.kotlin.idea.search.usagesSearch.isImportUsage
import org.jetbrains.kotlin.idea.util.DebuggerUtils
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
import org.jetbrains.kotlin.idea.util.application.runReadAction
import org.jetbrains.kotlin.load.java.JvmAbi
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.parents
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
import org.jetbrains.kotlin.resolve.inline.InlineUtil
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
import org.jetbrains.kotlin.resolve.source.getPsi
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
import java.util.*
import com.intellij.debugger.engine.DebuggerUtils as JDebuggerUtils
class PositionedElement(val className: String?, val element: PsiElement?)
class KotlinPositionManager(private val myDebugProcess: DebugProcess) : MultiRequestPositionManager {
private val myTypeMappers = WeakHashMap<String, CachedValue<JetTypeMapper>>()
override fun getSourcePosition(location: Location?): SourcePosition? {
if (location == null) {
throw NoDataException.INSTANCE
}
val psiFile = getPsiFileByLocation(location)
if (psiFile == null) {
val isKotlinStrataAvailable = location.declaringType().containsKotlinStrata()
if (isKotlinStrataAvailable) {
try {
val javaSourceFileName = location.sourceName("Java")
val javaClassName = JvmClassName.byInternalName(defaultInternalName(location))
val project = myDebugProcess.project
val defaultPsiFile = DebuggerUtils.findSourceFileForClass(project, myDebugProcess.searchScope, javaClassName, javaSourceFileName)
if (defaultPsiFile != null) {
return SourcePosition.createFromLine(defaultPsiFile, 0)
}
}
catch(e: AbsentInformationException) {
// ignored
}
}
throw NoDataException.INSTANCE
}
val lineNumber = try {
location.lineNumber() - 1
}
catch (e: InternalError) {
-1
}
if (lineNumber >= 0) {
val lambdaOrFunIfInside = getLambdaOrFunIfInside(location, psiFile as KtFile, lineNumber)
if (lambdaOrFunIfInside != null) {
return SourcePosition.createFromElement(lambdaOrFunIfInside.bodyExpression!!)
}
return SourcePosition.createFromLine(psiFile, lineNumber)
}
throw NoDataException.INSTANCE
}
private fun getLambdaOrFunIfInside(location: Location, file: KtFile, lineNumber: Int): KtFunction? {
val currentLocationFqName = location.declaringType().name() ?: return null
val start = CodeInsightUtils.getStartLineOffset(file, lineNumber)
val end = CodeInsightUtils.getEndLineOffset(file, lineNumber)
if (start == null || end == null) return null
val literalsOrFunctions = getLambdasAtLineIfAny(file, lineNumber)
if (literalsOrFunctions.isEmpty()) return null;
val elementAt = file.findElementAt(start) ?: return null
val typeMapper = KotlinDebuggerCaches.getOrCreateTypeMapper(elementAt)
val currentLocationClassName = JvmClassName.byFqNameWithoutInnerClasses(FqName(currentLocationFqName)).internalName
for (literal in literalsOrFunctions) {
if (InlineUtil.isInlinedArgument(literal, typeMapper.bindingContext, true)) {
if (isInsideInlineArgument(literal, location, myDebugProcess as DebugProcessImpl)) {
return literal
}
continue
}
val internalClassNames = classNamesForPosition(literal.firstChild, true)
if (internalClassNames.any { it == currentLocationClassName }) {
return literal
}
}
return null
}
private fun getPsiFileByLocation(location: Location): PsiFile? {
val sourceName: String
try {
sourceName = location.sourceName()
}
catch (e: AbsentInformationException) {
return null
}
catch (e: InternalError) {
return null
}
val referenceInternalName: String
try {
if (location.declaringType().containsKotlinStrata()) {
//replace is required for windows
referenceInternalName = location.sourcePath().replace('\\', '/')
}
else {
referenceInternalName = defaultInternalName(location)
}
}
catch (e: AbsentInformationException) {
referenceInternalName = defaultInternalName(location)
}
val className = JvmClassName.byInternalName(referenceInternalName)
val project = myDebugProcess.project
return DebuggerUtils.findSourceFileForClass(project, myDebugProcess.searchScope, className, sourceName)
}
private fun defaultInternalName(location: Location): String {
//no stratum or source path => use default one
val referenceFqName = location.declaringType().name()
// JDI names are of form "package.Class$InnerClass"
return referenceFqName.replace('.', '/')
}
override fun getAllClasses(sourcePosition: SourcePosition): List<ReferenceType> {
val psiFile = sourcePosition.file
if (psiFile is KtFile) {
val result = ArrayList<ReferenceType>()
if (!ProjectRootsUtil.isInProjectOrLibSource(psiFile)) return result
val names = classNamesForPosition(sourcePosition, true)
for (name in names) {
result.addAll(myDebugProcess.virtualMachineProxy.classesByName(name))
}
return result
}
if (psiFile is ClsFileImpl) {
val decompiledPsiFile = psiFile.readAction { it.decompiledPsiFile }
if (decompiledPsiFile is KtClsFile && sourcePosition.line == -1) {
val className =
JvmFileClassUtil.getFileClassInfoNoResolve(decompiledPsiFile).fileClassFqName.internalNameWithoutInnerClasses
return myDebugProcess.virtualMachineProxy.classesByName(className)
}
}
throw NoDataException.INSTANCE
}
fun originalClassNameForPosition(sourcePosition: SourcePosition): String? {
return classNamesForPosition(sourcePosition, false).firstOrNull()
}
private fun classNamesForPosition(sourcePosition: SourcePosition, withInlines: Boolean): List<String> {
val element = sourcePosition.readAction { it.elementAt } ?: return emptyList()
val names = classNamesForPosition(element, withInlines)
val lambdas = findLambdas(sourcePosition)
if (lambdas.isEmpty()) {
return names
}
return names + lambdas
}
private fun classNamesForPosition(element: PsiElement?, withInlines: Boolean): List<String> {
if (DumbService.getInstance(myDebugProcess.project).isDumb) {
return emptyList()
}
else {
val baseElement = getElementToCalculateClassName(element) ?: return emptyList()
return getOrComputeClassNames(baseElement) {
element ->
val file = element.readAction { it.containingFile as KtFile }
val isInLibrary = LibraryUtil.findLibraryEntry(file.virtualFile, file.project) != null
val typeMapper = KotlinDebuggerCaches.getOrCreateTypeMapper(element)
getInternalClassNameForElement(element, typeMapper, file, isInLibrary, withInlines)
}
}
}
private fun findLambdas(sourcePosition: SourcePosition): Collection<String> {
val lambdas = sourcePosition.readAction { getLambdasAtLineIfAny(it) }
return lambdas.flatMap { classNamesForPosition(it, true) }
}
override fun locationsOfLine(type: ReferenceType, position: SourcePosition): List<Location> {
if (position.file !is KtFile) {
throw NoDataException.INSTANCE
}
try {
val line = position.line + 1
val locations = if (myDebugProcess.virtualMachineProxy.versionHigher("1.4"))
type.locationsOfLine("Kotlin", null, line)
else
type.locationsOfLine(line)
if (locations == null || locations.isEmpty()) throw NoDataException.INSTANCE
return locations
}
catch (e: AbsentInformationException) {
throw NoDataException.INSTANCE
}
}
@Deprecated("Since Idea 14.0.3 use createPrepareRequests fun")
override fun createPrepareRequest(classPrepareRequestor: ClassPrepareRequestor, sourcePosition: SourcePosition): ClassPrepareRequest? {
return createPrepareRequests(classPrepareRequestor, sourcePosition).firstOrNull()
}
override fun createPrepareRequests(requestor: ClassPrepareRequestor, position: SourcePosition): List<ClassPrepareRequest> {
if (position.file !is KtFile) {
throw NoDataException.INSTANCE
}
return classNamesForPosition(position, true).mapNotNull {
className ->
myDebugProcess.requestsManager.createClassPrepareRequest(requestor, className.replace('/', '.'))
}
}
private fun getInternalClassNameForElement(
element: KtElement,
typeMapper: JetTypeMapper,
file: KtFile,
isInLibrary: Boolean,
withInlines: Boolean
): KotlinDebuggerCaches.ComputedClassNames {
val parent = element.readAction { getElementToCalculateClassName(it.parent) }
when (element) {
is KtClassOrObject -> return CachedClassNames(getClassNameForClass(element, typeMapper))
is KtFunction -> {
val descriptor = element.readAction { InlineUtil.getInlineArgumentDescriptor(it, typeMapper.bindingContext) }
if (descriptor != null) {
val classNamesForParent = classNamesForPosition(parent, withInlines)
if (descriptor.isCrossinline) {
return CachedClassNames(classNamesForParent + findCrossInlineArguments(element, descriptor, typeMapper.bindingContext))
}
return CachedClassNames(classNamesForParent)
}
}
}
val crossInlineParameterUsages = element.readAction { it.containsCrossInlineParameterUsages(typeMapper.bindingContext) }
if (crossInlineParameterUsages.isNotEmpty()) {
return CachedClassNames(classNamesForCrossInlineParameters(crossInlineParameterUsages, typeMapper.bindingContext).toList())
}
when {
element is KtFunctionLiteral -> {
val asmType = CodegenBinding.asmTypeForAnonymousClass(typeMapper.bindingContext, element)
return CachedClassNames(asmType.internalName)
}
element is KtAnonymousInitializer -> {
// Class-object initializer
if (parent is KtObjectDeclaration && parent.isCompanion()) {
return CachedClassNames(classNamesForPosition(parent.parent, withInlines))
}
return CachedClassNames(classNamesForPosition(parent, withInlines))
}
element is KtPropertyAccessor && (!element.readAction { it.property.isTopLevel } || !isInLibrary) -> {
val classOrObject = element.readAction { PsiTreeUtil.getParentOfType(it, KtClassOrObject::class.java) }
if (classOrObject != null) {
return CachedClassNames(getClassNameForClass(classOrObject, typeMapper))
}
}
element is KtProperty && (!element.readAction { it.isTopLevel } || !isInLibrary) -> {
val descriptor = typeMapper.bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element)
if (descriptor !is PropertyDescriptor) {
return CachedClassNames(classNamesForPosition(parent, withInlines))
}
return CachedClassNames(getJvmInternalNameForPropertyOwner(typeMapper, descriptor))
}
element is KtNamedFunction -> {
val parentInternalName = if (parent is KtClassOrObject) {
getClassNameForClass(parent, typeMapper)
}
else if (parent != null) {
val asmType = CodegenBinding.asmTypeForAnonymousClass(typeMapper.bindingContext, element)
asmType.internalName
}
else {
getClassNameForFile(file)
}
if (!withInlines) return NonCachedClassNames(parentInternalName)
val inlinedCalls = findInlinedCalls(element, typeMapper.bindingContext)
if (parentInternalName == null) return CachedClassNames(inlinedCalls)
return CachedClassNames(listOf(parentInternalName) + inlinedCalls)
}
}
return CachedClassNames(getClassNameForFile(file))
}
private fun getClassNameForClass(klass: KtClassOrObject, typeMapper: JetTypeMapper) = klass.readAction { getJvmInternalNameForImpl(typeMapper, it) }
private fun getClassNameForFile(file: KtFile) = file.readAction { NoResolveFileClassesProvider.getFileClassInternalName(it) }
private val TYPES_TO_CALCULATE_CLASSNAME: Array<Class<out KtElement>> =
arrayOf(KtClass::class.java,
KtObjectDeclaration::class.java,
KtEnumEntry::class.java,
KtFunctionLiteral::class.java,
KtNamedFunction::class.java,
KtPropertyAccessor::class.java,
KtProperty::class.java,
KtClassInitializer::class.java)
private fun getElementToCalculateClassName(notPositionedElement: PsiElement?): KtElement? {
if (notPositionedElement?.javaClass as Class<*> in TYPES_TO_CALCULATE_CLASSNAME) return notPositionedElement as KtElement
return readAction { PsiTreeUtil.getParentOfType(notPositionedElement, *TYPES_TO_CALCULATE_CLASSNAME) }
}
fun getJvmInternalNameForPropertyOwner(typeMapper: JetTypeMapper, descriptor: PropertyDescriptor): String {
return descriptor.readAction {
typeMapper.mapOwner(
if (JvmAbi.isPropertyWithBackingFieldInOuterClass(it)) it.containingDeclaration else it
).internalName
}
}
private fun getJvmInternalNameForImpl(typeMapper: JetTypeMapper, ktClass: KtClassOrObject): String? {
val classDescriptor = typeMapper.bindingContext.get<PsiElement, ClassDescriptor>(BindingContext.CLASS, ktClass) ?: return null
if (ktClass is KtClass && ktClass.isInterface()) {
return typeMapper.mapDefaultImpls(classDescriptor).internalName
}
return typeMapper.mapClass(classDescriptor).internalName
}
private fun findInlinedCalls(function: KtNamedFunction, context: BindingContext): List<String> {
if (!InlineUtil.isInline(context.get(BindingContext.DECLARATION_TO_DESCRIPTOR, function))) {
return emptyList()
}
else {
val searchResult = hashSetOf<KtElement>()
val functionName = function.readAction { it.name }
val task = Runnable {
ReferencesSearch.search(function, myDebugProcess.searchScope).forEach {
if (!it.readAction { it.isImportUsage() }) {
val usage = (it.element as? KtElement)?.let { getElementToCalculateClassName(it) }
if (usage != null) {
searchResult.add(usage)
}
}
}
}
var isSuccess = true
ApplicationManager.getApplication().invokeAndWait(
{
isSuccess = ProgressManager.getInstance().runProcessWithProgressSynchronously(
task,
"Compute class names for function $functionName",
true,
myDebugProcess.project)
}, ModalityState.NON_MODAL)
if (!isSuccess) {
XDebugSessionImpl.NOTIFICATION_GROUP.createNotification(
"Debugger can skip some executions of $functionName method, because the computation of class names was interrupted", MessageType.WARNING
).notify(myDebugProcess.project)
}
// TODO recursive search
return searchResult.flatMap { classNamesForPosition(it, true) }
}
}
private fun findCrossInlineArguments(argument: KtFunction, parameterDescriptor: ValueParameterDescriptor, context: BindingContext): Set<String> {
return runReadAction {
val source = parameterDescriptor.source.getPsi() as? KtParameter
val functionName = source?.ownerFunction?.name
if (functionName != null) {
return@runReadAction setOf(getCrossInlineArgumentClassName(argument, functionName, context))
}
return@runReadAction emptySet()
}
}
private fun getCrossInlineArgumentClassName(argument: KtFunction, inlineFunctionName: String, context: BindingContext): String {
val anonymousClassNameForArgument = CodegenBinding.asmTypeForAnonymousClass(context, argument).internalName
val newName = anonymousClassNameForArgument.substringIndex() + InlineCodegenUtil.INLINE_TRANSFORMATION_SUFFIX + "$" + inlineFunctionName
return "$newName$*"
}
private fun KtElement.containsCrossInlineParameterUsages(context: BindingContext): Collection<ValueParameterDescriptor> {
fun KtElement.hasParameterCall(parameter: KtParameter): Boolean {
return ReferencesSearch.search(parameter).any {
this.textRange.contains(it.element.textRange)
}
}
val inlineFunction = this.parents.firstIsInstanceOrNull<KtNamedFunction>() ?: return emptySet()
val inlineFunctionDescriptor = context[BindingContext.FUNCTION, inlineFunction]
if (inlineFunctionDescriptor == null || !InlineUtil.isInline(inlineFunctionDescriptor)) return emptySet()
return inlineFunctionDescriptor.valueParameters
.filter { it.isCrossinline }
.mapNotNull {
val psiParameter = it.source.getPsi() as? KtParameter
if (psiParameter != null && [email protected](psiParameter))
it
else
null
}
}
private fun classNamesForCrossInlineParameters(usedParameters: Collection<ValueParameterDescriptor>, context: BindingContext): Set<String> {
// We could calculate className only for one of parameters, because we add '*' to match all crossInlined parameter calls
val parameter = usedParameters.first()
val result = hashSetOf<String>()
val inlineFunction = parameter.containingDeclaration.source.getPsi() as? KtNamedFunction ?: return emptySet()
ReferencesSearch.search(inlineFunction, myDebugProcess.searchScope).forEach {
runReadAction {
if (!it.isImportUsage()) {
val call = (it.element as? KtExpression)?.let { KtPsiUtil.getParentCallIfPresent(it) }
if (call != null) {
val resolvedCall = call.getResolvedCall(context)
val argument = resolvedCall?.valueArguments?.entries?.firstOrNull { it.key.original == parameter }?.value
if (argument != null) {
val argumentExpression = getArgumentExpression(argument.arguments.first())
if (argumentExpression is KtFunction) {
result.add(getCrossInlineArgumentClassName(argumentExpression, inlineFunction.name!!, context))
}
}
}
}
}
}
return result
}
private fun getArgumentExpression(it: ValueArgument) = (it.getArgumentExpression() as? KtLambdaExpression)?.functionLiteral ?: it.getArgumentExpression()
private fun String.substringIndex(): String {
if (lastIndexOf("$") < 0) return this
val suffix = substringAfterLast("$")
if (suffix.all { it.isDigit() }) {
return substringBeforeLast("$") + "$"
}
return this
}
private fun ReferenceType.containsKotlinStrata() = availableStrata().contains("Kotlin")
}
private inline fun <U, V> U.readAction(crossinline f: (U) -> V): V {
return runReadAction { f(this) }
}
| 1 | null | 2 | 1 | f713adc96e9adeacb1373fc170a5ece1bf2fc1a2 | 24,424 | kotlin | Apache License 2.0 |
reposilite-backend/src/main/kotlin/com/reposilite/storage/StoragePlugin.kt | dzikoysk | 96,474,388 | false | null | package com.reposilite.storage
import com.reposilite.plugin.api.Facade
import com.reposilite.plugin.api.Plugin
import com.reposilite.plugin.api.ReposilitePlugin
@Plugin(name = "storage")
class StoragePlugin : ReposilitePlugin() {
override fun initialize(): Facade =
StorageFacade()
}
| 16 | Kotlin | 104 | 631 | a4ad03ca8e060282308c1e9b63c454171cded47e | 300 | reposilite | Apache License 2.0 |
src/plugin/arguments/src/commonMain/kotlin/community/flock/wirespec/plugin/Format.kt | flock-community | 506,356,849 | false | {"Kotlin": 656506, "Shell": 6544, "TypeScript": 5819, "Witcher Script": 4248, "Java": 4221, "Dockerfile": 625, "Makefile": 501, "JavaScript": 140} | package community.flock.wirespec.plugin
enum class Format {
OpenApiV2, OpenApiV3;
companion object {
override fun toString() = entries.joinToString()
}
}
| 18 | Kotlin | 2 | 17 | 50f8b9a1e341d6d79fdc86f6bff9fca9b32b7579 | 176 | wirespec | Apache License 2.0 |
product/content/content-bl/src/main/java/com/yugyd/quiz/domain/content/ContentRemoteConfigSource.kt | Yugyd | 685,349,849 | false | {"Kotlin": 873471, "FreeMarker": 22968, "Fluent": 18} | package com.yugyd.quiz.domain.content
interface ContentRemoteConfigSource {
suspend fun getContentFormatUrl(): String
}
| 0 | Kotlin | 1 | 8 | 0192d1ccabe96b7ac9f9a844259cca7a018aa6b5 | 125 | quiz-platform | Apache License 2.0 |
litho-widget-kotlin/src/test/kotlin/com/facebook/litho/sections/widget/CollectionIdTest.kt | facebook | 80,179,724 | false | null | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.facebook.litho.sections.widget
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.facebook.litho.Component
import com.facebook.litho.testing.LithoViewRule
import com.facebook.litho.widget.EmptyComponent
import com.facebook.litho.widget.Text
import org.assertj.core.api.Assertions.assertThat
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.annotation.LooperMode
/** Tests for [Collection]'s children */
@LooperMode(LooperMode.Mode.LEGACY)
@RunWith(AndroidJUnit4::class)
class CollectionIdTest {
@Rule @JvmField val lithoViewRule = LithoViewRule()
private fun emptyComponent(): Component = EmptyComponent.create(lithoViewRule.context).build()
private fun textComponent(): Component = Text.create(lithoViewRule.context).text("Hello").build()
private fun CollectionContainerScope.getIds(): List<Any?> = collectionChildrenModels.map { it.id }
@Test
fun `test generated ids are unique`() {
val ids =
CollectionContainerScope()
.apply {
child(null)
child(emptyComponent())
child(id = null, component = emptyComponent())
child(deps = arrayOf()) { emptyComponent() }
}
.getIds()
assertThat(ids).hasSameSizeAs(ids.distinct())
}
@Test
fun `test generated ids are stable across recreations`() {
val ids1 =
CollectionContainerScope()
.apply {
child(null)
child(emptyComponent())
child(id = null, component = emptyComponent())
child(deps = arrayOf()) { emptyComponent() }
}
.getIds()
val ids2 =
CollectionContainerScope()
.apply {
child(null)
child(emptyComponent())
child(id = null, component = emptyComponent())
child(deps = arrayOf()) { emptyComponent() }
}
.getIds()
assertThat(ids1).hasSameElementsAs(ids2)
}
@Test
fun `test generated ids for same component type are stable`() {
val ids1 =
CollectionContainerScope()
.apply {
child(textComponent())
child(textComponent())
}
.getIds()
val ids2 =
CollectionContainerScope()
.apply {
child(textComponent())
child(emptyComponent()) // <-- Should not affect ids of other children
child(
id = 1,
component = textComponent()) // <-- Should not affect ids of other children
child(textComponent())
}
.getIds()
assertThat(ids2).containsAll(ids1)
}
@Test
fun `test generated ids in SubCollections are not impacted by other children`() {
val ids1 =
CollectionContainerScope()
.apply {
subCollection(id = "something") {
child(null)
child(emptyComponent())
child(id = 1, component = emptyComponent())
child(id = null, component = emptyComponent())
child(deps = arrayOf()) { emptyComponent() }
}
}
.getIds()
val ids2 =
CollectionContainerScope()
.apply {
child(emptyComponent()) // <-- Should not affect id assignment in SubCollection
subCollection(id = "something") {
child(null)
child(emptyComponent())
child(id = 1, component = emptyComponent())
child(id = null, component = emptyComponent())
child(deps = arrayOf()) { emptyComponent() }
}
}
.getIds()
assertThat(ids1).hasSameElementsAs(ids2.subList(1, ids2.size))
}
@Test
fun `test ids in SubCollections do not clash`() {
val ids1 =
CollectionContainerScope()
.apply {
subCollection(id = "something") {
child(null)
child(emptyComponent())
child(id = 1, component = emptyComponent())
child(id = null, component = emptyComponent())
child(deps = arrayOf()) { emptyComponent() }
}
}
.getIds()
val ids2 =
CollectionContainerScope()
.apply {
subCollection(id = "something else") {
child(null)
child(emptyComponent())
child(id = 1, component = emptyComponent())
child(id = null, component = emptyComponent())
child(deps = arrayOf()) { emptyComponent() }
}
}
.getIds()
assertThat(ids1).doesNotContainAnyElementsOf(ids2)
}
@Test
fun `test ids in nested SubCollections do not clash`() {
val ids1 =
CollectionContainerScope()
.apply {
subCollection(id = "something") {
subCollection(id = 2) {
child(null)
child(emptyComponent())
child(id = 1, component = emptyComponent())
child(id = null, component = emptyComponent())
child(deps = arrayOf()) { emptyComponent() }
}
}
}
.getIds()
val ids2 =
CollectionContainerScope()
.apply {
subCollection(id = "something else") {
subCollection(id = 2) {
child(null)
child(emptyComponent())
child(id = 1, component = emptyComponent())
child(id = null, component = emptyComponent())
child(deps = arrayOf()) { emptyComponent() }
}
}
}
.getIds()
assertThat(ids1).doesNotContainAnyElementsOf(ids2)
}
}
| 108 | null | 703 | 7,320 | 33e55dbda09b81ef79ba5f6de6dc7abdd4b79c29 | 6,550 | litho | Apache License 2.0 |
app/src/main/java/ru/tech/imageresizershrinker/presentation/main_screen/components/settings/ChangeLanguageSettingItem.kt | T8RIN | 478,710,402 | false | null | package ru.tech.imageresizershrinker.presentation.main_screen.components
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.provider.Settings
import androidx.appcompat.app.AppCompatDelegate
import androidx.compose.animation.animateContentSize
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Language
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.RadioButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.core.os.LocaleListCompat
import org.xmlpull.v1.XmlPullParser
import ru.tech.imageresizershrinker.R
import ru.tech.imageresizershrinker.presentation.root.utils.helper.ContextUtils
import ru.tech.imageresizershrinker.presentation.root.widget.controls.EnhancedButton
import ru.tech.imageresizershrinker.presentation.root.widget.preferences.PreferenceRow
import ru.tech.imageresizershrinker.presentation.root.widget.sheets.SimpleSheet
import ru.tech.imageresizershrinker.presentation.root.widget.text.AutoSizeText
import ru.tech.imageresizershrinker.presentation.root.widget.text.TitleItem
import java.util.Locale
@Composable
fun ChangeLanguagePreference(
modifier: Modifier = Modifier,
shape: Shape = RoundedCornerShape(16.dp)
) {
val context = LocalContext.current
val showDialog = rememberSaveable { mutableStateOf(false) }
Column(Modifier.animateContentSize()) {
PreferenceRow(
shape = shape,
modifier = modifier,
applyHorPadding = false,
title = stringResource(R.string.language),
subtitle = context.getCurrentLocaleString(),
endContent = {
Icon(
imageVector = Icons.Rounded.Language,
contentDescription = null,
)
},
onClick = {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && !ContextUtils.isMiUi()) {
kotlin.runCatching {
context.startActivity(
Intent(
Settings.ACTION_APP_LOCALE_SETTINGS,
Uri.parse("package:${context.packageName}")
)
)
}.getOrNull().let {
if (it == null) showDialog.value = true
}
} else {
showDialog.value = true
}
}
)
}
PickLanguageSheet(
entries = context.getLanguages(),
selected = context.getCurrentLocaleString(),
onSelect = {
val locale = if (it == "") {
LocaleListCompat.getEmptyLocaleList()
} else {
LocaleListCompat.forLanguageTags(it)
}
AppCompatDelegate.setApplicationLocales(locale)
},
visible = showDialog
)
}
@Composable
private fun PickLanguageSheet(
entries: Map<String, String>,
selected: String,
onSelect: (String) -> Unit,
visible: MutableState<Boolean>
) {
SimpleSheet(
title = {
TitleItem(
text = stringResource(R.string.language),
icon = Icons.Rounded.Language
)
},
sheetContent = {
Box {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.verticalScroll(rememberScrollState())
) {
Spacer(modifier = Modifier.height(8.dp))
entries.forEach { locale ->
Row(
modifier = Modifier
.fillMaxWidth()
.clip(MaterialTheme.shapes.medium)
.clickable {
onSelect(locale.key)
visible.value = false
}
.padding(start = 12.dp, end = 12.dp),
verticalAlignment = Alignment.CenterVertically
) {
RadioButton(
selected = selected == locale.value,
onClick = {
onSelect(locale.key)
visible.value = false
}
)
Text(locale.value)
}
}
Spacer(modifier = Modifier.height(8.dp))
}
}
},
confirmButton = {
EnhancedButton(
containerColor = MaterialTheme.colorScheme.secondaryContainer,
onClick = {
visible.value = false
}
) {
AutoSizeText(stringResource(R.string.cancel))
}
},
visible = visible
)
}
private fun Context.getLanguages(): Map<String, String> {
val languages = mutableListOf<Pair<String, String>>()
val parser = resources.getXml(R.xml.locales_config)
var eventType = parser.eventType
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG && parser.name == "locale") {
for (i in 0 until parser.attributeCount) {
if (parser.getAttributeName(i) == "name") {
val langTag = parser.getAttributeValue(i)
val displayName = getDisplayName(langTag)
if (displayName.isNotEmpty()) {
languages.add(Pair(langTag, displayName))
}
}
}
}
eventType = parser.next()
}
languages.sortBy { it.second }
languages.add(0, Pair("", getString(R.string.system)))
return languages.toMap()
}
private fun Context.getCurrentLocaleString(): String {
val locales = AppCompatDelegate.getApplicationLocales()
if (locales == LocaleListCompat.getEmptyLocaleList()) {
return getString(R.string.system)
}
return getDisplayName(locales.toLanguageTags())
}
private fun getDisplayName(lang: String?): String {
if (lang == null) {
return ""
}
val locale = when (lang) {
"" -> LocaleListCompat.getAdjustedDefault()[0]
else -> Locale.forLanguageTag(lang)
}
return locale!!.getDisplayName(locale).replaceFirstChar { it.uppercase(locale) }
}
| 9 | null | 77 | 979 | 7d164a02c463afede47c785f8b182c954abfcde9 | 7,750 | ImageToolbox | Apache License 2.0 |
libraries/stdlib/test/text/StringEncodingTest.kt | JetBrains | 3,432,266 | false | null | /*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package test.text
import test.assertArrayContentEquals
import test.testOnNonJvm6And7
import kotlin.test.*
// When decoding utf-8, JVM and JS implementations replace the sequence reflecting a surrogate code point differently.
// JS replaces each byte of the sequence by the replacement char, whereas JVM replaces the whole sequence with a single replacement char.
// See corresponding actual to find out the replacement.
internal expect val surrogateCodePointDecoding: String
// The byte sequence used to replace a surrogate char.
// JVM default replacement sequence consist of single 0x3F byte.
// JS and Native replacement byte sequence is [0xEF, 0xBF, 0xBD].
internal expect val surrogateCharEncoding: ByteArray
class StringEncodingTest {
private fun bytes(vararg elements: Int) = ByteArray(elements.size) { elements[it].toByte() }
private fun testEncoding(isWellFormed: Boolean, expected: ByteArray, string: String) {
assertArrayContentEquals(expected, string.encodeToByteArray())
if (!isWellFormed) {
assertFailsWith<CharacterCodingException> { string.encodeToByteArray(throwOnInvalidSequence = true) }
} else {
assertArrayContentEquals(expected, string.encodeToByteArray(throwOnInvalidSequence = true))
assertEquals(string, string.encodeToByteArray(throwOnInvalidSequence = true).decodeToString())
}
}
private fun testEncoding(isWellFormed: Boolean, expected: ByteArray, string: String, startIndex: Int, endIndex: Int) {
assertArrayContentEquals(expected, string.encodeToByteArray(startIndex, endIndex))
if (!isWellFormed) {
assertFailsWith<CharacterCodingException> { string.encodeToByteArray(startIndex, endIndex, true) }
} else {
assertArrayContentEquals(expected, string.encodeToByteArray(startIndex, endIndex, true))
assertEquals(
string.substring(startIndex, endIndex),
string.encodeToByteArray(startIndex, endIndex, true).decodeToString()
)
}
}
// https://youtrack.jetbrains.com/issue/KT-31614
private fun string(vararg codeUnits: Int): String {
return buildString { codeUnits.forEach { append(Char(it)) } }
}
@Test
fun encodeToByteArray() {
// empty string
testEncoding(true, bytes(), "")
// 1-byte chars
testEncoding(true, bytes(0), "\u0000")
testEncoding(true, bytes(0x2D), "-")
testEncoding(true, bytes(0x7F), "\u007F")
// 2-byte chars
testEncoding(true, bytes(0xC2, 0x80), "\u0080")
testEncoding(true, bytes(0xC2, 0xBF), "¿")
testEncoding(true, bytes(0xDF, 0xBF), "\u07FF")
// 3-byte chars
testEncoding(true, bytes(0xE0, 0xA0, 0x80), "\u0800")
testEncoding(true, bytes(0xE6, 0x96, 0xA4), "斤")
testEncoding(true, bytes(0xED, 0x9F, 0xBF), "\uD7FF")
// surrogate chars
testEncoding(false, surrogateCharEncoding, string(0xD800))
testEncoding(false, surrogateCharEncoding, string(0xDB6A))
testEncoding(false, surrogateCharEncoding, string(0xDFFF))
// 3-byte chars
testEncoding(true, bytes(0xEE, 0x80, 0x80), "\uE000")
testEncoding(true, bytes(0xEF, 0x98, 0xBC), "\uF63C")
testEncoding(true, bytes(0xEF, 0xBF, 0xBF), "\uFFFF")
// 4-byte surrogate pairs
testEncoding(true, bytes(0xF0, 0x90, 0x80, 0x80), "\uD800\uDC00")
testEncoding(true, bytes(0xF2, 0xA2, 0x97, 0xBC), "\uDA49\uDDFC")
testEncoding(true, bytes(0xF4, 0x8F, 0xBF, 0xBF), "\uDBFF\uDFFF")
// reversed surrogate pairs
testEncoding(false, surrogateCharEncoding + surrogateCharEncoding, string(0xDC00, 0xD800))
testEncoding(false, surrogateCharEncoding + surrogateCharEncoding, string(0xDDFC, 0xDA49))
testEncoding(false, surrogateCharEncoding + surrogateCharEncoding, string(0xDFFF, 0xDBFF))
testEncoding(
false,
bytes(
0, /**/ 0x2D, /**/ 0x7F, /**/ 0xC2, 0x80, /**/ 0xC2, 0xBF, /**/ 0xDF, 0xBF, /**/ 0xE0, 0xA0, 0x80, /**/
0xE6, 0x96, 0xA4, /**/ 0xED, 0x9F, 0xBF, /**/ 0x7A
) /**/ + surrogateCharEncoding /**/ + surrogateCharEncoding /**/ + 0x7A /**/ + surrogateCharEncoding /**/ + 0x7A /**/ + surrogateCharEncoding,
"\u0000-\u007F\u0080¿\u07FF\u0800斤\uD7FFz" + string(0xDFFF, 0xD800, 0x7A, 0xDB6A, 0x7A, 0xDB6A)
)
testEncoding(
true,
bytes(
0xEE, 0x80, 0x80, /**/ 0xEF, 0x98, 0xBC, /**/ 0xC2, 0xBF, /**/ 0xEF, 0xBF, 0xBF, /**/
0xF0, 0x90, 0x80, 0x80, /**/ 0xF2, 0xA2, 0x97, 0xBC, /**/ 0xF4, 0x8F, 0xBF, 0xBF
),
"\uE000\uF63C¿\uFFFF\uD800\uDC00\uDA49\uDDFC\uDBFF\uDFFF"
)
val longChars = CharArray(200_000) { 'k' }
val longBytes = longChars.concatToString().encodeToByteArray()
assertEquals(200_000, longBytes.size)
assertTrue { longBytes.all { it == 0x6B.toByte() } }
}
@Test
fun encodeToByteArraySlice() {
assertFailsWith<IllegalArgumentException> { "".encodeToByteArray(startIndex = 1) }
assertFailsWith<IllegalArgumentException> { "123".encodeToByteArray(startIndex = 10) }
assertFailsWith<IndexOutOfBoundsException> { "123".encodeToByteArray(startIndex = -1) }
assertFailsWith<IndexOutOfBoundsException> { "123".encodeToByteArray(endIndex = 10) }
assertFailsWith<IllegalArgumentException> { "123".encodeToByteArray(endIndex = -1) }
assertFailsWith<IndexOutOfBoundsException> { "123".encodeToByteArray(startIndex = 5, endIndex = 10) }
assertFailsWith<IllegalArgumentException> { "123".encodeToByteArray(startIndex = 5, endIndex = 2) }
assertFailsWith<IndexOutOfBoundsException> { "123".encodeToByteArray(startIndex = 1, endIndex = 4) }
testEncoding(true, bytes(), "abc", 0, 0)
testEncoding(true, bytes(), "abc", 3, 3)
testEncoding(true, bytes(0x62, 0x63), "abc", 1, 3)
testEncoding(true, bytes(0x61, 0x62), "abc", 0, 2)
testEncoding(true, bytes(0x62), "abc", 1, 2)
testEncoding(true, bytes(0x2D), "-", 0, 1)
testEncoding(true, bytes(0xC2, 0xBF), "¿", 0, 1)
testEncoding(true, bytes(0xE6, 0x96, 0xA4), "斤", 0, 1)
testEncoding(false, surrogateCharEncoding, string(0xDB6A), 0, 1)
testEncoding(true, bytes(0xEF, 0x98, 0xBC), "\uF63C", 0, 1)
testEncoding(true, bytes(0xF2, 0xA2, 0x97, 0xBC), "\uDA49\uDDFC", 0, 2)
testEncoding(false, surrogateCharEncoding, "\uDA49\uDDFC", 0, 1)
testEncoding(false, surrogateCharEncoding, "\uDA49\uDDFC", 1, 2)
testEncoding(
false,
bytes(0xE6, 0x96, 0xA4, /**/ 0xED, 0x9F, 0xBF, /**/ 0x7A) /**/ + surrogateCharEncoding /**/ + surrogateCharEncoding,
"\u0000-\u007F\u0080¿\u07FF\u0800斤\uD7FFz" + string(0xDFFF, 0xD800, 0x7A, 0xDB6A, 0x7A, 0xDB6A),
startIndex = 7,
endIndex = 12
)
testEncoding(
false,
bytes(0xC2, 0xBF, /**/ 0xEF, 0xBF, 0xBF, /**/ 0xF0, 0x90, 0x80, 0x80, /**/ 0xF2, 0xA2, 0x97, 0xBC) /**/ + surrogateCharEncoding,
"\uE000\uF63C¿\uFFFF\uD800\uDC00\uDA49\uDDFC\uDBFF\uDFFF",
startIndex = 2,
endIndex = 9
)
val longChars = CharArray(200_000) { 'k' }
val longBytes = longChars.concatToString().encodeToByteArray(startIndex = 5000, endIndex = 195_000)
assertEquals(190_000, longBytes.size)
assertTrue { longBytes.all { it == 0x6B.toByte() } }
}
private fun testDecoding(isWellFormed: Boolean, expected: String, bytes: ByteArray) {
assertEquals(expected, bytes.decodeToString())
if (!isWellFormed) {
assertFailsWith<CharacterCodingException> { bytes.decodeToString(throwOnInvalidSequence = true) }
} else {
assertEquals(expected, bytes.decodeToString(throwOnInvalidSequence = true))
assertArrayContentEquals(bytes, bytes.decodeToString(throwOnInvalidSequence = true).encodeToByteArray())
}
}
private fun testDecoding(isWellFormed: Boolean, expected: String, bytes: ByteArray, startIndex: Int, endIndex: Int) {
assertEquals(expected, bytes.decodeToString(startIndex, endIndex))
if (!isWellFormed) {
assertFailsWith<CharacterCodingException> { bytes.decodeToString(startIndex, endIndex, true) }
} else {
assertEquals(expected, bytes.decodeToString(startIndex, endIndex, true))
assertArrayContentEquals(
bytes.sliceArray(startIndex until endIndex),
bytes.decodeToString(startIndex, endIndex, true).encodeToByteArray()
)
}
}
private fun truncatedSurrogateDecoding() =
surrogateCodePointDecoding.let { if (it.length > 1) it.dropLast(1) else it }
@Test
fun decodeToString() {
testDecoding(true, "", bytes()) // empty
testDecoding(true, "\u0000", bytes(0x0)) // null char
testDecoding(true, "zC", bytes(0x7A, 0x43)) // 1-byte chars
testDecoding(false, "��", bytes(0x85, 0xAF)) // invalid bytes starting with 1 bit
testDecoding(true, "¿", bytes(0xC2, 0xBF)) // 2-byte char
testDecoding(false, "�z", bytes(0xCF, 0x7A)) // 2-byte char, second byte starts with 0 bit
testDecoding(false, "��", bytes(0xC1, 0xAA)) // 1-byte char written in two bytes
testDecoding(false, "�z", bytes(0xEF, 0xAF, 0x7A)) // 3-byte char, third byte starts with 0 bit
testDecoding(false, "���", bytes(0xE0, 0x9F, 0xAF)) // 2-byte char written in three bytes
testDecoding(false, "�z", bytes(0xE0, 0xAF, 0x7A)) // 3-byte char, third byte starts with 0 bit
testDecoding(true, "\u1FFF", bytes(0xE1, 0xBF, 0xBF)) // 3-byte char
testOnNonJvm6And7 {
testDecoding(false, surrogateCodePointDecoding, bytes(0xED, 0xAF, 0xBF)) // 3-byte high-surrogate char
testDecoding(false, surrogateCodePointDecoding, bytes(0xED, 0xB3, 0x9A)) // 3-byte low-surrogate char
testDecoding(
false,
surrogateCodePointDecoding + surrogateCodePointDecoding,
bytes(0xED, 0xAF, 0xBF, /**/ 0xED, 0xB3, 0x9A)
) // surrogate pair chars
testDecoding(false, "�z", bytes(0xEF, 0x7A)) // 3-byte char, second byte starts with 0 bit, third byte missing
testDecoding(false, "�����", bytes(0xF9, 0x94, 0x80, 0x80, 0x80)) // 5-byte code point larger than 0x10FFFF
testDecoding(false, "������", bytes(0xFD, 0x94, 0x80, 0x80, 0x80, 0x80)) // 6-byte code point larger than 0x10FFFF
// Ill-Formed Sequences for Surrogates
testDecoding(
false,
surrogateCodePointDecoding + surrogateCodePointDecoding + truncatedSurrogateDecoding() + "A",
bytes(0xED, 0xA0, 0x80, /**/ 0xED, 0xBF, 0xBF, /**/ 0xED, 0xAF, /**/ 0x41)
)
// Truncated Sequences
testDecoding(false, "����A", bytes(0xE1, 0x80, /**/ 0xE2, /**/ 0xF0, 0x91, 0x92, /**/ 0xF1, 0xBF, /**/ 0x41))
}
testDecoding(false, "�", bytes(0xE0, 0xAF)) // 3-byte char, third byte missing
testDecoding(true, "\uD83D\uDFDF", bytes(0xF0, 0x9F, 0x9F, 0x9F)) // 4-byte char
testDecoding(false, "����", bytes(0xF0, 0x8F, 0x9F, 0x9F)) // 3-byte char written in four bytes
testDecoding(false, "����", bytes(0xF4, 0x9F, 0x9F, 0x9F)) // 4-byte code point larger than 0x10FFFF
testDecoding(false, "����", bytes(0xF5, 0x80, 0x80, 0x80)) // 4-byte code point larger than 0x10FFFF
// Non-Shortest Form Sequences
testDecoding(false, "��������A", bytes(0xC0, 0xAF, /**/ 0xE0, 0x80, 0xBF, /**/ 0xF0, 0x81, 0x82, /**/ 0x41))
// Other Ill-Formed Sequences
testDecoding(false, "�����A��B", bytes(0xF4, 0x91, 0x92, 0x93, /**/ 0xFF, /**/ 0x41, /**/ 0x80, 0xBF, /**/ 0x42))
val longBytes = ByteArray(200_000) { 0x6B.toByte() }
val longString = longBytes.decodeToString()
assertEquals(200_000, longString.length)
assertTrue { longString.all { it == 'k' } }
}
@Test
fun decodeToStringSlice() {
assertFailsWith<IllegalArgumentException> { bytes().decodeToString(1, 0) }
assertFailsWith<IllegalArgumentException> { bytes(0x61, 0x62, 0x63).decodeToString(startIndex = 10) }
assertFailsWith<IndexOutOfBoundsException> { bytes(0x61, 0x62, 0x63).decodeToString(startIndex = -1) }
assertFailsWith<IndexOutOfBoundsException> { bytes(0x61, 0x62, 0x63).decodeToString(endIndex = 10) }
assertFailsWith<IllegalArgumentException> { bytes(0x61, 0x62, 0x63).decodeToString(endIndex = -1) }
assertFailsWith<IndexOutOfBoundsException> { bytes(0x61, 0x62, 0x63).decodeToString(startIndex = 5, endIndex = 10) }
assertFailsWith<IllegalArgumentException> { bytes(0x61, 0x62, 0x63).decodeToString(startIndex = 5, endIndex = 2) }
assertFailsWith<IndexOutOfBoundsException> { bytes(0x61, 0x62, 0x63).decodeToString(startIndex = 1, endIndex = 4) }
testDecoding(true, "", bytes(), startIndex = 0, endIndex = 0)
testDecoding(true, "", bytes(0x61, 0x62, 0x63), startIndex = 0, endIndex = 0)
testDecoding(true, "", bytes(0x61, 0x62, 0x63), startIndex = 3, endIndex = 3)
testDecoding(true, "abc", bytes(0x61, 0x62, 0x63), startIndex = 0, endIndex = 3)
testDecoding(true, "ab", bytes(0x61, 0x62, 0x63), startIndex = 0, endIndex = 2)
testDecoding(true, "bc", bytes(0x61, 0x62, 0x63), startIndex = 1, endIndex = 3)
testDecoding(true, "b", bytes(0x61, 0x62, 0x63), startIndex = 1, endIndex = 2)
testDecoding(true, "¿", bytes(0xC2, 0xBF), startIndex = 0, endIndex = 2)
testDecoding(false, "�", bytes(0xC2, 0xBF), startIndex = 0, endIndex = 1)
testDecoding(false, "�", bytes(0xC2, 0xBF), startIndex = 1, endIndex = 2)
testDecoding(false, "�", bytes(0xEF, 0xAF, 0x7A), startIndex = 0, endIndex = 2)
testDecoding(false, "�z", bytes(0xEF, 0xAF, 0x7A), startIndex = 1, endIndex = 3)
testDecoding(true, "z", bytes(0xEF, 0xAF, 0x7A), startIndex = 2, endIndex = 3)
testOnNonJvm6And7 {
testDecoding(false, surrogateCodePointDecoding, bytes(0xED, 0xAF, 0xBF), startIndex = 0, endIndex = 3)
testDecoding(false, truncatedSurrogateDecoding(), bytes(0xED, 0xB3, 0x9A), startIndex = 0, endIndex = 2)
testDecoding(false, "���", bytes(0xED, 0xAF, 0xBF, 0xED, 0xB3, 0x9A), startIndex = 1, endIndex = 4)
testDecoding(false, "�", bytes(0xEF, 0x7A), startIndex = 0, endIndex = 1)
testDecoding(true, "z", bytes(0xEF, 0x7A), startIndex = 1, endIndex = 2)
}
testDecoding(true, "\uD83D\uDFDF", bytes(0xF0, 0x9F, 0x9F, 0x9F), startIndex = 0, endIndex = 4)
testDecoding(false, "��", bytes(0xF0, 0x9F, 0x9F, 0x9F), startIndex = 2, endIndex = 4)
testDecoding(false, "��", bytes(0xF0, 0x9F, 0x9F, 0x9F), startIndex = 1, endIndex = 3)
val longBytes = ByteArray(200_000) { 0x6B.toByte() }
val longString = longBytes.decodeToString(startIndex = 5000, endIndex = 195_000)
assertEquals(190_000, longString.length)
assertTrue { longString.all { it == 'k' } }
}
@Test
fun kotlinxIOUnicodeTest() {
fun String.readHex(): ByteArray = split(" ")
.filter { it.isNotBlank() }
.map { it.toInt(16).toByte() }
.toByteArray()
val smokeTestData = "\ud83c\udf00"
val smokeTestDataCharArray: CharArray = smokeTestData.toCharArray()
val smokeTestDataAsBytes = "f0 9f 8c 80".readHex()
val testData = "file content with unicode " +
"\ud83c\udf00 :" +
" \u0437\u0434\u043e\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f :" +
" \uc5ec\ubcf4\uc138\uc694 :" +
" \u4f60\u597d :" +
" \u00f1\u00e7"
val testDataCharArray: CharArray = testData.toCharArray()
val testDataAsBytes: ByteArray = ("66 69 6c 65 20 63 6f 6e 74 65 6e 74 20 77 69 74 " +
" 68 20 75 6e 69 63 6f 64 65 20 f0 9f 8c 80 20 3a 20 d0 b7 d0 b4 d0 be d1 " +
"80 d0 be d0 b2 d0 b0 d1 82 d1 8c d1 81 d1 8f 20 3a 20 ec 97 ac eb b3 b4 ec " +
" 84 b8 ec 9a 94 20 3a 20 e4 bd a0 e5 a5 bd 20 3a 20 c3 b1 c3 a7").readHex()
assertArrayContentEquals(smokeTestDataAsBytes, smokeTestData.encodeToByteArray())
assertArrayContentEquals(testDataAsBytes, testData.encodeToByteArray())
assertEquals(smokeTestData, smokeTestDataAsBytes.decodeToString())
assertEquals(testData, testDataAsBytes.decodeToString())
assertEquals(smokeTestData, smokeTestDataCharArray.concatToString())
assertEquals(testData, testDataCharArray.concatToString())
assertArrayContentEquals(smokeTestDataCharArray, smokeTestData.toCharArray())
assertArrayContentEquals(testDataCharArray, testData.toCharArray())
assertArrayContentEquals(smokeTestDataAsBytes, smokeTestDataCharArray.concatToString().encodeToByteArray())
assertArrayContentEquals(testDataAsBytes, testDataCharArray.concatToString().encodeToByteArray())
assertArrayContentEquals(smokeTestDataCharArray, smokeTestDataAsBytes.decodeToString().toCharArray())
assertArrayContentEquals(testDataCharArray, testDataAsBytes.decodeToString().toCharArray())
assertEquals("\uD858\uDE18\n", bytes(0xF0, 0xA6, 0x88, 0x98, 0x0a).decodeToString())
assertEquals("\u0BF5\n", bytes(0xE0, 0xAF, 0xB5, 0x0A).decodeToString())
assertEquals("\u041a\n", bytes(0xD0, 0x9A, 0x0A).decodeToString())
}
}
| 181 | null | 5748 | 49,172 | 33eb9cef3d146062c103f9853d772f0a1da0450e | 18,068 | kotlin | Apache License 2.0 |
src/main/kotlin/com/intellij/codeInsight/inline/completion/InlineCompletionSuggestion.kt | sourcegraph | 702,947,607 | false | null | // Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.codeInsight.inline.completion
import com.intellij.codeInsight.inline.completion.elements.InlineCompletionElement
import com.intellij.openapi.util.UserDataHolderBase
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.FlowCollector
import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.flow.flow
/**
* Abstract class representing an inline completion suggestion.
*
* Provides the suggestion flow for generating only one suggestion.
* @see InlineCompletionElement
*/
abstract class InlineCompletionSuggestion : UserDataHolderBase() {
abstract val suggestionFlow: Flow<InlineCompletionElement>
class Default(override val suggestionFlow: Flow<InlineCompletionElement>) : InlineCompletionSuggestion()
companion object {
fun empty(): InlineCompletionSuggestion = Default(emptyFlow())
fun withFlow(buildSuggestion: suspend FlowCollector<InlineCompletionElement>.() -> Unit): InlineCompletionSuggestion {
return Default(flow(buildSuggestion))
}
}
}
| 358 | null | 5079 | 67 | 437e3e2e53ae85edb7e445b2a0d412fbb7a54db0 | 1,148 | jetbrains | Apache License 2.0 |
arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-effect-guide-12.kt | arrow-kt | 86,057,409 | false | {"Kotlin": 2793646, "Java": 7691} | // This file was automatically generated from Effect.kt by Knit tool. Do not edit.
package arrow.core.examples.exampleEffectGuide12
import arrow.core.continuations.effect
import io.kotest.assertions.fail
import io.kotest.matchers.shouldBe
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
suspend fun main() {
val errorA = "ErrorA"
val errorB = "ErrorB"
effect<String, Int> {
coroutineScope<Int> {
launch { shift(errorA) }
launch { shift(errorB) }
45
}
}.fold({ fail("Shift can never finish") }, ::println)
}
| 38 | Kotlin | 436 | 5,958 | 5f0da6334b834bad481c7e3c906bee5a34c1237b | 569 | arrow | Apache License 2.0 |
app/src/main/java/kushbhati/camcode/domain/CameraController.kt | kushbhati | 692,191,903 | false | {"Kotlin": 25643, "C++": 2128, "CMake": 1840} | package kushbhati.camcode.domain
import kushbhati.camcode.datamodels.YUVImage
interface CameraController {
interface FrameReceiver {
fun onReceive(image: YUVImage)
}
fun openCamera()
fun setFrameReceiver(frameReceiver: FrameReceiver?)
} | 0 | Kotlin | 0 | 0 | d02b36aa3bf0c40900388cbaab3fb89217f71b76 | 265 | CodeCam | Apache License 2.0 |
src/main/kotlin/net/ltgt/gradle/j2cl/tasks/GwtIncompatibleStrip.kt | tbroyer | 279,092,022 | false | null | package net.ltgt.gradle.j2cl.tasks
import com.google.j2cl.tools.gwtincompatible.GwtIncompatibleStripper
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.FileType
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.Classpath
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.TaskAction
import org.gradle.kotlin.dsl.submit
import org.gradle.work.ChangeType
import org.gradle.work.InputChanges
import org.gradle.workers.WorkAction
import org.gradle.workers.WorkParameters
import org.gradle.workers.WorkerExecutor
import javax.inject.Inject
abstract class GwtIncompatibleStrip : IncrementalSourceTask() {
@get:PathSensitive(PathSensitivity.RELATIVE)
override val stableSources: ConfigurableFileCollection
get() = super.stableSources
@get:OutputDirectory
abstract val destinationDirectory: DirectoryProperty
@get:Classpath
abstract val stripperClasspath: ConfigurableFileCollection
@get:Inject
protected abstract val workerExecutor: WorkerExecutor
@TaskAction
fun execute(inputChanges: InputChanges) {
// XXX: allow using processIsolation with configurable forkOptions?
val workQueue = workerExecutor.classLoaderIsolation {
classpath.from([email protected])
}
inputChanges.getFileChanges(stableSources).forEach { change ->
if (change.fileType == FileType.DIRECTORY) return@forEach
val targetFile = destinationDirectory.file(change.normalizedPath)
if (change.changeType == ChangeType.REMOVED) {
project.delete(targetFile)
} else {
workQueue.submit(GwtIncompatibleStripperWorker::class) {
sourceFile.set(change.file)
destinationFile.set(targetFile)
}
}
}
}
}
private interface GwtIncompatibleStripperParameters : WorkParameters {
val sourceFile: RegularFileProperty
val destinationFile: RegularFileProperty
}
private abstract class GwtIncompatibleStripperWorker : WorkAction<GwtIncompatibleStripperParameters> {
override fun execute() {
val strippedContent = GwtIncompatibleStripper.strip(parameters.sourceFile.get().asFile.readText())
parameters.destinationFile.get().asFile.apply {
parentFile.mkdirs()
writeText(strippedContent)
}
}
}
| 0 | Kotlin | 0 | 19 | c41080e9d73fda834b8aa455a5872cc2b54b9720 | 2,592 | gradle-j2cl-plugin | Apache License 2.0 |
compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/pipeline/convertToIr.kt | JetBrains | 3,432,266 | false | null | /*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir.pipeline
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.backend.Fir2IrConverter
import org.jetbrains.kotlin.fir.backend.Fir2IrExtensions
import org.jetbrains.kotlin.fir.backend.Fir2IrResult
import org.jetbrains.kotlin.fir.backend.jvm.Fir2IrJvmSpecialAnnotationSymbolProvider
import org.jetbrains.kotlin.fir.backend.jvm.FirJvmKotlinMangler
import org.jetbrains.kotlin.fir.backend.jvm.FirJvmVisibilityConverter
import org.jetbrains.kotlin.fir.declarations.FirFile
import org.jetbrains.kotlin.fir.languageVersionSettings
import org.jetbrains.kotlin.fir.moduleData
import org.jetbrains.kotlin.fir.resolve.ScopeSession
import org.jetbrains.kotlin.fir.resolve.providers.firProvider
import org.jetbrains.kotlin.fir.resolve.providers.impl.FirProviderImpl
import org.jetbrains.kotlin.ir.backend.jvm.serialization.JvmIrMangler
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
fun FirSession.convertToIr(
scopeSession: ScopeSession,
firFiles: List<FirFile>,
fir2IrExtensions: Fir2IrExtensions,
irGeneratorExtensions: Collection<IrGenerationExtension>
): Fir2IrResult {
val commonFirFiles = moduleData.dependsOnDependencies
.map { it.session }
.filter { it.kind == FirSession.Kind.Source }
.flatMap { (it.firProvider as FirProviderImpl).getAllFirFiles() }
return Fir2IrConverter.createModuleFragmentWithoutSignatures(
this, scopeSession, firFiles + commonFirFiles,
languageVersionSettings, fir2IrExtensions,
FirJvmKotlinMangler(this),
JvmIrMangler, IrFactoryImpl, FirJvmVisibilityConverter,
Fir2IrJvmSpecialAnnotationSymbolProvider(),
irGeneratorExtensions
)
}
| 7 | null | 5209 | 42,102 | 65f712ab2d54e34c5b02ffa3ca8c659740277133 | 2,013 | kotlin | Apache License 2.0 |
platform/vcs-tests/testSrc/com/intellij/vcs/VcsDirtyScopeManagerTest.kt | androidports | 115,100,208 | false | null | /*
* Copyright 2000-2016 JetBrains s.r.o.
*
* 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.vcs
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.service
import com.intellij.openapi.vcs.AbstractVcs
import com.intellij.openapi.vcs.FilePath
import com.intellij.openapi.vcs.ProjectLevelVcsManager
import com.intellij.openapi.vcs.changes.*
import com.intellij.openapi.vcs.changes.committed.MockAbstractVcs
import com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.testFramework.runInEdtAndWait
import com.intellij.util.continuation.SemaphoreContinuationContext
import com.intellij.vcs.test.VcsPlatformTest
import com.intellij.vcsUtil.VcsUtil.getFilePath
// see also VcsDirtyScopeTest
class VcsDirtyScopeManagerTest : VcsPlatformTest() {
private lateinit var dirtyScopeManager: VcsDirtyScopeManager
private lateinit var vcsManager: ProjectLevelVcsManagerImpl
private lateinit var vcs: MockAbstractVcs
private lateinit var baseRoot: VirtualFile
private lateinit var basePath: FilePath
override fun setUp() {
super.setUp()
dirtyScopeManager = VcsDirtyScopeManager.getInstance(myProject)
vcs = MockAbstractVcs(myProject)
baseRoot = myProject.baseDir
basePath = getFilePath(baseRoot)
disableVcsDirtyScopeVfsListener()
disableChangeListManager()
vcsManager = ProjectLevelVcsManager.getInstance(myProject) as ProjectLevelVcsManagerImpl
vcsManager.registerVcs(vcs)
registerRootMapping(baseRoot)
}
override fun getDebugLogCategories() = super.getDebugLogCategories().plus("#com.intellij.openapi.vcs.changes")
fun `test simple case`() {
val file = createFile(baseRoot, "file.txt")
dirtyScopeManager.fileDirty(file)
val invalidated = dirtyScopeManager.retrieveScopes()
assertTrue(invalidated.isFileDirty(file))
val scope = assertOneScope(invalidated)
assertTrue(scope.dirtyFiles.contains(file))
}
fun `test recursively dirty directory makes files under it dirty`() {
val dir = createDir(baseRoot, "dir")
val file = createFile(dir, "file.txt")
dirtyScopeManager.dirDirtyRecursively(dir)
val invalidated = dirtyScopeManager.retrieveScopes()
assertTrue(invalidated.isFileDirty(file))
val scope = assertOneScope(invalidated)
assertTrue(scope.recursivelyDirtyDirectories.contains(dir))
assertFalse(scope.dirtyFiles.contains(file))
}
fun `test dirty files from different roots`() {
val otherRoot = createSubRoot(myTestRootFile, "otherRoot")
val file = createFile(baseRoot, "file.txt")
val subFile = createFile(otherRoot, "other.txt")
dirtyScopeManager.filePathsDirty(listOf(file), listOf(otherRoot))
val invalidated = dirtyScopeManager.retrieveScopes()
assertDirtiness(invalidated, file, otherRoot, subFile)
val scope = assertOneScope(invalidated)
assertTrue(scope.recursivelyDirtyDirectories.contains(otherRoot))
assertTrue(scope.dirtyFiles.contains(file))
}
fun `test mark everything dirty should mark dirty all roots`() {
val subRoot = createSubRoot(baseRoot, "subroot")
val file = createFile(baseRoot, "file.txt")
val subFile = createFile(subRoot, "sub.txt")
dirtyScopeManager.markEverythingDirty()
val invalidated = dirtyScopeManager.retrieveScopes()
assertDirtiness(invalidated, file, basePath, subRoot, subFile)
}
// this is already implicitly checked in several other tests, but better to have it explicit
fun `test all roots from a single vcs belong to a single scope`() {
val otherRoot = createSubRoot(myTestRootFile, "otherRoot")
val file = createFile(baseRoot, "file.txt")
val subFile = createFile(otherRoot, "other.txt")
dirtyScopeManager.filePathsDirty(listOf(), listOf(basePath, otherRoot))
val invalidated = dirtyScopeManager.retrieveScopes()
assertOneScope(invalidated)
assertDirtiness(invalidated, file, otherRoot, subFile)
}
fun `test marking file outside of any VCS root dirty has no effect`() {
val file = createFile(myTestRootFile, "outside.txt")
dirtyScopeManager.fileDirty(file)
val invalidated = dirtyScopeManager.retrieveScopes()
assertTrue(invalidated.isEmpty)
assertFalse(invalidated.isEverythingDirty)
}
fun `test mark files from different VCSs dirty produce two dirty scopes`() {
val basePath = getFilePath(baseRoot)
val subRoot = createDir(baseRoot, "othervcs")
val otherVcs = MockAbstractVcs(myProject, "otherVCS")
vcsManager.registerVcs(otherVcs)
registerRootMapping(subRoot.virtualFile!!, otherVcs)
dirtyScopeManager.filePathsDirty(null, listOf(basePath, subRoot))
val invalidated = dirtyScopeManager.retrieveScopes()
val scopes = invalidated.scopes
assertEquals(2, scopes.size)
val mainVcsScope = scopes.find { it.vcs.name == vcs.name }!!
assertTrue(mainVcsScope.recursivelyDirtyDirectories.contains(basePath))
val otherVcsScope = scopes.find { it.vcs.name == otherVcs.name }!!
assertTrue(otherVcsScope.recursivelyDirtyDirectories.contains(subRoot))
}
private fun disableVcsDirtyScopeVfsListener() {
myProject.service<VcsDirtyScopeVfsListener>().setForbid(true)
}
private fun disableChangeListManager() {
(ChangeListManager.getInstance(myProject) as ChangeListManagerEx).freeze(SemaphoreContinuationContext(), "For tests")
}
private fun createSubRoot(parent: VirtualFile, name: String): FilePath {
val dir = createDir(parent, name)
registerRootMapping(dir.virtualFile!!)
return dir
}
private fun registerRootMapping(root: VirtualFile) {
registerRootMapping(root, vcs)
}
private fun registerRootMapping(root: VirtualFile, vcs: AbstractVcs<*>) {
vcsManager.setDirectoryMapping(root.path, vcs.name)
dirtyScopeManager.retrieveScopes() // ignore the dirty event after adding the mapping
}
private fun createFile(parentDir: FilePath, name: String): FilePath {
return createFile(parentDir.virtualFile!!, name, false)
}
private fun createFile(parentDir: VirtualFile, name: String): FilePath {
return createFile(parentDir, name, false)
}
private fun createDir(parentDir: VirtualFile, name: String): FilePath {
return createFile(parentDir, name, true)
}
private fun createFile(parentDir: VirtualFile, name: String, dir: Boolean): FilePath {
var file: VirtualFile? = null
runInEdtAndWait {
ApplicationManager.getApplication().runWriteAction {
file = if (dir) parentDir.createChildDirectory(this, name) else parentDir.createChildData(this, name)
}
}
return getFilePath(file!!)
}
private fun assertOneScope(invalidated: VcsInvalidated): VcsDirtyScope {
assertEquals(1, invalidated.scopes.size)
val scope = invalidated.scopes.first()
return scope
}
private fun assertDirtiness(invalidated: VcsInvalidated, vararg dirty: FilePath, clean: Collection<FilePath> = emptyList()) {
dirty.forEach { assertTrue(invalidated.isFileDirty(it)) }
clean.forEach { assertFalse(invalidated.isFileDirty(it)) }
}
}
| 6 | null | 1 | 4 | 6e4f7135c5843ed93c15a9782f29e4400df8b068 | 7,629 | intellij-community | Apache License 2.0 |
app/src/main/java/com/allat/mboychenko/silverthread/presentation/views/dialogs/BaseEventsCalendarDialog.kt | mboychenko | 184,405,918 | false | null | package com.allat.mboychenko.silverthread.presentation.views.dialogs
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.Window
import android.widget.TextView
import android.widget.Toast
import androidx.annotation.LayoutRes
import androidx.core.widget.ContentLoadingProgressBar
import androidx.fragment.app.DialogFragment
import com.allat.mboychenko.silverthread.R
import com.allat.mboychenko.silverthread.presentation.viewstate.BaseEventCalendarViewState
import com.applandeo.materialcalendarview.EventDay
import java.util.*
abstract class BaseEventsCalendarDialog<T : BaseEventCalendarViewState> : DialogFragment() {
private lateinit var calendarView: com.applandeo.materialcalendarview.CalendarView
private lateinit var filterButton: TextView
private lateinit var progress: ContentLoadingProgressBar
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
dialog?.window?.requestFeature(Window.FEATURE_NO_TITLE)
val view = inflater.inflate(getLayoutRes(), container, false)
with(view) {
calendarView = findViewById(R.id.calendar_view)
progress = findViewById(R.id.progress)
filterButton = findViewById(R.id.filter)
calendarView.setMaximumDate(Calendar.getInstance())
}
return view
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
dialog?.window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
filterButton.setOnClickListener {
if (calendarView.selectedDates.size > 1) {
filterAction(calendarView.selectedDates.first(), calendarView.selectedDates.last())
} else if (calendarView.selectedDates.size == 1) {
filterAction(calendarView.selectedDates.first())
}
dismiss()
}
calendarView.setMinimumDate(Calendar.getInstance())
}
protected open fun renderer(state: T) {
if (state.loading) {
progress.show()
} else {
progress.hide()
state.data?.let { result ->
result.lastOrNull()?.first?.let { calendarView.setMinimumDate(it) } ?: run {
Toast.makeText(context, getString(R.string.no_items_to_filter), Toast.LENGTH_LONG).show()
}
val events = mutableListOf<EventDay>()
result.forEach { dayTimes ->
val (day, times) = dayTimes
val drawable: Int = when(times) {
1 -> R.drawable.ic_single_event
2 -> R.drawable.ic_two_events
else -> R.drawable.ic_multi_events
}
events.add(EventDay(day, drawable))
}
calendarView.setEvents(events)
}
}
}
@LayoutRes
abstract fun getLayoutRes(): Int
abstract fun filterAction(firstDate: Calendar, secondDate: Calendar? = null)
protected fun clearSelection() {
calendarView.selectedDates = emptyList()
}
} | 0 | Kotlin | 1 | 2 | 31fa2a6ccfcb2ee49bd7dbb6c0a29dd4286f477a | 3,288 | SilverThread | Apache License 2.0 |
sudoklify/src/main/kotlin/dev/teogor/sudoklify/model/Sudoku.kt | teogor | 656,370,747 | false | null | package dev.teogor.sudoklify.model
import dev.teogor.sudoklify.types.Board
data class Sudoku(
val puzzle: Board,
val solution: Board,
val difficulty: Difficulty,
val type: Type,
) {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as Sudoku
if (!puzzle.contentDeepEquals(other.puzzle)) return false
if (!solution.contentDeepEquals(other.solution)) return false
if (difficulty != other.difficulty) return false
if (type != other.type) return false
return true
}
override fun hashCode(): Int {
var result = puzzle.contentDeepHashCode()
result = 31 * result + solution.contentDeepHashCode()
result = 31 * result + difficulty.hashCode()
result = 31 * result + type.hashCode()
return result
}
}
| 0 | Kotlin | 3 | 5 | d968e24109a1635f1ea5d53893670e867f6c63b6 | 845 | sudoklify | Apache License 2.0 |
src/main/kotlin/ru/ozon/ideplugin/kelp/resourceIcons/GetDsIconResourceName.kt | ozontech | 728,178,660 | false | null | package ru.ozon.ideplugin.kelp.resourceIcons
import ru.ozon.ideplugin.kelp.camelToSnakeCase
import ru.ozon.ideplugin.kelp.pluginConfig.KelpConfig
/**
* @return true, if the property with [propertyName] MUST be rendered with an icon
*/
internal fun filterDsIconProperty(
propertyNameFilter: KelpConfig.IconsRendering.IconPropertyNameFilter?,
propertyName: String,
): Boolean {
val startsWithFilterPassed = propertyNameFilter?.startsWith
?.any { prefix -> propertyName.startsWith(prefix) } != false
val doesNotStartWithFilterPassed = propertyNameFilter?.doesNotStartWith
?.all { prefix -> !propertyName.startsWith(prefix) } != false
return startsWithFilterPassed && doesNotStartWithFilterPassed
}
/**
* Converts the property name of the ds icons class to the actual drawable resource name
*/
internal fun getDsIconResourceName(
mapper: KelpConfig.IconsRendering.PropertyToResourceMapper?,
propertyName: String,
): String {
val prefix = mapper?.addPrefix ?: ""
val resourceName = prefix + if (mapper?.convertToSnakeCase == true) {
propertyName.camelToSnakeCase()
} else {
propertyName
}
return resourceName
}
| 0 | null | 1 | 97 | 7110df10d83afacd2444808ff8525d6fecef2a7a | 1,195 | kelp | Apache License 2.0 |
compiler/testData/codegen/box/javaInterop/generics/kt42824.kt | JetBrains | 3,432,266 | false | {"Kotlin": 79571273, "Java": 6776465, "Swift": 4063829, "C": 2609744, "C++": 1957654, "Objective-C++": 175279, "JavaScript": 130754, "Python": 59855, "Shell": 34920, "Objective-C": 21463, "Lex": 21452, "Batchfile": 11382, "CSS": 11368, "Ruby": 10470, "Dockerfile": 9907, "Groovy": 7092, "EJS": 5241, "CMake": 4473, "HTML": 2699, "Puppet": 1698, "FreeMarker": 1393, "Roff": 725, "Scala": 80} | // TARGET_BACKEND: JVM
// FILE: DiagnosticFactory0.java
import org.jetbrains.annotations.NotNull;
public class DiagnosticFactory0<E> {
@NotNull
public SimpleDiagnostic<E> on(@NotNull E element) {
return new SimpleDiagnostic<E>(element);
}
}
// FILE: test.kt
class SimpleDiagnostic<E>(val element: E)
interface KtAnnotationEntry
fun foo(error: DiagnosticFactory0<in KtAnnotationEntry>, entry: KtAnnotationEntry) {
error.on(entry) // used to be INAPPLICABLE_CANDIDATE
}
fun box() = "OK"
| 181 | Kotlin | 5748 | 49,172 | 33eb9cef3d146062c103f9853d772f0a1da0450e | 516 | kotlin | Apache License 2.0 |
shared/src/commonTest/kotlin/com/mr3y/ludi/shared/core/network/datasources/internal/RAWGMockResponses.kt | mr3y-the-programmer | 606,875,717 | false | null | package com.mr3y.ludi.shared.core.network.datasources.internal
import com.mr3y.ludi.shared.core.network.model.DetailedRAWGPlatformInfo
import com.mr3y.ludi.shared.core.network.model.RAWGGameGenre
import com.mr3y.ludi.shared.core.network.model.RAWGGameScreenshot
import com.mr3y.ludi.shared.core.network.model.RAWGGameTag
import com.mr3y.ludi.shared.core.network.model.RAWGPage
import com.mr3y.ludi.shared.core.network.model.RAWGPlatformProperties
import com.mr3y.ludi.shared.core.network.model.RAWGPlatformRequirements
import com.mr3y.ludi.shared.core.network.model.RAWGShallowGame
import com.mr3y.ludi.shared.core.network.model.RAWGStoreProperties
import com.mr3y.ludi.shared.core.network.model.ShallowRAWGPlatformInfo
import com.mr3y.ludi.shared.core.network.model.ShallowRAWGStoreInfo
import com.mr3y.ludi.shared.core.network.model.ShallowRAWGStoreInfoWithId
val serializedMockResponseA =
"""{
"count": 886906,
"next": "https://api.rawg.io/api/games?key=<KEY>&page=2&page_size=3",
"previous": null,
"results": [
{
"id": 3498,
"slug": "grand-theft-auto-v",
"name": "Grand Theft Auto V",
"released": "2013-09-17",
"tba": false,
"background_image": "https://media.rawg.io/media/games/456/456dea5e1c7e3cd07060c14e96612001.jpg",
"rating": 4.47,
"rating_top": 5,
"ratings": [
{
"id": 5,
"title": "exceptional",
"count": 3726,
"percent": 59.07
},
{
"id": 4,
"title": "recommended",
"count": 2070,
"percent": 32.82
},
{
"id": 3,
"title": "meh",
"count": 398,
"percent": 6.31
},
{
"id": 1,
"title": "skip",
"count": 114,
"percent": 1.81
}
],
"ratings_count": 6223,
"reviews_text_count": 47,
"added": 19057,
"added_by_status": {
"yet": 492,
"owned": 11035,
"beaten": 5308,
"toplay": 555,
"dropped": 986,
"playing": 681
},
"metacritic": 92,
"playtime": 73,
"suggestions_count": 410,
"updated": "2023-03-18T19:06:53",
"user_game": null,
"reviews_count": 6308,
"saturated_color": "0f0f0f",
"dominant_color": "0f0f0f",
"platforms": [
{
"platform": {
"id": 187,
"name": "PlayStation 5",
"slug": "playstation5",
"image": null,
"year_end": null,
"year_start": 2020,
"games_count": 824,
"image_background": "https://media.rawg.io/media/games/253/2534a46f3da7fa7c315f1387515ca393.jpg"
},
"released_at": "2013-09-17",
"requirements_en": null,
"requirements_ru": null
},
{
"platform": {
"id": 186,
"name": "Xbox Series S/X",
"slug": "xbox-series-x",
"image": null,
"year_end": null,
"year_start": 2020,
"games_count": 731,
"image_background": "https://media.rawg.io/media/games/618/618c2031a07bbff6b4f611f10b6bcdbc.jpg"
},
"released_at": "2013-09-17",
"requirements_en": null,
"requirements_ru": null
},
{
"platform": {
"id": 18,
"name": "PlayStation 4",
"slug": "playstation4",
"image": null,
"year_end": null,
"year_start": null,
"games_count": 6597,
"image_background": "https://media.rawg.io/media/games/b72/b7233d5d5b1e75e86bb860ccc7aeca85.jpg"
},
"released_at": "2013-09-17",
"requirements_en": null,
"requirements_ru": null
},
{
"platform": {
"id": 4,
"name": "PC",
"slug": "pc",
"image": null,
"year_end": null,
"year_start": null,
"games_count": 536875,
"image_background": "https://media.rawg.io/media/games/6fc/6fcf4cd3b17c288821388e6085bb0fc9.jpg"
},
"released_at": "2013-09-17",
"requirements_en": {
"minimum": "Minimum:OS: Windows 10 64 Bit, Windows 8.1 64 Bit, Windows 8 64 Bit, Windows 7 64 Bit Service Pack 1, Windows Vista 64 Bit Service Pack 2* (*NVIDIA video card recommended if running Vista OS)Processor: Intel Core 2 Quad CPU Q6600 @ 2.40GHz (4 CPUs) / AMD Phenom 9850 Quad-Core Processor (4 CPUs) @ 2.5GHzMemory: 4 GB RAMGraphics: NVIDIA 9800 GT 1GB / AMD HD 4870 1GB (DX 10, 10.1, 11)Storage: 72 GB available spaceSound Card: 100% DirectX 10 compatibleAdditional Notes: Over time downloadable content and programming changes will change the system requirements for this game. Please refer to your hardware manufacturer and www.rockstargames.com/support for current compatibility information. Some system components such as mobile chipsets, integrated, and AGP graphics cards may be incompatible. Unlisted specifications may not be supported by publisher. Other requirements: Installation and online play requires log-in to Rockstar Games Social Club (13+) network; internet connection required for activation, online play, and periodic entitlement verification; software installations required including Rockstar Games Social Club platform, DirectX , Chromium, and Microsoft Visual C++ 2008 sp1 Redistributable Package, and authentication software that recognizes certain hardware attributes for entitlement, digital rights management, system, and other support purposes. SINGLE USE SERIAL CODE REGISTRATION VIA INTERNET REQUIRED; REGISTRATION IS LIMITED TO ONE ROCKSTAR GAMES SOCIAL CLUB ACCOUNT (13+) PER SERIAL CODE; ONLY ONE PC LOG-IN ALLOWED PER SOCIAL CLUB ACCOUNT AT ANY TIME; SERIAL CODE(S) ARE NON-TRANSFERABLE ONCE USED; SOCIAL CLUB ACCOUNTS ARE NON-TRANSFERABLE. Partner Requirements: Please check the terms of service of this site before purchasing this software.",
"recommended": "Recommended:OS: Windows 10 64 Bit, Windows 8.1 64 Bit, Windows 8 64 Bit, Windows 7 64 Bit Service Pack 1Processor: Intel Core i5 3470 @ 3.2GHz (4 CPUs) / AMD X8 FX-8350 @ 4GHz (8 CPUs)Memory: 8 GB RAMGraphics: NVIDIA GTX 660 2GB / AMD HD 7870 2GBStorage: 72 GB available spaceSound Card: 100% DirectX 10 compatibleAdditional Notes:"
},
"requirements_ru": null
},
{
"platform": {
"id": 16,
"name": "PlayStation 3",
"slug": "playstation3",
"image": null,
"year_end": null,
"year_start": null,
"games_count": 3269,
"image_background": "https://media.rawg.io/media/games/234/23410661770ae13eac11066980834367.jpg"
},
"released_at": "2013-09-17",
"requirements_en": null,
"requirements_ru": null
},
{
"platform": {
"id": 14,
"name": "Xbox 360",
"slug": "xbox360",
"image": null,
"year_end": null,
"year_start": null,
"games_count": 2781,
"image_background": "https://media.rawg.io/media/games/5c0/5c0dd63002cb23f804aab327d40ef119.jpg"
},
"released_at": "2013-09-17",
"requirements_en": null,
"requirements_ru": null
},
{
"platform": {
"id": 1,
"name": "Xbox One",
"slug": "xbox-one",
"image": null,
"year_end": null,
"year_start": null,
"games_count": 5488,
"image_background": "https://media.rawg.io/media/games/562/562553814dd54e001a541e4ee83a591c.jpg"
},
"released_at": "2013-09-17",
"requirements_en": null,
"requirements_ru": null
}
],
"parent_platforms": [
{
"platform": {
"id": 1,
"name": "PC",
"slug": "pc"
}
},
{
"platform": {
"id": 2,
"name": "PlayStation",
"slug": "playstation"
}
},
{
"platform": {
"id": 3,
"name": "Xbox",
"slug": "xbox"
}
}
],
"genres": [
{
"id": 4,
"name": "Action",
"slug": "action",
"games_count": 177875,
"image_background": "https://media.rawg.io/media/games/b8c/b8c243eaa0fbac8115e0cdccac3f91dc.jpg"
},
{
"id": 3,
"name": "Adventure",
"slug": "adventure",
"games_count": 136825,
"image_background": "https://media.rawg.io/media/games/995/9951d9d55323d08967640f7b9ab3e342.jpg"
}
],
"stores": [
{
"id": 290375,
"store": {
"id": 3,
"name": "PlayStation Store",
"slug": "playstation-store",
"domain": "store.playstation.com",
"games_count": 7796,
"image_background": "https://media.rawg.io/media/games/bc0/bc06a29ceac58652b684deefe7d56099.jpg"
}
},
{
"id": 438095,
"store": {
"id": 11,
"name": "Epic Games",
"slug": "epic-games",
"domain": "epicgames.com",
"games_count": 1215,
"image_background": "https://media.rawg.io/media/games/b54/b54598d1d5cc31899f4f0a7e3122a7b0.jpg"
}
},
{
"id": 290376,
"store": {
"id": 1,
"name": "Steam",
"slug": "steam",
"domain": "store.steampowered.com",
"games_count": 73115,
"image_background": "https://media.rawg.io/media/games/120/1201a40e4364557b124392ee50317b99.jpg"
}
},
{
"id": 290377,
"store": {
"id": 7,
"name": "Xbox 360 Store",
"slug": "xbox360",
"domain": "marketplace.xbox.com",
"games_count": 1914,
"image_background": "https://media.rawg.io/media/games/e2d/e2d3f396b16dded0f841c17c9799a882.jpg"
}
},
{
"id": 290378,
"store": {
"id": 2,
"name": "Xbox Store",
"slug": "xbox-store",
"domain": "microsoft.com",
"games_count": 4756,
"image_background": "https://media.rawg.io/media/games/26d/26d4437715bee60138dab4a7c8c59c92.jpg"
}
}
],
"clip": null,
"tags": [
{
"id": 31,
"name": "Singleplayer",
"slug": "singleplayer",
"language": "eng",
"games_count": 209582,
"image_background": "https://media.rawg.io/media/games/73e/73eecb8909e0c39fb246f457b5d6cbbe.jpg"
},
{
"id": 40847,
"name": "Steam Achievements",
"slug": "steam-achievements",
"language": "eng",
"games_count": 29451,
"image_background": "https://media.rawg.io/media/games/8cc/8cce7c0e99dcc43d66c8efd42f9d03e3.jpg"
},
{
"id": 7,
"name": "Multiplayer",
"slug": "multiplayer",
"language": "eng",
"games_count": 35586,
"image_background": "https://media.rawg.io/media/games/328/3283617cb7d75d67257fc58339188742.jpg"
},
{
"id": 40836,
"name": "Full controller support",
"slug": "full-controller-support",
"language": "eng",
"games_count": 13833,
"image_background": "https://media.rawg.io/media/games/490/49016e06ae2103881ff6373248843069.jpg"
},
{
"id": 13,
"name": "Atmospheric",
"slug": "atmospheric",
"language": "eng",
"games_count": 29424,
"image_background": "https://media.rawg.io/media/games/7cf/7cfc9220b401b7a300e409e539c9afd5.jpg"
},
{
"id": 42,
"name": "Great Soundtrack",
"slug": "great-soundtrack",
"language": "eng",
"games_count": 3230,
"image_background": "https://media.rawg.io/media/games/7a2/7a2500ee8b2c0e1ff268bb4479463dea.jpg"
},
{
"id": 24,
"name": "RPG",
"slug": "rpg",
"language": "eng",
"games_count": 16758,
"image_background": "https://media.rawg.io/media/games/6cd/6cd653e0aaef5ff8bbd295bf4bcb12eb.jpg"
},
{
"id": 18,
"name": "Co-op",
"slug": "co-op",
"language": "eng",
"games_count": 9686,
"image_background": "https://media.rawg.io/media/games/8cc/8cce7c0e99dcc43d66c8efd42f9d03e3.jpg"
},
{
"id": 36,
"name": "Open World",
"slug": "open-world",
"language": "eng",
"games_count": 6237,
"image_background": "https://media.rawg.io/media/games/ee3/ee3e10193aafc3230ba1cae426967d10.jpg"
},
{
"id": 411,
"name": "cooperative",
"slug": "cooperative",
"language": "eng",
"games_count": 3925,
"image_background": "https://media.rawg.io/media/games/d0f/d0f91fe1d92332147e5db74e207cfc7a.jpg"
},
{
"id": 8,
"name": "First-Person",
"slug": "first-person",
"language": "eng",
"games_count": 29119,
"image_background": "https://media.rawg.io/media/games/c4b/c4b0cab189e73432de3a250d8cf1c84e.jpg"
},
{
"id": 149,
"name": "<NAME>",
"slug": "third-person",
"language": "eng",
"games_count": 9288,
"image_background": "https://media.rawg.io/media/games/951/951572a3dd1e42544bd39a5d5b42d234.jpg"
},
{
"id": 4,
"name": "Funny",
"slug": "funny",
"language": "eng",
"games_count": 23019,
"image_background": "https://media.rawg.io/media/games/5bb/5bb55ccb8205aadbb6a144cf6d8963f1.jpg"
},
{
"id": 37,
"name": "Sandbox",
"slug": "sandbox",
"language": "eng",
"games_count": 5963,
"image_background": "https://media.rawg.io/media/games/25c/25c4776ab5723d5d735d8bf617ca12d9.jpg"
},
{
"id": 123,
"name": "Comedy",
"slug": "comedy",
"language": "eng",
"games_count": 10907,
"image_background": "https://media.rawg.io/media/games/48c/48cb04ca483be865e3a83119c94e6097.jpg"
},
{
"id": 150,
"name": "<NAME>",
"slug": "third-person-shooter",
"language": "eng",
"games_count": 2884,
"image_background": "https://media.rawg.io/media/games/b45/b45575f34285f2c4479c9a5f719d972e.jpg"
},
{
"id": 62,
"name": "Moddable",
"slug": "moddable",
"language": "eng",
"games_count": 778,
"image_background": "https://media.rawg.io/media/games/48e/48e63bbddeddbe9ba81942772b156664.jpg"
},
{
"id": 144,
"name": "Crime",
"slug": "crime",
"language": "eng",
"games_count": 2544,
"image_background": "https://media.rawg.io/media/games/26d/26d4437715bee60138dab4a7c8c59c92.jpg"
},
{
"id": 62349,
"name": "vr mod",
"slug": "vr-mod",
"language": "eng",
"games_count": 17,
"image_background": "https://media.rawg.io/media/screenshots/1bb/1bb3f78f0fe43b5d5ca2f3da5b638840.jpg"
}
],
"esrb_rating": {
"id": 4,
"name": "Mature",
"slug": "mature"
},
"short_screenshots": [
{
"id": -1,
"image": "https://media.rawg.io/media/games/456/456dea5e1c7e3cd07060c14e96612001.jpg"
},
{
"id": 1827221,
"image": "https://media.rawg.io/media/screenshots/a7c/a7c43871a54bed6573a6a429451564ef.jpg"
},
{
"id": 1827222,
"image": "https://media.rawg.io/media/screenshots/cf4/cf4367daf6a1e33684bf19adb02d16d6.jpg"
},
{
"id": 1827223,
"image": "https://media.rawg.io/media/screenshots/f95/f9518b1d99210c0cae21fc09e95b4e31.jpg"
},
{
"id": 1827225,
"image": "https://media.rawg.io/media/screenshots/a5c/a5c95ea539c87d5f538763e16e18fb99.jpg"
},
{
"id": 1827226,
"image": "https://media.rawg.io/media/screenshots/a7e/a7e990bc574f4d34e03b5926361d1ee7.jpg"
},
{
"id": 1827227,
"image": "https://media.rawg.io/media/screenshots/592/592e2501d8734b802b2a34fee2df59fa.jpg"
}
]
},
{
"id": 3328,
"slug": "the-witcher-3-wild-hunt",
"name": "The Witcher 3: Wild Hunt",
"released": "2015-05-18",
"tba": false,
"background_image": "https://media.rawg.io/media/games/618/618c2031a07bbff6b4f611f10b6bcdbc.jpg",
"rating": 4.66,
"rating_top": 5,
"ratings": [
{
"id": 5,
"title": "exceptional",
"count": 4645,
"percent": 77.58
},
{
"id": 4,
"title": "recommended",
"count": 949,
"percent": 15.85
},
{
"id": 3,
"title": "meh",
"count": 244,
"percent": 4.08
},
{
"id": 1,
"title": "skip",
"count": 149,
"percent": 2.49
}
],
"ratings_count": 5901,
"reviews_text_count": 59,
"added": 18203,
"added_by_status": {
"yet": 1038,
"owned": 10488,
"beaten": 4302,
"toplay": 717,
"dropped": 820,
"playing": 838
},
"metacritic": 92,
"playtime": 46,
"suggestions_count": 649,
"updated": "2023-03-18T19:56:50",
"user_game": null,
"reviews_count": 5987,
"saturated_color": "0f0f0f",
"dominant_color": "0f0f0f",
"platforms": [
{
"platform": {
"id": 186,
"name": "Xbox Series S/X",
"slug": "xbox-series-x",
"image": null,
"year_end": null,
"year_start": 2020,
"games_count": 731,
"image_background": "https://media.rawg.io/media/games/618/618c2031a07bbff6b4f611f10b6bcdbc.jpg"
},
"released_at": "2015-05-18",
"requirements_en": null,
"requirements_ru": null
},
{
"platform": {
"id": 18,
"name": "PlayStation 4",
"slug": "playstation4",
"image": null,
"year_end": null,
"year_start": null,
"games_count": 6597,
"image_background": "https://media.rawg.io/media/games/b72/b7233d5d5b1e75e86bb860ccc7aeca85.jpg"
},
"released_at": "2015-05-18",
"requirements_en": null,
"requirements_ru": null
},
{
"platform": {
"id": 7,
"name": "Nintendo Switch",
"slug": "nintendo-switch",
"image": null,
"year_end": null,
"year_start": null,
"games_count": 5199,
"image_background": "https://media.rawg.io/media/games/b72/b7233d5d5b1e75e86bb860ccc7aeca85.jpg"
},
"released_at": "2015-05-18",
"requirements_en": null,
"requirements_ru": null
},
{
"platform": {
"id": 4,
"name": "PC",
"slug": "pc",
"image": null,
"year_end": null,
"year_start": null,
"games_count": 536875,
"image_background": "https://media.rawg.io/media/games/6fc/6fcf4cd3b17c288821388e6085bb0fc9.jpg"
},
"released_at": "2015-05-18",
"requirements_en": null,
"requirements_ru": null
},
{
"platform": {
"id": 1,
"name": "Xbox One",
"slug": "xbox-one",
"image": null,
"year_end": null,
"year_start": null,
"games_count": 5488,
"image_background": "https://media.rawg.io/media/games/562/562553814dd54e001a541e4ee83a591c.jpg"
},
"released_at": "2015-05-18",
"requirements_en": null,
"requirements_ru": null
},
{
"platform": {
"id": 187,
"name": "PlayStation 5",
"slug": "playstation5",
"image": null,
"year_end": null,
"year_start": 2020,
"games_count": 824,
"image_background": "https://media.rawg.io/media/games/253/2534a46f3da7fa7c315f1387515ca393.jpg"
},
"released_at": "2015-05-18",
"requirements_en": null,
"requirements_ru": null
}
],
"parent_platforms": [
{
"platform": {
"id": 1,
"name": "PC",
"slug": "pc"
}
},
{
"platform": {
"id": 2,
"name": "PlayStation",
"slug": "playstation"
}
},
{
"platform": {
"id": 3,
"name": "Xbox",
"slug": "xbox"
}
},
{
"platform": {
"id": 7,
"name": "Nintendo",
"slug": "nintendo"
}
}
],
"genres": [
{
"id": 4,
"name": "Action",
"slug": "action",
"games_count": 177875,
"image_background": "https://media.rawg.io/media/games/b8c/b8c243eaa0fbac8115e0cdccac3f91dc.jpg"
},
{
"id": 3,
"name": "Adventure",
"slug": "adventure",
"games_count": 136825,
"image_background": "https://media.rawg.io/media/games/995/9951d9d55323d08967640f7b9ab3e342.jpg"
},
{
"id": 5,
"name": "RPG",
"slug": "role-playing-games-rpg",
"games_count": 53787,
"image_background": "https://media.rawg.io/media/games/d1a/d1a2e99ade53494c6330a0ed945fe823.jpg"
}
],
"stores": [
{
"id": 354780,
"store": {
"id": 5,
"name": "GOG",
"slug": "gog",
"domain": "gog.com",
"games_count": 4934,
"image_background": "https://media.rawg.io/media/games/4cf/4cfc6b7f1850590a4634b08bfab308ab.jpg"
}
},
{
"id": 3565,
"store": {
"id": 3,
"name": "PlayStation Store",
"slug": "playstation-store",
"domain": "store.playstation.com",
"games_count": 7796,
"image_background": "https://media.rawg.io/media/games/bc0/bc06a29ceac58652b684deefe7d56099.jpg"
}
},
{
"id": 305376,
"store": {
"id": 1,
"name": "Steam",
"slug": "steam",
"domain": "store.steampowered.com",
"games_count": 73115,
"image_background": "https://media.rawg.io/media/games/120/1201a40e4364557b124392ee50317b99.jpg"
}
},
{
"id": 312313,
"store": {
"id": 2,
"name": "Xbox Store",
"slug": "xbox-store",
"domain": "microsoft.com",
"games_count": 4756,
"image_background": "https://media.rawg.io/media/games/26d/26d4437715bee60138dab4a7c8c59c92.jpg"
}
},
{
"id": 676022,
"store": {
"id": 6,
"name": "Nintendo Store",
"slug": "nintendo",
"domain": "nintendo.com",
"games_count": 8862,
"image_background": "https://media.rawg.io/media/games/7c4/7c448374df84b607f67ce9182a3a3ca7.jpg"
}
}
],
"clip": null,
"tags": [
{
"id": 31,
"name": "Singleplayer",
"slug": "singleplayer",
"language": "eng",
"games_count": 209582,
"image_background": "https://media.rawg.io/media/games/73e/73eecb8909e0c39fb246f457b5d6cbbe.jpg"
},
{
"id": 40836,
"name": "Full controller support",
"slug": "full-controller-support",
"language": "eng",
"games_count": 13833,
"image_background": "https://media.rawg.io/media/games/490/49016e06ae2103881ff6373248843069.jpg"
},
{
"id": 13,
"name": "Atmospheric",
"slug": "atmospheric",
"language": "eng",
"games_count": 29424,
"image_background": "https://media.rawg.io/media/games/7cf/7cfc9220b401b7a300e409e539c9afd5.jpg"
},
{
"id": 42,
"name": "Great Soundtrack",
"slug": "great-soundtrack",
"language": "eng",
"games_count": 3230,
"image_background": "https://media.rawg.io/media/games/7a2/7a2500ee8b2c0e1ff268bb4479463dea.jpg"
},
{
"id": 24,
"name": "RPG",
"slug": "rpg",
"language": "eng",
"games_count": 16758,
"image_background": "https://media.rawg.io/media/games/6cd/6cd653e0aaef5ff8bbd295bf4bcb12eb.jpg"
},
{
"id": 118,
"name": "<NAME>",
"slug": "story-rich",
"language": "eng",
"games_count": 18114,
"image_background": "https://media.rawg.io/media/games/fc1/fc1307a2774506b5bd65d7e8424664a7.jpg"
},
{
"id": 36,
"name": "Open World",
"slug": "open-world",
"language": "eng",
"games_count": 6237,
"image_background": "https://media.rawg.io/media/games/ee3/ee3e10193aafc3230ba1cae426967d10.jpg"
},
{
"id": 149,
"name": "<NAME>",
"slug": "third-person",
"language": "eng",
"games_count": 9288,
"image_background": "https://media.rawg.io/media/games/951/951572a3dd1e42544bd39a5d5b42d234.jpg"
},
{
"id": 64,
"name": "Fantasy",
"slug": "fantasy",
"language": "eng",
"games_count": 24635,
"image_background": "https://media.rawg.io/media/screenshots/88b/88b5f27f07d6ca2f8a3cd0b36e03a670.jpg"
},
{
"id": 37,
"name": "Sandbox",
"slug": "sandbox",
"language": "eng",
"games_count": 5963,
"image_background": "https://media.rawg.io/media/games/25c/25c4776ab5723d5d735d8bf617ca12d9.jpg"
},
{
"id": 97,
"name": "Action RPG",
"slug": "action-rpg",
"language": "eng",
"games_count": 5774,
"image_background": "https://media.rawg.io/media/games/849/849414b978db37d4563ff9e4b0d3a787.jpg"
},
{
"id": 41,
"name": "Dark",
"slug": "dark",
"language": "eng",
"games_count": 14252,
"image_background": "https://media.rawg.io/media/games/4e6/4e6e8e7f50c237d76f38f3c885dae3d2.jpg"
},
{
"id": 44,
"name": "Nudity",
"slug": "nudity",
"language": "eng",
"games_count": 4681,
"image_background": "https://media.rawg.io/media/games/16b/16b1b7b36e2042d1128d5a3e852b3b2f.jpg"
},
{
"id": 336,
"name": "controller support",
"slug": "controller-support",
"language": "eng",
"games_count": 293,
"image_background": "https://media.rawg.io/media/games/f46/f466571d536f2e3ea9e815ad17177501.jpg"
},
{
"id": 145,
"name": "Choices Matter",
"slug": "choices-matter",
"language": "eng",
"games_count": 3254,
"image_background": "https://media.rawg.io/media/games/562/562553814dd54e001a541e4ee83a591c.jpg"
},
{
"id": 192,
"name": "Mature",
"slug": "mature",
"language": "eng",
"games_count": 2001,
"image_background": "https://media.rawg.io/media/games/5fa/5fae5fec3c943179e09da67a4427d68f.jpg"
},
{
"id": 40,
"name": "<NAME>",
"slug": "dark-fantasy",
"language": "eng",
"games_count": 3190,
"image_background": "https://media.rawg.io/media/games/da1/da1b267764d77221f07a4386b6548e5a.jpg"
},
{
"id": 66,
"name": "Medieval",
"slug": "medieval",
"language": "eng",
"games_count": 5299,
"image_background": "https://media.rawg.io/media/games/ee3/ee3e10193aafc3230ba1cae426967d10.jpg"
},
{
"id": 82,
"name": "Magic",
"slug": "magic",
"language": "eng",
"games_count": 8040,
"image_background": "https://media.rawg.io/media/screenshots/6d3/6d367773c06886535620f2d7fb1cb866.jpg"
},
{
"id": 218,
"name": "Multiple Endings",
"slug": "multiple-endings",
"language": "eng",
"games_count": 6936,
"image_background": "https://media.rawg.io/media/games/951/951572a3dd1e42544bd39a5d5b42d234.jpg"
}
],
"esrb_rating": {
"id": 4,
"name": "Mature",
"slug": "mature"
},
"short_screenshots": [
{
"id": -1,
"image": "https://media.rawg.io/media/games/618/618c2031a07bbff6b4f611f10b6bcdbc.jpg"
},
{
"id": 30336,
"image": "https://media.rawg.io/media/screenshots/1ac/1ac19f31974314855ad7be266adeb500.jpg"
},
{
"id": 30337,
"image": "https://media.rawg.io/media/screenshots/6a0/6a08afca95261a2fe221ea9e01d28762.jpg"
},
{
"id": 30338,
"image": "https://media.rawg.io/media/screenshots/cdd/cdd31b6b4a687425a87b5ce231ac89d7.jpg"
},
{
"id": 30339,
"image": "https://media.rawg.io/media/screenshots/862/862397b153221a625922d3bb66337834.jpg"
},
{
"id": 30340,
"image": "https://media.rawg.io/media/screenshots/166/166787c442a45f52f4f230c33fd7d605.jpg"
},
{
"id": 30342,
"image": "https://media.rawg.io/media/screenshots/f63/f6373ee614046d81503d63f167181803.jpg"
}
]
},
{
"id": 4200,
"slug": "portal-2",
"name": "Portal 2",
"released": "2011-04-18",
"tba": false,
"background_image": "https://media.rawg.io/media/games/328/3283617cb7d75d67257fc58339188742.jpg",
"rating": 4.62,
"rating_top": 5,
"ratings": [
{
"id": 5,
"title": "exceptional",
"count": 3684,
"percent": 70.63
},
{
"id": 4,
"title": "recommended",
"count": 1285,
"percent": 24.64
},
{
"id": 3,
"title": "meh",
"count": 140,
"percent": 2.68
},
{
"id": 1,
"title": "skip",
"count": 107,
"percent": 2.05
}
],
"ratings_count": 5170,
"reviews_text_count": 31,
"added": 17148,
"added_by_status": {
"yet": 565,
"owned": 10591,
"beaten": 4996,
"toplay": 332,
"dropped": 526,
"playing": 138
},
"metacritic": 95,
"playtime": 11,
"suggestions_count": 534,
"updated": "2023-03-18T16:37:18",
"user_game": null,
"reviews_count": 5216,
"saturated_color": "0f0f0f",
"dominant_color": "0f0f0f",
"platforms": [
{
"platform": {
"id": 14,
"name": "Xbox 360",
"slug": "xbox360",
"image": null,
"year_end": null,
"year_start": null,
"games_count": 2781,
"image_background": "https://media.rawg.io/media/games/5c0/5c0dd63002cb23f804aab327d40ef119.jpg"
},
"released_at": "2011-04-19",
"requirements_en": null,
"requirements_ru": null
},
{
"platform": {
"id": 6,
"name": "Linux",
"slug": "linux",
"image": null,
"year_end": null,
"year_start": null,
"games_count": 79193,
"image_background": "https://media.rawg.io/media/games/46d/46d98e6910fbc0706e2948a7cc9b10c5.jpg"
},
"released_at": "2011-04-19",
"requirements_en": null,
"requirements_ru": null
},
{
"platform": {
"id": 5,
"name": "macOS",
"slug": "macos",
"image": null,
"year_end": null,
"year_start": null,
"games_count": 106472,
"image_background": "https://media.rawg.io/media/games/960/960b601d9541cec776c5fa42a00bf6c4.jpg"
},
"released_at": null,
"requirements_en": null,
"requirements_ru": null
},
{
"platform": {
"id": 16,
"name": "PlayStation 3",
"slug": "playstation3",
"image": null,
"year_end": null,
"year_start": null,
"games_count": 3269,
"image_background": "https://media.rawg.io/media/games/234/23410661770ae13eac11066980834367.jpg"
},
"released_at": "2011-04-19",
"requirements_en": null,
"requirements_ru": null
},
{
"platform": {
"id": 4,
"name": "PC",
"slug": "pc",
"image": null,
"year_end": null,
"year_start": null,
"games_count": 536875,
"image_background": "https://media.rawg.io/media/games/6fc/6fcf4cd3b17c288821388e6085bb0fc9.jpg"
},
"released_at": null,
"requirements_en": null,
"requirements_ru": {
"minimum": "Core 2 Duo/Athlon X2 2 ГГц,1 Гб памяти,GeForce 7600/Radeon X800,10 Гб на винчестере,интернет-соединение",
"recommended": "Core 2 Duo/Athlon X2 2.5 ГГц,2 Гб памяти,GeForce GTX 280/Radeon HD 2600,10 Гб на винчестере,интернет-соединение"
}
},
{
"platform": {
"id": 1,
"name": "Xbox One",
"slug": "xbox-one",
"image": null,
"year_end": null,
"year_start": null,
"games_count": 5488,
"image_background": "https://media.rawg.io/media/games/562/562553814dd54e001a541e4ee83a591c.jpg"
},
"released_at": "2011-04-18",
"requirements_en": null,
"requirements_ru": null
}
],
"parent_platforms": [
{
"platform": {
"id": 1,
"name": "PC",
"slug": "pc"
}
},
{
"platform": {
"id": 2,
"name": "PlayStation",
"slug": "playstation"
}
},
{
"platform": {
"id": 3,
"name": "Xbox",
"slug": "xbox"
}
},
{
"platform": {
"id": 5,
"name": "Apple Macintosh",
"slug": "mac"
}
},
{
"platform": {
"id": 6,
"name": "Linux",
"slug": "linux"
}
}
],
"genres": [
{
"id": 2,
"name": "Shooter",
"slug": "shooter",
"games_count": 62981,
"image_background": "https://media.rawg.io/media/games/328/3283617cb7d75d67257fc58339188742.jpg"
},
{
"id": 7,
"name": "Puzzle",
"slug": "puzzle",
"games_count": 100172,
"image_background": "https://media.rawg.io/media/games/2e1/2e187b31e5cee21c110bd16798d75fab.jpg"
}
],
"stores": [
{
"id": 465889,
"store": {
"id": 2,
"name": "Xbox Store",
"slug": "xbox-store",
"domain": "microsoft.com",
"games_count": 4756,
"image_background": "https://media.rawg.io/media/games/26d/26d4437715bee60138dab4a7c8c59c92.jpg"
}
},
{
"id": 13134,
"store": {
"id": 1,
"name": "Steam",
"slug": "steam",
"domain": "store.steampowered.com",
"games_count": 73115,
"image_background": "https://media.rawg.io/media/games/120/1201a40e4364557b124392ee50317b99.jpg"
}
},
{
"id": 4526,
"store": {
"id": 3,
"name": "PlayStation Store",
"slug": "playstation-store",
"domain": "store.playstation.com",
"games_count": 7796,
"image_background": "https://media.rawg.io/media/games/bc0/bc06a29ceac58652b684deefe7d56099.jpg"
}
},
{
"id": 33916,
"store": {
"id": 7,
"name": "Xbox 360 Store",
"slug": "xbox360",
"domain": "marketplace.xbox.com",
"games_count": 1914,
"image_background": "https://media.rawg.io/media/games/e2d/e2d3f396b16dded0f841c17c9799a882.jpg"
}
}
],
"clip": null,
"tags": [
{
"id": 31,
"name": "Singleplayer",
"slug": "singleplayer",
"language": "eng",
"games_count": 209582,
"image_background": "https://media.rawg.io/media/games/73e/73eecb8909e0c39fb246f457b5d6cbbe.jpg"
},
{
"id": 40847,
"name": "Steam Achievements",
"slug": "steam-achievements",
"language": "eng",
"games_count": 29451,
"image_background": "https://media.rawg.io/media/games/8cc/8cce7c0e99dcc43d66c8efd42f9d03e3.jpg"
},
{
"id": 7,
"name": "Multiplayer",
"slug": "multiplayer",
"language": "eng",
"games_count": 35586,
"image_background": "https://media.rawg.io/media/games/328/3283617cb7d75d67257fc58339188742.jpg"
},
{
"id": 40836,
"name": "Full controller support",
"slug": "full-controller-support",
"language": "eng",
"games_count": 13833,
"image_background": "https://media.rawg.io/media/games/490/49016e06ae2103881ff6373248843069.jpg"
},
{
"id": 13,
"name": "Atmospheric",
"slug": "atmospheric",
"language": "eng",
"games_count": 29424,
"image_background": "https://media.rawg.io/media/games/7cf/7cfc9220b401b7a300e409e539c9afd5.jpg"
},
{
"id": 40849,
"name": "Steam Cloud",
"slug": "steam-cloud",
"language": "eng",
"games_count": 13564,
"image_background": "https://media.rawg.io/media/games/49c/49c3dfa4ce2f6f140cc4825868e858cb.jpg"
},
{
"id": 7808,
"name": "steam-trading-cards",
"slug": "steam-trading-cards",
"language": "eng",
"games_count": 7582,
"image_background": "https://media.rawg.io/media/games/310/3106b0e012271c5ffb16497b070be739.jpg"
},
{
"id": 18,
"name": "Co-op",
"slug": "co-op",
"language": "eng",
"games_count": 9686,
"image_background": "https://media.rawg.io/media/games/8cc/8cce7c0e99dcc43d66c8efd42f9d03e3.jpg"
},
{
"id": 118,
"name": "<NAME>",
"slug": "story-rich",
"language": "eng",
"games_count": 18114,
"image_background": "https://media.rawg.io/media/games/fc1/fc1307a2774506b5bd65d7e8424664a7.jpg"
},
{
"id": 411,
"name": "cooperative",
"slug": "cooperative",
"language": "eng",
"games_count": 3925,
"image_background": "https://media.rawg.io/media/games/d0f/d0f91fe1d92332147e5db74e207cfc7a.jpg"
},
{
"id": 8,
"name": "First-Person",
"slug": "first-person",
"language": "eng",
"games_count": 29119,
"image_background": "https://media.rawg.io/media/games/c4b/c4b0cab189e73432de3a250d8cf1c84e.jpg"
},
{
"id": 32,
"name": "Sci-fi",
"slug": "sci-fi",
"language": "eng",
"games_count": 17348,
"image_background": "https://media.rawg.io/media/games/8e4/8e4de3f54ac659e08a7ba6a2b731682a.jpg"
},
{
"id": 30,
"name": "FPS",
"slug": "fps",
"language": "eng",
"games_count": 12564,
"image_background": "https://media.rawg.io/media/games/120/1201a40e4364557b124392ee50317b99.jpg"
},
{
"id": 9,
"name": "Online Co-Op",
"slug": "online-co-op",
"language": "eng",
"games_count": 4190,
"image_background": "https://media.rawg.io/media/games/d0f/d0f91fe1d92332147e5db74e207cfc7a.jpg"
},
{
"id": 4,
"name": "Funny",
"slug": "funny",
"language": "eng",
"games_count": 23019,
"image_background": "https://media.rawg.io/media/games/5bb/5bb55ccb8205aadbb6a144cf6d8963f1.jpg"
},
{
"id": 189,
"name": "Female Protagonist",
"slug": "female-protagonist",
"language": "eng",
"games_count": 10429,
"image_background": "https://media.rawg.io/media/games/021/021c4e21a1824d2526f925eff6324653.jpg"
},
{
"id": 123,
"name": "Comedy",
"slug": "comedy",
"language": "eng",
"games_count": 10907,
"image_background": "https://media.rawg.io/media/games/48c/48cb04ca483be865e3a83119c94e6097.jpg"
},
{
"id": 75,
"name": "Local Co-Op",
"slug": "local-co-op",
"language": "eng",
"games_count": 4977,
"image_background": "https://media.rawg.io/media/games/226/2262cea0b385db6cf399f4be831603b0.jpg"
},
{
"id": 11669,
"name": "stats",
"slug": "stats",
"language": "eng",
"games_count": 4436,
"image_background": "https://media.rawg.io/media/games/179/179245a3693049a11a25b900ab18f8f7.jpg"
},
{
"id": 40852,
"name": "Steam Workshop",
"slug": "steam-workshop",
"language": "eng",
"games_count": 1276,
"image_background": "https://media.rawg.io/media/games/f3e/f3eec35c6218dcfd93a537751e6bfa61.jpg"
},
{
"id": 25,
"name": "Space",
"slug": "space",
"language": "eng",
"games_count": 43383,
"image_background": "https://media.rawg.io/media/games/e1f/e1ffbeb1bac25b19749ad285ca29e158.jpg"
},
{
"id": 40838,
"name": "Includes level editor",
"slug": "includes-level-editor",
"language": "eng",
"games_count": 1607,
"image_background": "https://media.rawg.io/media/games/9cc/9cc11e2e81403186c7fa9c00c143d6e4.jpg"
},
{
"id": 40833,
"name": "Captions available",
"slug": "captions-available",
"language": "eng",
"games_count": 1219,
"image_background": "https://media.rawg.io/media/games/a12/a12f806432cb385bc286f0935c49cd14.jpg"
},
{
"id": 40834,
"name": "Commentary available",
"slug": "commentary-available",
"language": "eng",
"games_count": 252,
"image_background": "https://media.rawg.io/media/screenshots/405/40567fe45e6074a5b2bfbd4a3fea7809.jpg"
},
{
"id": 87,
"name": "Science",
"slug": "science",
"language": "eng",
"games_count": 1510,
"image_background": "https://media.rawg.io/media/screenshots/f93/f93ee651619bb5b273f1b51528ee872a.jpg"
}
],
"esrb_rating": {
"id": 2,
"name": "Everyone 10+",
"slug": "everyone-10-plus"
},
"short_screenshots": [
{
"id": -1,
"image": "https://media.rawg.io/media/games/328/3283617cb7d75d67257fc58339188742.jpg"
},
{
"id": 99018,
"image": "https://media.rawg.io/media/screenshots/221/221a03c11e5ff9f765d62f60d4b4cbf5.jpg"
},
{
"id": 99019,
"image": "https://media.rawg.io/media/screenshots/173/1737ff43c14f40294011a209b1012875.jpg"
},
{
"id": 99020,
"image": "https://media.rawg.io/media/screenshots/b11/b11a2ae0664f0e8a1ef2346f99df26e1.jpg"
},
{
"id": 99021,
"image": "https://media.rawg.io/media/screenshots/9b1/9b107a790909b31918ebe2f40547cc85.jpg"
},
{
"id": 99022,
"image": "https://media.rawg.io/media/screenshots/d05/d058fc7f7fa6128916c311eb14267fed.jpg"
},
{
"id": 99023,
"image": "https://media.rawg.io/media/screenshots/415/41543dcc12dffc8e97d85a56ad42cda8.jpg"
}
]
}
],
"seo_title": "All Games",
"seo_description": "",
"seo_keywords": "",
"seo_h1": "All Games",
"noindex": false,
"nofollow": false,
"description": "",
"filters": {
"years": [
{
"from": 2020,
"to": 2023,
"filter": "2020-01-01,2023-12-31",
"decade": 2020,
"years": [
{
"year": 2023,
"count": 38460,
"nofollow": false
},
{
"year": 2022,
"count": 177959,
"nofollow": false
},
{
"year": 2021,
"count": 173238,
"nofollow": false
},
{
"year": 2020,
"count": 133047,
"nofollow": false
}
],
"nofollow": true,
"count": 522704
},
{
"from": 2010,
"to": 2019,
"filter": "2010-01-01,2019-12-31",
"decade": 2010,
"years": [
{
"year": 2019,
"count": 79741,
"nofollow": false
},
{
"year": 2018,
"count": 71561,
"nofollow": false
},
{
"year": 2017,
"count": 56544,
"nofollow": true
},
{
"year": 2016,
"count": 41363,
"nofollow": true
},
{
"year": 2015,
"count": 26440,
"nofollow": true
},
{
"year": 2014,
"count": 15620,
"nofollow": true
},
{
"year": 2013,
"count": 6341,
"nofollow": true
},
{
"year": 2012,
"count": 5379,
"nofollow": true
},
{
"year": 2011,
"count": 4320,
"nofollow": true
},
{
"year": 2010,
"count": 3881,
"nofollow": true
}
],
"nofollow": true,
"count": 311190
},
{
"from": 2000,
"to": 2009,
"filter": "2000-01-01,2009-12-31",
"decade": 2000,
"years": [
{
"year": 2009,
"count": 3108,
"nofollow": true
},
{
"year": 2008,
"count": 2030,
"nofollow": true
},
{
"year": 2007,
"count": 1553,
"nofollow": true
},
{
"year": 2006,
"count": 1280,
"nofollow": true
},
{
"year": 2005,
"count": 1148,
"nofollow": true
},
{
"year": 2004,
"count": 1157,
"nofollow": true
},
{
"year": 2003,
"count": 1137,
"nofollow": true
},
{
"year": 2002,
"count": 985,
"nofollow": true
},
{
"year": 2001,
"count": 1108,
"nofollow": true
},
{
"year": 2000,
"count": 999,
"nofollow": true
}
],
"nofollow": true,
"count": 14505
},
{
"from": 1990,
"to": 1999,
"filter": "1990-01-01,1999-12-31",
"decade": 1990,
"years": [
{
"year": 1999,
"count": 780,
"nofollow": true
},
{
"year": 1998,
"count": 723,
"nofollow": true
},
{
"year": 1997,
"count": 872,
"nofollow": true
},
{
"year": 1996,
"count": 759,
"nofollow": true
},
{
"year": 1995,
"count": 861,
"nofollow": true
},
{
"year": 1994,
"count": 814,
"nofollow": true
},
{
"year": 1993,
"count": 744,
"nofollow": true
},
{
"year": 1992,
"count": 648,
"nofollow": true
},
{
"year": 1991,
"count": 578,
"nofollow": true
},
{
"year": 1990,
"count": 538,
"nofollow": true
}
],
"nofollow": true,
"count": 7317
},
{
"from": 1980,
"to": 1989,
"filter": "1980-01-01,1989-12-31",
"decade": 1980,
"years": [
{
"year": 1989,
"count": 434,
"nofollow": true
},
{
"year": 1988,
"count": 317,
"nofollow": true
},
{
"year": 1987,
"count": 339,
"nofollow": true
},
{
"year": 1986,
"count": 248,
"nofollow": true
},
{
"year": 1985,
"count": 231,
"nofollow": true
},
{
"year": 1984,
"count": 185,
"nofollow": true
},
{
"year": 1983,
"count": 206,
"nofollow": true
},
{
"year": 1982,
"count": 148,
"nofollow": true
},
{
"year": 1981,
"count": 65,
"nofollow": true
},
{
"year": 1980,
"count": 35,
"nofollow": true
}
],
"nofollow": true,
"count": 2208
},
{
"from": 1970,
"to": 1979,
"filter": "1970-01-01,1979-12-31",
"decade": 1970,
"years": [
{
"year": 1979,
"count": 15,
"nofollow": true
},
{
"year": 1978,
"count": 17,
"nofollow": true
},
{
"year": 1977,
"count": 13,
"nofollow": true
},
{
"year": 1976,
"count": 7,
"nofollow": true
},
{
"year": 1975,
"count": 3,
"nofollow": true
},
{
"year": 1974,
"count": 2,
"nofollow": true
},
{
"year": 1973,
"count": 1,
"nofollow": true
},
{
"year": 1972,
"count": 2,
"nofollow": true
},
{
"year": 1971,
"count": 6,
"nofollow": true
},
{
"year": 1970,
"count": 1,
"nofollow": true
}
],
"nofollow": true,
"count": 67
},
{
"from": 1960,
"to": 1969,
"filter": "1960-01-01,1969-12-31",
"decade": 1960,
"years": [
{
"year": 1962,
"count": 1,
"nofollow": true
}
],
"nofollow": true,
"count": 1
},
{
"from": 1950,
"to": 1959,
"filter": "1950-01-01,1959-12-31",
"decade": 1950,
"years": [
{
"year": 1958,
"count": 1,
"nofollow": true
},
{
"year": 1954,
"count": 2,
"nofollow": true
}
],
"nofollow": true,
"count": 3
}
]
},
"nofollow_collections": [
"stores"
]
}
""".trimIndent()
val deserializedMockResponseA = RAWGPage(
count = 886906,
nextPageUrl = "https://api.rawg.io/api/games?key=<KEY>&page=2&page_size=3",
previousPageUrl = null,
results = listOf(
RAWGShallowGame(
id = 3498,
slug = "grand-theft-auto-v",
name = "Grand Theft Auto V",
releaseDate = "2013-09-17",
toBeAnnounced = false,
imageUrl = "https://media.rawg.io/media/games/456/456dea5e1c7e3cd07060c14e96612001.jpg",
rating = 4.47f,
metaCriticScore = 92,
playtime = 73,
suggestionsCount = 410,
platforms = listOf(
DetailedRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 187,
name = "PlayStation 5",
slug = "playstation5",
imageUrl = null,
yearEnd = null,
yearStart = 2020,
gamesCount = 824,
imageBackground = "https://media.rawg.io/media/games/253/2534a46f3da7fa7c315f1387515ca393.jpg"
),
releaseDate = "2013-09-17",
requirementsInEnglish = null
),
DetailedRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 186,
name = "Xbox Series S/X",
slug = "xbox-series-x",
imageUrl = null,
yearEnd = null,
yearStart = 2020,
gamesCount = 731,
imageBackground = "https://media.rawg.io/media/games/618/618c2031a07bbff6b4f611f10b6bcdbc.jpg"
),
releaseDate = "2013-09-17",
requirementsInEnglish = null
),
DetailedRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 18,
name = "PlayStation 4",
slug = "playstation4",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = 6597,
imageBackground = "https://media.rawg.io/media/games/b72/b7233d5d5b1e75e86bb860ccc7aeca85.jpg"
),
releaseDate = "2013-09-17",
requirementsInEnglish = null
),
DetailedRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 4,
name = "PC",
slug = "pc",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = 536875,
imageBackground = "https://media.rawg.io/media/games/6fc/6fcf4cd3b17c288821388e6085bb0fc9.jpg"
),
releaseDate = "2013-09-17",
requirementsInEnglish = RAWGPlatformRequirements(
minimum = "Minimum:OS: Windows 10 64 Bit, Windows 8.1 64 Bit, Windows 8 64 Bit, Windows 7 64 Bit Service Pack 1, Windows Vista 64 Bit Service Pack 2* (*NVIDIA video card recommended if running Vista OS)Processor: Intel Core 2 Quad CPU Q6600 @ 2.40GHz (4 CPUs) / AMD Phenom 9850 Quad-Core Processor (4 CPUs) @ 2.5GHzMemory: 4 GB RAMGraphics: NVIDIA 9800 GT 1GB / AMD HD 4870 1GB (DX 10, 10.1, 11)Storage: 72 GB available spaceSound Card: 100% DirectX 10 compatibleAdditional Notes: Over time downloadable content and programming changes will change the system requirements for this game. Please refer to your hardware manufacturer and www.rockstargames.com/support for current compatibility information. Some system components such as mobile chipsets, integrated, and AGP graphics cards may be incompatible. Unlisted specifications may not be supported by publisher. Other requirements: Installation and online play requires log-in to Rockstar Games Social Club (13+) network; internet connection required for activation, online play, and periodic entitlement verification; software installations required including Rockstar Games Social Club platform, DirectX , Chromium, and Microsoft Visual C++ 2008 sp1 Redistributable Package, and authentication software that recognizes certain hardware attributes for entitlement, digital rights management, system, and other support purposes. SINGLE USE SERIAL CODE REGISTRATION VIA INTERNET REQUIRED; REGISTRATION IS LIMITED TO ONE ROCKSTAR GAMES SOCIAL CLUB ACCOUNT (13+) PER SERIAL CODE; ONLY ONE PC LOG-IN ALLOWED PER SOCIAL CLUB ACCOUNT AT ANY TIME; SERIAL CODE(S) ARE NON-TRANSFERABLE ONCE USED; SOCIAL CLUB ACCOUNTS ARE NON-TRANSFERABLE. Partner Requirements: Please check the terms of service of this site before purchasing this software.",
recommended = "Recommended:OS: Windows 10 64 Bit, Windows 8.1 64 Bit, Windows 8 64 Bit, Windows 7 64 Bit Service Pack 1Processor: Intel Core i5 3470 @ 3.2GHz (4 CPUs) / AMD X8 FX-8350 @ 4GHz (8 CPUs)Memory: 8 GB RAMGraphics: NVIDIA GTX 660 2GB / AMD HD 7870 2GBStorage: 72 GB available spaceSound Card: 100% DirectX 10 compatibleAdditional Notes:"
)
),
DetailedRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 16,
name = "PlayStation 3",
slug = "playstation3",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = 3269,
imageBackground = "https://media.rawg.io/media/games/234/23410661770ae13eac11066980834367.jpg"
),
releaseDate = "2013-09-17",
requirementsInEnglish = null
),
DetailedRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 14,
name = "Xbox 360",
slug = "xbox360",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = 2781,
imageBackground = "https://media.rawg.io/media/games/5c0/5c0dd63002cb23f804aab327d40ef119.jpg"
),
releaseDate = "2013-09-17",
requirementsInEnglish = null
),
DetailedRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 1,
name = "Xbox One",
slug = "xbox-one",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = 5488,
imageBackground = "https://media.rawg.io/media/games/562/562553814dd54e001a541e4ee83a591c.jpg"
),
releaseDate = "2013-09-17",
requirementsInEnglish = null
)
),
stores = listOf(
ShallowRAWGStoreInfoWithId(
id = 290375,
store = RAWGStoreProperties(
id = 3,
name = "PlayStation Store",
slug = "playstation-store",
domain = "store.playstation.com",
gamesCount = 7796,
imageUrl = "https://media.rawg.io/media/games/bc0/bc06a29ceac58652b684deefe7d56099.jpg"
)
),
ShallowRAWGStoreInfoWithId(
id = 438095,
store = RAWGStoreProperties(
id = 11,
name = "Epic Games",
slug = "epic-games",
domain = "epicgames.com",
gamesCount = 1215,
imageUrl = "https://media.rawg.io/media/games/b54/b54598d1d5cc31899f4f0a7e3122a7b0.jpg"
)
),
ShallowRAWGStoreInfoWithId(
id = 290376,
store = RAWGStoreProperties(
id = 1,
name = "Steam",
slug = "steam",
domain = "store.steampowered.com",
gamesCount = 73115,
imageUrl = "https://media.rawg.io/media/games/120/1201a40e4364557b124392ee50317b99.jpg"
)
),
ShallowRAWGStoreInfoWithId(
id = 290377,
store = RAWGStoreProperties(
id = 7,
name = "Xbox 360 Store",
slug = "xbox360",
domain = "marketplace.xbox.com",
gamesCount = 1914,
imageUrl = "https://media.rawg.io/media/games/e2d/e2d3f396b16dded0f841c17c9799a882.jpg"
)
),
ShallowRAWGStoreInfoWithId(
id = 290378,
store = RAWGStoreProperties(
id = 2,
name = "Xbox Store",
slug = "xbox-store",
domain = "microsoft.com",
gamesCount = 4756,
imageUrl = "https://media.rawg.io/media/games/26d/26d4437715bee60138dab4a7c8c59c92.jpg"
)
)
),
tags = listOf(
RAWGGameTag(
id = 31,
name = "Singleplayer",
slug = "singleplayer",
language = "eng",
gamesCount = 209582,
imageUrl = "https://media.rawg.io/media/games/73e/73eecb8909e0c39fb246f457b5d6cbbe.jpg"
),
RAWGGameTag(
id = 40847,
name = "Steam Achievements",
slug = "steam-achievements",
language = "eng",
gamesCount = 29451,
imageUrl = "https://media.rawg.io/media/games/8cc/8cce7c0e99dcc43d66c8efd42f9d03e3.jpg"
),
RAWGGameTag(
id = 7,
name = "Multiplayer",
slug = "multiplayer",
language = "eng",
gamesCount = 35586,
imageUrl = "https://media.rawg.io/media/games/328/3283617cb7d75d67257fc58339188742.jpg"
),
RAWGGameTag(
id = 40836,
name = "Full controller support",
slug = "full-controller-support",
language = "eng",
gamesCount = 13833,
imageUrl = "https://media.rawg.io/media/games/490/49016e06ae2103881ff6373248843069.jpg"
),
RAWGGameTag(
id = 13,
name = "Atmospheric",
slug = "atmospheric",
language = "eng",
gamesCount = 29424,
imageUrl = "https://media.rawg.io/media/games/7cf/7cfc9220b401b7a300e409e539c9afd5.jpg"
),
RAWGGameTag(
id = 42,
name = "Great Soundtrack",
slug = "great-soundtrack",
language = "eng",
gamesCount = 3230,
imageUrl = "https://media.rawg.io/media/games/7a2/7a2500ee8b2c0e1ff268bb4479463dea.jpg"
),
RAWGGameTag(
id = 24,
name = "RPG",
slug = "rpg",
language = "eng",
gamesCount = 16758,
imageUrl = "https://media.rawg.io/media/games/6cd/6cd653e0aaef5ff8bbd295bf4bcb12eb.jpg"
),
RAWGGameTag(
id = 18,
name = "Co-op",
slug = "co-op",
language = "eng",
gamesCount = 9686,
imageUrl = "https://media.rawg.io/media/games/8cc/8cce7c0e99dcc43d66c8efd42f9d03e3.jpg"
),
RAWGGameTag(
id = 36,
name = "Open World",
slug = "open-world",
language = "eng",
gamesCount = 6237,
imageUrl = "https://media.rawg.io/media/games/ee3/ee3e10193aafc3230ba1cae426967d10.jpg"
),
RAWGGameTag(
id = 411,
name = "cooperative",
slug = "cooperative",
language = "eng",
gamesCount = 3925,
imageUrl = "https://media.rawg.io/media/games/d0f/d0f91fe1d92332147e5db74e207cfc7a.jpg"
),
RAWGGameTag(
id = 8,
name = "First-Person",
slug = "first-person",
language = "eng",
gamesCount = 29119,
imageUrl = "https://media.rawg.io/media/games/c4b/c4b0cab189e73432de3a250d8cf1c84e.jpg"
),
RAWGGameTag(
id = 149,
name = "Third Person",
slug = "third-person",
language = "eng",
gamesCount = 9288,
imageUrl = "https://media.rawg.io/media/games/951/951572a3dd1e42544bd39a5d5b42d234.jpg"
),
RAWGGameTag(
id = 4,
name = "Funny",
slug = "funny",
language = "eng",
gamesCount = 23019,
imageUrl = "https://media.rawg.io/media/games/5bb/5bb55ccb8205aadbb6a144cf6d8963f1.jpg"
),
RAWGGameTag(
id = 37,
name = "Sandbox",
slug = "sandbox",
language = "eng",
gamesCount = 5963,
imageUrl = "https://media.rawg.io/media/games/25c/25c4776ab5723d5d735d8bf617ca12d9.jpg"
),
RAWGGameTag(
id = 123,
name = "Comedy",
slug = "comedy",
language = "eng",
gamesCount = 10907,
imageUrl = "https://media.rawg.io/media/games/48c/48cb04ca483be865e3a83119c94e6097.jpg"
),
RAWGGameTag(
id = 150,
name = "Third-Person Shooter",
slug = "third-person-shooter",
language = "eng",
gamesCount = 2884,
imageUrl = "https://media.rawg.io/media/games/b45/b45575f34285f2c4479c9a5f719d972e.jpg"
),
RAWGGameTag(
id = 62,
name = "Moddable",
slug = "moddable",
language = "eng",
gamesCount = 778,
imageUrl = "https://media.rawg.io/media/games/48e/48e63bbddeddbe9ba81942772b156664.jpg"
),
RAWGGameTag(
id = 144,
name = "Crime",
slug = "crime",
language = "eng",
gamesCount = 2544,
imageUrl = "https://media.rawg.io/media/games/26d/26d4437715bee60138dab4a7c8c59c92.jpg"
),
RAWGGameTag(
id = 62349,
name = "vr mod",
slug = "vr-mod",
language = "eng",
gamesCount = 17,
imageUrl = "https://media.rawg.io/media/screenshots/1bb/1bb3f78f0fe43b5d5ca2f3da5b638840.jpg"
)
),
screenshots = listOf(
RAWGGameScreenshot(
id = -1,
imageUrl = "https://media.rawg.io/media/games/456/456dea5e1c7e3cd07060c14e96612001.jpg"
),
RAWGGameScreenshot(
id = 1827221,
imageUrl = "https://media.rawg.io/media/screenshots/a7c/a7c43871a54bed6573a6a429451564ef.jpg"
),
RAWGGameScreenshot(
id = 1827222,
imageUrl = "https://media.rawg.io/media/screenshots/cf4/cf4367daf6a1e33684bf19adb02d16d6.jpg"
),
RAWGGameScreenshot(
id = 1827223,
imageUrl = "https://media.rawg.io/media/screenshots/f95/f9518b1d99210c0cae21fc09e95b4e31.jpg"
),
RAWGGameScreenshot(
id = 1827225,
imageUrl = "https://media.rawg.io/media/screenshots/a5c/a5c95ea539c87d5f538763e16e18fb99.jpg"
),
RAWGGameScreenshot(
id = 1827226,
imageUrl = "https://media.rawg.io/media/screenshots/a7e/a7e990bc574f4d34e03b5926361d1ee7.jpg"
),
RAWGGameScreenshot(
id = 1827227,
imageUrl = "https://media.rawg.io/media/screenshots/592/592e2501d8734b802b2a34fee2df59fa.jpg"
)
),
genres = listOf(
RAWGGameGenre(
id = 4,
name = "Action",
slug = "action",
gamesCount = 177875,
imageUrl = "https://media.rawg.io/media/games/b8c/b8c243eaa0fbac8115e0cdccac3f91dc.jpg"
),
RAWGGameGenre(
id = 3,
name = "Adventure",
slug = "adventure",
gamesCount = 136825,
imageUrl = "https://media.rawg.io/media/games/995/9951d9d55323d08967640f7b9ab3e342.jpg"
)
)
),
RAWGShallowGame(
id = 3328,
slug = "the-witcher-3-wild-hunt",
name = "The Witcher 3: Wild Hunt",
releaseDate = "2015-05-18",
toBeAnnounced = false,
imageUrl = "https://media.rawg.io/media/games/618/618c2031a07bbff6b4f611f10b6bcdbc.jpg",
rating = 4.66f,
metaCriticScore = 92,
playtime = 46,
suggestionsCount = 649,
platforms = listOf(
DetailedRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 186,
name = "Xbox Series S/X",
slug = "xbox-series-x",
imageUrl = null,
yearEnd = null,
yearStart = 2020,
gamesCount = 731,
imageBackground = "https://media.rawg.io/media/games/618/618c2031a07bbff6b4f611f10b6bcdbc.jpg"
),
releaseDate = "2015-05-18",
requirementsInEnglish = null
),
DetailedRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 18,
name = "PlayStation 4",
slug = "playstation4",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = 6597,
imageBackground = "https://media.rawg.io/media/games/b72/b7233d5d5b1e75e86bb860ccc7aeca85.jpg"
),
releaseDate = "2015-05-18",
requirementsInEnglish = null
),
DetailedRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 7,
name = "Nintendo Switch",
slug = "nintendo-switch",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = 5199,
imageBackground = "https://media.rawg.io/media/games/b72/b7233d5d5b1e75e86bb860ccc7aeca85.jpg"
),
releaseDate = "2015-05-18",
requirementsInEnglish = null
),
DetailedRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 4,
name = "PC",
slug = "pc",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = 536875,
imageBackground = "https://media.rawg.io/media/games/6fc/6fcf4cd3b17c288821388e6085bb0fc9.jpg"
),
releaseDate = "2015-05-18",
requirementsInEnglish = null
),
DetailedRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 1,
name = "Xbox One",
slug = "xbox-one",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = 5488,
imageBackground = "https://media.rawg.io/media/games/562/562553814dd54e001a541e4ee83a591c.jpg"
),
releaseDate = "2015-05-18",
requirementsInEnglish = null
),
DetailedRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 187,
name = "PlayStation 5",
slug = "playstation5",
imageUrl = null,
yearEnd = null,
yearStart = 2020,
gamesCount = 824,
imageBackground = "https://media.rawg.io/media/games/253/2534a46f3da7fa7c315f1387515ca393.jpg"
),
releaseDate = "2015-05-18",
requirementsInEnglish = null
)
),
stores = listOf(
ShallowRAWGStoreInfoWithId(
id = 354780,
store = RAWGStoreProperties(
id = 5,
name = "GOG",
slug = "gog",
domain = "gog.com",
gamesCount = 4934,
imageUrl = "https://media.rawg.io/media/games/4cf/4cfc6b7f1850590a4634b08bfab308ab.jpg"
)
),
ShallowRAWGStoreInfoWithId(
id = 3565,
store = RAWGStoreProperties(
id = 3,
name = "PlayStation Store",
slug = "playstation-store",
domain = "store.playstation.com",
gamesCount = 7796,
imageUrl = "https://media.rawg.io/media/games/bc0/bc06a29ceac58652b684deefe7d56099.jpg"
)
),
ShallowRAWGStoreInfoWithId(
id = 305376,
store = RAWGStoreProperties(
id = 1,
name = "Steam",
slug = "steam",
domain = "store.steampowered.com",
gamesCount = 73115,
imageUrl = "https://media.rawg.io/media/games/120/1201a40e4364557b124392ee50317b99.jpg"
)
),
ShallowRAWGStoreInfoWithId(
id = 312313,
store = RAWGStoreProperties(
id = 2,
name = "Xbox Store",
slug = "xbox-store",
domain = "microsoft.com",
gamesCount = 4756,
imageUrl = "https://media.rawg.io/media/games/26d/26d4437715bee60138dab4a7c8c59c92.jpg"
)
),
ShallowRAWGStoreInfoWithId(
id = 676022,
store = RAWGStoreProperties(
id = 6,
name = "Nintendo Store",
slug = "nintendo",
domain = "nintendo.com",
gamesCount = 8862,
imageUrl = "https://media.rawg.io/media/games/7c4/7c448374df84b607f67ce9182a3a3ca7.jpg"
)
)
),
tags = listOf(
RAWGGameTag(
id = 31,
name = "Singleplayer",
slug = "singleplayer",
language = "eng",
gamesCount = 209582,
imageUrl = "https://media.rawg.io/media/games/73e/73eecb8909e0c39fb246f457b5d6cbbe.jpg"
),
RAWGGameTag(
id = 40836,
name = "Full controller support",
slug = "full-controller-support",
language = "eng",
gamesCount = 13833,
imageUrl = "https://media.rawg.io/media/games/490/49016e06ae2103881ff6373248843069.jpg"
),
RAWGGameTag(
id = 13,
name = "Atmospheric",
slug = "atmospheric",
language = "eng",
gamesCount = 29424,
imageUrl = "https://media.rawg.io/media/games/7cf/7cfc9220b401b7a300e409e539c9afd5.jpg"
),
RAWGGameTag(
id = 42,
name = "Great Soundtrack",
slug = "great-soundtrack",
language = "eng",
gamesCount = 3230,
imageUrl = "https://media.rawg.io/media/games/7a2/7a2500ee8b2c0e1ff268bb4479463dea.jpg"
),
RAWGGameTag(
id = 24,
name = "RPG",
slug = "rpg",
language = "eng",
gamesCount = 16758,
imageUrl = "https://media.rawg.io/media/games/6cd/6cd653e0aaef5ff8bbd295bf4bcb12eb.jpg"
),
RAWGGameTag(
id = 118,
name = "Story Rich",
slug = "story-rich",
language = "eng",
gamesCount = 18114,
imageUrl = "https://media.rawg.io/media/games/fc1/fc1307a2774506b5bd65d7e8424664a7.jpg"
),
RAWGGameTag(
id = 36,
name = "Open World",
slug = "open-world",
language = "eng",
gamesCount = 6237,
imageUrl = "https://media.rawg.io/media/games/ee3/ee3e10193aafc3230ba1cae426967d10.jpg"
),
RAWGGameTag(
id = 149,
name = "Third Person",
slug = "third-person",
language = "eng",
gamesCount = 9288,
imageUrl = "https://media.rawg.io/media/games/951/951572a3dd1e42544bd39a5d5b42d234.jpg"
),
RAWGGameTag(
id = 64,
name = "Fantasy",
slug = "fantasy",
language = "eng",
gamesCount = 24635,
imageUrl = "https://media.rawg.io/media/screenshots/88b/88b5f27f07d6ca2f8a3cd0b36e03a670.jpg"
),
RAWGGameTag(
id = 37,
name = "Sandbox",
slug = "sandbox",
language = "eng",
gamesCount = 5963,
imageUrl = "https://media.rawg.io/media/games/25c/25c4776ab5723d5d735d8bf617ca12d9.jpg"
),
RAWGGameTag(
id = 97,
name = "Action RPG",
slug = "action-rpg",
language = "eng",
gamesCount = 5774,
imageUrl = "https://media.rawg.io/media/games/849/849414b978db37d4563ff9e4b0d3a787.jpg"
),
RAWGGameTag(
id = 41,
name = "Dark",
slug = "dark",
language = "eng",
gamesCount = 14252,
imageUrl = "https://media.rawg.io/media/games/4e6/4e6e8e7f50c237d76f38f3c885dae3d2.jpg"
),
RAWGGameTag(
id = 44,
name = "Nudity",
slug = "nudity",
language = "eng",
gamesCount = 4681,
imageUrl = "https://media.rawg.io/media/games/16b/16b1b7b36e2042d1128d5a3e852b3b2f.jpg"
),
RAWGGameTag(
id = 336,
name = "controller support",
slug = "controller-support",
language = "eng",
gamesCount = 293,
imageUrl = "https://media.rawg.io/media/games/f46/f466571d536f2e3ea9e815ad17177501.jpg"
),
RAWGGameTag(
id = 145,
name = "Choices Matter",
slug = "choices-matter",
language = "eng",
gamesCount = 3254,
imageUrl = "https://media.rawg.io/media/games/562/562553814dd54e001a541e4ee83a591c.jpg"
),
RAWGGameTag(
id = 192,
name = "Mature",
slug = "mature",
language = "eng",
gamesCount = 2001,
imageUrl = "https://media.rawg.io/media/games/5fa/5fae5fec3c943179e09da67a4427d68f.jpg"
),
RAWGGameTag(
id = 40,
name = "Dark Fantasy",
slug = "dark-fantasy",
language = "eng",
gamesCount = 3190,
imageUrl = "https://media.rawg.io/media/games/da1/da1b267764d77221f07a4386b6548e5a.jpg"
),
RAWGGameTag(
id = 66,
name = "Medieval",
slug = "medieval",
language = "eng",
gamesCount = 5299,
imageUrl = "https://media.rawg.io/media/games/ee3/ee3e10193aafc3230ba1cae426967d10.jpg"
),
RAWGGameTag(
id = 82,
name = "Magic",
slug = "magic",
language = "eng",
gamesCount = 8040,
imageUrl = "https://media.rawg.io/media/screenshots/6d3/6d367773c06886535620f2d7fb1cb866.jpg"
),
RAWGGameTag(
id = 218,
name = "Multiple Endings",
slug = "multiple-endings",
language = "eng",
gamesCount = 6936,
imageUrl = "https://media.rawg.io/media/games/951/951572a3dd1e42544bd39a5d5b42d234.jpg"
)
),
screenshots = listOf(
RAWGGameScreenshot(
id = -1,
imageUrl = "https://media.rawg.io/media/games/618/618c2031a07bbff6b4f611f10b6bcdbc.jpg"
),
RAWGGameScreenshot(
id = 30336,
imageUrl = "https://media.rawg.io/media/screenshots/1ac/1ac19f31974314855ad7be266adeb500.jpg"
),
RAWGGameScreenshot(
id = 30337,
imageUrl = "https://media.rawg.io/media/screenshots/6a0/6a08afca95261a2fe221ea9e01d28762.jpg"
),
RAWGGameScreenshot(
id = 30338,
imageUrl = "https://media.rawg.io/media/screenshots/cdd/cdd31b6b4a687425a87b5ce231ac89d7.jpg"
),
RAWGGameScreenshot(
id = 30339,
imageUrl = "https://media.rawg.io/media/screenshots/862/862397b153221a625922d3bb66337834.jpg"
),
RAWGGameScreenshot(
id = 30340,
imageUrl = "https://media.rawg.io/media/screenshots/166/166787c442a45f52f4f230c33fd7d605.jpg"
),
RAWGGameScreenshot(
id = 30342,
imageUrl = "https://media.rawg.io/media/screenshots/f63/f6373ee614046d81503d63f167181803.jpg"
)
),
genres = listOf(
RAWGGameGenre(
id = 4,
name = "Action",
slug = "action",
gamesCount = 177875,
imageUrl = "https://media.rawg.io/media/games/b8c/b8c243eaa0fbac8115e0cdccac3f91dc.jpg"
),
RAWGGameGenre(
id = 3,
name = "Adventure",
slug = "adventure",
gamesCount = 136825,
imageUrl = "https://media.rawg.io/media/games/995/9951d9d55323d08967640f7b9ab3e342.jpg"
),
RAWGGameGenre(
id = 5,
name = "RPG",
slug = "role-playing-games-rpg",
gamesCount = 53787,
imageUrl = "https://media.rawg.io/media/games/d1a/d1a2e99ade53494c6330a0ed945fe823.jpg"
)
)
),
RAWGShallowGame(
id = 4200,
slug = "portal-2",
name = "Portal 2",
releaseDate = "2011-04-18",
toBeAnnounced = false,
imageUrl = "https://media.rawg.io/media/games/328/3283617cb7d75d67257fc58339188742.jpg",
rating = 4.62f,
metaCriticScore = 95,
playtime = 11,
suggestionsCount = 534,
platforms = listOf(
DetailedRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 14,
name = "Xbox 360",
slug = "xbox360",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = 2781,
imageBackground = "https://media.rawg.io/media/games/5c0/5c0dd63002cb23f804aab327d40ef119.jpg"
),
releaseDate = "2011-04-19",
requirementsInEnglish = null
),
DetailedRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 6,
name = "Linux",
slug = "linux",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = 79193,
imageBackground = "https://media.rawg.io/media/games/46d/46d98e6910fbc0706e2948a7cc9b10c5.jpg"
),
releaseDate = "2011-04-19",
requirementsInEnglish = null
),
DetailedRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 5,
name = "macOS",
slug = "macos",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = 106472,
imageBackground = "https://media.rawg.io/media/games/960/960b601d9541cec776c5fa42a00bf6c4.jpg"
),
releaseDate = null,
requirementsInEnglish = null
),
DetailedRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 16,
name = "PlayStation 3",
slug = "playstation3",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = 3269,
imageBackground = "https://media.rawg.io/media/games/234/23410661770ae13eac11066980834367.jpg"
),
releaseDate = "2011-04-19",
requirementsInEnglish = null
),
DetailedRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 4,
name = "PC",
slug = "pc",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = 536875,
imageBackground = "https://media.rawg.io/media/games/6fc/6fcf4cd3b17c288821388e6085bb0fc9.jpg"
),
releaseDate = null,
requirementsInEnglish = null
),
DetailedRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 1,
name = "Xbox One",
slug = "xbox-one",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = 5488,
imageBackground = "https://media.rawg.io/media/games/562/562553814dd54e001a541e4ee83a591c.jpg"
),
releaseDate = "2011-04-18",
requirementsInEnglish = null
)
),
stores = listOf(
ShallowRAWGStoreInfoWithId(
id = 465889,
store = RAWGStoreProperties(
id = 2,
name = "Xbox Store",
slug = "xbox-store",
domain = "microsoft.com",
gamesCount = 4756,
imageUrl = "https://media.rawg.io/media/games/26d/26d4437715bee60138dab4a7c8c59c92.jpg"
)
),
ShallowRAWGStoreInfoWithId(
id = 13134,
store = RAWGStoreProperties(
id = 1,
name = "Steam",
slug = "steam",
domain = "store.steampowered.com",
gamesCount = 73115,
imageUrl = "https://media.rawg.io/media/games/120/1201a40e4364557b124392ee50317b99.jpg"
)
),
ShallowRAWGStoreInfoWithId(
id = 4526,
store = RAWGStoreProperties(
id = 3,
name = "PlayStation Store",
slug = "playstation-store",
domain = "store.playstation.com",
gamesCount = 7796,
imageUrl = "https://media.rawg.io/media/games/bc0/bc06a29ceac58652b684deefe7d56099.jpg"
)
),
ShallowRAWGStoreInfoWithId(
id = 33916,
store = RAWGStoreProperties(
id = 7,
name = "Xbox 360 Store",
slug = "xbox360",
domain = "marketplace.xbox.com",
gamesCount = 1914,
imageUrl = "https://media.rawg.io/media/games/e2d/e2d3f396b16dded0f841c17c9799a882.jpg"
)
)
),
tags = listOf(
RAWGGameTag(
id = 31,
name = "Singleplayer",
slug = "singleplayer",
language = "eng",
gamesCount = 209582,
imageUrl = "https://media.rawg.io/media/games/73e/73eecb8909e0c39fb246f457b5d6cbbe.jpg"
),
RAWGGameTag(
id = 40847,
name = "Steam Achievements",
slug = "steam-achievements",
language = "eng",
gamesCount = 29451,
imageUrl = "https://media.rawg.io/media/games/8cc/8cce7c0e99dcc43d66c8efd42f9d03e3.jpg"
),
RAWGGameTag(
id = 7,
name = "Multiplayer",
slug = "multiplayer",
language = "eng",
gamesCount = 35586,
imageUrl = "https://media.rawg.io/media/games/328/3283617cb7d75d67257fc58339188742.jpg"
),
RAWGGameTag(
id = 40836,
name = "Full controller support",
slug = "full-controller-support",
language = "eng",
gamesCount = 13833,
imageUrl = "https://media.rawg.io/media/games/490/49016e06ae2103881ff6373248843069.jpg"
),
RAWGGameTag(
id = 13,
name = "Atmospheric",
slug = "atmospheric",
language = "eng",
gamesCount = 29424,
imageUrl = "https://media.rawg.io/media/games/7cf/7cfc9220b401b7a300e409e539c9afd5.jpg"
),
RAWGGameTag(
id = 40849,
name = "Steam Cloud",
slug = "steam-cloud",
language = "eng",
gamesCount = 13564,
imageUrl = "https://media.rawg.io/media/games/49c/49c3dfa4ce2f6f140cc4825868e858cb.jpg"
),
RAWGGameTag(
id = 7808,
name = "steam-trading-cards",
slug = "steam-trading-cards",
language = "eng",
gamesCount = 7582,
imageUrl = "https://media.rawg.io/media/games/310/3106b0e012271c5ffb16497b070be739.jpg"
),
RAWGGameTag(
id = 18,
name = "Co-op",
slug = "co-op",
language = "eng",
gamesCount = 9686,
imageUrl = "https://media.rawg.io/media/games/8cc/8cce7c0e99dcc43d66c8efd42f9d03e3.jpg"
),
RAWGGameTag(
id = 118,
name = "Story Rich",
slug = "story-rich",
language = "eng",
gamesCount = 18114,
imageUrl = "https://media.rawg.io/media/games/fc1/fc1307a2774506b5bd65d7e8424664a7.jpg"
),
RAWGGameTag(
id = 411,
name = "cooperative",
slug = "cooperative",
language = "eng",
gamesCount = 3925,
imageUrl = "https://media.rawg.io/media/games/d0f/d0f91fe1d92332147e5db74e207cfc7a.jpg"
),
RAWGGameTag(
id = 8,
name = "First-Person",
slug = "first-person",
language = "eng",
gamesCount = 29119,
imageUrl = "https://media.rawg.io/media/games/c4b/c4b0cab189e73432de3a250d8cf1c84e.jpg"
),
RAWGGameTag(
id = 32,
name = "Sci-fi",
slug = "sci-fi",
language = "eng",
gamesCount = 17348,
imageUrl = "https://media.rawg.io/media/games/8e4/8e4de3f54ac659e08a7ba6a2b731682a.jpg"
),
RAWGGameTag(
id = 30,
name = "FPS",
slug = "fps",
language = "eng",
gamesCount = 12564,
imageUrl = "https://media.rawg.io/media/games/120/1201a40e4364557b124392ee50317b99.jpg"
),
RAWGGameTag(
id = 9,
name = "Online Co-Op",
slug = "online-co-op",
language = "eng",
gamesCount = 4190,
imageUrl = "https://media.rawg.io/media/games/d0f/d0f91fe1d92332147e5db74e207cfc7a.jpg"
),
RAWGGameTag(
id = 4,
name = "Funny",
slug = "funny",
language = "eng",
gamesCount = 23019,
imageUrl = "https://media.rawg.io/media/games/5bb/5bb55ccb8205aadbb6a144cf6d8963f1.jpg"
),
RAWGGameTag(
id = 189,
name = "Female Protagonist",
slug = "female-protagonist",
language = "eng",
gamesCount = 10429,
imageUrl = "https://media.rawg.io/media/games/021/021c4e21a1824d2526f925eff6324653.jpg"
),
RAWGGameTag(
id = 123,
name = "Comedy",
slug = "comedy",
language = "eng",
gamesCount = 10907,
imageUrl = "https://media.rawg.io/media/games/48c/48cb04ca483be865e3a83119c94e6097.jpg"
),
RAWGGameTag(
id = 75,
name = "Local Co-Op",
slug = "local-co-op",
language = "eng",
gamesCount = 4977,
imageUrl = "https://media.rawg.io/media/games/226/2262cea0b385db6cf399f4be831603b0.jpg"
),
RAWGGameTag(
id = 11669,
name = "stats",
slug = "stats",
language = "eng",
gamesCount = 4436,
imageUrl = "https://media.rawg.io/media/games/179/179245a3693049a11a25b900ab18f8f7.jpg"
),
RAWGGameTag(
id = 40852,
name = "Steam Workshop",
slug = "steam-workshop",
language = "eng",
gamesCount = 1276,
imageUrl = "https://media.rawg.io/media/games/f3e/f3eec35c6218dcfd93a537751e6bfa61.jpg"
),
RAWGGameTag(
id = 25,
name = "Space",
slug = "space",
language = "eng",
gamesCount = 43383,
imageUrl = "https://media.rawg.io/media/games/e1f/e1ffbeb1bac25b19749ad285ca29e158.jpg"
),
RAWGGameTag(
id = 40838,
name = "Includes level editor",
slug = "includes-level-editor",
language = "eng",
gamesCount = 1607,
imageUrl = "https://media.rawg.io/media/games/9cc/9cc11e2e81403186c7fa9c00c143d6e4.jpg"
),
RAWGGameTag(
id = 40833,
name = "Captions available",
slug = "captions-available",
language = "eng",
gamesCount = 1219,
imageUrl = "https://media.rawg.io/media/games/a12/a12f806432cb385bc286f0935c49cd14.jpg"
),
RAWGGameTag(
id = 40834,
name = "Commentary available",
slug = "commentary-available",
language = "eng",
gamesCount = 252,
imageUrl = "https://media.rawg.io/media/screenshots/405/40567fe45e6074a5b2bfbd4a3fea7809.jpg"
),
RAWGGameTag(
id = 87,
name = "Science",
slug = "science",
language = "eng",
gamesCount = 1510,
imageUrl = "https://media.rawg.io/media/screenshots/f93/f93ee651619bb5b273f1b51528ee872a.jpg"
)
),
screenshots = listOf(
RAWGGameScreenshot(
id = -1,
imageUrl = "https://media.rawg.io/media/games/328/3283617cb7d75d67257fc58339188742.jpg"
),
RAWGGameScreenshot(
id = 99018,
imageUrl = "https://media.rawg.io/media/screenshots/221/221a03c11e5ff9f765d62f60d4b4cbf5.jpg"
),
RAWGGameScreenshot(
id = 99019,
imageUrl = "https://media.rawg.io/media/screenshots/173/1737ff43c14f40294011a209b1012875.jpg"
),
RAWGGameScreenshot(
id = 99020,
imageUrl = "https://media.rawg.io/media/screenshots/b11/b11a2ae0664f0e8a1ef2346f99df26e1.jpg"
),
RAWGGameScreenshot(
id = 99021,
imageUrl = "https://media.rawg.io/media/screenshots/9b1/9b107a790909b31918ebe2f40547cc85.jpg"
),
RAWGGameScreenshot(
id = 99022,
imageUrl = "https://media.rawg.io/media/screenshots/d05/d058fc7f7fa6128916c311eb14267fed.jpg"
),
RAWGGameScreenshot(
id = 99023,
imageUrl = "https://media.rawg.io/media/screenshots/415/41543dcc12dffc8e97d85a56ad42cda8.jpg"
)
),
genres = listOf(
RAWGGameGenre(
id = 2,
name = "Shooter",
slug = "shooter",
gamesCount = 62981,
imageUrl = "https://media.rawg.io/media/games/328/3283617cb7d75d67257fc58339188742.jpg"
),
RAWGGameGenre(
id = 7,
name = "Puzzle",
slug = "puzzle",
gamesCount = 100172,
imageUrl = "https://media.rawg.io/media/games/2e1/2e187b31e5cee21c110bd16798d75fab.jpg"
)
)
)
)
)
val serializedMockResponseB =
"""
{
"count": 149,
"next": "https://api.rawg.io/api/games?dates=2019-09-01%2C2019-09-30&key=<KEY>&page=2&page_size=3&platforms=18%2C1%2C7",
"previous": null,
"results": [
{
"slug": "borderlands-3",
"name": "Borderlands 3",
"playtime": 10,
"platforms": [
{
"platform": {
"id": 4,
"name": "PC",
"slug": "pc"
}
},
{
"platform": {
"id": 187,
"name": "PlayStation 5",
"slug": "playstation5"
}
},
{
"platform": {
"id": 1,
"name": "Xbox One",
"slug": "xbox-one"
}
},
{
"platform": {
"id": 18,
"name": "PlayStation 4",
"slug": "playstation4"
}
},
{
"platform": {
"id": 186,
"name": "Xbox Series S/X",
"slug": "xbox-series-x"
}
}
],
"stores": [
{
"store": {
"id": 1,
"name": "Steam",
"slug": "steam"
}
},
{
"store": {
"id": 3,
"name": "PlayStation Store",
"slug": "playstation-store"
}
},
{
"store": {
"id": 2,
"name": "Xbox Store",
"slug": "xbox-store"
}
},
{
"store": {
"id": 11,
"name": "Epic Games",
"slug": "epic-games"
}
}
],
"released": "2019-09-13",
"tba": false,
"background_image": "https://media.rawg.io/media/games/9f1/9f1891779cb20f44de93cef33b067e50.jpg",
"rating": 3.9,
"rating_top": 4,
"ratings": [
{
"id": 4,
"title": "recommended",
"count": 395,
"percent": 50.9
},
{
"id": 5,
"title": "exceptional",
"count": 193,
"percent": 24.87
},
{
"id": 3,
"title": "meh",
"count": 146,
"percent": 18.81
},
{
"id": 1,
"title": "skip",
"count": 42,
"percent": 5.41
}
],
"ratings_count": 761,
"reviews_text_count": 12,
"added": 5008,
"added_by_status": {
"yet": 371,
"owned": 3170,
"beaten": 483,
"toplay": 547,
"dropped": 245,
"playing": 192
},
"metacritic": 83,
"suggestions_count": 917,
"updated": "2023-03-19T19:53:43",
"id": 58617,
"score": null,
"clip": null,
"tags": [
{
"id": 31,
"name": "Singleplayer",
"slug": "singleplayer",
"language": "eng",
"games_count": 209582,
"image_background": "https://media.rawg.io/media/games/73e/73eecb8909e0c39fb246f457b5d6cbbe.jpg"
},
{
"id": 42396,
"name": "Для одного игрока",
"slug": "dlia-odnogo-igroka",
"language": "rus",
"games_count": 32259,
"image_background": "https://media.rawg.io/media/games/618/618c2031a07bbff6b4f611f10b6bcdbc.jpg"
},
{
"id": 42417,
"name": "Экшен",
"slug": "ekshen",
"language": "rus",
"games_count": 30948,
"image_background": "https://media.rawg.io/media/games/d58/d588947d4286e7b5e0e12e1bea7d9844.jpg"
},
{
"id": 42392,
"name": "Приключение",
"slug": "prikliuchenie",
"language": "rus",
"games_count": 28893,
"image_background": "https://media.rawg.io/media/games/960/960b601d9541cec776c5fa42a00bf6c4.jpg"
},
{
"id": 40847,
"name": "Steam Achievements",
"slug": "steam-achievements",
"language": "eng",
"games_count": 29451,
"image_background": "https://media.rawg.io/media/games/8cc/8cce7c0e99dcc43d66c8efd42f9d03e3.jpg"
},
{
"id": 7,
"name": "Multiplayer",
"slug": "multiplayer",
"language": "eng",
"games_count": 35586,
"image_background": "https://media.rawg.io/media/games/328/3283617cb7d75d67257fc58339188742.jpg"
},
{
"id": 40836,
"name": "Full controller support",
"slug": "full-controller-support",
"language": "eng",
"games_count": 13833,
"image_background": "https://media.rawg.io/media/games/490/49016e06ae2103881ff6373248843069.jpg"
},
{
"id": 13,
"name": "Atmospheric",
"slug": "atmospheric",
"language": "eng",
"games_count": 29424,
"image_background": "https://media.rawg.io/media/games/7cf/7cfc9220b401b7a300e409e539c9afd5.jpg"
},
{
"id": 40849,
"name": "Steam Cloud",
"slug": "steam-cloud",
"language": "eng",
"games_count": 13564,
"image_background": "https://media.rawg.io/media/games/49c/49c3dfa4ce2f6f140cc4825868e858cb.jpg"
},
{
"id": 42425,
"name": "Для нескольких игроков",
"slug": "dlia-neskolkikh-igrokov",
"language": "rus",
"games_count": 7497,
"image_background": "https://media.rawg.io/media/games/d69/d69810315bd7e226ea2d21f9156af629.jpg"
},
{
"id": 42401,
"name": "<NAME>",
"slug": "otlichnyi-saundtrek",
"language": "rus",
"games_count": 4453,
"image_background": "https://media.rawg.io/media/games/618/618c2031a07bbff6b4f611f10b6bcdbc.jpg"
},
{
"id": 42,
"name": "Great Soundtrack",
"slug": "great-soundtrack",
"language": "eng",
"games_count": 3230,
"image_background": "https://media.rawg.io/media/games/7a2/7a2500ee8b2c0e1ff268bb4479463dea.jpg"
},
{
"id": 24,
"name": "RPG",
"slug": "rpg",
"language": "eng",
"games_count": 16758,
"image_background": "https://media.rawg.io/media/games/6cd/6cd653e0aaef5ff8bbd295bf4bcb12eb.jpg"
},
{
"id": 18,
"name": "Co-op",
"slug": "co-op",
"language": "eng",
"games_count": 9686,
"image_background": "https://media.rawg.io/media/games/8cc/8cce7c0e99dcc43d66c8efd42f9d03e3.jpg"
},
{
"id": 42412,
"name": "<NAME>",
"slug": "rolevaia-igra",
"language": "rus",
"games_count": 13092,
"image_background": "https://media.rawg.io/media/games/7cf/7cfc9220b401b7a300e409e539c9afd5.jpg"
},
{
"id": 42442,
"name": "<NAME>",
"slug": "otkrytyi-mir",
"language": "rus",
"games_count": 4231,
"image_background": "https://media.rawg.io/media/games/490/49016e06ae2103881ff6373248843069.jpg"
},
{
"id": 36,
"name": "Open World",
"slug": "open-world",
"language": "eng",
"games_count": 6237,
"image_background": "https://media.rawg.io/media/games/ee3/ee3e10193aafc3230ba1cae426967d10.jpg"
},
{
"id": 411,
"name": "cooperative",
"slug": "cooperative",
"language": "eng",
"games_count": 3925,
"image_background": "https://media.rawg.io/media/games/d0f/d0f91fe1d92332147e5db74e207cfc7a.jpg"
},
{
"id": 42428,
"name": "Шутер",
"slug": "shuter",
"language": "rus",
"games_count": 6356,
"image_background": "https://media.rawg.io/media/games/fc1/fc1307a2774506b5bd65d7e8424664a7.jpg"
},
{
"id": 8,
"name": "First-Person",
"slug": "first-person",
"language": "eng",
"games_count": 29119,
"image_background": "https://media.rawg.io/media/games/c4b/c4b0cab189e73432de3a250d8cf1c84e.jpg"
},
{
"id": 42435,
"name": "Шедевр",
"slug": "shedevr",
"language": "rus",
"games_count": 1059,
"image_background": "https://media.rawg.io/media/games/9dd/9ddabb34840ea9227556670606cf8ea3.jpg"
},
{
"id": 42429,
"name": "От первого лица",
"slug": "ot-pervogo-litsa",
"language": "rus",
"games_count": 7085,
"image_background": "https://media.rawg.io/media/games/fc1/fc1307a2774506b5bd65d7e8424664a7.jpg"
},
{
"id": 30,
"name": "FPS",
"slug": "fps",
"language": "eng",
"games_count": 12564,
"image_background": "https://media.rawg.io/media/games/120/1201a40e4364557b124392ee50317b99.jpg"
},
{
"id": 42427,
"name": "Шутер от первого лица",
"slug": "shuter-ot-pervogo-litsa",
"language": "rus",
"games_count": 3883,
"image_background": "https://media.rawg.io/media/games/c4b/c4b0cab189e73432de3a250d8cf1c84e.jpg"
},
{
"id": 9,
"name": "Online Co-Op",
"slug": "online-co-op",
"language": "eng",
"games_count": 4190,
"image_background": "https://media.rawg.io/media/games/d0f/d0f91fe1d92332147e5db74e207cfc7a.jpg"
},
{
"id": 42491,
"name": "Мясо",
"slug": "miaso",
"language": "rus",
"games_count": 3817,
"image_background": "https://media.rawg.io/media/games/7f6/7f6cd70ba2ad57053b4847c13569f2d8.jpg"
},
{
"id": 26,
"name": "Gore",
"slug": "gore",
"language": "eng",
"games_count": 5029,
"image_background": "https://media.rawg.io/media/games/d58/d588947d4286e7b5e0e12e1bea7d9844.jpg"
},
{
"id": 6,
"name": "Exploration",
"slug": "exploration",
"language": "eng",
"games_count": 19251,
"image_background": "https://media.rawg.io/media/games/34b/34b1f1850a1c06fd971bc6ab3ac0ce0e.jpg"
},
{
"id": 42433,
"name": "Совместная игра по сети",
"slug": "sovmestnaia-igra-po-seti",
"language": "rus",
"games_count": 1229,
"image_background": "https://media.rawg.io/media/screenshots/88b/88b5f27f07d6ca2f8a3cd0b36e03a670.jpg"
},
{
"id": 42402,
"name": "Насилие",
"slug": "nasilie",
"language": "rus",
"games_count": 4717,
"image_background": "https://media.rawg.io/media/games/951/951572a3dd1e42544bd39a5d5b42d234.jpg"
},
{
"id": 34,
"name": "Violent",
"slug": "violent",
"language": "eng",
"games_count": 5852,
"image_background": "https://media.rawg.io/media/games/5be/5bec14622f6faf804a592176577c1347.jpg"
},
{
"id": 198,
"name": "Split Screen",
"slug": "split-screen",
"language": "eng",
"games_count": 5481,
"image_background": "https://media.rawg.io/media/games/27b/27b02ffaab6b250cc31bf43baca1fc34.jpg"
},
{
"id": 75,
"name": "Local Co-Op",
"slug": "local-co-op",
"language": "eng",
"games_count": 4977,
"image_background": "https://media.rawg.io/media/games/226/2262cea0b385db6cf399f4be831603b0.jpg"
},
{
"id": 72,
"name": "Local Multiplayer",
"slug": "local-multiplayer",
"language": "eng",
"games_count": 12736,
"image_background": "https://media.rawg.io/media/games/bbf/bbf8d74ab64440ad76294cff2f4d9cfa.jpg"
},
{
"id": 69,
"name": "Action-Adventure",
"slug": "action-adventure",
"language": "eng",
"games_count": 13563,
"image_background": "https://media.rawg.io/media/games/7f6/7f6cd70ba2ad57053b4847c13569f2d8.jpg"
},
{
"id": 42406,
"name": "Нагота",
"slug": "nagota",
"language": "rus",
"games_count": 4293,
"image_background": "https://media.rawg.io/media/games/473/473bd9a5e9522629d6cb28b701fb836a.jpg"
},
{
"id": 25,
"name": "Space",
"slug": "space",
"language": "eng",
"games_count": 43383,
"image_background": "https://media.rawg.io/media/games/e1f/e1ffbeb1bac25b19749ad285ca29e158.jpg"
},
{
"id": 468,
"name": "role-playing",
"slug": "role-playing",
"language": "eng",
"games_count": 1454,
"image_background": "https://media.rawg.io/media/games/596/596a48ef3b62b63b4cc59633e28be903.jpg"
},
{
"id": 40832,
"name": "Cross-Platform Multiplayer",
"slug": "cross-platform-multiplayer",
"language": "eng",
"games_count": 2169,
"image_background": "https://media.rawg.io/media/games/009/009e4e84975d6a60173ec1199db25aa3.jpg"
},
{
"id": 44,
"name": "Nudity",
"slug": "nudity",
"language": "eng",
"games_count": 4681,
"image_background": "https://media.rawg.io/media/games/16b/16b1b7b36e2042d1128d5a3e852b3b2f.jpg"
},
{
"id": 40937,
"name": "Steam Trading Cards",
"slug": "steam-trading-cards-2",
"language": "eng",
"games_count": 381,
"image_background": "https://media.rawg.io/media/games/6cc/6cc23249972a427f697a3d10eb57a820.jpg"
},
{
"id": 413,
"name": "online",
"slug": "online",
"language": "eng",
"games_count": 6624,
"image_background": "https://media.rawg.io/media/games/9f1/9f1891779cb20f44de93cef33b067e50.jpg"
},
{
"id": 130,
"name": "Driving",
"slug": "driving",
"language": "eng",
"games_count": 4710,
"image_background": "https://media.rawg.io/media/games/d7d/d7d33daa1892e2468cd0263d5dfc957e.jpg"
},
{
"id": 98,
"name": "Loot",
"slug": "loot",
"language": "eng",
"games_count": 1905,
"image_background": "https://media.rawg.io/media/games/c6b/c6bfece1daf8d06bc0a60632ac78e5bf.jpg"
},
{
"id": 42575,
"name": "Лут",
"slug": "lut",
"language": "rus",
"games_count": 710,
"image_background": "https://media.rawg.io/media/games/a7d/a7d57092a650030e2a868117f474efbc.jpg"
},
{
"id": 5816,
"name": "console",
"slug": "console",
"language": "eng",
"games_count": 1408,
"image_background": "https://media.rawg.io/media/games/415/41563ce6cb061a210160687a4e5d39f6.jpg"
},
{
"id": 744,
"name": "friends",
"slug": "friends",
"language": "eng",
"games_count": 15183,
"image_background": "https://media.rawg.io/media/games/415/41563ce6cb061a210160687a4e5d39f6.jpg"
},
{
"id": 581,
"name": "Epic",
"slug": "epic",
"language": "eng",
"games_count": 4101,
"image_background": "https://media.rawg.io/media/screenshots/671/6716b656707c65cdf21882ee51b4f2ff.jpg"
},
{
"id": 578,
"name": "Masterpiece",
"slug": "masterpiece",
"language": "eng",
"games_count": 272,
"image_background": "https://media.rawg.io/media/screenshots/0de/0defee61ebe38390fd3750b32213796d.jpg"
},
{
"id": 42611,
"name": "Эпичная",
"slug": "epichnaia",
"language": "rus",
"games_count": 95,
"image_background": "https://media.rawg.io/media/games/879/879c930f9c6787c920153fa2df452eb3.jpg"
},
{
"id": 4565,
"name": "offline",
"slug": "offline",
"language": "eng",
"games_count": 1073,
"image_background": "https://media.rawg.io/media/games/5dd/5dd4d2dd986d2826800bc37fff64aa4f.jpg"
},
{
"id": 152,
"name": "Western",
"slug": "western",
"language": "eng",
"games_count": 1260,
"image_background": "https://media.rawg.io/media/games/985/985dc43fe4fd5f0a7ae2a725673d6ac6.jpg"
},
{
"id": 42659,
"name": "Совместная кампания",
"slug": "sovmestnaia-kampaniia",
"language": "rus",
"games_count": 278,
"image_background": "https://media.rawg.io/media/screenshots/cfa/cfac855f997f4877b64fc908b8bda7b7.jpg"
},
{
"id": 163,
"name": "Co-op Campaign",
"slug": "co-op-campaign",
"language": "eng",
"games_count": 259,
"image_background": "https://media.rawg.io/media/games/10d/10d19e52e5e8415d16a4d344fe711874.jpg"
},
{
"id": 1484,
"name": "skill",
"slug": "skill",
"language": "eng",
"games_count": 3507,
"image_background": "https://media.rawg.io/media/games/fc8/fc839beb76bd63c2a5b176c46bdb7681.jpg"
},
{
"id": 500,
"name": "Solo",
"slug": "solo",
"language": "eng",
"games_count": 1675,
"image_background": "https://media.rawg.io/media/screenshots/643/64372c2b698ff4b0608e3d72a54adf2b.jpg"
},
{
"id": 2405,
"name": "planets",
"slug": "planets",
"language": "eng",
"games_count": 1513,
"image_background": "https://media.rawg.io/media/screenshots/839/8399a76a597fc93b43ae3103f041ea9e.jpg"
},
{
"id": 1753,
"name": "guns",
"slug": "guns",
"language": "eng",
"games_count": 2504,
"image_background": "https://media.rawg.io/media/games/662/66261db966238da20c306c4b78ae4603.jpg"
},
{
"id": 38844,
"name": "looter shooter",
"slug": "looter-shooter",
"language": "eng",
"games_count": 316,
"image_background": "https://media.rawg.io/media/screenshots/4a2/4a295497bbb0d1c5c5ef054bba31d41e.jpg"
},
{
"id": 499,
"name": "Team",
"slug": "team",
"language": "eng",
"games_count": 24,
"image_background": "https://media.rawg.io/media/screenshots/87f/87f4fe4138cc8f0829acceb37dbe1734.jpg"
},
{
"id": 46115,
"name": "LAN Co-op",
"slug": "lan-co-op",
"language": "eng",
"games_count": 361,
"image_background": "https://media.rawg.io/media/games/3cb/3cbf69d79420191a2255ffe6a580889e.jpg"
},
{
"id": 6755,
"name": "wasteland",
"slug": "wasteland",
"language": "eng",
"games_count": 20,
"image_background": "https://media.rawg.io/media/screenshots/22c/22c30aa67d6518120727170c9ac711e4.jpg"
},
{
"id": 2723,
"name": "trees",
"slug": "trees",
"language": "eng",
"games_count": 618,
"image_background": "https://media.rawg.io/media/screenshots/f40/f401985ddf9f041f039052b1d1c55fa3.jpg"
}
],
"esrb_rating": {
"id": 4,
"name": "Mature",
"slug": "mature",
"name_en": "Mature",
"name_ru": "С 17 лет"
},
"user_game": null,
"reviews_count": 776,
"saturated_color": "0f0f0f",
"dominant_color": "0f0f0f",
"short_screenshots": [
{
"id": -1,
"image": "https://media.rawg.io/media/games/9f1/9f1891779cb20f44de93cef33b067e50.jpg"
},
{
"id": 2597139,
"image": "https://media.rawg.io/media/screenshots/85f/85fa0742541492cb4b2562311d455918.jpg"
},
{
"id": 2597140,
"image": "https://media.rawg.io/media/screenshots/1b6/1b6159bbc9e33c29cfd47cac82322b48.jpg"
},
{
"id": 2597141,
"image": "https://media.rawg.io/media/screenshots/825/8255610d24155b27576155b21eda167d.jpg"
},
{
"id": 2597142,
"image": "https://media.rawg.io/media/screenshots/9ab/9aba5fc11168844159e3fe83d7327294.jpg"
},
{
"id": 1884080,
"image": "https://media.rawg.io/media/screenshots/293/293c4401fd411de976aec0df8597580c.jpg"
},
{
"id": 1884081,
"image": "https://media.rawg.io/media/screenshots/c3e/c3ef63402fd812717da342ba73444ca0.jpg"
}
],
"parent_platforms": [
{
"platform": {
"id": 1,
"name": "PC",
"slug": "pc"
}
},
{
"platform": {
"id": 2,
"name": "PlayStation",
"slug": "playstation"
}
},
{
"platform": {
"id": 3,
"name": "Xbox",
"slug": "xbox"
}
}
],
"genres": [
{
"id": 2,
"name": "Shooter",
"slug": "shooter"
},
{
"id": 3,
"name": "Adventure",
"slug": "adventure"
},
{
"id": 4,
"name": "Action",
"slug": "action"
},
{
"id": 5,
"name": "RPG",
"slug": "role-playing-games-rpg"
}
]
},
{
"slug": "gears-5",
"name": "Gears 5",
"playtime": 6,
"platforms": [
{
"platform": {
"id": 4,
"name": "PC",
"slug": "pc"
}
},
{
"platform": {
"id": 1,
"name": "Xbox One",
"slug": "xbox-one"
}
},
{
"platform": {
"id": 186,
"name": "Xbox Series S/X",
"slug": "xbox-series-x"
}
}
],
"stores": [
{
"store": {
"id": 1,
"name": "Steam",
"slug": "steam"
}
},
{
"store": {
"id": 2,
"name": "Xbox Store",
"slug": "xbox-store"
}
}
],
"released": "2019-09-10",
"tba": false,
"background_image": "https://media.rawg.io/media/games/121/1213f8b9b0a26307e672cf51f34882f8.jpg",
"rating": 3.93,
"rating_top": 4,
"ratings": [
{
"id": 4,
"title": "recommended",
"count": 458,
"percent": 58.05
},
{
"id": 5,
"title": "exceptional",
"count": 168,
"percent": 21.29
},
{
"id": 3,
"title": "meh",
"count": 134,
"percent": 16.98
},
{
"id": 1,
"title": "skip",
"count": 29,
"percent": 3.68
}
],
"ratings_count": 773,
"reviews_text_count": 10,
"added": 4102,
"added_by_status": {
"yet": 255,
"owned": 2700,
"beaten": 510,
"toplay": 370,
"dropped": 160,
"playing": 107
},
"metacritic": 83,
"suggestions_count": 646,
"updated": "2023-03-19T14:08:47",
"id": 326252,
"score": null,
"clip": null,
"tags": [
{
"id": 31,
"name": "Singleplayer",
"slug": "singleplayer",
"language": "eng",
"games_count": 209582,
"image_background": "https://media.rawg.io/media/games/73e/73eecb8909e0c39fb246f457b5d6cbbe.jpg"
},
{
"id": 42396,
"name": "Для одного игрока",
"slug": "dlia-odnogo-igroka",
"language": "rus",
"games_count": 32259,
"image_background": "https://media.rawg.io/media/games/618/618c2031a07bbff6b4f611f10b6bcdbc.jpg"
},
{
"id": 42417,
"name": "Экшен",
"slug": "ekshen",
"language": "rus",
"games_count": 30948,
"image_background": "https://media.rawg.io/media/games/d58/d588947d4286e7b5e0e12e1bea7d9844.jpg"
},
{
"id": 7,
"name": "Multiplayer",
"slug": "multiplayer",
"language": "eng",
"games_count": 35586,
"image_background": "https://media.rawg.io/media/games/328/3283617cb7d75d67257fc58339188742.jpg"
},
{
"id": 42425,
"name": "Для нескольких игроков",
"slug": "dlia-neskolkikh-igrokov",
"language": "rus",
"games_count": 7497,
"image_background": "https://media.rawg.io/media/games/d69/d69810315bd7e226ea2d21f9156af629.jpg"
},
{
"id": 42394,
"name": "Глубокий сюжет",
"slug": "glubokii-siuzhet",
"language": "rus",
"games_count": 8424,
"image_background": "https://media.rawg.io/media/games/4cf/4cfc6b7f1850590a4634b08bfab308ab.jpg"
},
{
"id": 18,
"name": "Co-op",
"slug": "co-op",
"language": "eng",
"games_count": 9686,
"image_background": "https://media.rawg.io/media/games/8cc/8cce7c0e99dcc43d66c8efd42f9d03e3.jpg"
},
{
"id": 411,
"name": "cooperative",
"slug": "cooperative",
"language": "eng",
"games_count": 3925,
"image_background": "https://media.rawg.io/media/games/d0f/d0f91fe1d92332147e5db74e207cfc7a.jpg"
},
{
"id": 40845,
"name": "Partial Controller Support",
"slug": "partial-controller-support",
"language": "eng",
"games_count": 9487,
"image_background": "https://media.rawg.io/media/games/7fa/7fa0b586293c5861ee32490e953a4996.jpg"
},
{
"id": 9,
"name": "Online Co-Op",
"slug": "online-co-op",
"language": "eng",
"games_count": 4190,
"image_background": "https://media.rawg.io/media/games/d0f/d0f91fe1d92332147e5db74e207cfc7a.jpg"
},
{
"id": 42491,
"name": "Мясо",
"slug": "miaso",
"language": "rus",
"games_count": 3817,
"image_background": "https://media.rawg.io/media/games/7f6/7f6cd70ba2ad57053b4847c13569f2d8.jpg"
},
{
"id": 26,
"name": "Gore",
"slug": "gore",
"language": "eng",
"games_count": 5029,
"image_background": "https://media.rawg.io/media/games/d58/d588947d4286e7b5e0e12e1bea7d9844.jpg"
},
{
"id": 189,
"name": "Female Protagonist",
"slug": "female-protagonist",
"language": "eng",
"games_count": 10429,
"image_background": "https://media.rawg.io/media/games/021/021c4e21a1824d2526f925eff6324653.jpg"
},
{
"id": 42404,
"name": "Женщина-протагонист",
"slug": "zhenshchina-protagonist",
"language": "rus",
"games_count": 2416,
"image_background": "https://media.rawg.io/media/games/62c/62c7c8b28a27b83680b22fb9d33fc619.jpg"
},
{
"id": 42402,
"name": "Насилие",
"slug": "nasilie",
"language": "rus",
"games_count": 4717,
"image_background": "https://media.rawg.io/media/games/951/951572a3dd1e42544bd39a5d5b42d234.jpg"
},
{
"id": 34,
"name": "Violent",
"slug": "violent",
"language": "eng",
"games_count": 5852,
"image_background": "https://media.rawg.io/media/games/5be/5bec14622f6faf804a592176577c1347.jpg"
},
{
"id": 397,
"name": "Online multiplayer",
"slug": "online-multiplayer",
"language": "eng",
"games_count": 3811,
"image_background": "https://media.rawg.io/media/games/fc0/fc076b974197660a582abd34ebccc27f.jpg"
},
{
"id": 198,
"name": "Split Screen",
"slug": "split-screen",
"language": "eng",
"games_count": 5481,
"image_background": "https://media.rawg.io/media/games/27b/27b02ffaab6b250cc31bf43baca1fc34.jpg"
},
{
"id": 75,
"name": "Local Co-Op",
"slug": "local-co-op",
"language": "eng",
"games_count": 4977,
"image_background": "https://media.rawg.io/media/games/226/2262cea0b385db6cf399f4be831603b0.jpg"
},
{
"id": 42446,
"name": "Шутер от третьего лица",
"slug": "shuter-ot-tretego-litsa",
"language": "rus",
"games_count": 1410,
"image_background": "https://media.rawg.io/media/games/e2d/e2d3f396b16dded0f841c17c9799a882.jpg"
},
{
"id": 72,
"name": "Local Multiplayer",
"slug": "local-multiplayer",
"language": "eng",
"games_count": 12736,
"image_background": "https://media.rawg.io/media/games/bbf/bbf8d74ab64440ad76294cff2f4d9cfa.jpg"
},
{
"id": 40832,
"name": "Cross-Platform Multiplayer",
"slug": "cross-platform-multiplayer",
"language": "eng",
"games_count": 2169,
"image_background": "https://media.rawg.io/media/games/009/009e4e84975d6a60173ec1199db25aa3.jpg"
},
{
"id": 81,
"name": "Military",
"slug": "military",
"language": "eng",
"games_count": 1305,
"image_background": "https://media.rawg.io/media/games/ac7/ac7b8327343da12c971cfc418f390a11.jpg"
},
{
"id": 3068,
"name": "future",
"slug": "future",
"language": "eng",
"games_count": 3176,
"image_background": "https://media.rawg.io/media/screenshots/f85/f856c14f8c8d7cb72085723960f5c8d5.jpg"
}
],
"esrb_rating": null,
"user_game": null,
"reviews_count": 789,
"saturated_color": "0f0f0f",
"dominant_color": "0f0f0f",
"short_screenshots": [
{
"id": -1,
"image": "https://media.rawg.io/media/games/121/1213f8b9b0a26307e672cf51f34882f8.jpg"
},
{
"id": 1957721,
"image": "https://media.rawg.io/media/screenshots/9f0/9f085738a4ee6bb44b4b26cd3eb9ef93.jpg"
},
{
"id": 1957722,
"image": "https://media.rawg.io/media/screenshots/1c8/1c8eb3c87b9396e924ade589d543790e.jpg"
},
{
"id": 1957723,
"image": "https://media.rawg.io/media/screenshots/a83/a832752f82cfde4a811c581e9cd3efd0.jpg"
},
{
"id": 1957724,
"image": "https://media.rawg.io/media/screenshots/a6f/a6fafe1183ce4b3f68287219ea3dd6c8.jpg"
},
{
"id": 1957725,
"image": "https://media.rawg.io/media/screenshots/38c/38c4c8601a72e1d0dacf6d1fe1c5dfb3.jpg"
},
{
"id": 778890,
"image": "https://media.rawg.io/media/screenshots/ae7/ae7fcd1a2d11be26e1ea72e6d5d83ecc.jpg"
}
],
"parent_platforms": [
{
"platform": {
"id": 1,
"name": "PC",
"slug": "pc"
}
},
{
"platform": {
"id": 3,
"name": "Xbox",
"slug": "xbox"
}
}
],
"genres": [
{
"id": 2,
"name": "Shooter",
"slug": "shooter"
},
{
"id": 4,
"name": "Action",
"slug": "action"
}
]
},
{
"slug": "blasphemous",
"name": "Blasphemous",
"playtime": 3,
"platforms": [
{
"platform": {
"id": 4,
"name": "PC",
"slug": "pc"
}
},
{
"platform": {
"id": 1,
"name": "Xbox One",
"slug": "xbox-one"
}
},
{
"platform": {
"id": 18,
"name": "PlayStation 4",
"slug": "playstation4"
}
},
{
"platform": {
"id": 7,
"name": "Nintendo Switch",
"slug": "nintendo-switch"
}
},
{
"platform": {
"id": 5,
"name": "macOS",
"slug": "macos"
}
},
{
"platform": {
"id": 6,
"name": "Linux",
"slug": "linux"
}
}
],
"stores": [
{
"store": {
"id": 1,
"name": "Steam",
"slug": "steam"
}
},
{
"store": {
"id": 3,
"name": "PlayStation Store",
"slug": "playstation-store"
}
},
{
"store": {
"id": 2,
"name": "Xbox Store",
"slug": "xbox-store"
}
},
{
"store": {
"id": 5,
"name": "GOG",
"slug": "gog"
}
},
{
"store": {
"id": 6,
"name": "Nintendo Store",
"slug": "nintendo"
}
},
{
"store": {
"id": 11,
"name": "Epic Games",
"slug": "epic-games"
}
}
],
"released": "2019-09-09",
"tba": false,
"background_image": "https://media.rawg.io/media/games/b01/b01aa6b2d6d4f683203e9471a8b8d5b5.jpg",
"rating": 4.04,
"rating_top": 4,
"ratings": [
{
"id": 4,
"title": "recommended",
"count": 223,
"percent": 49.12
},
{
"id": 5,
"title": "exceptional",
"count": 148,
"percent": 32.6
},
{
"id": 3,
"title": "meh",
"count": 59,
"percent": 13.0
},
{
"id": 1,
"title": "skip",
"count": 24,
"percent": 5.29
}
],
"ratings_count": 446,
"reviews_text_count": 4,
"added": 3255,
"added_by_status": {
"yet": 261,
"owned": 2199,
"beaten": 280,
"toplay": 259,
"dropped": 162,
"playing": 94
},
"metacritic": 78,
"suggestions_count": 393,
"updated": "2023-03-19T14:10:41",
"id": 258322,
"score": null,
"clip": null,
"tags": [
{
"id": 31,
"name": "Singleplayer",
"slug": "singleplayer",
"language": "eng",
"games_count": 209582,
"image_background": "https://media.rawg.io/media/games/73e/73eecb8909e0c39fb246f457b5d6cbbe.jpg"
},
{
"id": 42396,
"name": "Для одного игрока",
"slug": "dlia-odnogo-igroka",
"language": "rus",
"games_count": 32259,
"image_background": "https://media.rawg.io/media/games/618/618c2031a07bbff6b4f611f10b6bcdbc.jpg"
},
{
"id": 42417,
"name": "Экшен",
"slug": "ekshen",
"language": "rus",
"games_count": 30948,
"image_background": "https://media.rawg.io/media/games/d58/d588947d4286e7b5e0e12e1bea7d9844.jpg"
},
{
"id": 42392,
"name": "Приключение",
"slug": "prikliuchenie",
"language": "rus",
"games_count": 28893,
"image_background": "https://media.rawg.io/media/games/960/960b601d9541cec776c5fa42a00bf6c4.jpg"
},
{
"id": 40847,
"name": "Steam Achievements",
"slug": "steam-achievements",
"language": "eng",
"games_count": 29451,
"image_background": "https://media.rawg.io/media/games/8cc/8cce7c0e99dcc43d66c8efd42f9d03e3.jpg"
},
{
"id": 42398,
"name": "Инди",
"slug": "indi-2",
"language": "rus",
"games_count": 44678,
"image_background": "https://media.rawg.io/media/games/226/2262cea0b385db6cf399f4be831603b0.jpg"
},
{
"id": 40836,
"name": "Full controller support",
"slug": "full-controller-support",
"language": "eng",
"games_count": 13833,
"image_background": "https://media.rawg.io/media/games/490/49016e06ae2103881ff6373248843069.jpg"
},
{
"id": 42401,
"name": "Отличный саундтрек",
"slug": "otlichnyi-saundtrek",
"language": "rus",
"games_count": 4453,
"image_background": "https://media.rawg.io/media/games/618/618c2031a07bbff6b4f611f10b6bcdbc.jpg"
},
{
"id": 45,
"name": "2D",
"slug": "2d",
"language": "eng",
"games_count": 197659,
"image_background": "https://media.rawg.io/media/screenshots/c97/c97b943741f5fbc936fe054d9d58851d.jpg"
},
{
"id": 42420,
"name": "Сложная",
"slug": "slozhnaia",
"language": "rus",
"games_count": 4353,
"image_background": "https://media.rawg.io/media/games/9bf/9bfac18ff678f41a4674250fa0e04a52.jpg"
},
{
"id": 42491,
"name": "Мясо",
"slug": "miaso",
"language": "rus",
"games_count": 3817,
"image_background": "https://media.rawg.io/media/games/7f6/7f6cd70ba2ad57053b4847c13569f2d8.jpg"
},
{
"id": 26,
"name": "Gore",
"slug": "gore",
"language": "eng",
"games_count": 5029,
"image_background": "https://media.rawg.io/media/games/d58/d588947d4286e7b5e0e12e1bea7d9844.jpg"
},
{
"id": 49,
"name": "Difficult",
"slug": "difficult",
"language": "eng",
"games_count": 12897,
"image_background": "https://media.rawg.io/media/games/6cd/6cd653e0aaef5ff8bbd295bf4bcb12eb.jpg"
},
{
"id": 6,
"name": "Exploration",
"slug": "exploration",
"language": "eng",
"games_count": 19251,
"image_background": "https://media.rawg.io/media/games/34b/34b1f1850a1c06fd971bc6ab3ac0ce0e.jpg"
},
{
"id": 42463,
"name": "Платформер",
"slug": "platformer-2",
"language": "rus",
"games_count": 6201,
"image_background": "https://media.rawg.io/media/games/fc8/fc838d98c9b944e6a15176eabf40bee8.jpg"
},
{
"id": 42402,
"name": "Насилие",
"slug": "nasilie",
"language": "rus",
"games_count": 4717,
"image_background": "https://media.rawg.io/media/games/951/951572a3dd1e42544bd39a5d5b42d234.jpg"
},
{
"id": 34,
"name": "Violent",
"slug": "violent",
"language": "eng",
"games_count": 5852,
"image_background": "https://media.rawg.io/media/games/5be/5bec14622f6faf804a592176577c1347.jpg"
},
{
"id": 42464,
"name": "Исследование",
"slug": "issledovanie",
"language": "rus",
"games_count": 2990,
"image_background": "https://media.rawg.io/media/games/bce/bce62fbc7cf74bf6a1a37340993ec148.jpg"
},
{
"id": 42415,
"name": "Пиксельная графика",
"slug": "pikselnaia-grafika",
"language": "rus",
"games_count": 8404,
"image_background": "https://media.rawg.io/media/screenshots/f81/f81fd968a3161e7d35612d8c4232923e.jpg"
},
{
"id": 122,
"name": "Pixel Graphics",
"slug": "pixel-graphics",
"language": "eng",
"games_count": 93980,
"image_background": "https://media.rawg.io/media/games/501/501e7019925a3c692bf1c8062f07abe6.jpg"
},
{
"id": 42406,
"name": "Нагота",
"slug": "nagota",
"language": "rus",
"games_count": 4293,
"image_background": "https://media.rawg.io/media/games/473/473bd9a5e9522629d6cb28b701fb836a.jpg"
},
{
"id": 468,
"name": "role-playing",
"slug": "role-playing",
"language": "eng",
"games_count": 1454,
"image_background": "https://media.rawg.io/media/games/596/596a48ef3b62b63b4cc59633e28be903.jpg"
},
{
"id": 44,
"name": "Nudity",
"slug": "nudity",
"language": "eng",
"games_count": 4681,
"image_background": "https://media.rawg.io/media/games/16b/16b1b7b36e2042d1128d5a3e852b3b2f.jpg"
},
{
"id": 42469,
"name": "Вид сбоку",
"slug": "vid-sboku",
"language": "rus",
"games_count": 2850,
"image_background": "https://media.rawg.io/media/games/9cc/9cc11e2e81403186c7fa9c00c143d6e4.jpg"
},
{
"id": 42506,
"name": "Тёмное фэнтези",
"slug": "tiomnoe-fentezi",
"language": "rus",
"games_count": 1786,
"image_background": "https://media.rawg.io/media/games/789/7896837ec22a83e4007018ddd55e8c9a.jpg"
},
{
"id": 40,
"name": "Dark Fantasy",
"slug": "dark-fantasy",
"language": "eng",
"games_count": 3190,
"image_background": "https://media.rawg.io/media/games/da1/da1b267764d77221f07a4386b6548e5a.jpg"
},
{
"id": 259,
"name": "Metroidvania",
"slug": "metroidvania",
"language": "eng",
"games_count": 4024,
"image_background": "https://media.rawg.io/media/games/c40/c40f9f0a3d1b4601a7a44d230c95f126.jpg"
},
{
"id": 42462,
"name": "Метроидвания",
"slug": "metroidvaniia",
"language": "rus",
"games_count": 887,
"image_background": "https://media.rawg.io/media/games/c50/c5085506fe4b5e20fc7aa5ace842c20b.jpg"
},
{
"id": 42592,
"name": "Похожа на Dark Souls",
"slug": "pokhozha-na-dark-souls",
"language": "rus",
"games_count": 585,
"image_background": "https://media.rawg.io/media/games/d09/d096ad37b7f522e11c02848252213a9a.jpg"
},
{
"id": 205,
"name": "Lore-Rich",
"slug": "lore-rich",
"language": "eng",
"games_count": 718,
"image_background": "https://media.rawg.io/media/screenshots/c98/c988bb637b38eac52b3ea878781e73d0.jpg"
},
{
"id": 42594,
"name": "Проработанная вселенная",
"slug": "prorabotannaia-vselennaia",
"language": "rus",
"games_count": 745,
"image_background": "https://media.rawg.io/media/screenshots/525/525b5da62342fa726bfe2820e8f93c09.jpg"
},
{
"id": 42677,
"name": "Готика",
"slug": "gotika",
"language": "rus",
"games_count": 339,
"image_background": "https://media.rawg.io/media/games/af7/af7a831001c5c32c46e950cc883b8cb7.jpg"
},
{
"id": 580,
"name": "Souls-like",
"slug": "souls-like",
"language": "eng",
"games_count": 988,
"image_background": "https://media.rawg.io/media/games/3b0/3b0f57d0fbb23854f300fb203c18889b.jpg"
}
],
"esrb_rating": {
"id": 4,
"name": "Mature",
"slug": "mature",
"name_en": "Mature",
"name_ru": "С 17 лет"
},
"user_game": null,
"reviews_count": 454,
"saturated_color": "0f0f0f",
"dominant_color": "0f0f0f",
"short_screenshots": [
{
"id": -1,
"image": "https://media.rawg.io/media/games/b01/b01aa6b2d6d4f683203e9471a8b8d5b5.jpg"
},
{
"id": 1702324,
"image": "https://media.rawg.io/media/screenshots/350/35004ab01b59310d9682c069efe0c0b2.jpg"
},
{
"id": 1702325,
"image": "https://media.rawg.io/media/screenshots/993/9930282406e7dd2819451ec16373a688.jpg"
},
{
"id": 1702329,
"image": "https://media.rawg.io/media/screenshots/b70/b70109ffdfabfe36e36cc43e1ad80277.jpg"
},
{
"id": 1702331,
"image": "https://media.rawg.io/media/screenshots/29d/29d417920697a7c637612a9ea7cd7d74.jpg"
},
{
"id": 1702332,
"image": "https://media.rawg.io/media/screenshots/a14/a14cacc86c817d7f039ac1f9ac2819e1.jpg"
},
{
"id": 1702333,
"image": "https://media.rawg.io/media/screenshots/1f7/1f7da2126ecea73a7a44623f768f7b94.jpg"
}
],
"parent_platforms": [
{
"platform": {
"id": 1,
"name": "PC",
"slug": "pc"
}
},
{
"platform": {
"id": 2,
"name": "PlayStation",
"slug": "playstation"
}
},
{
"platform": {
"id": 3,
"name": "Xbox",
"slug": "xbox"
}
},
{
"platform": {
"id": 5,
"name": "Apple Macintosh",
"slug": "mac"
}
},
{
"platform": {
"id": 6,
"name": "Linux",
"slug": "linux"
}
},
{
"platform": {
"id": 7,
"name": "Nintendo",
"slug": "nintendo"
}
}
],
"genres": [
{
"id": 51,
"name": "Indie",
"slug": "indie"
},
{
"id": 83,
"name": "Platformer",
"slug": "platformer"
},
{
"id": 3,
"name": "Adventure",
"slug": "adventure"
},
{
"id": 4,
"name": "Action",
"slug": "action"
}
]
}
],
"user_platforms": false
}
""".trimIndent()
val deserializedMockResponseB = RAWGPage(
count = 149,
nextPageUrl = "https://api.rawg.io/api/games?dates=2019-09-01%2C2019-09-30&key=b10a96c96f124283b10cf6f1aa18f973&page=2&page_size=3&platforms=18%2C1%2C7",
previousPageUrl = null,
results = listOf(
RAWGShallowGame(
id = 58617,
slug = "borderlands-3",
name = "Borderlands 3",
releaseDate = "2019-09-13",
toBeAnnounced = false,
imageUrl = "https://media.rawg.io/media/games/9f1/9f1891779cb20f44de93cef33b067e50.jpg",
rating = 3.9f,
metaCriticScore = 83,
playtime = 10,
suggestionsCount = 917,
platforms = listOf(
ShallowRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 4,
name = "PC",
slug = "pc",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = null,
imageBackground = null
)
),
ShallowRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 187,
name = "PlayStation 5",
slug = "playstation5",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = null,
imageBackground = null
)
),
ShallowRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 1,
name = "Xbox One",
slug = "xbox-one",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = null,
imageBackground = null
)
),
ShallowRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 18,
name = "PlayStation 4",
slug = "playstation4",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = null,
imageBackground = null
)
),
ShallowRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 186,
name = "Xbox Series S/X",
slug = "xbox-series-x",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = null,
imageBackground = null
)
)
),
stores = listOf(
ShallowRAWGStoreInfo(
store = RAWGStoreProperties(
id = 1,
name = "Steam",
slug = "steam",
domain = null,
gamesCount = null,
imageUrl = null
)
),
ShallowRAWGStoreInfo(
store = RAWGStoreProperties(
id = 3,
name = "PlayStation Store",
slug = "playstation-store",
domain = null,
gamesCount = null,
imageUrl = null
)
),
ShallowRAWGStoreInfo(
store = RAWGStoreProperties(
id = 2,
name = "Xbox Store",
slug = "xbox-store",
domain = null,
gamesCount = null,
imageUrl = null
)
),
ShallowRAWGStoreInfo(
store = RAWGStoreProperties(
id = 11,
name = "Epic Games",
slug = "epic-games",
domain = null,
gamesCount = null,
imageUrl = null
)
)
),
tags = listOf(
RAWGGameTag(
id = 31,
name = "Singleplayer",
slug = "singleplayer",
language = "eng",
gamesCount = 209582,
imageUrl = "https://media.rawg.io/media/games/73e/73eecb8909e0c39fb246f457b5d6cbbe.jpg"
),
RAWGGameTag(
id = 42396,
name = "Для одного игрока",
slug = "dlia-odnogo-igroka",
language = "rus",
gamesCount = 32259,
imageUrl = "https://media.rawg.io/media/games/618/618c2031a07bbff6b4f611f10b6bcdbc.jpg"
),
RAWGGameTag(
id = 42417,
name = "Экшен",
slug = "ekshen",
language = "rus",
gamesCount = 30948,
imageUrl = "https://media.rawg.io/media/games/d58/d588947d4286e7b5e0e12e1bea7d9844.jpg"
),
RAWGGameTag(
id = 42392,
name = "Приключение",
slug = "prikliuchenie",
language = "rus",
gamesCount = 28893,
imageUrl = "https://media.rawg.io/media/games/960/960b601d9541cec776c5fa42a00bf6c4.jpg"
),
RAWGGameTag(
id = 40847,
name = "Steam Achievements",
slug = "steam-achievements",
language = "eng",
gamesCount = 29451,
imageUrl = "https://media.rawg.io/media/games/8cc/8cce7c0e99dcc43d66c8efd42f9d03e3.jpg"
),
RAWGGameTag(
id = 7,
name = "Multiplayer",
slug = "multiplayer",
language = "eng",
gamesCount = 35586,
imageUrl = "https://media.rawg.io/media/games/328/3283617cb7d75d67257fc58339188742.jpg"
),
RAWGGameTag(
id = 40836,
name = "Full controller support",
slug = "full-controller-support",
language = "eng",
gamesCount = 13833,
imageUrl = "https://media.rawg.io/media/games/490/49016e06ae2103881ff6373248843069.jpg"
),
RAWGGameTag(
id = 13,
name = "Atmospheric",
slug = "atmospheric",
language = "eng",
gamesCount = 29424,
imageUrl = "https://media.rawg.io/media/games/7cf/7cfc9220b401b7a300e409e539c9afd5.jpg"
),
RAWGGameTag(
id = 40849,
name = "Steam Cloud",
slug = "steam-cloud",
language = "eng",
gamesCount = 13564,
imageUrl = "https://media.rawg.io/media/games/49c/49c3dfa4ce2f6f140cc4825868e858cb.jpg"
),
RAWGGameTag(
id = 42425,
name = "Для нескольких игроков",
slug = "dlia-neskolkikh-igrokov",
language = "rus",
gamesCount = 7497,
imageUrl = "https://media.rawg.io/media/games/d69/d69810315bd7e226ea2d21f9156af629.jpg"
),
RAWGGameTag(
id = 42401,
name = "Отличный саундтрек",
slug = "otlichnyi-saundtrek",
language = "rus",
gamesCount = 4453,
imageUrl = "https://media.rawg.io/media/games/618/618c2031a07bbff6b4f611f10b6bcdbc.jpg"
),
RAWGGameTag(
id = 42,
name = "Great Soundtrack",
slug = "great-soundtrack",
language = "eng",
gamesCount = 3230,
imageUrl = "https://media.rawg.io/media/games/7a2/7a2500ee8b2c0e1ff268bb4479463dea.jpg"
),
RAWGGameTag(
id = 24,
name = "RPG",
slug = "rpg",
language = "eng",
gamesCount = 16758,
imageUrl = "https://media.rawg.io/media/games/6cd/6cd653e0aaef5ff8bbd295bf4bcb12eb.jpg"
),
RAWGGameTag(
id = 18,
name = "Co-op",
slug = "co-op",
language = "eng",
gamesCount = 9686,
imageUrl = "https://media.rawg.io/media/games/8cc/8cce7c0e99dcc43d66c8efd42f9d03e3.jpg"
),
RAWGGameTag(
id = 42412,
name = "Ролевая игра",
slug = "rolevaia-igra",
language = "rus",
gamesCount = 13092,
imageUrl = "https://media.rawg.io/media/games/7cf/7cfc9220b401b7a300e409e539c9afd5.jpg"
),
RAWGGameTag(
id = 42442,
name = "Открытый мир",
slug = "otkrytyi-mir",
language = "rus",
gamesCount = 4231,
imageUrl = "https://media.rawg.io/media/games/490/49016e06ae2103881ff6373248843069.jpg"
),
RAWGGameTag(
id = 36,
name = "Open World",
slug = "open-world",
language = "eng",
gamesCount = 6237,
imageUrl = "https://media.rawg.io/media/games/ee3/ee3e10193aafc3230ba1cae426967d10.jpg"
),
RAWGGameTag(
id = 411,
name = "cooperative",
slug = "cooperative",
language = "eng",
gamesCount = 3925,
imageUrl = "https://media.rawg.io/media/games/d0f/d0f91fe1d92332147e5db74e207cfc7a.jpg"
),
RAWGGameTag(
id = 42428,
name = "Шутер",
slug = "shuter",
language = "rus",
gamesCount = 6356,
imageUrl = "https://media.rawg.io/media/games/fc1/fc1307a2774506b5bd65d7e8424664a7.jpg"
),
RAWGGameTag(
id = 8,
name = "First-Person",
slug = "first-person",
language = "eng",
gamesCount = 29119,
imageUrl = "https://media.rawg.io/media/games/c4b/c4b0cab189e73432de3a250d8cf1c84e.jpg"
),
RAWGGameTag(
id = 42435,
name = "Шедевр",
slug = "shedevr",
language = "rus",
gamesCount = 1059,
imageUrl = "https://media.rawg.io/media/games/9dd/9ddabb34840ea9227556670606cf8ea3.jpg"
),
RAWGGameTag(
id = 42429,
name = "От первого лица",
slug = "ot-pervogo-litsa",
language = "rus",
gamesCount = 7085,
imageUrl = "https://media.rawg.io/media/games/fc1/fc1307a2774506b5bd65d7e8424664a7.jpg"
),
RAWGGameTag(
id = 30,
name = "FPS",
slug = "fps",
language = "eng",
gamesCount = 12564,
imageUrl = "https://media.rawg.io/media/games/120/1201a40e4364557b124392ee50317b99.jpg"
),
RAWGGameTag(
id = 42427,
name = "Шутер от первого лица",
slug = "shuter-ot-pervogo-litsa",
language = "rus",
gamesCount = 3883,
imageUrl = "https://media.rawg.io/media/games/c4b/c4b0cab189e73432de3a250d8cf1c84e.jpg"
),
RAWGGameTag(
id = 9,
name = "Online Co-Op",
slug = "online-co-op",
language = "eng",
gamesCount = 4190,
imageUrl = "https://media.rawg.io/media/games/d0f/d0f91fe1d92332147e5db74e207cfc7a.jpg"
),
RAWGGameTag(
id = 42491,
name = "Мясо",
slug = "miaso",
language = "rus",
gamesCount = 3817,
imageUrl = "https://media.rawg.io/media/games/7f6/7f6cd70ba2ad57053b4847c13569f2d8.jpg"
),
RAWGGameTag(
id = 26,
name = "Gore",
slug = "gore",
language = "eng",
gamesCount = 5029,
imageUrl = "https://media.rawg.io/media/games/d58/d588947d4286e7b5e0e12e1bea7d9844.jpg"
),
RAWGGameTag(
id = 6,
name = "Exploration",
slug = "exploration",
language = "eng",
gamesCount = 19251,
imageUrl = "https://media.rawg.io/media/games/34b/34b1f1850a1c06fd971bc6ab3ac0ce0e.jpg"
),
RAWGGameTag(
id = 42433,
name = "Совместная игра по сети",
slug = "sovmestnaia-igra-po-seti",
language = "rus",
gamesCount = 1229,
imageUrl = "https://media.rawg.io/media/screenshots/88b/88b5f27f07d6ca2f8a3cd0b36e03a670.jpg"
),
RAWGGameTag(
id = 42402,
name = "Насилие",
slug = "nasilie",
language = "rus",
gamesCount = 4717,
imageUrl = "https://media.rawg.io/media/games/951/951572a3dd1e42544bd39a5d5b42d234.jpg"
),
RAWGGameTag(
id = 34,
name = "Violent",
slug = "violent",
language = "eng",
gamesCount = 5852,
imageUrl = "https://media.rawg.io/media/games/5be/5bec14622f6faf804a592176577c1347.jpg"
),
RAWGGameTag(
id = 198,
name = "Split Screen",
slug = "split-screen",
language = "eng",
gamesCount = 5481,
imageUrl = "https://media.rawg.io/media/games/27b/27b02ffaab6b250cc31bf43baca1fc34.jpg"
),
RAWGGameTag(
id = 75,
name = "Local Co-Op",
slug = "local-co-op",
language = "eng",
gamesCount = 4977,
imageUrl = "https://media.rawg.io/media/games/226/2262cea0b385db6cf399f4be831603b0.jpg"
),
RAWGGameTag(
id = 72,
name = "Local Multiplayer",
slug = "local-multiplayer",
language = "eng",
gamesCount = 12736,
imageUrl = "https://media.rawg.io/media/games/bbf/bbf8d74ab64440ad76294cff2f4d9cfa.jpg"
),
RAWGGameTag(
id = 69,
name = "Action-Adventure",
slug = "action-adventure",
language = "eng",
gamesCount = 13563,
imageUrl = "https://media.rawg.io/media/games/7f6/7f6cd70ba2ad57053b4847c13569f2d8.jpg"
),
RAWGGameTag(
id = 42406,
name = "Нагота",
slug = "nagota",
language = "rus",
gamesCount = 4293,
imageUrl = "https://media.rawg.io/media/games/473/473bd9a5e9522629d6cb28b701fb836a.jpg"
),
RAWGGameTag(
id = 25,
name = "Space",
slug = "space",
language = "eng",
gamesCount = 43383,
imageUrl = "https://media.rawg.io/media/games/e1f/e1ffbeb1bac25b19749ad285ca29e158.jpg"
),
RAWGGameTag(
id = 468,
name = "role-playing",
slug = "role-playing",
language = "eng",
gamesCount = 1454,
imageUrl = "https://media.rawg.io/media/games/596/596a48ef3b62b63b4cc59633e28be903.jpg"
),
RAWGGameTag(
id = 40832,
name = "Cross-Platform Multiplayer",
slug = "cross-platform-multiplayer",
language = "eng",
gamesCount = 2169,
imageUrl = "https://media.rawg.io/media/games/009/009e4e84975d6a60173ec1199db25aa3.jpg"
),
RAWGGameTag(
id = 44,
name = "Nudity",
slug = "nudity",
language = "eng",
gamesCount = 4681,
imageUrl = "https://media.rawg.io/media/games/16b/16b1b7b36e2042d1128d5a3e852b3b2f.jpg"
),
RAWGGameTag(
id = 40937,
name = "Steam Trading Cards",
slug = "steam-trading-cards-2",
language = "eng",
gamesCount = 381,
imageUrl = "https://media.rawg.io/media/games/6cc/6cc23249972a427f697a3d10eb57a820.jpg"
),
RAWGGameTag(
id = 413,
name = "online",
slug = "online",
language = "eng",
gamesCount = 6624,
imageUrl = "https://media.rawg.io/media/games/9f1/9f1891779cb20f44de93cef33b067e50.jpg"
),
RAWGGameTag(
id = 130,
name = "Driving",
slug = "driving",
language = "eng",
gamesCount = 4710,
imageUrl = "https://media.rawg.io/media/games/d7d/d7d33daa1892e2468cd0263d5dfc957e.jpg"
),
RAWGGameTag(
id = 98,
name = "Loot",
slug = "loot",
language = "eng",
gamesCount = 1905,
imageUrl = "https://media.rawg.io/media/games/c6b/c6bfece1daf8d06bc0a60632ac78e5bf.jpg"
),
RAWGGameTag(
id = 42575,
name = "Лут",
slug = "lut",
language = "rus",
gamesCount = 710,
imageUrl = "https://media.rawg.io/media/games/a7d/a7d57092a650030e2a868117f474efbc.jpg"
),
RAWGGameTag(
id = 5816,
name = "console",
slug = "console",
language = "eng",
gamesCount = 1408,
imageUrl = "https://media.rawg.io/media/games/415/41563ce6cb061a210160687a4e5d39f6.jpg"
),
RAWGGameTag(
id = 744,
name = "friends",
slug = "friends",
language = "eng",
gamesCount = 15183,
imageUrl = "https://media.rawg.io/media/games/415/41563ce6cb061a210160687a4e5d39f6.jpg"
),
RAWGGameTag(
id = 581,
name = "Epic",
slug = "epic",
language = "eng",
gamesCount = 4101,
imageUrl = "https://media.rawg.io/media/screenshots/671/6716b656707c65cdf21882ee51b4f2ff.jpg"
),
RAWGGameTag(
id = 578,
name = "Masterpiece",
slug = "masterpiece",
language = "eng",
gamesCount = 272,
imageUrl = "https://media.rawg.io/media/screenshots/0de/0defee61ebe38390fd3750b32213796d.jpg"
),
RAWGGameTag(
id = 42611,
name = "Эпичная",
slug = "epichnaia",
language = "rus",
gamesCount = 95,
imageUrl = "https://media.rawg.io/media/games/879/879c930f9c6787c920153fa2df452eb3.jpg"
),
RAWGGameTag(
id = 4565,
name = "offline",
slug = "offline",
language = "eng",
gamesCount = 1073,
imageUrl = "https://media.rawg.io/media/games/5dd/5dd4d2dd986d2826800bc37fff64aa4f.jpg"
),
RAWGGameTag(
id = 152,
name = "Western",
slug = "western",
language = "eng",
gamesCount = 1260,
imageUrl = "https://media.rawg.io/media/games/985/985dc43fe4fd5f0a7ae2a725673d6ac6.jpg"
),
RAWGGameTag(
id = 42659,
name = "Совместная кампания",
slug = "sovmestnaia-kampaniia",
language = "rus",
gamesCount = 278,
imageUrl = "https://media.rawg.io/media/screenshots/cfa/cfac855f997f4877b64fc908b8bda7b7.jpg"
),
RAWGGameTag(
id = 163,
name = "Co-op Campaign",
slug = "co-op-campaign",
language = "eng",
gamesCount = 259,
imageUrl = "https://media.rawg.io/media/games/10d/10d19e52e5e8415d16a4d344fe711874.jpg"
),
RAWGGameTag(
id = 1484,
name = "skill",
slug = "skill",
language = "eng",
gamesCount = 3507,
imageUrl = "https://media.rawg.io/media/games/fc8/fc839beb76bd63c2a5b176c46bdb7681.jpg"
),
RAWGGameTag(
id = 500,
name = "Solo",
slug = "solo",
language = "eng",
gamesCount = 1675,
imageUrl = "https://media.rawg.io/media/screenshots/643/64372c2b698ff4b0608e3d72a54adf2b.jpg"
),
RAWGGameTag(
id = 2405,
name = "planets",
slug = "planets",
language = "eng",
gamesCount = 1513,
imageUrl = "https://media.rawg.io/media/screenshots/839/8399a76a597fc93b43ae3103f041ea9e.jpg"
),
RAWGGameTag(
id = 1753,
name = "guns",
slug = "guns",
language = "eng",
gamesCount = 2504,
imageUrl = "https://media.rawg.io/media/games/662/66261db966238da20c306c4b78ae4603.jpg"
),
RAWGGameTag(
id = 38844,
name = "looter shooter",
slug = "looter-shooter",
language = "eng",
gamesCount = 316,
imageUrl = "https://media.rawg.io/media/screenshots/4a2/4a295497bbb0d1c5c5ef054bba31d41e.jpg"
),
RAWGGameTag(
id = 499,
name = "Team",
slug = "team",
language = "eng",
gamesCount = 24,
imageUrl = "https://media.rawg.io/media/screenshots/87f/87f4fe4138cc8f0829acceb37dbe1734.jpg"
),
RAWGGameTag(
id = 46115,
name = "LAN Co-op",
slug = "lan-co-op",
language = "eng",
gamesCount = 361,
imageUrl = "https://media.rawg.io/media/games/3cb/3cbf69d79420191a2255ffe6a580889e.jpg"
),
RAWGGameTag(
id = 6755,
name = "wasteland",
slug = "wasteland",
language = "eng",
gamesCount = 20,
imageUrl = "https://media.rawg.io/media/screenshots/22c/22c30aa67d6518120727170c9ac711e4.jpg"
),
RAWGGameTag(
id = 2723,
name = "trees",
slug = "trees",
language = "eng",
gamesCount = 618,
imageUrl = "https://media.rawg.io/media/screenshots/f40/f401985ddf9f041f039052b1d1c55fa3.jpg"
)
),
screenshots = listOf(
RAWGGameScreenshot(
id = -1,
imageUrl = "https://media.rawg.io/media/games/9f1/9f1891779cb20f44de93cef33b067e50.jpg"
),
RAWGGameScreenshot(
id = 2597139,
imageUrl = "https://media.rawg.io/media/screenshots/85f/85fa0742541492cb4b2562311d455918.jpg"
),
RAWGGameScreenshot(
id = 2597140,
imageUrl = "https://media.rawg.io/media/screenshots/1b6/1b6159bbc9e33c29cfd47cac82322b48.jpg"
),
RAWGGameScreenshot(
id = 2597141,
imageUrl = "https://media.rawg.io/media/screenshots/825/8255610d24155b27576155b21eda167d.jpg"
),
RAWGGameScreenshot(
id = 2597142,
imageUrl = "https://media.rawg.io/media/screenshots/9ab/9aba5fc11168844159e3fe83d7327294.jpg"
),
RAWGGameScreenshot(
id = 1884080,
imageUrl = "https://media.rawg.io/media/screenshots/293/293c4401fd411de976aec0df8597580c.jpg"
),
RAWGGameScreenshot(
id = 1884081,
imageUrl = "https://media.rawg.io/media/screenshots/c3e/c3ef63402fd812717da342ba73444ca0.jpg"
)
),
genres = listOf(
RAWGGameGenre(
id = 2,
name = "Shooter",
slug = "shooter",
gamesCount = null,
imageUrl = null
),
RAWGGameGenre(
id = 3,
name = "Adventure",
slug = "adventure",
gamesCount = null,
imageUrl = null
),
RAWGGameGenre(
id = 4,
name = "Action",
slug = "action",
gamesCount = null,
imageUrl = null
),
RAWGGameGenre(
id = 5,
name = "RPG",
slug = "role-playing-games-rpg",
gamesCount = null,
imageUrl = null
)
)
),
RAWGShallowGame(
id = 326252,
slug = "gears-5",
name = "Gears 5",
releaseDate = "2019-09-10",
toBeAnnounced = false,
imageUrl = "https://media.rawg.io/media/games/121/1213f8b9b0a26307e672cf51f34882f8.jpg",
rating = 3.93f,
metaCriticScore = 83,
playtime = 6,
suggestionsCount = 646,
platforms = listOf(
ShallowRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 4,
name = "PC",
slug = "pc",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = null,
imageBackground = null
)
),
ShallowRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 1,
name = "Xbox One",
slug = "xbox-one",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = null,
imageBackground = null
)
),
ShallowRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 186,
name = "Xbox Series S/X",
slug = "xbox-series-x",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = null,
imageBackground = null
)
)
),
stores = listOf(
ShallowRAWGStoreInfo(
store = RAWGStoreProperties(
id = 1,
name = "Steam",
slug = "steam",
domain = null,
gamesCount = null,
imageUrl = null
)
),
ShallowRAWGStoreInfo(
store = RAWGStoreProperties(
id = 2,
name = "Xbox Store",
slug = "xbox-store",
domain = null,
gamesCount = null,
imageUrl = null
)
)
),
tags = listOf(
RAWGGameTag(
id = 31,
name = "Singleplayer",
slug = "singleplayer",
language = "eng",
gamesCount = 209582,
imageUrl = "https://media.rawg.io/media/games/73e/73eecb8909e0c39fb246f457b5d6cbbe.jpg"
),
RAWGGameTag(
id = 42396,
name = "Для одного игрока",
slug = "dlia-odnogo-igroka",
language = "rus",
gamesCount = 32259,
imageUrl = "https://media.rawg.io/media/games/618/618c2031a07bbff6b4f611f10b6bcdbc.jpg"
),
RAWGGameTag(
id = 42417,
name = "Экшен",
slug = "ekshen",
language = "rus",
gamesCount = 30948,
imageUrl = "https://media.rawg.io/media/games/d58/d588947d4286e7b5e0e12e1bea7d9844.jpg"
),
RAWGGameTag(
id = 7,
name = "Multiplayer",
slug = "multiplayer",
language = "eng",
gamesCount = 35586,
imageUrl = "https://media.rawg.io/media/games/328/3283617cb7d75d67257fc58339188742.jpg"
),
RAWGGameTag(
id = 42425,
name = "Для нескольких игроков",
slug = "dlia-neskolkikh-igrokov",
language = "rus",
gamesCount = 7497,
imageUrl = "https://media.rawg.io/media/games/d69/d69810315bd7e226ea2d21f9156af629.jpg"
),
RAWGGameTag(
id = 42394,
name = "Глубокий сюжет",
slug = "glubokii-siuzhet",
language = "rus",
gamesCount = 8424,
imageUrl = "https://media.rawg.io/media/games/4cf/4cfc6b7f1850590a4634b08bfab308ab.jpg"
),
RAWGGameTag(
id = 18,
name = "Co-op",
slug = "co-op",
language = "eng",
gamesCount = 9686,
imageUrl = "https://media.rawg.io/media/games/8cc/8cce7c0e99dcc43d66c8efd42f9d03e3.jpg"
),
RAWGGameTag(
id = 411,
name = "cooperative",
slug = "cooperative",
language = "eng",
gamesCount = 3925,
imageUrl = "https://media.rawg.io/media/games/d0f/d0f91fe1d92332147e5db74e207cfc7a.jpg"
),
RAWGGameTag(
id = 40845,
name = "Partial Controller Support",
slug = "partial-controller-support",
language = "eng",
gamesCount = 9487,
imageUrl = "https://media.rawg.io/media/games/7fa/7fa0b586293c5861ee32490e953a4996.jpg"
),
RAWGGameTag(
id = 9,
name = "Online Co-Op",
slug = "online-co-op",
language = "eng",
gamesCount = 4190,
imageUrl = "https://media.rawg.io/media/games/d0f/d0f91fe1d92332147e5db74e207cfc7a.jpg"
),
RAWGGameTag(
id = 42491,
name = "Мясо",
slug = "miaso",
language = "rus",
gamesCount = 3817,
imageUrl = "https://media.rawg.io/media/games/7f6/7f6cd70ba2ad57053b4847c13569f2d8.jpg"
),
RAWGGameTag(
id = 26,
name = "Gore",
slug = "gore",
language = "eng",
gamesCount = 5029,
imageUrl = "https://media.rawg.io/media/games/d58/d588947d4286e7b5e0e12e1bea7d9844.jpg"
),
RAWGGameTag(
id = 189,
name = "Female Protagonist",
slug = "female-protagonist",
language = "eng",
gamesCount = 10429,
imageUrl = "https://media.rawg.io/media/games/021/021c4e21a1824d2526f925eff6324653.jpg"
),
RAWGGameTag(
id = 42404,
name = "Женщина-протагонист",
slug = "zhenshchina-protagonist",
language = "rus",
gamesCount = 2416,
imageUrl = "https://media.rawg.io/media/games/62c/62c7c8b28a27b83680b22fb9d33fc619.jpg"
),
RAWGGameTag(
id = 42402,
name = "Насилие",
slug = "nasilie",
language = "rus",
gamesCount = 4717,
imageUrl = "https://media.rawg.io/media/games/951/951572a3dd1e42544bd39a5d5b42d234.jpg"
),
RAWGGameTag(
id = 34,
name = "Violent",
slug = "violent",
language = "eng",
gamesCount = 5852,
imageUrl = "https://media.rawg.io/media/games/5be/5bec14622f6faf804a592176577c1347.jpg"
),
RAWGGameTag(
id = 397,
name = "Online multiplayer",
slug = "online-multiplayer",
language = "eng",
gamesCount = 3811,
imageUrl = "https://media.rawg.io/media/games/fc0/fc076b974197660a582abd34ebccc27f.jpg"
),
RAWGGameTag(
id = 198,
name = "Split Screen",
slug = "split-screen",
language = "eng",
gamesCount = 5481,
imageUrl = "https://media.rawg.io/media/games/27b/27b02ffaab6b250cc31bf43baca1fc34.jpg"
),
RAWGGameTag(
id = 75,
name = "Local Co-Op",
slug = "local-co-op",
language = "eng",
gamesCount = 4977,
imageUrl = "https://media.rawg.io/media/games/226/2262cea0b385db6cf399f4be831603b0.jpg"
),
RAWGGameTag(
id = 42446,
name = "Шутер от третьего лица",
slug = "shuter-ot-tretego-litsa",
language = "rus",
gamesCount = 1410,
imageUrl = "https://media.rawg.io/media/games/e2d/e2d3f396b16dded0f841c17c9799a882.jpg"
),
RAWGGameTag(
id = 72,
name = "Local Multiplayer",
slug = "local-multiplayer",
language = "eng",
gamesCount = 12736,
imageUrl = "https://media.rawg.io/media/games/bbf/bbf8d74ab64440ad76294cff2f4d9cfa.jpg"
),
RAWGGameTag(
id = 40832,
name = "Cross-Platform Multiplayer",
slug = "cross-platform-multiplayer",
language = "eng",
gamesCount = 2169,
imageUrl = "https://media.rawg.io/media/games/009/009e4e84975d6a60173ec1199db25aa3.jpg"
),
RAWGGameTag(
id = 81,
name = "Military",
slug = "military",
language = "eng",
gamesCount = 1305,
imageUrl = "https://media.rawg.io/media/games/ac7/ac7b8327343da12c971cfc418f390a11.jpg"
),
RAWGGameTag(
id = 3068,
name = "future",
slug = "future",
language = "eng",
gamesCount = 3176,
imageUrl = "https://media.rawg.io/media/screenshots/f85/f856c14f8c8d7cb72085723960f5c8d5.jpg"
)
),
screenshots = listOf(
RAWGGameScreenshot(
id = -1,
imageUrl = "https://media.rawg.io/media/games/121/1213f8b9b0a26307e672cf51f34882f8.jpg"
),
RAWGGameScreenshot(
id = 1957721,
imageUrl = "https://media.rawg.io/media/screenshots/9f0/9f085738a4ee6bb44b4b26cd3eb9ef93.jpg"
),
RAWGGameScreenshot(
id = 1957722,
imageUrl = "https://media.rawg.io/media/screenshots/1c8/1c8eb3c87b9396e924ade589d543790e.jpg"
),
RAWGGameScreenshot(
id = 1957723,
imageUrl = "https://media.rawg.io/media/screenshots/a83/a832752f82cfde4a811c581e9cd3efd0.jpg"
),
RAWGGameScreenshot(
id = 1957724,
imageUrl = "https://media.rawg.io/media/screenshots/a6f/a6fafe1183ce4b3f68287219ea3dd6c8.jpg"
),
RAWGGameScreenshot(
id = 1957725,
imageUrl = "https://media.rawg.io/media/screenshots/38c/38c4c8601a72e1d0dacf6d1fe1c5dfb3.jpg"
),
RAWGGameScreenshot(
id = 778890,
imageUrl = "https://media.rawg.io/media/screenshots/ae7/ae7fcd1a2d11be26e1ea72e6d5d83ecc.jpg"
)
),
genres = listOf(
RAWGGameGenre(
id = 2,
name = "Shooter",
slug = "shooter",
gamesCount = null,
imageUrl = null
),
RAWGGameGenre(
id = 4,
name = "Action",
slug = "action",
gamesCount = null,
imageUrl = null
)
)
),
RAWGShallowGame(
id = 258322,
slug = "blasphemous",
name = "Blasphemous",
releaseDate = "2019-09-09",
toBeAnnounced = false,
imageUrl = "https://media.rawg.io/media/games/b01/b01aa6b2d6d4f683203e9471a8b8d5b5.jpg",
rating = 4.04f,
metaCriticScore = 78,
playtime = 3,
suggestionsCount = 393,
platforms = listOf(
ShallowRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 4,
name = "PC",
slug = "pc",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = null,
imageBackground = null
)
),
ShallowRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 1,
name = "Xbox One",
slug = "xbox-one",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = null,
imageBackground = null
)
),
ShallowRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 18,
name = "PlayStation 4",
slug = "playstation4",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = null,
imageBackground = null
)
),
ShallowRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 7,
name = "Nintendo Switch",
slug = "nintendo-switch",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = null,
imageBackground = null
)
),
ShallowRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 5,
name = "macOS",
slug = "macos",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = null,
imageBackground = null
)
),
ShallowRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = 6,
name = "Linux",
slug = "linux",
imageUrl = null,
yearEnd = null,
yearStart = null,
gamesCount = null,
imageBackground = null
)
)
),
stores = listOf(
ShallowRAWGStoreInfo(
store = RAWGStoreProperties(
id = 1,
name = "Steam",
slug = "steam",
domain = null,
gamesCount = null,
imageUrl = null
)
),
ShallowRAWGStoreInfo(
store = RAWGStoreProperties(
id = 3,
name = "PlayStation Store",
slug = "playstation-store",
domain = null,
gamesCount = null,
imageUrl = null
)
),
ShallowRAWGStoreInfo(
store = RAWGStoreProperties(
id = 2,
name = "Xbox Store",
slug = "xbox-store",
domain = null,
gamesCount = null,
imageUrl = null
)
),
ShallowRAWGStoreInfo(
store = RAWGStoreProperties(
id = 5,
name = "GOG",
slug = "gog",
domain = null,
gamesCount = null,
imageUrl = null
)
),
ShallowRAWGStoreInfo(
store = RAWGStoreProperties(
id = 6,
name = "Nintendo Store",
slug = "nintendo",
domain = null,
gamesCount = null,
imageUrl = null
)
),
ShallowRAWGStoreInfo(
store = RAWGStoreProperties(
id = 11,
name = "Epic Games",
slug = "epic-games",
domain = null,
gamesCount = null,
imageUrl = null
)
)
),
tags = listOf(
RAWGGameTag(
id = 31,
name = "Singleplayer",
slug = "singleplayer",
language = "eng",
gamesCount = 209582,
imageUrl = "https://media.rawg.io/media/games/73e/73eecb8909e0c39fb246f457b5d6cbbe.jpg"
),
RAWGGameTag(
id = 42396,
name = "Для одного игрока",
slug = "dlia-odnogo-igroka",
language = "rus",
gamesCount = 32259,
imageUrl = "https://media.rawg.io/media/games/618/618c2031a07bbff6b4f611f10b6bcdbc.jpg"
),
RAWGGameTag(
id = 42417,
name = "Экшен",
slug = "ekshen",
language = "rus",
gamesCount = 30948,
imageUrl = "https://media.rawg.io/media/games/d58/d588947d4286e7b5e0e12e1bea7d9844.jpg"
),
RAWGGameTag(
id = 42392,
name = "Приключение",
slug = "prikliuchenie",
language = "rus",
gamesCount = 28893,
imageUrl = "https://media.rawg.io/media/games/960/960b601d9541cec776c5fa42a00bf6c4.jpg"
),
RAWGGameTag(
id = 40847,
name = "Steam Achievements",
slug = "steam-achievements",
language = "eng",
gamesCount = 29451,
imageUrl = "https://media.rawg.io/media/games/8cc/8cce7c0e99dcc43d66c8efd42f9d03e3.jpg"
),
RAWGGameTag(
id = 42398,
name = "Инди",
slug = "indi-2",
language = "rus",
gamesCount = 44678,
imageUrl = "https://media.rawg.io/media/games/226/2262cea0b385db6cf399f4be831603b0.jpg"
),
RAWGGameTag(
id = 40836,
name = "Full controller support",
slug = "full-controller-support",
language = "eng",
gamesCount = 13833,
imageUrl = "https://media.rawg.io/media/games/490/49016e06ae2103881ff6373248843069.jpg"
),
RAWGGameTag(
id = 42401,
name = "Отличный саундтрек",
slug = "otlichnyi-saundtrek",
language = "rus",
gamesCount = 4453,
imageUrl = "https://media.rawg.io/media/games/618/618c2031a07bbff6b4f611f10b6bcdbc.jpg"
),
RAWGGameTag(
id = 45,
name = "2D",
slug = "2d",
language = "eng",
gamesCount = 197659,
imageUrl = "https://media.rawg.io/media/screenshots/c97/c97b943741f5fbc936fe054d9d58851d.jpg"
),
RAWGGameTag(
id = 42420,
name = "Сложная",
slug = "slozhnaia",
language = "rus",
gamesCount = 4353,
imageUrl = "https://media.rawg.io/media/games/9bf/9bfac18ff678f41a4674250fa0e04a52.jpg"
),
RAWGGameTag(
id = 42491,
name = "Мясо",
slug = "miaso",
language = "rus",
gamesCount = 3817,
imageUrl = "https://media.rawg.io/media/games/7f6/7f6cd70ba2ad57053b4847c13569f2d8.jpg"
),
RAWGGameTag(
id = 26,
name = "Gore",
slug = "gore",
language = "eng",
gamesCount = 5029,
imageUrl = "https://media.rawg.io/media/games/d58/d588947d4286e7b5e0e12e1bea7d9844.jpg"
),
RAWGGameTag(
id = 49,
name = "Difficult",
slug = "difficult",
language = "eng",
gamesCount = 12897,
imageUrl = "https://media.rawg.io/media/games/6cd/6cd653e0aaef5ff8bbd295bf4bcb12eb.jpg"
),
RAWGGameTag(
id = 6,
name = "Exploration",
slug = "exploration",
language = "eng",
gamesCount = 19251,
imageUrl = "https://media.rawg.io/media/games/34b/34b1f1850a1c06fd971bc6ab3ac0ce0e.jpg"
),
RAWGGameTag(
id = 42463,
name = "Платформер",
slug = "platformer-2",
language = "rus",
gamesCount = 6201,
imageUrl = "https://media.rawg.io/media/games/fc8/fc838d98c9b944e6a15176eabf40bee8.jpg"
),
RAWGGameTag(
id = 42402,
name = "Насилие",
slug = "nasilie",
language = "rus",
gamesCount = 4717,
imageUrl = "https://media.rawg.io/media/games/951/951572a3dd1e42544bd39a5d5b42d234.jpg"
),
RAWGGameTag(
id = 34,
name = "Violent",
slug = "violent",
language = "eng",
gamesCount = 5852,
imageUrl = "https://media.rawg.io/media/games/5be/5bec14622f6faf804a592176577c1347.jpg"
),
RAWGGameTag(
id = 42464,
name = "Исследование",
slug = "issledovanie",
language = "rus",
gamesCount = 2990,
imageUrl = "https://media.rawg.io/media/games/bce/bce62fbc7cf74bf6a1a37340993ec148.jpg"
),
RAWGGameTag(
id = 42415,
name = "Пиксельная графика",
slug = "pikselnaia-grafika",
language = "rus",
gamesCount = 8404,
imageUrl = "https://media.rawg.io/media/screenshots/f81/f81fd968a3161e7d35612d8c4232923e.jpg"
),
RAWGGameTag(
id = 122,
name = "Pixel Graphics",
slug = "pixel-graphics",
language = "eng",
gamesCount = 93980,
imageUrl = "https://media.rawg.io/media/games/501/501e7019925a3c692bf1c8062f07abe6.jpg"
),
RAWGGameTag(
id = 42406,
name = "Нагота",
slug = "nagota",
language = "rus",
gamesCount = 4293,
imageUrl = "https://media.rawg.io/media/games/473/473bd9a5e9522629d6cb28b701fb836a.jpg"
),
RAWGGameTag(
id = 468,
name = "role-playing",
slug = "role-playing",
language = "eng",
gamesCount = 1454,
imageUrl = "https://media.rawg.io/media/games/596/596a48ef3b62b63b4cc59633e28be903.jpg"
),
RAWGGameTag(
id = 44,
name = "Nudity",
slug = "nudity",
language = "eng",
gamesCount = 4681,
imageUrl = "https://media.rawg.io/media/games/16b/16b1b7b36e2042d1128d5a3e852b3b2f.jpg"
),
RAWGGameTag(
id = 42469,
name = "Вид сбоку",
slug = "vid-sboku",
language = "rus",
gamesCount = 2850,
imageUrl = "https://media.rawg.io/media/games/9cc/9cc11e2e81403186c7fa9c00c143d6e4.jpg"
),
RAWGGameTag(
id = 42506,
name = "Тёмное фэнтези",
slug = "tiomnoe-fentezi",
language = "rus",
gamesCount = 1786,
imageUrl = "https://media.rawg.io/media/games/789/7896837ec22a83e4007018ddd55e8c9a.jpg"
),
RAWGGameTag(
id = 40,
name = "Dark Fantasy",
slug = "dark-fantasy",
language = "eng",
gamesCount = 3190,
imageUrl = "https://media.rawg.io/media/games/da1/da1b267764d77221f07a4386b6548e5a.jpg"
),
RAWGGameTag(
id = 259,
name = "Metroidvania",
slug = "metroidvania",
language = "eng",
gamesCount = 4024,
imageUrl = "https://media.rawg.io/media/games/c40/c40f9f0a3d1b4601a7a44d230c95f126.jpg"
),
RAWGGameTag(
id = 42462,
name = "Метроидвания",
slug = "metroidvaniia",
language = "rus",
gamesCount = 887,
imageUrl = "https://media.rawg.io/media/games/c50/c5085506fe4b5e20fc7aa5ace842c20b.jpg"
),
RAWGGameTag(
id = 42592,
name = "Похожа на Dark Souls",
slug = "pokhozha-na-dark-souls",
language = "rus",
gamesCount = 585,
imageUrl = "https://media.rawg.io/media/games/d09/d096ad37b7f522e11c02848252213a9a.jpg"
),
RAWGGameTag(
id = 205,
name = "Lore-Rich",
slug = "lore-rich",
language = "eng",
gamesCount = 718,
imageUrl = "https://media.rawg.io/media/screenshots/c98/c988bb637b38eac52b3ea878781e73d0.jpg"
),
RAWGGameTag(
id = 42594,
name = "Проработанная вселенная",
slug = "prorabotannaia-vselennaia",
language = "rus",
gamesCount = 745,
imageUrl = "https://media.rawg.io/media/screenshots/525/525b5da62342fa726bfe2820e8f93c09.jpg"
),
RAWGGameTag(
id = 42677,
name = "Готика",
slug = "gotika",
language = "rus",
gamesCount = 339,
imageUrl = "https://media.rawg.io/media/games/af7/af7a831001c5c32c46e950cc883b8cb7.jpg"
),
RAWGGameTag(
id = 580,
name = "Souls-like",
slug = "souls-like",
language = "eng",
gamesCount = 988,
imageUrl = "https://media.rawg.io/media/games/3b0/3b0f57d0fbb23854f300fb203c18889b.jpg"
)
),
screenshots = listOf(
RAWGGameScreenshot(
id = -1,
imageUrl = "https://media.rawg.io/media/games/b01/b01aa6b2d6d4f683203e9471a8b8d5b5.jpg"
),
RAWGGameScreenshot(
id = 1702324,
imageUrl = "https://media.rawg.io/media/screenshots/350/35004ab01b59310d9682c069efe0c0b2.jpg"
),
RAWGGameScreenshot(
id = 1702325,
imageUrl = "https://media.rawg.io/media/screenshots/993/9930282406e7dd2819451ec16373a688.jpg"
),
RAWGGameScreenshot(
id = 1702329,
imageUrl = "https://media.rawg.io/media/screenshots/b70/b70109ffdfabfe36e36cc43e1ad80277.jpg"
),
RAWGGameScreenshot(
id = 1702331,
imageUrl = "https://media.rawg.io/media/screenshots/29d/29d417920697a7c637612a9ea7cd7d74.jpg"
),
RAWGGameScreenshot(
id = 1702332,
imageUrl = "https://media.rawg.io/media/screenshots/a14/a14cacc86c817d7f039ac1f9ac2819e1.jpg"
),
RAWGGameScreenshot(
id = 1702333,
imageUrl = "https://media.rawg.io/media/screenshots/1f7/1f7da2126ecea73a7a44623f768f7b94.jpg"
)
),
genres = listOf(
RAWGGameGenre(
id = 51,
name = "Indie",
slug = "indie",
gamesCount = null,
imageUrl = null
),
RAWGGameGenre(
id = 83,
name = "Platformer",
slug = "platformer",
gamesCount = null,
imageUrl = null
),
RAWGGameGenre(
id = 3,
name = "Adventure",
slug = "adventure",
gamesCount = null,
imageUrl = null
),
RAWGGameGenre(
id = 4,
name = "Action",
slug = "action",
gamesCount = null,
imageUrl = null
)
)
)
)
)
// TODO: write a ksp plugin to generate this boilerplate automatically
/**
* Returns the model with all string values in it wrapped in quotes.
* This is typically useful in copying & pasting large fake data
*/
internal fun RAWGPage.quotify(): RAWGPage {
return let {
RAWGPage(
count = it.count,
nextPageUrl = "\"${it.nextPageUrl}\"",
previousPageUrl = it.previousPageUrl?.let { "\"$it\"" },
results = it.results.map {
RAWGShallowGame(
id = it.id,
name = "\"${it.name}\"",
slug = "\"${it.slug}\"",
releaseDate = "\"${it.releaseDate}\"",
toBeAnnounced = it.toBeAnnounced,
imageUrl = "\"${it.imageUrl}\"",
rating = it.rating,
metaCriticScore = it.metaCriticScore,
playtime = it.playtime,
suggestionsCount = it.suggestionsCount,
platforms = it.platforms?.map {
ShallowRAWGPlatformInfo(
platform = RAWGPlatformProperties(
id = it.platform.id,
name = "\"${it.platform.name}\"",
slug = "\"${it.platform.slug}\"",
imageUrl = it.platform.imageUrl?.let { "\"$it\"" },
yearEnd = it.platform.yearEnd,
yearStart = it.platform.yearStart,
gamesCount = it.platform.gamesCount,
imageBackground = it.platform.imageBackground?.let { "\"$it\"" }
)
// releaseDate = (it as DetailedRAWGPlatformInfo).releaseDate?.let { "\"$it\"" },
// requirementsInEnglish = if (it.requirementsInEnglish != null) RAWGPlatformRequirements(
// minimum = "\"${it.requirementsInEnglish!!.minimum}\"",
// recommended = "\"${it.requirementsInEnglish!!.recommended}\"",
// ) else null
)
},
stores = it.stores?.map {
// it as ShallowRAWGStoreInfoWithId
ShallowRAWGStoreInfo(
// id = it.id,
store = RAWGStoreProperties(
id = it.store.id,
name = "\"${it.store.name}\"",
slug = "\"${it.store.slug}\"",
domain = it.store.domain?.let { "\"$it\"" },
gamesCount = it.store.gamesCount,
imageUrl = it.store.imageUrl?.let { "\"$it\"" }
)
)
},
tags = it.tags.map {
RAWGGameTag(
id = it.id,
name = "\"${it.name}\"",
slug = "\"${it.slug}\"",
language = "\"${it.language}\"",
gamesCount = it.gamesCount,
imageUrl = it.imageUrl.let { "\"$it\"" }
)
},
screenshots = it.screenshots.map {
RAWGGameScreenshot(
id = it.id,
imageUrl = "\"${it.imageUrl}\""
)
},
genres = it.genres.map {
RAWGGameGenre(
id = it.id,
name = "\"${it.name}\"",
slug = "\"${it.slug}\"",
gamesCount = it.gamesCount,
imageUrl = it.imageUrl?.let { "\"$it\"" }
)
}
)
}
)
}
}
| 8 | null | 0 | 9 | c34f17c014f7ef050834a18b6854d67485b6bd83 | 270,820 | Ludi | Apache License 2.0 |
Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/sources/fallback/DefaultAppConfigTest.kt | corona-warn-app | 268,027,139 | false | null | package de.rki.coronawarnapp.appconfig.sources.fallback
import android.content.Context
import android.os.Build
import androidx.test.core.app.ApplicationProvider
import com.google.protobuf.UnknownFieldSetLite
import de.rki.coronawarnapp.server.protocols.internal.v2.AppConfigAndroid
import de.rki.coronawarnapp.util.HashExtensions.toSHA256
import io.kotest.assertions.throwables.shouldNotThrowAny
import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNotBe
import io.mockk.MockKAnnotations
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
import testhelpers.BaseTest
import testhelpers.EmptyApplication
@Config(sdk = [Build.VERSION_CODES.P], application = EmptyApplication::class)
@RunWith(RobolectricTestRunner::class)
class DefaultAppConfigSanityCheck : BaseTest() {
private val configName = "default_app_config_android.bin"
private val checkSumName = "default_app_config_android.sha256"
@Before
fun setup() {
MockKAnnotations.init(this)
}
val context: Context
get() = ApplicationProvider.getApplicationContext()
@Test
fun `current default matches checksum`() {
val config = context.assets.open(configName).readBytes()
val sha256 = context.assets.open(checkSumName).readBytes().toString(Charsets.UTF_8)
sha256 shouldBe "12d0b93c0c02c6870ef75c173a53a8ffb9cab6828fbf22e751053329c425eef2"
config.toSHA256() shouldBe sha256
}
@Test
fun `current default config can be parsed`() {
shouldNotThrowAny {
val config = context.assets.open(configName).readBytes()
val parsedConfig = AppConfigAndroid.ApplicationConfigurationAndroid.parseFrom(config)
parsedConfig shouldNotBe null
val unknownFields = parsedConfig.javaClass.superclass!!.getDeclaredField("unknownFields").let {
it.isAccessible = true
it.get(parsedConfig) as UnknownFieldSetLite
}
unknownFields.serializedSize shouldBe 0
}
}
}
| 6 | null | 8 | 2,495 | d3833a212bd4c84e38a1fad23b282836d70ab8d5 | 2,132 | cwa-app-android | Apache License 2.0 |
aws-runtime/aws-http/common/test/aws/sdk/kotlin/runtime/http/operation/CustomUserAgentMetadataTest.kt | awslabs | 121,333,316 | false | {"Kotlin": 1076968, "Smithy": 8546, "TypeScript": 1488, "JavaScript": 1134, "Dockerfile": 391} | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package aws.sdk.kotlin.runtime.http.operation
import aws.sdk.kotlin.runtime.http.ApiMetadata
import aws.sdk.kotlin.runtime.http.loadAwsUserAgentMetadataFromEnvironment
import aws.smithy.kotlin.runtime.util.TestPlatformProvider
import io.kotest.matchers.string.shouldContain
import kotlin.test.Test
import kotlin.test.assertEquals
class CustomUserAgentMetadataTest {
@Test
fun testCustomMetadata() {
val provider = TestPlatformProvider()
val metadata = loadAwsUserAgentMetadataFromEnvironment(provider, ApiMetadata("Test Service", "1.2.3"))
val customMetadata = CustomUserAgentMetadata()
customMetadata.add("foo", "bar")
customMetadata.add("truthy", "true")
customMetadata.add("falsey", "false")
val configMetadata = ConfigMetadata("retry-mode", "standard")
customMetadata.add(configMetadata)
customMetadata.add(FeatureMetadata("s3-transfer", "1.2.3"))
customMetadata.add(FeatureMetadata("waiter"))
val actual = metadata.copy(customMetadata = customMetadata).xAmzUserAgent
listOf(
"md/foo#bar",
"md/truthy",
"md/falsey#false",
"cfg/retry-mode#standard",
"ft/s3-transfer#1.2.3",
"ft/waiter",
).forEach { partial ->
actual.shouldContain(partial)
}
}
@Test
fun testFromEnvironment() {
val props = mapOf(
"irrelevantProp" to "shouldBeIgnored",
"aws.customMetadata" to "shouldBeIgnored",
"aws.customMetadata.foo" to "bar",
"aws.customMetadata.baz" to "qux",
"aws.customMetadata.priority" to "props",
)
val envVars = mapOf(
"IRRELEVANT_PROP" to "shouldBeIgnored",
"AWS_CUSTOM_METADATA" to "shouldBeIgnored",
"AWS_CUSTOM_METADATA_oof" to "rab",
"AWS_CUSTOM_METADATA_zab" to "xuq",
"AWS_CUSTOM_METADATA_priority" to "envVars",
)
val provider = TestPlatformProvider(env = envVars, props = props)
val metadata = CustomUserAgentMetadata.fromEnvironment(provider)
val expected = mapOf(
"foo" to "bar",
"baz" to "qux",
"oof" to "rab",
"zab" to "xuq",
"priority" to "props", // System properties take precedence over env vars
)
assertEquals(expected, metadata.extras)
}
}
| 92 | Kotlin | 49 | 407 | 287408211f193624d37678d66b0f31f457017d08 | 2,555 | aws-sdk-kotlin | Apache License 2.0 |
data/src/main/java/com/apiguave/tinderclonedata/match/MatchRemoteDataSource.kt | alejandro-piguave | 567,907,964 | false | {"Kotlin": 191481} | package com.apiguave.tinderclonedata.match
import com.apiguave.tinderclonedata.api.match.FirestoreMatch
import com.apiguave.tinderclonedata.api.match.MatchApi
import com.apiguave.tinderclonedata.api.picture.PictureApi
import com.apiguave.tinderclonedata.api.user.UserApi
import com.apiguave.tinderclonedata.api.auth.exception.AuthException
import com.apiguave.tinderclonedata.extension.toAge
import com.apiguave.tinderclonedata.extension.toShortString
import com.google.firebase.auth.FirebaseAuth
import kotlinx.coroutines.async
import kotlinx.coroutines.coroutineScope
import com.apiguave.tinderclonedomain.match.Match
import kotlinx.coroutines.awaitAll
class MatchRemoteDataSource(private val matchApi: MatchApi, private val userApi: UserApi, private val pictureApi: PictureApi) {
private val currentUserId: String
get() = FirebaseAuth.getInstance().currentUser?.uid ?: throw AuthException("User not logged in")
suspend fun getMatches(): List<Match> = coroutineScope {
val apiMatches = matchApi.getMatches(currentUserId)
val matches = apiMatches.map { async { getMatch(it) }}.awaitAll()
matches.filterNotNull()
}
private suspend fun getMatch(match: FirestoreMatch): Match? {
val userId = match.usersMatched.firstOrNull { it != currentUserId } ?: return null
val user = userApi.getUser(userId)
val picture = pictureApi.getPicture(user.id, user.pictures.first())
return Match(
match.id,
user.birthDate?.toDate()?.toAge() ?: 0,
userId,
user.name,
picture.uri,
match.timestamp?.toShortString() ?: "",
match.lastMessage
)
}
} | 1 | Kotlin | 9 | 35 | 47d3825d3a446f121b30142a764a9b034f0c953e | 1,705 | TinderCloneCompose | MIT License |
ktor-banner-sample/src/main/kotlin/team/yi/ktor/sample/Main2.kt | ymind | 351,300,926 | false | null | package team.yi.ktor.sample
import io.ktor.application.*
import io.ktor.response.*
import io.ktor.routing.*
import io.ktor.server.engine.*
import io.ktor.server.netty.*
import team.yi.kfiglet.FigFont
import team.yi.ktor.features.banner
fun main2() {
embeddedServer(Netty, port = 8000) {
banner {
bannerText = "Ktor Banner"
// custom font
loadFigFont = {
val inputStream = ::main2.javaClass.classLoader.getResourceAsStream("fonts/starwars.flf")!!
FigFont.loadFigFont(inputStream)
}
// custom render
render {
println(it.text)
}
// append custom footer
beforeBanner { banner ->
println("".padEnd(banner.width, '-'))
}
// append custom footer
afterBanner { banner ->
val title = " MyKtorApp v1.2.3 "
val homepage = "https://yi.team/"
val filling = "".padEnd(banner.width - title.length - homepage.length, ' ')
println("".padEnd(banner.width, '-'))
println("$title$filling$homepage")
}
}
routing {
get("/") {
call.respondText("Hello, world!")
}
}
}.start(wait = true)
}
| 0 | Kotlin | 0 | 1 | fab4dfa5591a766cdae63de0c349a1935bdede2a | 1,354 | ktor-banner | MIT License |
data/src/main/java/com/grekov/translate/data/mapper/LangApiToLangMapper.kt | sgrekov | 111,900,693 | false | null | package com.grekov.translate.data.mapper
import com.grekov.translate.data.model.cloud.LangRespone
import com.grekov.translate.domain.model.Lang
import com.grekov.translate.domain.utils.BaseDataMapper
import java.util.*
import javax.inject.Inject
class LangApiToLangMapper @Inject
constructor()//constructor for injection
: BaseDataMapper<LangRespone, List<Lang>>() {
override fun transform(item: LangRespone): List<Lang> {
val langs = LinkedList<Lang>()
item.langs?.let {
for ((key, value) in it) {
langs.add(Lang(key, value))
}
}
return langs
}
} | 0 | Kotlin | 4 | 22 | 24a1a1955ca901d4bf5ff08ff2f8e3eb2719c825 | 634 | Translater | Apache License 2.0 |
src/main/kotlin/org/jooq/impl/tools.kt | sungmin-park | 39,015,495 | false | null | package org.jooq.impl
import org.jooq.DSLContext
import org.jooq.Select
object tools {
fun dslContext(select: Select<*>): DSLContext {
val configuration = ((select as AbstractDelegatingQuery<*>).delegate as AbstractQuery).configuration()
return DSL.using(configuration)
}
}
fun Select<*>.dslContext(): DSLContext = tools.dslContext(this)
| 0 | Kotlin | 0 | 0 | 7c339db7392ba925991aabb55bd3645c23a30d80 | 365 | jOOQ-tools | MIT License |
app/shared/auth/impl/src/commonMain/kotlin/build/wallet/auth/AccountAuthenticatorImpl.kt | proto-at-block | 761,306,853 | false | null | package build.wallet.auth
import build.wallet.auth.AccountAuthenticator.AuthData
import build.wallet.bitkey.app.AppAuthKey
import build.wallet.bitkey.f8e.FullAccountId
import build.wallet.crypto.PublicKey
import build.wallet.f8e.F8eEnvironment
import build.wallet.f8e.auth.AuthenticationService
import build.wallet.ktor.result.HttpError
import build.wallet.logging.LogLevel
import build.wallet.logging.log
import com.github.michaelbull.result.Result
import com.github.michaelbull.result.coroutines.binding.binding
import com.github.michaelbull.result.mapError
import io.ktor.http.HttpStatusCode.Companion.NotFound
import okio.ByteString.Companion.encodeUtf8
class AccountAuthenticatorImpl(
private val appAuthKeyMessageSigner: AppAuthKeyMessageSigner,
private val authenticationService: AuthenticationService,
) : AccountAuthenticator {
override suspend fun appAuth(
f8eEnvironment: F8eEnvironment,
appAuthPublicKey: PublicKey<out AppAuthKey>,
authTokenScope: AuthTokenScope,
): Result<AuthData, AuthError> =
binding {
log(level = LogLevel.Debug) {
"Attempting to authenticate with app auth public key $appAuthPublicKey"
}
val signInResponse =
authenticationService
.initiateAuthentication(f8eEnvironment, appAuthPublicKey, authTokenScope)
.mapError { error ->
when (error) {
is HttpError.ClientError -> if (error.response.status == NotFound) {
AuthSignatureMismatch
} else {
AuthNetworkError("Could not sign in: ${error.message}", error)
}
else -> AuthNetworkError("Could not sign in: ${error.message}", error)
}
}
.bind()
val signature =
appAuthKeyMessageSigner
.signMessage(appAuthPublicKey, signInResponse.challenge.encodeUtf8())
.mapError { AuthProtocolError("Cannot sign message: ${it.message}", it) }.bind()
val authTokens =
respondToAuthChallenge(
f8eEnvironment,
signInResponse.username,
signInResponse.session,
signature
).bind()
AuthData(signInResponse.accountId, authTokens)
}
override suspend fun hwAuth(
f8eEnvironment: F8eEnvironment,
fullAccountId: FullAccountId,
session: String,
signature: String,
): Result<AccountAuthTokens, AuthError> {
return respondToAuthChallenge(f8eEnvironment, fullAccountId.serverId, session, signature)
}
private suspend fun respondToAuthChallenge(
f8eEnvironment: F8eEnvironment,
username: String,
session: String,
signature: String,
): Result<AccountAuthTokens, AuthError> {
return authenticationService
.completeAuthentication(f8eEnvironment, username, signature, session)
.mapError { AuthNetworkError("Cannot complete authentication: ${it.message}") }
}
}
| 0 | null | 6 | 98 | 1f9f2298919dac77e6791aa3f1dbfd67efe7f83c | 2,893 | bitkey | MIT License |
waltid-libraries/crypto/waltid-target-ios/src/iosMain/kotlin/id/walt/target/ios/keys/RSA.kt | walt-id | 701,058,624 | false | {"Kotlin": 3448224, "Vue": 474904, "TypeScript": 129086, "Swift": 40383, "JavaScript": 18819, "Ruby": 15159, "Dockerfile": 13118, "Python": 3114, "Shell": 1783, "Objective-C": 388, "CSS": 345, "C": 104} | package id.walt.target.ios.keys
import id.walt.platform.utils.ios.DS_Operations
import id.walt.platform.utils.ios.RSAKeyUtils
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.decodeFromJsonElement
import kotlinx.serialization.json.jsonObject
import platform.Foundation.CFBridgingRelease
import platform.Security.SecKeyRef
import kotlin.io.encoding.Base64
sealed class RSA {
sealed class PrivateKey : KeyRepresentation, Signing {
companion object {
fun createInKeychain(kid: String, size: UInt): PrivateKey {
deleteFromKeychain(kid)
KeychainOperations.RSA.create(kid, size)
return RSAPrivateKeyKeychain(kid)
}
fun loadFromKeychain(kid: String): PrivateKey {
KeychainOperations.RSA.load(kid)
return RSAPrivateKeyKeychain(kid)
}
fun deleteFromKeychain(kid: String) {
KeychainOperations.RSA.delete(kid)
}
}
abstract fun publicKey(): PublicKey
}
sealed class PublicKey : KeyRepresentation, Verification {
companion object {
fun fromJwk(jwk: String): PublicKey {
return RSAPublicKeyJwk(jwk)
}
}
internal abstract fun <T> publicSecKey(block: (SecKeyRef?) -> T): T
override fun thumbprint(): String {
return publicSecKey {
RSAKeyUtils.thumbprintWithPublicKey(it, null)!!
}
}
override fun externalRepresentation(): ByteArray {
return publicSecKey {
KeychainOperations.keyExternalRepresentation(it)
}
}
override fun pem(): String = externalRepresentation().let {
Base64.encode(it)
}
override fun verifyJws(jws: String): Result<JsonObject> {
return publicSecKey {
val result = DS_Operations.verifyWithJws(jws, it)
check(result.success()) {
result.errorMessage()!!
}
result.isValidData()!!.toByteArray().let {
Json.parseToJsonElement(it.decodeToString())
}.let {
Result.success(it.jsonObject)
}
}
}
override fun verifyRaw(signature: ByteArray, signedData: ByteArray): Result<ByteArray> {
return publicSecKey {
KeychainOperations.RSA.verifyRaw(it, signature, signedData)
}
}
}
}
internal class RSAPrivateKeyKeychain(private val kid: String) : RSA.PrivateKey() {
override fun publicKey(): RSA.PublicKey = RSAPublicKeyKeychain(kid)
override fun jwk(): JsonObject {
error("RSAPrivateKeyKeychain::jwk() - Not yet implemented")
}
override fun thumbprint(): String {
error("RSAPrivateKeyKeychain::thumbprint() - Not yet implemented")
}
override fun pem(): String {
error("RSAPrivateKeyKeychain::pem() - Not yet implemented")
}
override fun kid(): String = kid
override fun externalRepresentation(): ByteArray {
return KeychainOperations.RSA.withPrivateKey(kid) {
KeychainOperations.keyExternalRepresentation(it)
}
}
override fun signJws(plainText: ByteArray, headers: Map<String, JsonElement>): String {
return KeychainOperations.RSA.withPrivateKey(kid) {
val result = DS_Operations.signWithBody(
plainText.toNSData(), "RS256", it, headersData = JsonObject(headers).toString().toNSData()
)
check(result.success()) {
result.errorMessage()!!
}
result.data()!!
}
}
override fun signRaw(plainText: ByteArray): ByteArray {
return KeychainOperations.RSA.signRaw(kid, plainText)
}
}
internal class RSAPublicKeyKeychain(private val kid: String) : RSA.PublicKey() {
override fun <T> publicSecKey(block: (SecKeyRef?) -> T): T {
return KeychainOperations.RSA.withPublicKey(kid) {
block(it)
}
}
override fun jwk(): JsonObject {
return KeychainOperations.RSA.withPublicKey(kid) {
RSAKeyUtils.exportJwkWithPublicKey(it, null)
}.let {
Json.parseToJsonElement(it!!).jsonObject
}
}
override fun kid(): String = kid
}
internal class RSAPublicKeyJwk(private val jwk: String) : RSA.PublicKey() {
private val json = Json {
ignoreUnknownKeys = true
}
private val _jwk by lazy { json.decodeFromJsonElement<Jwk>(jwk()) }
@Serializable
internal data class Jwk(var kid: String? = null)
override fun <T> publicSecKey(block: (SecKeyRef?) -> T): T {
val secKeyRef = RSAKeyUtils.publicJwkToSecKeyWithJwk(jwk, error = null)
return try {
block(secKeyRef)
} finally {
CFBridgingRelease(secKeyRef)
}
}
override fun jwk(): JsonObject {
return Json.parseToJsonElement(jwk).jsonObject
}
override fun kid(): String? {
return _jwk.kid
}
} | 20 | Kotlin | 46 | 121 | 48c6b8cfef532e7e837db0bdb39ba64def985568 | 5,284 | waltid-identity | Apache License 2.0 |
core/jvmTest/src/kotlinx/serialization/SerializationMethodInvocationOrderTest.kt | Kotlin | 97,827,246 | false | null | /*
* Copyright 2017-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package kotlinx.serialization
import org.junit.*
// Serializable data class
@Serializable
data class Container(val data: Data)
class SerializationMethodInvocationOrderTest {
@Test
fun testRec() {
val out = Out()
out.encode(Container::class.serializer(), Container(Data("s1", 42)))
out.done()
val inp = Inp()
inp.decode(Container::class.serializer())
inp.done()
}
companion object {
fun fail(msg: String): Nothing = throw RuntimeException(msg)
fun checkContainerDesc(desc: SerialDescriptor) {
if (desc.name != "kotlinx.serialization.Container") fail("checkContainerDesc name $desc")
if (desc.getElementName(0) != "data") fail("checkContainerDesc $desc")
}
fun checkDataDesc(desc: SerialDescriptor) {
if (desc.name != "kotlinx.serialization.Data") fail("checkDataDesc name $desc")
if (desc.getElementName(0) != "value1") fail("checkDataDesc.0 $desc")
if (desc.getElementName(1) != "value2") fail("checkDataDesc.1 $desc")
}
}
class Out : ElementValueEncoder() {
var step = 0
override fun beginStructure(desc: SerialDescriptor, vararg typeParams: KSerializer<*>): CompositeEncoder {
when(step) {
1 -> { checkContainerDesc(desc); step++; return this }
4 -> { checkDataDesc(desc); step++; return this }
}
fail("@$step: beginStructure($desc)")
}
override fun encodeElement(desc: SerialDescriptor, index: Int): Boolean {
when (step) {
2 -> { checkContainerDesc(desc); if (index == 0) { step++; return true } }
5 -> { checkDataDesc(desc); if (index == 0) { step++; return true } }
7 -> { checkDataDesc(desc); if (index == 1) { step++; return true } }
}
fail("@$step: encodeElement($desc, $index)")
}
override fun <T : Any?> encodeSerializableValue(serializer: SerializationStrategy<T>, value: T) {
when (step) {
0, 3 -> { step++; serializer.serialize(this, value); return }
}
fail("@$step: encodeSerializableValue($value)")
}
override fun encodeString(value: String) {
when (step) {
6 -> if (value == "s1") { step++; return }
}
fail("@$step: encodeString($value)")
}
override fun encodeInt(value: Int) {
when (step) {
8 -> if (value == 42) { step++; return }
}
fail("@$step: decodeInt($value)")
}
override fun endStructure(desc: SerialDescriptor) {
when(step) {
9 -> { checkDataDesc(desc); step++; return }
10 -> { checkContainerDesc(desc); step++; return }
}
fail("@$step: endStructure($desc)")
}
fun done() {
if (step != 11) fail("@$step: OUT FAIL")
}
}
class Inp : ElementValueDecoder() {
var step = 0
override fun beginStructure(desc: SerialDescriptor, vararg typeParams: KSerializer<*>): CompositeDecoder {
when(step) {
1 -> { checkContainerDesc(desc); step++; return this }
4 -> { checkDataDesc(desc); step++; return this }
}
fail("@$step: beginStructure($desc)")
}
override fun decodeElementIndex(desc: SerialDescriptor): Int {
when (step) {
2 -> { checkContainerDesc(desc); step++; return 0 }
5 -> { checkDataDesc(desc); step++; return 0 }
7 -> { checkDataDesc(desc); step++; return 1 }
9 -> { checkDataDesc(desc); step++; return -1 }
11 -> { checkContainerDesc(desc); step++; return -1 }
}
fail("@$step: decodeElementIndex($desc)")
}
override fun <T : Any?> decodeSerializableValue(deserializer: DeserializationStrategy<T>): T {
when (step) {
0, 3 -> { step++; return deserializer.deserialize(this) }
}
fail("@$step: decodeSerializableValue()")
}
override fun decodeString(): String {
when (step) {
6 -> { step++; return "s1" }
}
fail("@$step: decodeString()")
}
override fun decodeInt(): Int {
when (step) {
8 -> { step++; return 42 }
}
fail("@$step: decodeInt()")
}
override fun endStructure(desc: SerialDescriptor) {
when(step) {
10 -> { checkDataDesc(desc); step++; return }
12 -> { checkContainerDesc(desc); step++; return }
}
fail("@$step: endStructure($desc)")
}
fun done() {
if (step != 13) fail("@$step: INP FAIL")
}
}
}
| 407 | null | 621 | 5,396 | d4d066d72a9f92f06c640be5a36a22f75d0d7659 | 5,098 | kotlinx.serialization | Apache License 2.0 |
spigot-core/src/main/kotlin/ru/astrainteractive/astralibs/utils/Permission.kt | Astra-Interactive | 422,588,271 | false | null | package ru.astrainteractive.astrashop.utils
import org.bukkit.command.CommandSender
import org.bukkit.entity.Player
interface IPermission {
val value: String
fun hasPermission(player: CommandSender) = player.hasPermission(value)
/**
* If has astra_template.damage.2 => returns 2
*/
fun permissionSize(player: Player) = player.effectivePermissions
.firstOrNull { it.permission.startsWith(value) }
?.permission
?.replace("$value.", "")
?.toIntOrNull()
} | 1 | null | 0 | 2 | edf18911e3b12c84975c8287e4f3eecba9396d04 | 512 | AstraLibs | MIT License |
player/app/src/main/java/uk/co/bbc/perceptivepodcasts/useractivity/UserActivityManager.kt | bbc | 532,884,049 | false | {"JavaScript": 1574746, "HTML": 501243, "Kotlin": 233361, "CSS": 8526, "Java": 797} | package uk.co.bbc.perceptivepodcasts.useractivity
import android.annotation.SuppressLint
import android.app.PendingIntent
import android.app.PendingIntent.FLAG_MUTABLE
import android.app.PendingIntent.FLAG_UPDATE_CURRENT
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.os.Build
import android.util.Log
import com.google.android.gms.location.*
import com.google.android.gms.location.ActivityTransition.ACTIVITY_TRANSITION_ENTER
import com.google.android.gms.location.ActivityTransition.ACTIVITY_TRANSITION_EXIT
import com.google.android.gms.location.DetectedActivity.*
import uk.co.bbc.perceptivepodcasts.getApp
private const val TAG = "UerActivity"
private const val REQUEST_CODE_INTENT_ACTIVITY_TRANSITION = 1
private const val REQUEST_CODE_INTENT_ACTIVITY = 2
private const val LAST_ACTIVITY_KEY = "lastActivity"
class ActivityTransitionReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if (ActivityTransitionResult.hasResult(intent)) {
val result = ActivityTransitionResult.extractResult(intent)
val enteringActivity = result?.transitionEvents?.find {
it.transitionType == ACTIVITY_TRANSITION_ENTER
}
enteringActivity?.let {
context.getApp().userActivityManager.onActivityEntered(it.activityType)
}
}
if(ActivityRecognitionResult.hasResult(intent)) {
val result = ActivityRecognitionResult.extractResult(intent)
val activity = result?.mostProbableActivity
activity?.let {
context.getApp().userActivityManager.onActivityEntered(it.type)
}
}
}
}
class UserActivityManager(private val context: Context,
private val storage: SharedPreferences) {
var lastActivityType: Int? = readLast()
private val client = ActivityRecognition.getClient(context)
private val appSettingsManager = context.getApp().appSettingsManager
private var permissionsConfirmed = false
private var enabled = false
init {
appSettingsManager.liveData.observeForever {
enabled = it.userActivityMonitoringEnabled
if(enabled && permissionsConfirmed) {
start()
} else {
stop()
}
}
}
fun onPermissionConfirmed() {
permissionsConfirmed = true
if(enabled) {
start()
}
}
private fun start() {
requestForUpdates()
}
private fun stop() {
deregisterForUpdates()
}
@SuppressLint("MissingPermission")
private fun requestForUpdates() {
Log.d(TAG, "Starting UserActivity monitoring")
val request = ActivityTransitionRequest(getTransitions())
val transitionPendingIntent = getPendingIntent(REQUEST_CODE_INTENT_ACTIVITY_TRANSITION)
client.requestActivityTransitionUpdates(request, transitionPendingIntent)
.addOnFailureListener { e -> e.printStackTrace() }
val activityPendingIntent = getPendingIntent(REQUEST_CODE_INTENT_ACTIVITY)
client.requestActivityUpdates(500, activityPendingIntent)
.addOnFailureListener { e -> e.printStackTrace() }
}
@SuppressLint("MissingPermission")
private fun deregisterForUpdates() {
Log.d(TAG, "Stopping UserActivity monitoring")
val transitionPendingIntent = getPendingIntent(REQUEST_CODE_INTENT_ACTIVITY_TRANSITION)
client.removeActivityTransitionUpdates(transitionPendingIntent)
.addOnFailureListener { e -> e.printStackTrace() }
val activityPendingIntent = getPendingIntent(REQUEST_CODE_INTENT_ACTIVITY)
client.removeActivityTransitionUpdates(activityPendingIntent)
.addOnFailureListener { e -> e.printStackTrace() }
}
private fun getPendingIntent(requestCode: Int): PendingIntent {
val intent = Intent(context, ActivityTransitionReceiver::class.java)
val flags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
// See: https://stackoverflow.com/questions/69862244/android-activityrecognition-and-immutable-pendingintent
FLAG_UPDATE_CURRENT or FLAG_MUTABLE
} else {
FLAG_UPDATE_CURRENT
}
return PendingIntent.getBroadcast(context, requestCode, intent, flags)
}
fun onActivityEntered(activityType: Int) {
Log.d(TAG, "Activity started: ${activityType.toActivityString()}")
lastActivityType = activityType
storage.edit().putInt(LAST_ACTIVITY_KEY, activityType).apply()
}
private fun readLast(): Int? {
return if(storage.contains(LAST_ACTIVITY_KEY)) {
storage.getInt(LAST_ACTIVITY_KEY, UNKNOWN)
} else {
null
}
}
}
private fun getTransitions(): List<ActivityTransition> {
return listOf(
activityTransition(IN_VEHICLE, ACTIVITY_TRANSITION_ENTER),
activityTransition(IN_VEHICLE, ACTIVITY_TRANSITION_EXIT),
activityTransition(WALKING, ACTIVITY_TRANSITION_ENTER),
activityTransition(WALKING, ACTIVITY_TRANSITION_EXIT),
activityTransition(STILL, ACTIVITY_TRANSITION_ENTER),
activityTransition(STILL, ACTIVITY_TRANSITION_EXIT),
activityTransition(RUNNING, ACTIVITY_TRANSITION_ENTER),
activityTransition(RUNNING, ACTIVITY_TRANSITION_EXIT)
)
}
private fun activityTransition(type: Int, transition: Int) = ActivityTransition.Builder()
.setActivityType(type)
.setActivityTransition(transition)
.build()
| 6 | JavaScript | 0 | 19 | 4f710ad459cc8dd23f2a5e702fdc6c340892a967 | 5,694 | adaptivepodcasting | Apache License 2.0 |
scientific/src/commonMain/kotlin/converter/areaDensity/convertToDensity.kt | splendo | 191,371,940 | false | null | /*
Copyright 2021 Splendo Consulting B.V. The Netherlands
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
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.splendo.kaluga.scientific.converter.areaDensity
import com.splendo.kaluga.scientific.PhysicalQuantity
import com.splendo.kaluga.scientific.ScientificValue
import com.splendo.kaluga.scientific.converter.area.times
import com.splendo.kaluga.scientific.converter.density.density
import com.splendo.kaluga.scientific.invoke
import com.splendo.kaluga.scientific.unit.AreaDensity
import com.splendo.kaluga.scientific.unit.CubicMeter
import com.splendo.kaluga.scientific.unit.ImperialAreaDensity
import com.splendo.kaluga.scientific.unit.ImperialLength
import com.splendo.kaluga.scientific.unit.Kilogram
import com.splendo.kaluga.scientific.unit.Length
import com.splendo.kaluga.scientific.unit.MetricAreaDensity
import com.splendo.kaluga.scientific.unit.MetricLength
import com.splendo.kaluga.scientific.unit.UKImperialAreaDensity
import com.splendo.kaluga.scientific.unit.USCustomaryAreaDensity
import com.splendo.kaluga.scientific.unit.per
import kotlin.jvm.JvmName
@JvmName("metricAreaDensityDivMetricLength")
infix operator fun <LengthUnit : MetricLength> ScientificValue<PhysicalQuantity.AreaDensity, MetricAreaDensity>.div(
length: ScientificValue<PhysicalQuantity.Length, LengthUnit>
) = (unit.weight per (1(unit.per) * 1(length.unit)).unit).density(this, length)
@JvmName("imperialAreaDensityDivImperialLength")
infix operator fun <LengthUnit : ImperialLength> ScientificValue<PhysicalQuantity.AreaDensity, ImperialAreaDensity>.div(
length: ScientificValue<PhysicalQuantity.Length, LengthUnit>
) = (unit.weight per (1(unit.per) * 1(length.unit)).unit).density(this, length)
@JvmName("ukImperialAreaDensityDivImperialLength")
infix operator fun <LengthUnit : ImperialLength> ScientificValue<PhysicalQuantity.AreaDensity, UKImperialAreaDensity>.div(
length: ScientificValue<PhysicalQuantity.Length, LengthUnit>
) = (unit.weight per (1(unit.per) * 1(length.unit)).unit).density(this, length)
@JvmName("usCustomaryAreaDensityDivImperialLength")
infix operator fun <LengthUnit : ImperialLength> ScientificValue<PhysicalQuantity.AreaDensity, USCustomaryAreaDensity>.div(
length: ScientificValue<PhysicalQuantity.Length, LengthUnit>
) = (unit.weight per (1(unit.per) * 1(length.unit)).unit).density(this, length)
@JvmName("areaDensityDivLength")
infix operator fun <AreaDensityUnit : AreaDensity, LengthUnit : Length> ScientificValue<PhysicalQuantity.AreaDensity, AreaDensityUnit>.div(
length: ScientificValue<PhysicalQuantity.Length, LengthUnit>
) = (Kilogram per CubicMeter).density(this, length)
| 91 | null | 7 | 93 | cd0f3a583efb69464aa020d206f598c6d15a0899 | 3,156 | kaluga | Apache License 2.0 |
components/discovery/src/main/kotlin/io/barinek/continuum/discovery/InstanceRecord.kt | initialcapacity | 130,564,725 | false | {"Kotlin": 97259} | package io.barinek.continuum.discovery
data class InstanceRecord(val appId: String, val url: String) | 0 | Kotlin | 40 | 86 | c895096890c251b75d6f6f369890c89aaca83791 | 101 | application-continuum | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.