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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
app/src/main/java/com/fanrong/frwallet/dapp/walletconnect/page/ConnectedFragment.kt | iamprivatewallet | 464,003,911 | false | {"JavaScript": 2822760, "Kotlin": 1140535, "Java": 953177, "HTML": 17003} | package com.fanrong.frwallet.dapp.walletconnect.page
import android.view.View
import com.fanrong.frwallet.R
import com.fanrong.frwallet.dapp.walletconnect.WalletConnectUtil
import com.fanrong.frwallet.tools.extFormatAddr
import kotlinx.android.synthetic.main.wc_fragment_connected.*
import xc.common.framework.ui.base.BaseFragment
import xc.common.kotlinext.extFinishWithAnim
import xc.common.tool.ext.extHasDefault
class ConnectedFragment : BaseFragment() {
override fun getLayoutId(): Int {
return R.layout.wc_fragment_connected
}
override fun initView() {
var wallet = WalletConnectUtil.getWalletNotNull()
tv_wallet_addr.setText(wallet.address.extFormatAddr())
tv_wallet_name.setText("(${wallet.walletName.extHasDefault(wallet.chainType!!)})")
tv_url.setText(WalletConnectUtil.dappPeerMeta?.url)
tv_disconnect.setOnClickListener {
WalletConnectUtil.session.kill()
extFinishWithAnim()
}
}
override fun loadData() {
}
override fun onNoShakeClick(v: View) {
}
} | 0 | JavaScript | 0 | 1 | be8003e419afbe0429f2eb3fd757866e2e4b9152 | 1,081 | PrivateWallet.Android | MIT License |
src/main/kotlin/org/uevola/jsonautovalidation/core/validators/DefaultJsonSchemaValidator.kt | ugoevola | 646,607,242 | false | {"Kotlin": 73345} | package org.uevola.jsonautovalidation.core.validators
import org.json.JSONObject
import org.springframework.cache.annotation.Cacheable
import org.springframework.stereotype.Component
import org.uevola.jsonautovalidation.utils.Util
import org.uevola.jsonautovalidation.utils.annotations.jsonValidationAnnotation.IsJsonValidation
import org.uevola.jsonautovalidation.core.strategies.schemaGenerators.JsonSchemaGeneratorStrategy
import java.lang.reflect.Parameter
@Component
class DefaultJsonSchemaValidator(
private val jsonGenerationStrategies: Set<JsonSchemaGeneratorStrategy>
) : AbstractValidator() {
fun validate(parameter: Parameter, json: String) =
validate(json, emptyMap(), getSchema(parameter).toString())
@Cacheable
fun getSchema(parameter: Parameter): JSONObject? {
val annotations = parameter.annotations
.filter { annotation -> annotation.annotationClass.annotations.any { it is IsJsonValidation } }
val value = annotations.map { annotation ->
jsonGenerationStrategies.sortedBy { it.getOrdered() }.find { it.resolve(annotation) }
?.generate(annotation, parameter)
}.fold(JSONObject()) { acc, jsonObject ->
Util.mergeJSONObject(acc, jsonObject)
acc
}
if (value.isEmpty) return null
val json = JSONObject()
json.put(parameter.name, value)
return json
}
} | 0 | Kotlin | 0 | 0 | edd264448997bd498f172df66542cf2381e67c53 | 1,425 | json-auto-validation | MIT License |
px-addons/src/test/java/com/mercadopago/android/px/addons/ThreeDSDefaultBehaviourTest.kt | mercadopago | 49,529,486 | false | null | package com.mercadopago.android.px.addons
import org.junit.Assert.assertNull
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.junit.MockitoJUnitRunner
@RunWith(MockitoJUnitRunner::class)
class ThreeDSDefaultBehaviourTest {
@Test
fun testThreeDSDefaultBehaviour() {
assertNull(BehaviourProvider.getThreeDSBehaviour().getAuthenticationParameters())
}
} | 38 | null | 69 | 94 | f5cfa00ea5963f9153a237c3f329af5d2d6cd87f | 397 | px-android | MIT License |
src/main/kotlin/com/pollux/repository/DatabaseFactory.kt | k-arabadzhiev | 378,814,412 | false | null | package com.pollux.repository
import com.pollux.repository.tables.*
import com.zaxxer.hikari.HikariConfig
import com.zaxxer.hikari.HikariDataSource
import kotlinx.coroutines.Dispatchers
import org.jetbrains.exposed.sql.Database.Companion.connect
import org.jetbrains.exposed.sql.SchemaUtils
import org.jetbrains.exposed.sql.StdOutSqlLogger
import org.jetbrains.exposed.sql.addLogger
import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransaction
import org.jetbrains.exposed.sql.transactions.transaction
object DatabaseFactory {
private val config = HikariConfig("/hikari.properties")
fun initDB() {
val ds = HikariDataSource(config)
transaction(connect(ds)) {
SchemaUtils.create(
AnimalTable,
AnimalDetailsTable,
SpeciesTable,
ZookeeperTable,
HabitatTable,
DietTable
)
}
}
suspend fun <T> dbQuery(block: suspend () -> T): T =
newSuspendedTransaction(Dispatchers.IO) {
addLogger(StdOutSqlLogger)
block()
}
} | 0 | Kotlin | 1 | 0 | f6f2db864f4fd796e713da69bf2447fe1d4c3c28 | 1,132 | Digital-Zoo-REST-API | MIT License |
src/test/kotlin/codes/monkey/tictactoe/ScreenSpec.kt | monkey-codes | 647,581,768 | false | null | package codes.monkey.tictactoe
import arrow.core.Either
import arrow.core.left
import arrow.core.raise.either
import arrow.core.right
import codes.monkey.tictactoe.Symbol.NOUGHT
import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.collections.shouldHaveSize
import io.kotest.matchers.string.shouldContain
class ScreenSpec :
StringSpec({
"should handle in progress games" {
either {
val (_, context) = simulateGame().bind()
context shouldMatchScreen
{
"""
| - - -
| - - -
| - - -
|
|move for CROSS (eg: 0 0) :
"""
}
}
}
"should handle won games" {
either {
val (_, context) =
simulateGame { """
|x0 o1 __
|x6 o3 o5
|x2 __ x4""" }
.bind()
context shouldMatchScreen
{
"""
| x o -
| x o o
| x - x
|x Won
|Ctrl-C to quit or enter for a new game:
"""
}
}
}
"should handle drawn games" {
either {
val (_, context) =
simulateGame { """
|x0 o1 x2
|o3 x4 x6
|o7 x8 o5""" }
.bind()
context shouldMatchScreen
{
"""
| x o x
| o x x
| o x o
|Draw
|Ctrl-C to quit or enter for a new game:
"""
}
}
}
"should handle error states" {
either {
val programState = Pair(Game.new().bind(), NotPlayersTurn(NOUGHT))
val io = IOs.gameScreen(programState.left())
val (_, context) = interpret(io)
context shouldMatchScreen
{
"""
| - - -
| - - -
| - - -
|NotPlayersTurn
|move for CROSS (eg: 0 0) :
"""
}
}
}
})
fun <A> interpret(io: IO<A>, vararg inputValues: String): Pair<A, TestInterpreterContext> =
with(TestInterpreterContext(*inputValues)) { Interpreter.run(io, this) to this }
infix fun TestInterpreterContext.shouldMatchScreen(f: () -> String) {
this.outputs shouldHaveSize 1
val expected = f().trimIndent().trimMargin()
outputs.first() shouldContain expected
}
fun simulateGame(
f: () -> String? = { null }
): Either<GameError, Pair<ProgramState, TestInterpreterContext>> {
return either {
val moves = f()?.toMoveList()?.bind().orEmpty()
val game = Game.new().bind().make(moves).bind()
val io = IOs.gameScreen(game.right())
interpret(io)
}
}
| 0 | Kotlin | 0 | 0 | 2910bf641106fe63f38ce74b73cf0f2eb741cd0b | 2,927 | fp-kotlin-tictactoe | MIT License |
composeApp/src/commonMain/kotlin/ru/slartus/boostbuddy/ui/common/BottomView.kt | slartus | 767,913,639 | false | {"Kotlin": 299148, "Swift": 1264} | package ru.slartus.boostbuddy.ui.common
import androidx.compose.foundation.layout.Column
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.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
@Composable
internal fun BottomView(
title: String,
content: @Composable () -> Unit
) {
Column(Modifier) {
Text(
modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp),
text = title,
style = MaterialTheme.typography.titleLarge
)
Spacer(Modifier.height(16.dp))
content()
Spacer(Modifier.height(16.dp))
}
} | 0 | Kotlin | 2 | 11 | 5d5c65497c094bf2a213be34bd3c346a6afa53a0 | 899 | BoostBuddy | Apache License 2.0 |
core/ui/src/commonMain/kotlin/dev/alvr/katana/core/ui/utils/utils.kt | alvr | 446,535,707 | false | {"Kotlin": 466639, "Swift": 594} | package dev.alvr.katana.core.ui.utils
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass
import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass
import androidx.compose.runtime.Composable
import androidx.lifecycle.compose.LocalLifecycleOwner
import androidx.lifecycle.compose.dropUnlessResumed
import androidx.navigation.NavDeepLink
import coil3.compose.LocalPlatformContext
import coil3.request.ImageRequest
val WindowInsets.Companion.noInsets: WindowInsets
get() = WindowInsets(0)
@Composable
@OptIn(ExperimentalMaterial3WindowSizeClassApi::class)
fun isLandscape() = calculateWindowSizeClass().widthSizeClass > WindowWidthSizeClass.Medium
@Composable
fun doNavigation(onNavigation: () -> Unit) = dropUnlessResumed(LocalLifecycleOwner.current, onNavigation)
fun navDeepLink(deepLinkBuilder: NavDeepLink.Builder.() -> Unit): NavDeepLink =
NavDeepLink.Builder().apply(deepLinkBuilder).build()
@Composable
fun imageRequest(builder: ImageRequest.Builder.() -> Unit) =
ImageRequest.Builder(LocalPlatformContext.current)
.apply(builder)
.build()
| 2 | Kotlin | 0 | 59 | cff6ed544165beb5cb730ebb558fda94f216bab6 | 1,260 | katana | Apache License 2.0 |
app/src/main/java/com/holiday/data/repository/HolidayPreferenceRepositoryImpl.kt | kelvinkioko | 595,959,798 | false | null | package com.holiday.data.repository
import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.edit
import androidx.datastore.preferences.core.emptyPreferences
import androidx.datastore.preferences.core.intPreferencesKey
import androidx.datastore.preferences.core.stringPreferencesKey
import com.holiday.domain.repository.HolidayPreferenceRepository
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.firstOrNull
import kotlinx.coroutines.flow.map
import java.io.IOException
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class HolidayPreferenceRepositoryImpl @Inject constructor(
private val holidayPreferences: DataStore<Preferences>
) : HolidayPreferenceRepository {
override suspend fun setCountry(countryCode: String) {
Result.runCatching {
holidayPreferences.edit { preferences ->
preferences[COUNTRY_CODE] = countryCode
}
}
}
override suspend fun getCountry(): Result<String> {
return Result.runCatching {
val flow = holidayPreferences.data
.catch { exception ->
if (exception is IOException) {
emit(emptyPreferences())
} else {
throw exception
}
}
.map { preferences ->
preferences[COUNTRY_CODE]
}
val countryCode = flow.firstOrNull() ?: ""
countryCode
}
}
override suspend fun setYear(year: Int) {
Result.runCatching {
holidayPreferences.edit { preferences ->
preferences[YEAR_CODE] = year
}
}
}
override suspend fun getYear(): Result<Int> {
return Result.runCatching {
val flow = holidayPreferences.data
.catch { exception ->
if (exception is IOException) {
emit(emptyPreferences())
} else {
throw exception
}
}
.map { preferences ->
preferences[YEAR_CODE]
}
val countryCode = flow.firstOrNull() ?: 0
countryCode
}
}
private companion object {
val COUNTRY_CODE = stringPreferencesKey(name = "country_code")
val YEAR_CODE = intPreferencesKey(name = "year_code")
}
}
| 0 | Kotlin | 0 | 0 | 183d6e084e1803f8ea818697885fa0c51027aa2d | 2,560 | Public-Holiday | Apache License 2.0 |
app/src/main/java/com/anibalventura/flagsquiz/data/local/Flags.kt | anibalventura | 291,282,037 | false | null | package com.anibalventura.flagsquiz.data.local
import com.anibalventura.flagsquiz.R
import com.anibalventura.flagsquiz.Utils
// Resources working.
val utils = Utils.resourses!!
/*
* All the data for every question in the quiz.
*/
data class Flags(
val image: Int,
var answers: List<String>
)
/*
* Africa continent.
*/
object Africa {
fun getFlags(): MutableList<Flags> {
return mutableListOf(
Flags(
R.drawable.af_algeria_flag,
listOf(
utils.getString(R.string.country_af_algeria),
utils.getString(R.string.country_af_angola),
utils.getString(R.string.country_af_zimbabwe),
utils.getString(R.string.country_af_tunisia)
)
),
Flags(
R.drawable.af_angola_flag,
listOf(
utils.getString(R.string.country_af_angola),
utils.getString(R.string.country_af_swaziland),
utils.getString(R.string.country_af_tanzania),
utils.getString(R.string.country_af_south_sudan)
)
),
Flags(
R.drawable.af_benin_flag,
listOf(
utils.getString(R.string.country_af_benin),
utils.getString(R.string.country_af_zimbabwe),
utils.getString(R.string.country_af_senegal),
utils.getString(R.string.country_af_angola)
)
),
Flags(
R.drawable.af_botswana_flag,
listOf(
utils.getString(R.string.country_af_botswana),
utils.getString(R.string.country_af_tunisia),
utils.getString(R.string.country_af_swaziland),
utils.getString(R.string.country_af_south_sudan)
)
),
Flags(
R.drawable.af_burkina_faso_flag,
listOf(
utils.getString(R.string.country_af_burkina_faso),
utils.getString(R.string.country_af_zimbabwe),
utils.getString(R.string.country_af_lesotho),
utils.getString(R.string.country_af_algeria)
)
),
Flags(
R.drawable.af_burundi_flag,
listOf(
utils.getString(R.string.country_af_burundi),
utils.getString(R.string.country_af_zimbabwe),
utils.getString(R.string.country_af_swaziland),
utils.getString(R.string.country_af_libya)
)
),
Flags(
R.drawable.af_cameroon_flag,
listOf(
utils.getString(R.string.country_af_cameroon),
utils.getString(R.string.country_af_angola),
utils.getString(R.string.country_af_burkina_faso),
utils.getString(R.string.country_af_tunisia)
)
),
Flags(
R.drawable.af_cape_verde_flag,
listOf(
utils.getString(R.string.country_af_cape_verde),
utils.getString(R.string.country_af_zimbabwe),
utils.getString(R.string.country_af_swaziland),
utils.getString(R.string.country_af_senegal)
)
),
Flags(
R.drawable.af_central_african_republic_flag,
listOf(
utils.getString(R.string.country_af_central_african_republic),
utils.getString(R.string.country_af_botswana),
utils.getString(R.string.country_af_burkina_faso),
utils.getString(R.string.country_af_zimbabwe)
)
),
Flags(
R.drawable.af_chad_flag,
listOf(
utils.getString(R.string.country_af_chad),
utils.getString(R.string.country_af_algeria),
utils.getString(R.string.country_af_tunisia),
utils.getString(R.string.country_af_tanzania)
)
),
Flags(
R.drawable.af_comoros_flag,
listOf(
utils.getString(R.string.country_af_comoros),
utils.getString(R.string.country_af_burkina_faso),
utils.getString(R.string.country_af_swaziland),
utils.getString(R.string.country_af_zimbabwe)
)
),
Flags(
R.drawable.af_congo_democratic_republic_of_the_flag,
listOf(
utils.getString(R.string.country_af_democatic_republic_congo),
utils.getString(R.string.country_af_senegal),
utils.getString(R.string.country_af_angola),
utils.getString(R.string.country_af_tunisia)
)
),
Flags(
R.drawable.af_congo_republic_of_the_flag,
listOf(
utils.getString(R.string.country_af_republic_congo),
utils.getString(R.string.country_af_zimbabwe),
utils.getString(R.string.country_af_burkina_faso),
utils.getString(R.string.country_af_cote_d_ivoire)
)
),
Flags(
R.drawable.af_cote_d_ivoire_flag,
listOf(
utils.getString(R.string.country_af_cote_d_ivoire),
utils.getString(R.string.country_af_botswana),
utils.getString(R.string.country_af_algeria),
utils.getString(R.string.country_af_zimbabwe)
)
),
Flags(
R.drawable.af_djibouti_flag,
listOf(
utils.getString(R.string.country_af_djibouti),
utils.getString(R.string.country_af_burkina_faso),
utils.getString(R.string.country_af_tunisia),
utils.getString(R.string.country_af_angola)
)
),
Flags(
R.drawable.af_egypt_flag,
listOf(
utils.getString(R.string.country_af_egypt),
utils.getString(R.string.country_af_senegal),
utils.getString(R.string.country_af_zimbabwe),
utils.getString(R.string.country_af_burkina_faso)
)
),
Flags(
R.drawable.af_equatorial_guinea_flag,
listOf(
utils.getString(R.string.country_af_equatorial_guinea),
utils.getString(R.string.country_af_lesotho),
utils.getString(R.string.country_af_burkina_faso),
utils.getString(R.string.country_af_tunisia)
)
),
Flags(
R.drawable.af_eritrea_flag,
listOf(
utils.getString(R.string.country_af_eritrea),
utils.getString(R.string.country_af_angola),
utils.getString(R.string.country_af_zimbabwe),
utils.getString(R.string.country_af_tanzania)
)
),
Flags(
R.drawable.af_ethiopia_flag,
listOf(
utils.getString(R.string.country_af_ethiopia),
utils.getString(R.string.country_af_algeria),
utils.getString(R.string.country_af_equatorial_guinea),
utils.getString(R.string.country_af_burkina_faso)
)
),
Flags(
R.drawable.af_gabon_flag,
listOf(
utils.getString(R.string.country_af_gabon),
utils.getString(R.string.country_af_angola),
utils.getString(R.string.country_af_zimbabwe),
utils.getString(R.string.country_af_botswana)
)
),
Flags(
R.drawable.af_gambia_flag,
listOf(
utils.getString(R.string.country_af_gambia),
utils.getString(R.string.country_af_burkina_faso),
utils.getString(R.string.country_af_angola),
utils.getString(R.string.country_af_ethiopia)
)
),
Flags(
R.drawable.af_ghana_flag,
listOf(
utils.getString(R.string.country_af_ghana),
utils.getString(R.string.country_af_zimbabwe),
utils.getString(R.string.country_af_libya),
utils.getString(R.string.country_af_gambia)
)
),
Flags(
R.drawable.af_guinea_bissau_flag,
listOf(
utils.getString(R.string.country_af_guinea_bissau),
utils.getString(R.string.country_af_equatorial_guinea),
utils.getString(R.string.country_af_algeria),
utils.getString(R.string.country_af_zimbabwe)
)
),
Flags(
R.drawable.af_guinea_flag,
listOf(
utils.getString(R.string.country_af_guinea),
utils.getString(R.string.country_af_ethiopia),
utils.getString(R.string.country_af_gambia),
utils.getString(R.string.country_af_angola)
)
),
Flags(
R.drawable.af_kenya_flag,
listOf(
utils.getString(R.string.country_af_kenya),
utils.getString(R.string.country_af_lesotho),
utils.getString(R.string.country_af_botswana),
utils.getString(R.string.country_af_gambia)
)
),
Flags(
R.drawable.af_lesotho_flag,
listOf(
utils.getString(R.string.country_af_lesotho),
utils.getString(R.string.country_af_kenya),
utils.getString(R.string.country_af_ethiopia),
utils.getString(R.string.country_af_gambia)
)
),
Flags(
R.drawable.af_liberia_flag,
listOf(
utils.getString(R.string.country_af_liberia),
utils.getString(R.string.country_af_equatorial_guinea),
utils.getString(R.string.country_af_kenya),
utils.getString(R.string.country_af_algeria)
)
),
Flags(
R.drawable.af_libya_flag,
listOf(
utils.getString(R.string.country_af_libya),
utils.getString(R.string.country_af_angola),
utils.getString(R.string.country_af_gambia),
utils.getString(R.string.country_af_tanzania)
)
),
Flags(
R.drawable.af_madagascar_flag,
listOf(
utils.getString(R.string.country_af_madagascar),
utils.getString(R.string.country_af_ethiopia),
utils.getString(R.string.country_af_gambia),
utils.getString(R.string.country_af_kenya)
)
),
Flags(
R.drawable.af_malawi_flag,
listOf(
utils.getString(R.string.country_af_malawi),
utils.getString(R.string.country_af_lesotho),
utils.getString(R.string.country_af_equatorial_guinea),
utils.getString(R.string.country_af_kenya)
)
),
Flags(
R.drawable.af_mali_flag,
listOf(
utils.getString(R.string.country_af_mali),
utils.getString(R.string.country_af_ethiopia),
utils.getString(R.string.country_af_botswana),
utils.getString(R.string.country_af_algeria)
)
),
Flags(
R.drawable.af_mauritania_flag,
listOf(
utils.getString(R.string.country_af_mauritania),
utils.getString(R.string.country_af_angola),
utils.getString(R.string.country_af_kenya),
utils.getString(R.string.country_af_libya)
)
),
Flags(
R.drawable.af_mauritius_flag,
listOf(
utils.getString(R.string.country_af_mauritius),
utils.getString(R.string.country_af_ethiopia),
utils.getString(R.string.country_af_gambia),
utils.getString(R.string.country_af_kenya)
)
),
Flags(
R.drawable.af_morocco_flag,
listOf(
utils.getString(R.string.country_af_morocco),
utils.getString(R.string.country_af_equatorial_guinea),
utils.getString(R.string.country_af_angola),
utils.getString(R.string.country_af_cote_d_ivoire)
)
),
Flags(
R.drawable.af_mozambique_flag,
listOf(
utils.getString(R.string.country_af_mozambique),
utils.getString(R.string.country_af_gambia),
utils.getString(R.string.country_af_algeria),
utils.getString(R.string.country_af_kenya)
)
),
Flags(
R.drawable.af_namibia_flag,
listOf(
utils.getString(R.string.country_af_namibia),
utils.getString(R.string.country_af_morocco),
utils.getString(R.string.country_af_gambia),
utils.getString(R.string.country_af_angola)
)
),
Flags(
R.drawable.af_niger_flag,
listOf(
utils.getString(R.string.country_af_niger),
utils.getString(R.string.country_af_ethiopia),
utils.getString(R.string.country_af_botswana),
utils.getString(R.string.country_af_niger)
)
),
Flags(
R.drawable.af_nigeria_flag,
listOf(
utils.getString(R.string.country_af_nigeria),
utils.getString(R.string.country_af_morocco),
utils.getString(R.string.country_af_algeria),
utils.getString(R.string.country_af_equatorial_guinea)
)
),
Flags(
R.drawable.af_rwanda_flag,
listOf(
utils.getString(R.string.country_af_rwanda),
utils.getString(R.string.country_af_niger),
utils.getString(R.string.country_af_lesotho),
utils.getString(R.string.country_af_angola)
)
),
Flags(
R.drawable.af_sao_tome_and_principe_flag,
listOf(
utils.getString(R.string.country_af_sao_tome_principe),
utils.getString(R.string.country_af_morocco),
utils.getString(R.string.country_af_niger),
utils.getString(R.string.country_af_libya)
)
),
Flags(
R.drawable.af_senegal_flag,
listOf(
utils.getString(R.string.country_af_senegal),
utils.getString(R.string.country_af_equatorial_guinea),
utils.getString(R.string.country_af_algeria),
utils.getString(R.string.country_af_niger)
)
),
Flags(
R.drawable.af_seychelles_flag,
listOf(
utils.getString(R.string.country_af_seychelles),
utils.getString(R.string.country_af_morocco),
utils.getString(R.string.country_af_botswana),
utils.getString(R.string.country_af_angola)
)
),
Flags(
R.drawable.af_sierra_leone_flag,
listOf(
utils.getString(R.string.country_af_sierra_leone),
utils.getString(R.string.country_af_niger),
utils.getString(R.string.country_af_senegal),
utils.getString(R.string.country_af_morocco)
)
),
Flags(
R.drawable.af_somalia_flag,
listOf(
utils.getString(R.string.country_af_somalia),
utils.getString(R.string.country_af_niger),
utils.getString(R.string.country_af_lesotho),
utils.getString(R.string.country_af_algeria)
)
),
Flags(
R.drawable.af_south_africa_flag,
listOf(
utils.getString(R.string.country_af_south_africa),
utils.getString(R.string.country_af_equatorial_guinea),
utils.getString(R.string.country_af_angola),
utils.getString(R.string.country_af_niger)
)
),
Flags(
R.drawable.af_south_sudan_flag,
listOf(
utils.getString(R.string.country_af_south_sudan),
utils.getString(R.string.country_af_morocco),
utils.getString(R.string.country_af_senegal),
utils.getString(R.string.country_af_niger)
)
),
Flags(
R.drawable.af_sudan_flag,
listOf(
utils.getString(R.string.country_af_sudan),
utils.getString(R.string.country_af_lesotho),
utils.getString(R.string.country_af_south_sudan),
utils.getString(R.string.country_af_morocco)
)
),
Flags(
R.drawable.af_swaziland_flag,
listOf(
utils.getString(R.string.country_af_swaziland),
utils.getString(R.string.country_af_niger),
utils.getString(R.string.country_af_algeria),
utils.getString(R.string.country_af_botswana)
)
),
Flags(
R.drawable.af_tanzania_flag,
listOf(
utils.getString(R.string.country_af_tanzania),
utils.getString(R.string.country_af_senegal),
utils.getString(R.string.country_af_niger),
utils.getString(R.string.country_af_swaziland)
)
),
Flags(
R.drawable.af_togo_flag,
listOf(
utils.getString(R.string.country_af_togo),
utils.getString(R.string.country_af_south_sudan),
utils.getString(R.string.country_af_equatorial_guinea),
utils.getString(R.string.country_af_libya)
)
),
Flags(
R.drawable.af_tunisia_flag,
listOf(
utils.getString(R.string.country_af_tunisia),
utils.getString(R.string.country_af_niger),
utils.getString(R.string.country_af_swaziland),
utils.getString(R.string.country_af_algeria)
)
),
Flags(
R.drawable.af_uganda_flag,
listOf(
utils.getString(R.string.country_af_uganda),
utils.getString(R.string.country_af_senegal),
utils.getString(R.string.country_af_south_sudan),
utils.getString(R.string.country_af_equatorial_guinea)
)
),
Flags(
R.drawable.af_zambia_flag,
listOf(
utils.getString(R.string.country_af_zambia),
utils.getString(R.string.country_af_swaziland),
utils.getString(R.string.country_af_niger),
utils.getString(R.string.country_af_tunisia)
)
),
Flags(
R.drawable.af_zimbabwe_flag,
listOf(
utils.getString(R.string.country_af_zimbabwe),
utils.getString(R.string.country_af_algeria),
utils.getString(R.string.country_af_senegal),
utils.getString(R.string.country_af_south_sudan)
)
)
)
}
}
/*
* Asia continent.
*/
object Asia {
fun getFlags(): MutableList<Flags> {
return mutableListOf(
Flags(
R.drawable.as_afghanistan_flag,
listOf(
utils.getString(R.string.country_as_afghanistan),
utils.getString(R.string.country_as_turkey),
utils.getString(R.string.country_as_kuwait),
utils.getString(R.string.country_as_uzbekistan)
)
),
Flags(
R.drawable.as_armenia_flag,
listOf(
utils.getString(R.string.country_as_armenia),
utils.getString(R.string.country_as_cyprus),
utils.getString(R.string.country_as_turkey),
utils.getString(R.string.country_as_afghanistan)
)
),
Flags(
R.drawable.as_azerbaijan_flag,
listOf(
utils.getString(R.string.country_as_azerbaijan),
utils.getString(R.string.country_as_uzbekistan),
utils.getString(R.string.country_as_kuwait),
utils.getString(R.string.country_as_iraq)
)
),
Flags(
R.drawable.as_bahrain_flag,
listOf(
utils.getString(R.string.country_as_bahrain),
utils.getString(R.string.country_as_afghanistan),
utils.getString(R.string.country_as_turkey),
utils.getString(R.string.country_as_uzbekistan)
)
),
Flags(
R.drawable.as_bangladesh_flag,
listOf(
utils.getString(R.string.country_as_bangladesh),
utils.getString(R.string.country_as_iraq),
utils.getString(R.string.country_as_afghanistan),
utils.getString(R.string.country_as_mongolia)
)
),
Flags(
R.drawable.as_bhutan_flag,
listOf(
utils.getString(R.string.country_as_bhutan),
utils.getString(R.string.country_as_uzbekistan),
utils.getString(R.string.country_as_turkey),
utils.getString(R.string.country_as_afghanistan)
)
),
Flags(
R.drawable.as_brunei_flag,
listOf(
utils.getString(R.string.country_as_brunei),
utils.getString(R.string.country_as_kuwait),
utils.getString(R.string.country_as_uzbekistan),
utils.getString(R.string.country_as_bhutan)
)
),
Flags(
R.drawable.as_cambodia_flag,
listOf(
utils.getString(R.string.country_as_cambodia),
utils.getString(R.string.country_as_kuwait),
utils.getString(R.string.country_as_afghanistan),
utils.getString(R.string.country_as_turkey)
)
),
Flags(
R.drawable.as_china_flag,
listOf(
utils.getString(R.string.country_as_china),
utils.getString(R.string.country_as_uzbekistan),
utils.getString(R.string.country_as_bhutan),
utils.getString(R.string.country_as_cyprus)
)
),
Flags(
R.drawable.as_cyprus_flag,
listOf(
utils.getString(R.string.country_as_cyprus),
utils.getString(R.string.country_as_kuwait),
utils.getString(R.string.country_as_afghanistan),
utils.getString(R.string.country_as_uzbekistan)
)
),
Flags(
R.drawable.as_india_flag,
listOf(
utils.getString(R.string.country_as_india),
utils.getString(R.string.country_as_turkey),
utils.getString(R.string.country_as_cyprus),
utils.getString(R.string.country_as_mongolia)
)
),
Flags(
R.drawable.as_indonesia_flag,
listOf(
utils.getString(R.string.country_as_indonesia),
utils.getString(R.string.country_as_uzbekistan),
utils.getString(R.string.country_as_iraq),
utils.getString(R.string.country_as_kuwait)
)
),
Flags(
R.drawable.as_iran_flag,
listOf(
utils.getString(R.string.country_as_iran),
utils.getString(R.string.country_as_uzbekistan),
utils.getString(R.string.country_as_indonesia),
utils.getString(R.string.country_as_afghanistan)
)
),
Flags(
R.drawable.as_iraq_flag,
listOf(
utils.getString(R.string.country_as_iraq),
utils.getString(R.string.country_as_cyprus),
utils.getString(R.string.country_as_uzbekistan),
utils.getString(R.string.country_as_kazakhstan)
)
),
Flags(
R.drawable.as_israel_flag,
listOf(
utils.getString(R.string.country_as_israel),
utils.getString(R.string.country_as_indonesia),
utils.getString(R.string.country_as_afghanistan),
utils.getString(R.string.country_as_uzbekistan)
)
),
Flags(
R.drawable.as_japan_flag,
listOf(
utils.getString(R.string.country_as_japan),
utils.getString(R.string.country_as_kuwait),
utils.getString(R.string.country_as_mongolia),
utils.getString(R.string.country_as_sri_lanka)
)
),
Flags(
R.drawable.as_jordan_flag,
listOf(
utils.getString(R.string.country_as_jordan),
utils.getString(R.string.country_as_japan),
utils.getString(R.string.country_as_indonesia),
utils.getString(R.string.country_as_cyprus)
)
),
Flags(
R.drawable.as_kazakhstan_flag,
listOf(
utils.getString(R.string.country_as_kazakhstan),
utils.getString(R.string.country_as_uzbekistan),
utils.getString(R.string.country_as_japan),
utils.getString(R.string.country_as_iraq)
)
),
Flags(
R.drawable.as_kuwait_flag,
listOf(
utils.getString(R.string.country_as_kuwait),
utils.getString(R.string.country_as_indonesia),
utils.getString(R.string.country_as_uzbekistan),
utils.getString(R.string.country_as_japan)
)
),
Flags(
R.drawable.as_kyrgyzstan_flag,
listOf(
utils.getString(R.string.country_as_kyrgyzstan),
utils.getString(R.string.country_as_mongolia),
utils.getString(R.string.country_as_oman),
utils.getString(R.string.country_as_japan)
)
),
Flags(
R.drawable.as_laos_flag,
listOf(
utils.getString(R.string.country_as_laos),
utils.getString(R.string.country_as_uzbekistan),
utils.getString(R.string.country_as_indonesia),
utils.getString(R.string.country_as_japan)
)
),
Flags(
R.drawable.as_lebanon_flag,
listOf(
utils.getString(R.string.country_as_lebanon),
utils.getString(R.string.country_as_kuwait),
utils.getString(R.string.country_as_uzbekistan),
utils.getString(R.string.country_as_japan)
)
),
Flags(
R.drawable.as_malaysia_flag,
listOf(
utils.getString(R.string.country_as_malaysia),
utils.getString(R.string.country_as_cyprus),
utils.getString(R.string.country_as_indonesia),
utils.getString(R.string.country_as_japan)
)
),
Flags(
R.drawable.as_maldives_flag,
listOf(
utils.getString(R.string.country_as_maldives),
utils.getString(R.string.country_as_uzbekistan),
utils.getString(R.string.country_as_oman),
utils.getString(R.string.country_as_maldives)
)
),
Flags(
R.drawable.as_mongolia_flag,
listOf(
utils.getString(R.string.country_as_mongolia),
utils.getString(R.string.country_as_uzbekistan),
utils.getString(R.string.country_as_kuwait),
utils.getString(R.string.country_as_maldives)
)
),
Flags(
R.drawable.as_myanmar_flag,
listOf(
utils.getString(R.string.country_as_myanmar),
utils.getString(R.string.country_as_indonesia),
utils.getString(R.string.country_as_oman),
utils.getString(R.string.country_as_maldives)
)
),
Flags(
R.drawable.as_nepal_flag,
listOf(
utils.getString(R.string.country_as_nepal),
utils.getString(R.string.country_as_myanmar),
utils.getString(R.string.country_as_mongolia),
utils.getString(R.string.country_as_maldives)
)
),
Flags(
R.drawable.as_north_korea_flag,
listOf(
utils.getString(R.string.country_as_north_korea),
utils.getString(R.string.country_as_indonesia),
utils.getString(R.string.country_as_myanmar),
utils.getString(R.string.country_as_maldives)
)
),
Flags(
R.drawable.as_oman_flag,
listOf(
utils.getString(R.string.country_as_oman),
utils.getString(R.string.country_as_cyprus),
utils.getString(R.string.country_as_north_korea),
utils.getString(R.string.country_as_maldives)
)
),
Flags(
R.drawable.as_pakistan_flag,
listOf(
utils.getString(R.string.country_as_pakistan),
utils.getString(R.string.country_as_myanmar),
utils.getString(R.string.country_as_maldives),
utils.getString(R.string.country_as_indonesia)
)
),
Flags(
R.drawable.as_philippines_flag,
listOf(
utils.getString(R.string.country_as_philippines),
utils.getString(R.string.country_as_oman),
utils.getString(R.string.country_as_south_korea),
utils.getString(R.string.country_as_myanmar)
)
),
Flags(
R.drawable.as_qatar_flag,
listOf(
utils.getString(R.string.country_as_qatar),
utils.getString(R.string.country_as_kuwait),
utils.getString(R.string.country_as_maldives),
utils.getString(R.string.country_as_indonesia)
)
),
Flags(
R.drawable.as_russia_flag,
listOf(
utils.getString(R.string.country_as_russia),
utils.getString(R.string.country_as_myanmar),
utils.getString(R.string.country_as_maldives),
utils.getString(R.string.country_as_iraq)
)
),
Flags(
R.drawable.as_saudi_arabia_flag,
listOf(
utils.getString(R.string.country_as_saudi_arabia),
utils.getString(R.string.country_as_russia),
utils.getString(R.string.country_as_south_korea),
utils.getString(R.string.country_as_indonesia)
)
),
Flags(
R.drawable.as_singapore_flag,
listOf(
utils.getString(R.string.country_as_singapore),
utils.getString(R.string.country_as_saudi_arabia),
utils.getString(R.string.country_as_kuwait),
utils.getString(R.string.country_as_myanmar)
)
),
Flags(
R.drawable.as_south_korea_flag,
listOf(
utils.getString(R.string.country_as_south_korea),
utils.getString(R.string.country_as_saudi_arabia),
utils.getString(R.string.country_as_mongolia),
utils.getString(R.string.country_as_indonesia)
)
),
Flags(
R.drawable.as_sri_lanka_flag,
listOf(
utils.getString(R.string.country_as_sri_lanka),
utils.getString(R.string.country_as_myanmar),
utils.getString(R.string.country_as_saudi_arabia),
utils.getString(R.string.country_as_oman)
)
),
Flags(
R.drawable.as_syria_flag,
listOf(
utils.getString(R.string.country_as_syria),
utils.getString(R.string.country_as_kuwait),
utils.getString(R.string.country_as_south_korea),
utils.getString(R.string.country_as_saudi_arabia)
)
),
Flags(
R.drawable.as_taiwan_flag,
listOf(
utils.getString(R.string.country_as_taiwan),
utils.getString(R.string.country_as_indonesia),
utils.getString(R.string.country_as_kuwait),
utils.getString(R.string.country_as_syria)
)
),
Flags(
R.drawable.as_tajikistan_flag,
listOf(
utils.getString(R.string.country_as_tajikistan),
utils.getString(R.string.country_as_uzbekistan),
utils.getString(R.string.country_as_oman),
utils.getString(R.string.country_as_saudi_arabia)
)
),
Flags(
R.drawable.as_thailand_flag,
listOf(
utils.getString(R.string.country_as_thailand),
utils.getString(R.string.country_as_sri_lanka),
utils.getString(R.string.country_as_myanmar),
utils.getString(R.string.country_as_syria)
)
),
Flags(
R.drawable.as_turkey_flag,
listOf(
utils.getString(R.string.country_as_turkey),
utils.getString(R.string.country_as_thailand),
utils.getString(R.string.country_as_indonesia),
utils.getString(R.string.country_as_sri_lanka)
)
),
Flags(
R.drawable.as_turkmenistan_flag,
listOf(
utils.getString(R.string.country_as_turkmenistan),
utils.getString(R.string.country_as_uzbekistan),
utils.getString(R.string.country_as_thailand),
utils.getString(R.string.country_as_saudi_arabia)
)
),
Flags(
R.drawable.as_united_arab_emirates_flag,
listOf(
utils.getString(R.string.country_as_united_arab_emirates),
utils.getString(R.string.country_as_cyprus),
utils.getString(R.string.country_as_turkey),
utils.getString(R.string.country_as_saudi_arabia)
)
),
Flags(
R.drawable.as_uzbekistan_flag,
listOf(
utils.getString(R.string.country_as_uzbekistan),
utils.getString(R.string.country_as_iraq),
utils.getString(R.string.country_as_oman),
utils.getString(R.string.country_as_sri_lanka)
)
),
Flags(
R.drawable.as_vietnam_flag,
listOf(
utils.getString(R.string.country_as_vietnam),
utils.getString(R.string.country_as_kuwait),
utils.getString(R.string.country_as_uzbekistan),
utils.getString(R.string.country_as_iraq)
)
),
Flags(
R.drawable.as_yemen_flag,
listOf(
utils.getString(R.string.country_as_yemen),
utils.getString(R.string.country_as_turkey),
utils.getString(R.string.country_as_uzbekistan),
utils.getString(R.string.country_as_oman)
)
)
)
}
}
/*
* Europe continent.
*/
object Europe {
fun getFlags(): MutableList<Flags> {
return mutableListOf(
Flags(
R.drawable.eu_albania_flag,
listOf(
utils.getString(R.string.country_eu_albania),
utils.getString(R.string.country_eu_malta),
utils.getString(R.string.country_eu_ukraine),
utils.getString(R.string.country_eu_latvia)
)
),
Flags(
R.drawable.eu_andorra_flag,
listOf(
utils.getString(R.string.country_eu_andorra),
utils.getString(R.string.country_eu_norway),
utils.getString(R.string.country_eu_kosovo),
utils.getString(R.string.country_eu_montenegro)
)
),
Flags(
R.drawable.eu_austria_flag,
listOf(
utils.getString(R.string.country_eu_austria),
utils.getString(R.string.country_eu_vatican_city),
utils.getString(R.string.country_eu_hungary),
utils.getString(R.string.country_eu_norway)
)
),
Flags(
R.drawable.eu_belarus_flag,
listOf(
utils.getString(R.string.country_eu_belarus),
utils.getString(R.string.country_eu_latvia),
utils.getString(R.string.country_eu_ukraine),
utils.getString(R.string.country_eu_malta)
)
),
Flags(
R.drawable.eu_belgium_flag,
listOf(
utils.getString(R.string.country_eu_belgium),
utils.getString(R.string.country_eu_spain),
utils.getString(R.string.country_eu_latvia),
utils.getString(R.string.country_eu_vatican_city)
)
),
Flags(
R.drawable.eu_bosnia_and_herzegovina_flag,
listOf(
utils.getString(R.string.country_eu_bosnia_and_herzegovina),
utils.getString(R.string.country_eu_ukraine),
utils.getString(R.string.country_eu_austria),
utils.getString(R.string.country_eu_belarus)
)
),
Flags(
R.drawable.eu_bulgaria_flag,
listOf(
utils.getString(R.string.country_eu_bulgaria),
utils.getString(R.string.country_eu_norway),
utils.getString(R.string.country_eu_bosnia_and_herzegovina),
utils.getString(R.string.country_eu_latvia)
)
),
Flags(
R.drawable.eu_croatia_flag,
listOf(
utils.getString(R.string.country_eu_croatia),
utils.getString(R.string.country_eu_bosnia_and_herzegovina),
utils.getString(R.string.country_eu_vatican_city),
utils.getString(R.string.country_eu_bulgaria)
)
),
Flags(
R.drawable.eu_czech_republic_flag,
listOf(
utils.getString(R.string.country_eu_czech_republic),
utils.getString(R.string.country_eu_ukraine),
utils.getString(R.string.country_eu_montenegro),
utils.getString(R.string.country_eu_latvia)
)
),
Flags(
R.drawable.eu_denmark_flag,
listOf(
utils.getString(R.string.country_eu_denmark),
utils.getString(R.string.country_eu_belarus),
utils.getString(R.string.country_eu_austria),
utils.getString(R.string.country_eu_bulgaria)
)
),
Flags(
R.drawable.eu_estonia_flag,
listOf(
utils.getString(R.string.country_eu_estonia),
utils.getString(R.string.country_eu_norway),
utils.getString(R.string.country_eu_spain),
utils.getString(R.string.country_eu_vatican_city)
)
),
Flags(
R.drawable.eu_finland_flag,
listOf(
utils.getString(R.string.country_eu_finland),
utils.getString(R.string.country_eu_ukraine),
utils.getString(R.string.country_eu_latvia),
utils.getString(R.string.country_eu_bulgaria)
)
),
Flags(
R.drawable.eu_france_flag,
listOf(
utils.getString(R.string.country_eu_france),
utils.getString(R.string.country_eu_bosnia_and_herzegovina),
utils.getString(R.string.country_eu_bosnia_and_herzegovina),
utils.getString(R.string.country_eu_belarus)
)
),
Flags(
R.drawable.eu_georgia_flag,
listOf(
utils.getString(R.string.country_eu_georgia),
utils.getString(R.string.country_eu_austria),
utils.getString(R.string.country_eu_ukraine),
utils.getString(R.string.country_eu_bulgaria)
)
),
Flags(
R.drawable.eu_germany_flag,
listOf(
utils.getString(R.string.country_eu_germany),
utils.getString(R.string.country_eu_latvia),
utils.getString(R.string.country_eu_vatican_city),
utils.getString(R.string.country_eu_bosnia_and_herzegovina)
)
),
Flags(
R.drawable.eu_greece_flag,
listOf(
utils.getString(R.string.country_eu_greece),
utils.getString(R.string.country_eu_latvia),
utils.getString(R.string.country_eu_ukraine),
utils.getString(R.string.country_eu_bulgaria)
)
),
Flags(
R.drawable.eu_hungary_flag,
listOf(
utils.getString(R.string.country_eu_hungary),
utils.getString(R.string.country_eu_belarus),
utils.getString(R.string.country_eu_bosnia_and_herzegovina),
utils.getString(R.string.country_eu_spain)
)
),
Flags(
R.drawable.eu_iceland_flag,
listOf(
utils.getString(R.string.country_eu_iceland),
utils.getString(R.string.country_eu_latvia),
utils.getString(R.string.country_eu_bulgaria),
utils.getString(R.string.country_eu_vatican_city)
)
),
Flags(
R.drawable.eu_ireland_flag,
listOf(
utils.getString(R.string.country_eu_ireland),
utils.getString(R.string.country_eu_ukraine),
utils.getString(R.string.country_eu_austria),
utils.getString(R.string.country_eu_bosnia_and_herzegovina)
)
),
Flags(
R.drawable.eu_italy_flag,
listOf(
utils.getString(R.string.country_eu_italy),
utils.getString(R.string.country_eu_bulgaria),
utils.getString(R.string.country_eu_belarus),
utils.getString(R.string.country_eu_bosnia_and_herzegovina)
)
),
Flags(
R.drawable.eu_kosovo_flag,
listOf(
utils.getString(R.string.country_eu_kosovo),
utils.getString(R.string.country_eu_bosnia_and_herzegovina),
utils.getString(R.string.country_eu_ireland),
utils.getString(R.string.country_eu_latvia)
)
),
Flags(
R.drawable.eu_latvia_flag,
listOf(
utils.getString(R.string.country_eu_latvia),
utils.getString(R.string.country_eu_vatican_city),
utils.getString(R.string.country_eu_ukraine),
utils.getString(R.string.country_eu_kosovo)
)
),
Flags(
R.drawable.eu_liechtenstein_flag,
listOf(
utils.getString(R.string.country_eu_liechtenstein),
utils.getString(R.string.country_eu_bosnia_and_herzegovina),
utils.getString(R.string.country_eu_belarus),
utils.getString(R.string.country_eu_bosnia_and_herzegovina)
)
),
Flags(
R.drawable.eu_lithuania_flag,
listOf(
utils.getString(R.string.country_eu_lithuania),
utils.getString(R.string.country_eu_ireland),
utils.getString(R.string.country_eu_kosovo),
utils.getString(R.string.country_eu_bosnia_and_herzegovina)
)
),
Flags(
R.drawable.eu_luxembourg_flag,
listOf(
utils.getString(R.string.country_eu_luxembourg),
utils.getString(R.string.country_eu_hungary),
utils.getString(R.string.country_eu_latvia),
utils.getString(R.string.country_eu_kosovo)
)
),
Flags(
R.drawable.eu_macedonia_flag,
listOf(
utils.getString(R.string.country_eu_macedonia),
utils.getString(R.string.country_eu_vatican_city),
utils.getString(R.string.country_eu_lithuania),
utils.getString(R.string.country_eu_belarus)
)
),
Flags(
R.drawable.eu_malta_flag,
listOf(
utils.getString(R.string.country_eu_malta),
utils.getString(R.string.country_eu_austria),
utils.getString(R.string.country_eu_ireland),
utils.getString(R.string.country_eu_bosnia_and_herzegovina)
)
),
Flags(
R.drawable.eu_moldova_flag,
listOf(
utils.getString(R.string.country_eu_moldova),
utils.getString(R.string.country_eu_poland),
utils.getString(R.string.country_eu_malta),
utils.getString(R.string.country_eu_lithuania)
)
),
Flags(
R.drawable.eu_monaco_flag,
listOf(
utils.getString(R.string.country_eu_monaco),
utils.getString(R.string.country_eu_bosnia_and_herzegovina),
utils.getString(R.string.country_eu_kosovo),
utils.getString(R.string.country_eu_lithuania)
)
),
Flags(
R.drawable.eu_montenegro_flag,
listOf(
utils.getString(R.string.country_eu_montenegro),
utils.getString(R.string.country_eu_belarus),
utils.getString(R.string.country_eu_ireland),
utils.getString(R.string.country_eu_poland)
)
),
Flags(
R.drawable.eu_netherlands_flag,
listOf(
utils.getString(R.string.country_eu_netherlands),
utils.getString(R.string.country_eu_lithuania),
utils.getString(R.string.country_eu_bosnia_and_herzegovina),
utils.getString(R.string.country_eu_malta)
)
),
Flags(
R.drawable.eu_norway_flag,
listOf(
utils.getString(R.string.country_eu_norway),
utils.getString(R.string.country_eu_latvia),
utils.getString(R.string.country_eu_austria),
utils.getString(R.string.country_eu_ireland)
)
),
Flags(
R.drawable.eu_poland_flag,
listOf(
utils.getString(R.string.country_eu_poland),
utils.getString(R.string.country_eu_kosovo),
utils.getString(R.string.country_eu_hungary),
utils.getString(R.string.country_eu_lithuania)
)
),
Flags(
R.drawable.eu_portugal_flag,
listOf(
utils.getString(R.string.country_eu_portugal),
utils.getString(R.string.country_eu_norway),
utils.getString(R.string.country_eu_bosnia_and_herzegovina),
utils.getString(R.string.country_eu_poland)
)
),
Flags(
R.drawable.eu_romania_flag,
listOf(
utils.getString(R.string.country_eu_romania),
utils.getString(R.string.country_eu_malta),
utils.getString(R.string.country_eu_bosnia_and_herzegovina),
utils.getString(R.string.country_eu_ireland)
)
),
Flags(
R.drawable.eu_san_marino_flag,
listOf(
utils.getString(R.string.country_eu_san_marino),
utils.getString(R.string.country_eu_lithuania),
utils.getString(R.string.country_eu_norway),
utils.getString(R.string.country_eu_austria)
)
),
Flags(
R.drawable.eu_serbia_flag,
listOf(
utils.getString(R.string.country_eu_serbia),
utils.getString(R.string.country_eu_kosovo),
utils.getString(R.string.country_eu_latvia),
utils.getString(R.string.country_eu_malta)
)
),
Flags(
R.drawable.eu_slovakia_flag,
listOf(
utils.getString(R.string.country_eu_slovakia),
utils.getString(R.string.country_eu_lithuania),
utils.getString(R.string.country_eu_ireland),
utils.getString(R.string.country_eu_norway)
)
),
Flags(
R.drawable.eu_slovenia_flag,
listOf(
utils.getString(R.string.country_eu_slovenia),
utils.getString(R.string.country_eu_bosnia_and_herzegovina),
utils.getString(R.string.country_eu_latvia),
utils.getString(R.string.country_eu_poland)
)
),
Flags(
R.drawable.eu_spain_flag,
listOf(
utils.getString(R.string.country_eu_spain),
utils.getString(R.string.country_eu_hungary),
utils.getString(R.string.country_eu_lithuania),
utils.getString(R.string.country_eu_kosovo)
)
),
Flags(
R.drawable.eu_sweden_flag,
listOf(
utils.getString(R.string.country_eu_sweden),
utils.getString(R.string.country_eu_malta),
utils.getString(R.string.country_eu_poland),
utils.getString(R.string.country_eu_latvia)
)
),
Flags(
R.drawable.eu_switzerland_flag,
listOf(
utils.getString(R.string.country_eu_switzerland),
utils.getString(R.string.country_eu_bosnia_and_herzegovina),
utils.getString(R.string.country_eu_spain),
utils.getString(R.string.country_eu_ireland)
)
),
Flags(
R.drawable.eu_ukraine_flag,
listOf(
utils.getString(R.string.country_eu_ukraine),
utils.getString(R.string.country_eu_lithuania),
utils.getString(R.string.country_eu_latvia),
utils.getString(R.string.country_eu_norway)
)
),
Flags(
R.drawable.eu_united_kingdom_flag,
listOf(
utils.getString(R.string.country_eu_united_kingdom),
utils.getString(R.string.country_eu_kosovo),
utils.getString(R.string.country_eu_malta),
utils.getString(R.string.country_eu_poland)
)
),
Flags(
R.drawable.eu_vatican_city_flag,
listOf(
utils.getString(R.string.country_eu_vatican_city),
utils.getString(R.string.country_eu_poland),
utils.getString(R.string.country_eu_ukraine),
utils.getString(R.string.country_eu_norway)
)
)
)
}
}
/*
* North America continent.
*/
object NorthAmerica {
fun getFlags(): MutableList<Flags> {
return mutableListOf(
Flags(
R.drawable.na_antigua_and_barbuda_flag,
listOf(
utils.getString(R.string.country_na_antigua_and_barbuda),
utils.getString(R.string.country_na_jamaica),
utils.getString(R.string.country_na_dominican_republic),
utils.getString(R.string.country_na_el_salvador)
)
),
Flags(
R.drawable.na_bahamas_flag,
listOf(
utils.getString(R.string.country_na_bahamas),
utils.getString(R.string.country_na_usa),
utils.getString(R.string.country_na_dominica),
utils.getString(R.string.country_na_grenada)
)
),
Flags(
R.drawable.na_barbados_flag,
listOf(
utils.getString(R.string.country_na_barbados),
utils.getString(R.string.country_na_antigua_and_barbuda),
utils.getString(R.string.country_na_el_salvador),
utils.getString(R.string.country_na_honduras)
)
),
Flags(
R.drawable.na_belize_flag,
listOf(
utils.getString(R.string.country_na_belize),
utils.getString(R.string.country_na_dominica),
utils.getString(R.string.country_na_usa),
utils.getString(R.string.country_na_el_salvador)
)
),
Flags(
R.drawable.na_canada_flag,
listOf(
utils.getString(R.string.country_na_canada),
utils.getString(R.string.country_na_jamaica),
utils.getString(R.string.country_na_dominica),
utils.getString(R.string.country_na_antigua_and_barbuda)
)
),
Flags(
R.drawable.na_costa_rica_flag,
listOf(
utils.getString(R.string.country_na_costa_rica),
utils.getString(R.string.country_na_dominican_republic),
utils.getString(R.string.country_na_usa),
utils.getString(R.string.country_na_cuba)
)
),
Flags(
R.drawable.na_cuba_flag,
listOf(
utils.getString(R.string.country_na_cuba),
utils.getString(R.string.country_na_jamaica),
utils.getString(R.string.country_na_costa_rica),
utils.getString(R.string.country_na_el_salvador)
)
),
Flags(
R.drawable.na_dominica_flag,
listOf(
utils.getString(R.string.country_na_dominica),
utils.getString(R.string.country_na_antigua_and_barbuda),
utils.getString(R.string.country_na_usa),
utils.getString(R.string.country_na_honduras)
)
),
Flags(
R.drawable.na_dominican_republic_flag,
listOf(
utils.getString(R.string.country_na_dominican_republic),
utils.getString(R.string.country_na_dominica),
utils.getString(R.string.country_na_honduras),
utils.getString(R.string.country_na_costa_rica)
)
),
Flags(
R.drawable.na_el_salvador_flag,
listOf(
utils.getString(R.string.country_na_el_salvador),
utils.getString(R.string.country_na_antigua_and_barbuda),
utils.getString(R.string.country_na_jamaica),
utils.getString(R.string.country_na_dominica)
)
),
Flags(
R.drawable.na_grenada_flag,
listOf(
utils.getString(R.string.country_na_grenada),
utils.getString(R.string.country_na_el_salvador),
utils.getString(R.string.country_na_usa),
utils.getString(R.string.country_na_costa_rica)
)
),
Flags(
R.drawable.na_guatemala_flag,
listOf(
utils.getString(R.string.country_na_guatemala),
utils.getString(R.string.country_na_cuba),
utils.getString(R.string.country_na_el_salvador),
utils.getString(R.string.country_na_antigua_and_barbuda)
)
),
Flags(
R.drawable.na_haiti_flag,
listOf(
utils.getString(R.string.country_na_haiti),
utils.getString(R.string.country_na_dominica),
utils.getString(R.string.country_na_honduras),
utils.getString(R.string.country_na_el_salvador)
)
),
Flags(
R.drawable.na_honduras_flag,
listOf(
utils.getString(R.string.country_na_honduras),
utils.getString(R.string.country_na_costa_rica),
utils.getString(R.string.country_na_dominican_republic),
utils.getString(R.string.country_na_usa)
)
),
Flags(
R.drawable.na_jamaica_flag,
listOf(
utils.getString(R.string.country_na_jamaica),
utils.getString(R.string.country_na_dominica),
utils.getString(R.string.country_na_antigua_and_barbuda),
utils.getString(R.string.country_na_el_salvador)
)
),
Flags(
R.drawable.na_mexico_flag,
listOf(
utils.getString(R.string.country_na_mexico),
utils.getString(R.string.country_na_costa_rica),
utils.getString(R.string.country_na_cuba),
utils.getString(R.string.country_na_dominica)
)
),
Flags(
R.drawable.na_nicaragua_flag,
listOf(
utils.getString(R.string.country_na_nicaragua),
utils.getString(R.string.country_na_jamaica),
utils.getString(R.string.country_na_costa_rica),
utils.getString(R.string.country_na_el_salvador)
)
),
Flags(
R.drawable.na_saint_kitts_and_nevis_flag,
listOf(
utils.getString(R.string.country_na_saint_kitts_and_nevis),
utils.getString(R.string.country_na_antigua_and_barbuda),
utils.getString(R.string.country_na_dominica),
utils.getString(R.string.country_na_usa)
)
),
Flags(
R.drawable.na_united_states_of_america_flag,
listOf(
utils.getString(R.string.country_na_usa),
utils.getString(R.string.country_na_costa_rica),
utils.getString(R.string.country_na_el_salvador),
utils.getString(R.string.country_na_dominica)
)
)
)
}
}
/*
* Oceania continent.
*/
object Oceania {
fun getFlags(): MutableList<Flags> {
return mutableListOf(
Flags(
R.drawable.oc_australia_flag,
listOf(
utils.getString(R.string.country_oc_australia),
utils.getString(R.string.country_oc_palau),
utils.getString(R.string.country_oc_east_timor),
utils.getString(R.string.country_oc_tonga)
)
),
Flags(
R.drawable.oc_east_timor_flag,
listOf(
utils.getString(R.string.country_oc_east_timor),
utils.getString(R.string.country_oc_kiribati),
utils.getString(R.string.country_oc_nauru),
utils.getString(R.string.country_oc_papua_new_guinea)
)
),
Flags(
R.drawable.oc_fiji_flag,
listOf(
utils.getString(R.string.country_oc_fiji),
utils.getString(R.string.country_oc_new_zealand),
utils.getString(R.string.country_oc_australia),
utils.getString(R.string.country_oc_niue)
)
),
Flags(
R.drawable.oc_kiribati_flag,
listOf(
utils.getString(R.string.country_oc_kiribati),
utils.getString(R.string.country_oc_east_timor),
utils.getString(R.string.country_oc_tonga),
utils.getString(R.string.country_oc_nauru)
)
),
Flags(
R.drawable.oc_marshall_islands_flag,
listOf(
utils.getString(R.string.country_oc_marshall_islands),
utils.getString(R.string.country_oc_papua_new_guinea),
utils.getString(R.string.country_oc_new_zealand),
utils.getString(R.string.country_oc_fiji)
)
),
Flags(
R.drawable.oc_micronesia_flag,
listOf(
utils.getString(R.string.country_oc_micronesia),
utils.getString(R.string.country_oc_east_timor),
utils.getString(R.string.country_oc_australia),
utils.getString(R.string.country_oc_nauru)
)
),
Flags(
R.drawable.oc_nauru_flag,
listOf(
utils.getString(R.string.country_oc_nauru),
utils.getString(R.string.country_oc_tonga),
utils.getString(R.string.country_oc_new_zealand),
utils.getString(R.string.country_oc_east_timor)
)
),
Flags(
R.drawable.oc_new_zealand_flag,
listOf(
utils.getString(R.string.country_oc_new_zealand),
utils.getString(R.string.country_oc_papua_new_guinea),
utils.getString(R.string.country_oc_kiribati),
utils.getString(R.string.country_oc_fiji)
)
),
Flags(
R.drawable.oc_niue_flag,
listOf(
utils.getString(R.string.country_oc_niue),
utils.getString(R.string.country_oc_nauru),
utils.getString(R.string.country_oc_tonga),
utils.getString(R.string.country_oc_palau)
)
),
Flags(
R.drawable.oc_palau_flag,
listOf(
utils.getString(R.string.country_oc_palau),
utils.getString(R.string.country_oc_niue),
utils.getString(R.string.country_oc_tonga),
utils.getString(R.string.country_oc_new_zealand)
)
),
Flags(
R.drawable.oc_papua_new_guinea_flag,
listOf(
utils.getString(R.string.country_oc_papua_new_guinea),
utils.getString(R.string.country_oc_nauru),
utils.getString(R.string.country_oc_east_timor),
utils.getString(R.string.country_oc_australia)
)
),
Flags(
R.drawable.oc_samoa_flag,
listOf(
utils.getString(R.string.country_oc_samoa),
utils.getString(R.string.country_oc_fiji),
utils.getString(R.string.country_oc_kiribati),
utils.getString(R.string.country_oc_papua_new_guinea)
)
),
Flags(
R.drawable.oc_solomon_islands_flag,
listOf(
utils.getString(R.string.country_oc_solomon_islands),
utils.getString(R.string.country_oc_nauru),
utils.getString(R.string.country_oc_new_zealand),
utils.getString(R.string.country_oc_palau)
)
),
Flags(
R.drawable.oc_tonga_flag,
listOf(
utils.getString(R.string.country_oc_tonga),
utils.getString(R.string.country_oc_east_timor),
utils.getString(R.string.country_oc_kiribati),
utils.getString(R.string.country_oc_fiji)
)
),
Flags(
R.drawable.oc_tuvalu_flag,
listOf(
utils.getString(R.string.country_oc_tuvalu),
utils.getString(R.string.country_oc_papua_new_guinea),
utils.getString(R.string.country_oc_tonga),
utils.getString(R.string.country_oc_new_zealand)
)
)
)
}
}
/*
* South America continent.
*/
object SouthAmerica {
fun getFlags(): MutableList<Flags> {
return mutableListOf(
Flags(
R.drawable.sa_argentina_flag,
listOf(
utils.getString(R.string.country_sa_argentina),
utils.getString(R.string.country_sa_bolivia),
utils.getString(R.string.country_sa_trinidad_and_tobago),
utils.getString(R.string.country_sa_uruguay)
)
),
Flags(
R.drawable.sa_bolivia_flag,
listOf(
utils.getString(R.string.country_sa_bolivia),
utils.getString(R.string.country_sa_saint_lucia),
utils.getString(R.string.country_sa_venezuela),
utils.getString(R.string.country_sa_colombia)
)
),
Flags(
R.drawable.sa_brazil_flag,
listOf(
utils.getString(R.string.country_sa_brazil),
utils.getString(R.string.country_sa_saint_lucia),
utils.getString(R.string.country_sa_uruguay),
utils.getString(R.string.country_sa_argentina)
)
),
Flags(
R.drawable.sa_chile_flag,
listOf(
utils.getString(R.string.country_sa_chile),
utils.getString(R.string.country_sa_trinidad_and_tobago),
utils.getString(R.string.country_sa_guyana),
utils.getString(R.string.country_sa_brazil)
)
),
Flags(
R.drawable.sa_colombia_flag,
listOf(
utils.getString(R.string.country_sa_colombia),
utils.getString(R.string.country_sa_uruguay),
utils.getString(R.string.country_sa_venezuela),
utils.getString(R.string.country_sa_chile)
)
),
Flags(
R.drawable.sa_ecuador_flag,
listOf(
utils.getString(R.string.country_sa_ecuador),
utils.getString(R.string.country_sa_trinidad_and_tobago),
utils.getString(R.string.country_sa_bolivia),
utils.getString(R.string.country_sa_uruguay)
)
),
Flags(
R.drawable.sa_guyana_flag,
listOf(
utils.getString(R.string.country_sa_guyana),
utils.getString(R.string.country_sa_brazil),
utils.getString(R.string.country_sa_chile),
utils.getString(R.string.country_sa_argentina)
)
),
Flags(
R.drawable.sa_panama_flag,
listOf(
utils.getString(R.string.country_sa_panama),
utils.getString(R.string.country_sa_trinidad_and_tobago),
utils.getString(R.string.country_sa_brazil),
utils.getString(R.string.country_sa_uruguay)
)
),
Flags(
R.drawable.sa_paraguay_flag,
listOf(
utils.getString(R.string.country_sa_paraguay),
utils.getString(R.string.country_sa_chile),
utils.getString(R.string.country_sa_colombia),
utils.getString(R.string.country_sa_venezuela)
)
),
Flags(
R.drawable.sa_peru_flag,
listOf(
utils.getString(R.string.country_sa_peru),
utils.getString(R.string.country_sa_trinidad_and_tobago),
utils.getString(R.string.country_sa_uruguay),
utils.getString(R.string.country_sa_brazil)
)
),
Flags(
R.drawable.sa_saint_lucia_flag,
listOf(
utils.getString(R.string.country_sa_saint_lucia),
utils.getString(R.string.country_sa_chile),
utils.getString(R.string.country_sa_colombia),
utils.getString(R.string.country_sa_argentina)
)
),
Flags(
R.drawable.sa_saint_vincent_and_the_grenadines_flag,
listOf(
utils.getString(R.string.country_sa_saint_vicente_and_grenadines),
utils.getString(R.string.country_sa_venezuela),
utils.getString(R.string.country_sa_saint_lucia),
utils.getString(R.string.country_sa_brazil)
)
),
Flags(
R.drawable.sa_suriname_flag,
listOf(
utils.getString(R.string.country_sa_suriname),
utils.getString(R.string.country_sa_chile),
utils.getString(R.string.country_sa_bolivia),
utils.getString(R.string.country_sa_saint_lucia)
)
),
Flags(
R.drawable.sa_trinidad_and_tobago_flag,
listOf(
utils.getString(R.string.country_sa_trinidad_and_tobago),
utils.getString(R.string.country_sa_colombia),
utils.getString(R.string.country_sa_brazil),
utils.getString(R.string.country_sa_argentina)
)
),
Flags(
R.drawable.sa_uruguay_flag,
listOf(
utils.getString(R.string.country_sa_uruguay),
utils.getString(R.string.country_sa_bolivia),
utils.getString(R.string.country_sa_chile),
utils.getString(R.string.country_sa_saint_lucia)
)
),
Flags(
R.drawable.sa_venezuela_flag,
listOf(
utils.getString(R.string.country_sa_venezuela),
utils.getString(R.string.country_sa_argentina),
utils.getString(R.string.country_sa_trinidad_and_tobago),
utils.getString(R.string.country_sa_saint_lucia)
)
)
)
}
} | 0 | Kotlin | 2 | 1 | eccd8513453490a814cb3b52116da3fbad3df99c | 77,631 | flags-quiz | Apache License 2.0 |
app/src/main/kotlin/com/github/midros/istheapp/receiver/MonitorReceiver.kt | M1Dr05 | 134,190,446 | false | null | package com.github.midros.istheapp.receiver
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.github.midros.istheapp.services.social.MonitorService
import com.github.midros.istheapp.utils.Consts.RESTART_MONITOR_RECEIVER
import com.pawegio.kandroid.IntentFor
/**
* Created by <NAME> on 13/03/18.
*/
class MonitorReceiver : BroadcastReceiver(){
override fun onReceive(context: Context, intent: Intent) {
if (intent.action == RESTART_MONITOR_RECEIVER) context.startService(IntentFor<MonitorService>(context))
}
} | 0 | null | 227 | 350 | b4dcfb64966e441ce27236f87644cf02970f036c | 592 | IsTheApp | Apache License 2.0 |
src/main/kotlin/com/abid/notflix/controller/UploadController.kt | gitAbid | 252,894,214 | false | null | package com.abid.notflix.controller
class UploadController {
} | 0 | Kotlin | 0 | 0 | b38cce8b75c13c6d66ede1a58e0955c3cb99fc28 | 63 | notflix | Apache License 2.0 |
src/main/kotlin/com/tafel/missions/tafelmissions/dao/sql/MissionSql.kt | prambrucke | 174,589,753 | false | null | package com.tafel.missions.tafelmissions.dao.sql
object MissionSql {
const val INSERT_MISSION = """
INSERT INTO tafel_missions.mission (id,name,description,created_by,updated_by,labels,estimation,assignee_ids,is_explored,status,sprint,team_id,critical,comments,created_at,updated_at)
values (:id,:name,:description,:created_by,:updated_by,:labels,:estimation,:assignee_ids,:is_explored,:status,:sprint,:team_id,:critical,:comments,:created_at,:updated_at);
"""
const val SELECT_MISSIONS = """
SELECT id, name, description, created_by,updated_by, estimation, labels, assignee_ids, is_explored, status, sprint, team_id, critical, comments, created_at, updated_at ,
row_number() over (order by critical , created_at desc)
FROM tafel_missions.mission WHERE team_id=:team_id and id=coalesce(:id , id)
"""
const val GET_NEXT_MISSION_ID = """
insert into tafel_missions.mission_sequence (team_id, next_mission_id) values (:team_id,'0') ON CONFLICT (team_id)
DO update set next_mission_id= coalesce(mission_sequence.next_mission_id::BIGINT+1 ,EXCLUDED.next_mission_id::BIGINT)
returning next_mission_id::BIGINT+1;
"""
const val UPDATE_MISSION = """
UPDATE tafel_missions.mission SET
name=coalesce(:name,name),
description=coalesce(:description,description),
labels=coalesce(:labels,labels),
estimation=coalesce(:estimation,estimation),
assignee_ids=coalesce(:assignee_ids,assignee_ids),
is_explored=coalesce(:is_explored,is_explored),
status=coalesce(:status,status),
sprint=coalesce(:sprint,sprint),
critical=coalesce(:critical,critical),
comments=coalesce(:comments,comments),
updated_by=:updated_by,
updated_at=:updated_at
WHERE id=:id and team_id=:team_id;
"""
const val SELECT_MISSIONS_PAGINATION_PREFIX = """select * from( """
const val SELECT_MISSIONS_PAGINATION_SUFFIX = """ ) ordered_mission where row_number between :current_cursor and :next_cursor """
const val SELECT_MISSIONS_LABELS_FILTER = """ and labels @> :labels::text[] """
const val SELECT_MISSIONS_CRITICAL_FILTER = """ and critical=coalesce(:critical , critical) """
const val SELECT_MISSIONS_ASSIGNEE_FILTER = """ and :assignee= ANY (assignee_ids) """
const val SELECT_MISSIONS_SPRINT_FILTER = """ and sprint=coalesce(:sprint , sprint)"""
} | 8 | Kotlin | 0 | 0 | 544651909027dd4e8ffb0c99dba34a26a7909399 | 2,632 | tafel-missions | MIT License |
app/src/main/java/cz/kudlav/vutindex/BaseApplication.kt | kudlav | 489,882,756 | false | null | package cz.kudlav.vutindex
import android.app.Application
import android.content.Context
import android.webkit.WebView
import org.koin.android.ext.koin.androidContext
import org.koin.core.context.startKoin
import cz.kudlav.vutindex.di.viewModelsModule
import cz.kudlav.vutindex.index.di.indexModule
import cz.kudlav.vutindex.webscraper.di.scrapersModule
import timber.log.Timber
import android.content.pm.ApplicationInfo
import cz.kudlav.vutindex.repository.di.repositoryModule
class BaseApplication : Application() {
override fun onCreate() {
super.onCreate()
if (0 != applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE) {
WebView.setWebContentsDebuggingEnabled(true)
}
startKoin {
androidContext(this@BaseApplication)
modules(listOf(viewModelsModule, repositoryModule, scrapersModule, indexModule))
}
if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
}
}
init {
instance = this
}
companion object {
private var instance: BaseApplication? = null
fun applicationContext() : Context {
return instance!!.applicationContext
}
}
} | 0 | Kotlin | 0 | 0 | b7dd9162638400b03e71620250b1499b021e2380 | 1,221 | VUT-index-2.0 | MIT License |
src/main/kotlin/br/ufs/kryptokarteira/backend/infrastructure/TraderInfrastructure.kt | ubiratansoares | 113,787,205 | false | null | package br.ufs.kryptokarteira.backend.infrastructure
import br.ufs.kryptokarteira.backend.domain.CryptoCurrencyTrader
import br.ufs.kryptokarteira.backend.domain.DataForTransaction
import br.ufs.kryptokarteira.backend.domain.Transaction
import br.ufs.kryptokarteira.backend.infrastructure.datasources.restdb.RestDBDataSource
import br.ufs.kryptokarteira.backend.infrastructure.util.AsDomainError
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter.ISO_DATE_TIME
class TraderInfrastructure(private val datasource: RestDBDataSource) : CryptoCurrencyTrader {
override fun performTransaction(data: DataForTransaction): Transaction {
val dateTime = LocalDateTime.now().format(ISO_DATE_TIME)
try {
datasource.registerTransaction(data, dateTime)
return Transaction("Success!")
} catch (incoming: Throwable) {
throw AsDomainError(incoming)
}
}
} | 0 | Kotlin | 0 | 0 | 7adad02def696c8af551c36d105f68a019f9b007 | 940 | kryptokarteira-backend | MIT License |
unity_life_android/UnityLife/app/src/main/java/com/example/unitylife/ext/ImageViewExt.kt | siiena25 | 505,861,165 | false | {"Java": 168626, "Kotlin": 106740, "Shell": 5603, "Procfile": 76} | package com.example.unitylife.ext
import android.widget.ImageView
import com.bumptech.glide.Glide
fun ImageView.loadAvatar(url: String?) {
Glide.with(this)
.load(url)
.into(this)
}
fun ImageView.loadBanner(url:String?) {
Glide.with(this)
.load(url)
.into(this)
} | 1 | null | 1 | 1 | 2cbbbe5648dd84548a8440fe2fe54bcf85d77f0c | 321 | unity-life | MIT License |
project-system-gradle/src/com/android/tools/idea/projectsystem/gradle/GradleProjectSystemBuildManager.kt | leobert-lan | 563,630,098 | true | {"Text": 355, "EditorConfig": 2, "Markdown": 64, "Shell": 32, "Ignore List": 193, "XML": 13507, "Starlark": 142, "Kotlin": 6746, "Java": 8085, "Gradle": 2753, "Proguard": 169, "INI": 72, "JSON": 80, "Graphviz (DOT)": 1, "Ant Build System": 2, "Protocol Buffer": 8, "Java Properties": 166, "HTML": 67, "Batchfile": 20, "Gradle Kotlin DSL": 1655, "CMake": 19, "C": 29, "Checksums": 339, "C++": 14, "TOML": 2, "Smali": 5, "SVG": 1329, "AIDL": 9, "JFlex": 8, "Prolog": 6, "QMake": 2, "RenderScript": 1, "NSIS": 4, "GraphQL": 5, "Python": 10, "Makefile": 8, "YAML": 1, "HAProxy": 1, "Org": 2, "JavaScript": 3} | package com.android.tools.idea.projectsystem.gradle
import com.android.tools.idea.gradle.project.build.BuildContext
import com.android.tools.idea.gradle.project.build.BuildStatus
import com.android.tools.idea.gradle.project.build.GradleBuildListener
import com.android.tools.idea.gradle.project.build.GradleBuildState
import com.android.tools.idea.gradle.project.build.invoker.GradleBuildInvoker
import com.android.tools.idea.gradle.project.build.invoker.TestCompileType
import com.android.tools.idea.gradle.util.BuildMode
import com.android.tools.idea.projectsystem.ProjectSystemBuildManager
import com.intellij.openapi.Disposable
import com.intellij.openapi.components.Service
import com.intellij.openapi.module.ModuleManager
import com.intellij.openapi.module.ModuleUtil
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.util.messages.Topic
private fun BuildStatus.toProjectSystemBuildStatus(): ProjectSystemBuildManager.BuildStatus = when(this) {
BuildStatus.SUCCESS -> ProjectSystemBuildManager.BuildStatus.SUCCESS
BuildStatus.FAILED -> ProjectSystemBuildManager.BuildStatus.FAILED
BuildStatus.CANCELED -> ProjectSystemBuildManager.BuildStatus.CANCELLED
else -> ProjectSystemBuildManager.BuildStatus.UNKNOWN
}
private fun BuildMode?.toProjectSystemBuildMode(): ProjectSystemBuildManager.BuildMode = when(this) {
BuildMode.CLEAN -> ProjectSystemBuildManager.BuildMode.CLEAN
BuildMode.COMPILE_JAVA -> ProjectSystemBuildManager.BuildMode.COMPILE
BuildMode.ASSEMBLE -> ProjectSystemBuildManager.BuildMode.ASSEMBLE
BuildMode.REBUILD -> ProjectSystemBuildManager.BuildMode.COMPILE
else -> ProjectSystemBuildManager.BuildMode.UNKNOWN
}
@Service
private class GradleProjectSystemBuildPublisher(val project: Project): GradleBuildListener.Adapter(), Disposable {
private val PROJECT_SYSTEM_BUILD_TOPIC = Topic("Project build", ProjectSystemBuildManager.BuildListener::class.java)
init {
GradleBuildState.subscribe(project, this, this)
}
override fun buildStarted(context: BuildContext) {
project.messageBus.syncPublisher(PROJECT_SYSTEM_BUILD_TOPIC).buildStarted(context.buildMode.toProjectSystemBuildMode())
}
override fun buildFinished(status: BuildStatus, context: BuildContext?) {
val result = ProjectSystemBuildManager.BuildResult(
context?.buildMode.toProjectSystemBuildMode(),
status.toProjectSystemBuildStatus(),
System.currentTimeMillis())
project.messageBus.syncPublisher(PROJECT_SYSTEM_BUILD_TOPIC).beforeBuildCompleted(result)
project.messageBus.syncPublisher(PROJECT_SYSTEM_BUILD_TOPIC).buildCompleted(result)
}
override fun dispose() {
}
fun addBuildListener(parentDisposable: Disposable, buildListener: ProjectSystemBuildManager.BuildListener) =
project.messageBus.connect(parentDisposable).subscribe(PROJECT_SYSTEM_BUILD_TOPIC, buildListener)
}
class GradleProjectSystemBuildManager(val project: Project): ProjectSystemBuildManager {
override fun compileProject() {
val modules = ModuleManager.getInstance(project).modules
GradleBuildInvoker.getInstance(project).compileJava(modules, TestCompileType.ALL)
}
override fun compileFilesAndDependencies(files: Collection<VirtualFile>) {
val modules = files.mapNotNull { ModuleUtil.findModuleForFile(it, project) }.toSet()
GradleBuildInvoker.getInstance(project).compileJava(modules.toTypedArray(), TestCompileType.NONE)
}
override fun getLastBuildResult(): ProjectSystemBuildManager.BuildResult =
GradleBuildState.getInstance(project).lastFinishedBuildSummary?.let {
ProjectSystemBuildManager.BuildResult(
it.context?.buildMode.toProjectSystemBuildMode(),
it.status.toProjectSystemBuildStatus(),
System.currentTimeMillis())
} ?: ProjectSystemBuildManager.BuildResult.createUnknownBuildResult()
override fun addBuildListener(parentDisposable: Disposable, buildListener: ProjectSystemBuildManager.BuildListener) =
project.getService(GradleProjectSystemBuildPublisher::class.java).addBuildListener(parentDisposable, buildListener)
} | 0 | null | 0 | 0 | b373163869f676145341d60985cdbdaca3565c0b | 4,105 | android | Apache License 2.0 |
project-system-gradle/src/com/android/tools/idea/projectsystem/gradle/GradleProjectSystemBuildManager.kt | leobert-lan | 563,630,098 | true | {"Text": 355, "EditorConfig": 2, "Markdown": 64, "Shell": 32, "Ignore List": 193, "XML": 13507, "Starlark": 142, "Kotlin": 6746, "Java": 8085, "Gradle": 2753, "Proguard": 169, "INI": 72, "JSON": 80, "Graphviz (DOT)": 1, "Ant Build System": 2, "Protocol Buffer": 8, "Java Properties": 166, "HTML": 67, "Batchfile": 20, "Gradle Kotlin DSL": 1655, "CMake": 19, "C": 29, "Checksums": 339, "C++": 14, "TOML": 2, "Smali": 5, "SVG": 1329, "AIDL": 9, "JFlex": 8, "Prolog": 6, "QMake": 2, "RenderScript": 1, "NSIS": 4, "GraphQL": 5, "Python": 10, "Makefile": 8, "YAML": 1, "HAProxy": 1, "Org": 2, "JavaScript": 3} | package com.android.tools.idea.projectsystem.gradle
import com.android.tools.idea.gradle.project.build.BuildContext
import com.android.tools.idea.gradle.project.build.BuildStatus
import com.android.tools.idea.gradle.project.build.GradleBuildListener
import com.android.tools.idea.gradle.project.build.GradleBuildState
import com.android.tools.idea.gradle.project.build.invoker.GradleBuildInvoker
import com.android.tools.idea.gradle.project.build.invoker.TestCompileType
import com.android.tools.idea.gradle.util.BuildMode
import com.android.tools.idea.projectsystem.ProjectSystemBuildManager
import com.intellij.openapi.Disposable
import com.intellij.openapi.components.Service
import com.intellij.openapi.module.ModuleManager
import com.intellij.openapi.module.ModuleUtil
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.util.messages.Topic
private fun BuildStatus.toProjectSystemBuildStatus(): ProjectSystemBuildManager.BuildStatus = when(this) {
BuildStatus.SUCCESS -> ProjectSystemBuildManager.BuildStatus.SUCCESS
BuildStatus.FAILED -> ProjectSystemBuildManager.BuildStatus.FAILED
BuildStatus.CANCELED -> ProjectSystemBuildManager.BuildStatus.CANCELLED
else -> ProjectSystemBuildManager.BuildStatus.UNKNOWN
}
private fun BuildMode?.toProjectSystemBuildMode(): ProjectSystemBuildManager.BuildMode = when(this) {
BuildMode.CLEAN -> ProjectSystemBuildManager.BuildMode.CLEAN
BuildMode.COMPILE_JAVA -> ProjectSystemBuildManager.BuildMode.COMPILE
BuildMode.ASSEMBLE -> ProjectSystemBuildManager.BuildMode.ASSEMBLE
BuildMode.REBUILD -> ProjectSystemBuildManager.BuildMode.COMPILE
else -> ProjectSystemBuildManager.BuildMode.UNKNOWN
}
@Service
private class GradleProjectSystemBuildPublisher(val project: Project): GradleBuildListener.Adapter(), Disposable {
private val PROJECT_SYSTEM_BUILD_TOPIC = Topic("Project build", ProjectSystemBuildManager.BuildListener::class.java)
init {
GradleBuildState.subscribe(project, this, this)
}
override fun buildStarted(context: BuildContext) {
project.messageBus.syncPublisher(PROJECT_SYSTEM_BUILD_TOPIC).buildStarted(context.buildMode.toProjectSystemBuildMode())
}
override fun buildFinished(status: BuildStatus, context: BuildContext?) {
val result = ProjectSystemBuildManager.BuildResult(
context?.buildMode.toProjectSystemBuildMode(),
status.toProjectSystemBuildStatus(),
System.currentTimeMillis())
project.messageBus.syncPublisher(PROJECT_SYSTEM_BUILD_TOPIC).beforeBuildCompleted(result)
project.messageBus.syncPublisher(PROJECT_SYSTEM_BUILD_TOPIC).buildCompleted(result)
}
override fun dispose() {
}
fun addBuildListener(parentDisposable: Disposable, buildListener: ProjectSystemBuildManager.BuildListener) =
project.messageBus.connect(parentDisposable).subscribe(PROJECT_SYSTEM_BUILD_TOPIC, buildListener)
}
class GradleProjectSystemBuildManager(val project: Project): ProjectSystemBuildManager {
override fun compileProject() {
val modules = ModuleManager.getInstance(project).modules
GradleBuildInvoker.getInstance(project).compileJava(modules, TestCompileType.ALL)
}
override fun compileFilesAndDependencies(files: Collection<VirtualFile>) {
val modules = files.mapNotNull { ModuleUtil.findModuleForFile(it, project) }.toSet()
GradleBuildInvoker.getInstance(project).compileJava(modules.toTypedArray(), TestCompileType.NONE)
}
override fun getLastBuildResult(): ProjectSystemBuildManager.BuildResult =
GradleBuildState.getInstance(project).lastFinishedBuildSummary?.let {
ProjectSystemBuildManager.BuildResult(
it.context?.buildMode.toProjectSystemBuildMode(),
it.status.toProjectSystemBuildStatus(),
System.currentTimeMillis())
} ?: ProjectSystemBuildManager.BuildResult.createUnknownBuildResult()
override fun addBuildListener(parentDisposable: Disposable, buildListener: ProjectSystemBuildManager.BuildListener) =
project.getService(GradleProjectSystemBuildPublisher::class.java).addBuildListener(parentDisposable, buildListener)
} | 0 | null | 0 | 0 | b373163869f676145341d60985cdbdaca3565c0b | 4,105 | android | Apache License 2.0 |
marcel-android-legacy/app/src/main/java/com/tambapps/marcel/android/marshell/repl/AndroidMarshellFactory.kt | tambapps | 587,877,674 | false | {"Maven POM": 26, "Text": 1, "Ignore List": 11, "Markdown": 87, "Kotlin": 465, "Gradle Kotlin DSL": 5, "INI": 4, "Java Properties": 4, "Shell": 5, "Batchfile": 2, "Proguard": 8, "XML": 83, "Java": 226, "YAML": 1, "JavaScript": 1, "TOML": 1, "Gradle": 5, "JFlex": 1} | package com.tambapps.marcel.android.marshell.repl
import com.tambapps.marcel.android.marshell.data.ShellSession
import com.tambapps.marcel.compiler.CompilerConfiguration
import com.tambapps.marcel.repl.printer.SuspendPrinter
import marcel.lang.Binding
import marcel.lang.MarcelDexClassLoader
import java.io.File
import javax.inject.Inject
import javax.inject.Named
class AndroidMarshellFactory @Inject constructor(
// these are not vals because hilt doesn't allow final fields when injecting
_compilerConfiguration: CompilerConfiguration,
@Named("initScriptFile")
_initScriptFile: File
) {
private val compilerConfiguration = _compilerConfiguration
private val initScriptFile = _initScriptFile
fun newShellRunner(session: ShellSession, printer: SuspendPrinter, lineReader: suspend (String) -> String,
exitFunc: () -> Unit): AndroidMarshellRunner {
return AndroidMarshellRunner(
session,
AndroidMarshell(compilerConfiguration, session.directory, initScriptFile, printer, exitFunc, session.classLoader,
session.binding, session.typeResolver, lineReader, session.history)
)
}
} | 0 | Java | 0 | 7 | 83bf3562f8bb6b43fe5d6f2e13c9ed5ad3300bce | 1,129 | marcel | Apache License 2.0 |
src/main/kotlin/io/github/nikpivkin/lifetime/event/LifetimeChangedEvent.kt | nikpivkin | 618,118,736 | false | {"Java": 24475, "Kotlin": 21796} | package io.github.nikpivkin.lifetime.event
import io.github.nikpivkin.lifetime.Lifetime
import org.bukkit.entity.Player
import org.bukkit.event.Event
import org.bukkit.event.HandlerList
data class LifetimeChangedEvent(
val player: Player,
val oldValue: Lifetime,
val newValue: Lifetime
) : Event() {
override fun getHandlers() = HANDLERS
companion object {
private val HANDLERS = HandlerList()
@JvmStatic
fun getHandlerList() = HANDLERS
}
}
| 1 | null | 1 | 1 | 14568b818dc90e318c9816353a52855e8fab5d14 | 494 | lifetime-min-plg | MIT License |
features/dd-sdk-android-session-replay/src/test/kotlin/com/datadog/android/sessionreplay/internal/SessionReplayRecordCallbackTest.kt | DataDog | 219,536,756 | false | null | /*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2016-Present Datadog, Inc.
*/
package com.datadog.android.sessionreplay.internal
import com.datadog.android.api.feature.FeatureSdkCore
import com.datadog.android.sessionreplay.forge.ForgeConfigurator
import com.datadog.android.sessionreplay.internal.processor.EnrichedRecord
import fr.xgouchet.elmyr.Forge
import fr.xgouchet.elmyr.junit5.ForgeConfiguration
import fr.xgouchet.elmyr.junit5.ForgeExtension
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import org.junit.jupiter.api.extension.Extensions
import org.mockito.Mock
import org.mockito.junit.jupiter.MockitoExtension
import org.mockito.junit.jupiter.MockitoSettings
import org.mockito.kotlin.argumentCaptor
import org.mockito.kotlin.eq
import org.mockito.kotlin.times
import org.mockito.kotlin.verify
import org.mockito.kotlin.verifyNoInteractions
import org.mockito.quality.Strictness
@Extensions(
ExtendWith(ForgeExtension::class),
ExtendWith(MockitoExtension::class)
)
@MockitoSettings(strictness = Strictness.LENIENT)
@ForgeConfiguration(ForgeConfigurator::class)
internal class SessionReplayRecordCallbackTest {
@Mock
lateinit var mockDatadogCore: FeatureSdkCore
lateinit var testedRecordCallback: SessionReplayRecordCallback
lateinit var fakeEnrichedRecord: EnrichedRecord
@BeforeEach
fun `set up`(forge: Forge) {
fakeEnrichedRecord = forge.forgeFakeValidEnrichedRecord()
testedRecordCallback = SessionReplayRecordCallback(mockDatadogCore)
}
@Suppress("UNCHECKED_CAST")
@Test
fun `M update session replay context W onRecordForViewSent`() {
// When
testedRecordCallback.onRecordForViewSent(fakeEnrichedRecord)
// Then
argumentCaptor<(MutableMap<String, Any?>) -> Unit> {
verify(mockDatadogCore).updateFeatureContext(
eq(SessionReplayFeature.SESSION_REPLAY_FEATURE_NAME),
capture()
)
val featureContext = mutableMapOf<String, Any?>()
lastValue.invoke(featureContext)
val viewMetadata = featureContext[fakeEnrichedRecord.viewId] as? Map<String, Any?>
assertThat(viewMetadata).isNotNull
val hasReplay = viewMetadata?.get(SessionReplayRecordCallback.HAS_REPLAY_KEY)
as? Boolean
assertThat(hasReplay).isTrue
val recordsCount = viewMetadata?.get(SessionReplayRecordCallback.VIEW_RECORDS_COUNT_KEY)
as? Long
assertThat(recordsCount).isEqualTo(fakeEnrichedRecord.records.size.toLong())
}
}
@Suppress("UNCHECKED_CAST")
@Test
fun `M do nothing W onRecordForViewSent{empty EnrichedRecord}`(forge: Forge) {
// Given
val fakeEmptyEnrichedRecord = forge.forgeEmptyValidEnrichedRecord()
// When
testedRecordCallback.onRecordForViewSent(fakeEmptyEnrichedRecord)
// Then
verifyNoInteractions(mockDatadogCore)
}
@Suppress("UNCHECKED_CAST")
@Test
fun `M discard prev keys if the types are incorrect onRecordForViewSent`(forge: Forge) {
// When
testedRecordCallback.onRecordForViewSent(fakeEnrichedRecord)
// Then
argumentCaptor<(MutableMap<String, Any?>) -> Unit> {
verify(mockDatadogCore).updateFeatureContext(
eq(SessionReplayFeature.SESSION_REPLAY_FEATURE_NAME),
capture()
)
val featureContext = mutableMapOf<String, Any?>(
SessionReplayRecordCallback.HAS_REPLAY_KEY to forge.aString(),
SessionReplayRecordCallback.VIEW_RECORDS_COUNT_KEY to forge.aString()
)
lastValue.invoke(featureContext)
val viewMetadata = featureContext[fakeEnrichedRecord.viewId] as? Map<String, Any?>
assertThat(viewMetadata).isNotNull
val hasReplay = viewMetadata?.get(SessionReplayRecordCallback.HAS_REPLAY_KEY)
as? Boolean
assertThat(hasReplay).isTrue
val recordsCount = viewMetadata?.get(SessionReplayRecordCallback.VIEW_RECORDS_COUNT_KEY)
as? Long
assertThat(recordsCount).isEqualTo(fakeEnrichedRecord.records.size.toLong())
}
}
@Suppress("UNCHECKED_CAST")
@Test
fun `M increase the records count W onRecordForViewSent`(forge: Forge) {
// Given
val fakeViewId = forge.aString()
val fakeNumberOfUpdates = forge.anInt(min = 1, max = 10)
val fakeEnrichedRecords = forge.aList(size = fakeNumberOfUpdates) {
forge.forgeFakeValidEnrichedRecord().copy(viewId = fakeViewId)
}
// When
fakeEnrichedRecords.forEach {
testedRecordCallback.onRecordForViewSent(it)
}
// Then
argumentCaptor<(MutableMap<String, Any?>) -> Unit> {
verify(mockDatadogCore, times(fakeNumberOfUpdates)).updateFeatureContext(
eq(SessionReplayFeature.SESSION_REPLAY_FEATURE_NAME),
capture()
)
val featureContext = mutableMapOf<String, Any?>()
this.allValues.forEach {
it.invoke(featureContext)
}
val viewMetadata = featureContext[fakeViewId] as? Map<String, Any?>
assertThat(viewMetadata).isNotNull
val hasReplay = viewMetadata?.get(SessionReplayRecordCallback.HAS_REPLAY_KEY)
as? Boolean
assertThat(hasReplay).isTrue
val recordsCount = viewMetadata?.get(SessionReplayRecordCallback.VIEW_RECORDS_COUNT_KEY)
as? Long
assertThat(recordsCount)
.isEqualTo(fakeEnrichedRecords.sumOf { it.records.size.toLong() })
}
}
private fun Forge.forgeFakeValidEnrichedRecord(): EnrichedRecord {
return getForgery<EnrichedRecord>()
.copy(records = aList(size = anInt(min = 1, max = 10)) { getForgery() })
}
private fun Forge.forgeEmptyValidEnrichedRecord(): EnrichedRecord {
return getForgery<EnrichedRecord>().copy(records = emptyList())
}
}
| 44 | null | 60 | 151 | d7e640cf6440ab150c2bbfbac261e09b27e258f4 | 6,421 | dd-sdk-android | Apache License 2.0 |
vector/src/main/java/im/vector/app/features/voicebroadcast/usecase/GetRoomLiveVoiceBroadcastsUseCase.kt | tchapgouv | 340,329,238 | false | {"Kotlin": 15930464, "HTML": 68524, "Shell": 57406, "Java": 28010, "Python": 25875, "FreeMarker": 7662, "JavaScript": 6925, "Ruby": 1587} | /*
* Copyright (c) 2022 New Vector Ltd
*
* 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 im.vector.app.features.voicebroadcast.usecase
import im.vector.app.core.di.ActiveSessionHolder
import im.vector.app.features.voicebroadcast.VoiceBroadcastConstants
import im.vector.app.features.voicebroadcast.isLive
import im.vector.app.features.voicebroadcast.model.VoiceBroadcast
import im.vector.app.features.voicebroadcast.model.VoiceBroadcastEvent
import im.vector.app.features.voicebroadcast.model.asVoiceBroadcastEvent
import im.vector.app.features.voicebroadcast.voiceBroadcastId
import org.matrix.android.sdk.api.query.QueryStringValue
import org.matrix.android.sdk.api.session.getRoom
import javax.inject.Inject
/**
* Get the list of live (not ended) voice broadcast events in the given room.
*/
class GetRoomLiveVoiceBroadcastsUseCase @Inject constructor(
private val activeSessionHolder: ActiveSessionHolder,
private val getVoiceBroadcastStateEventUseCase: GetVoiceBroadcastStateEventUseCase,
) {
fun execute(roomId: String): List<VoiceBroadcastEvent> {
val session = activeSessionHolder.getSafeActiveSession() ?: return emptyList()
val room = session.getRoom(roomId) ?: error("Unknown roomId: $roomId")
return room.stateService().getStateEvents(
setOf(VoiceBroadcastConstants.STATE_ROOM_VOICE_BROADCAST_INFO),
QueryStringValue.IsNotEmpty
)
.mapNotNull { stateEvent -> stateEvent.asVoiceBroadcastEvent()?.voiceBroadcastId }
.mapNotNull { voiceBroadcastId -> getVoiceBroadcastStateEventUseCase.execute(VoiceBroadcast(voiceBroadcastId, roomId)) }
.filter { it.isLive }
}
}
| 4 | Kotlin | 6 | 9 | b248ca2dbb0953761d2780e4fba756acc3899958 | 2,236 | tchap-android | Apache License 2.0 |
app/src/main/java/com/aritra/notify/data/relations/TrashNoteWithNotes.kt | aritra-tech | 659,098,498 | false | {"Kotlin": 249885} | package com.aritra.notify.data.relations
import androidx.room.Embedded
import androidx.room.Relation
import com.aritra.notify.domain.models.Note
import com.aritra.notify.domain.models.TrashNote
data class TrashNoteWithNotes(
@Embedded val trashNote: TrashNote,
@Relation(
parentColumn = "noteId",
entityColumn = "id"
)
val note: Note,
)
| 26 | Kotlin | 62 | 236 | 8d4275b94e2ab730e21077e74eeeaca33de845e8 | 371 | Notify | MIT License |
src/test/kotlin/de/consuli/aoc/year2022/days/Day09Test.kt | ulischulte | 572,773,554 | false | {"Kotlin": 40404} | package de.consuli.aoc.year2022.days
import de.consuli.aoc.DayTest
import de.consuli.aoc.PuzzleOutput
class Day09Test : DayTest<Day09>(
Day09(), PuzzleOutput(
partOneExpectedSampleOutput = 88,
partOneExpectedOutput = 5710,
partTwoExpectedSampleOutput = 36,
partTwoExpectedOutput = 2259
), Day09()
)
| 0 | Kotlin | 0 | 2 | 21e92b96b7912ad35ecb2a5f2890582674a0dd6a | 342 | advent-of-code | Apache License 2.0 |
presentation/src/test/java/az/khayalsharifli/presentation/MainCoroutineRule.kt | khayalsherif | 544,539,899 | false | {"Kotlin": 63276} | package az.khayalsharifli.presentation
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.*
import org.junit.rules.TestWatcher
import org.junit.runner.Description
@ExperimentalCoroutinesApi
class MainCoroutineRule(private val dispatcher: TestDispatcher = StandardTestDispatcher()) :
TestWatcher() {
override fun starting(description: Description?) {
super.starting(description)
Dispatchers.setMain(dispatcher)
}
override fun finished(description: Description?) {
super.finished(description)
Dispatchers.resetMain()
}
} | 0 | Kotlin | 0 | 1 | 526cd1076d202599bfbb72d3aea2e279f36962cd | 690 | nasa | The Unlicense |
app/src/main/java/br/com/mspandrade/navigationstories/di/Modules.kt | mspandrade | 838,088,060 | false | {"Kotlin": 24715} | package br.com.mspandrade.navigationstories.di
import android.os.Bundle
import br.com.mspandrade.navigation_stories_kit.data.ChannelContentData
import br.com.mspandrade.navigation_stories_kit.service.ChannelContentAdapter
import br.com.mspandrade.navigation_stories_kit.ui.framents.FragmentBaseContent
import br.com.mspandrade.navigationstories.ui.RenderPhotoFragment
import org.koin.dsl.module
const val ARG_SRC_IMAGE = "ARG_SRC_IMAGE"
val appModule = module {
single<ChannelContentAdapter> { object : ChannelContentAdapter {
override fun getChannelsCount(): Int = 6
override fun getChannelContent(position: Int): ChannelContentData = ChannelContentData(
id = position.toString(),
beginAt = 0
)
override fun getStoryBundles(channel: ChannelContentData): List<Bundle> {
val list = mutableListOf<Bundle>()
repeat(8) { position ->
list.add(instanceBundle(position + 1))
}
return list
}
override fun onStoryFragmentCreate(): FragmentBaseContent = RenderPhotoFragment()
private fun instanceBundle(position: Int): Bundle {
val imageSrc = when {
position.rem(2) == 0 ->
"https://s2-techtudo.glbimg.com/SSAPhiaAy_zLTOu3Tr3ZKu2H5vg=/0x0:1024x609/888x0/smart/filters:strip_icc()/i.s3.glbimg.com/v1/AUTH_08fbf48bc0524877943fe86e43087e7a/internal_photos/bs/2022/c/u/15eppqSmeTdHkoAKM0Uw/dall-e-2.jpg"
else ->
"https://cdn.pixabay.com/photo/2024/02/26/19/39/monochrome-image-8598798_640.jpg"
}
return Bundle().also {
it.putString("id", "story-$position")
it.putString(ARG_SRC_IMAGE, imageSrc)
}
}
}}
} | 0 | Kotlin | 0 | 0 | a0089f4a90df75b01db08382d706958f6087755d | 1,848 | navigation-stories | MIT License |
app/src/main/java/com/kssidll/arru/data/repository/VariantRepositorySource.kt | KSSidll | 655,360,420 | false | {"Kotlin": 826741} | package com.kssidll.arru.data.repository
import com.kssidll.arru.data.data.*
import kotlinx.coroutines.flow.*
interface VariantRepositorySource {
companion object {
sealed class InsertResult(
val id: Long? = null,
val error: Errors? = null
) {
class Success(id: Long): InsertResult(id)
class Error(error: Errors): InsertResult(error = error)
fun isError(): Boolean = this is Error
fun isNotError(): Boolean = isError().not()
sealed class Errors
data object InvalidProductId: Errors()
data object InvalidName: Errors()
data object DuplicateName: Errors()
}
sealed class UpdateResult(
val error: Errors? = null
) {
data object Success: UpdateResult()
class Error(error: Errors): UpdateResult(error = error)
fun isError(): Boolean = this is Error
fun isNotError(): Boolean = isError().not()
sealed class Errors
data object InvalidId: Errors()
data object InvalidProductId: Errors()
data object InvalidName: Errors()
data object DuplicateName: Errors()
}
sealed class DeleteResult(
val error: Errors? = null
) {
data object Success: DeleteResult()
class Error(error: Errors): DeleteResult(error = error)
fun isError(): Boolean = this is Error
fun isNotError(): Boolean = isError().not()
sealed class Errors
data object InvalidId: Errors()
}
}
// Create
/**
* Inserts [ProductVariant]
* @param productId id of the [Product] to insert the [ProductVariant] for
* @param name name of the variant
* @return [InsertResult] with id of the newly inserted [ProductVariant] or an error if any
*/
suspend fun insert(
productId: Long,
name: String
): InsertResult
// Update
/**
* Updates [ProductVariant] with [variantId] id to provided [name]
* @param variantId id to match [ProductVariant]
* @param name name to update the matching [ProductVariant] to
* @return [UpdateResult] with the result
*/
suspend fun update(
variantId: Long,
name: String
): UpdateResult
/**
* Updates [ProductVariant] with [variantId] id to provided [productId] and [name]
* @param variantId id to match [ProductVariant]
* @param productId [Product] id to update the matching [ProductVariant] to
* @param name name to update the matching [ProductVariant] to
* @return [UpdateResult] with the result
*/
suspend fun update(
variantId: Long,
productId: Long,
name: String
): UpdateResult
// Delete
/**
* Deletes [ProductVariant]
* @param variantId id of the [ProductVariant] to delete
* @return [DeleteResult] with the result
*/
suspend fun delete(variantId: Long): DeleteResult
// Read
/**
* @param variantId id of the [ProductVariant]
* @return [ProductVariant] matching [variantId] id or null if none match
*/
suspend fun get(variantId: Long): ProductVariant?
/**
* @param variantId id of the [ProductVariant]
* @return [ProductVariant] matching [variantId] id or null if none match, as flow
*/
fun getFlow(variantId: Long): Flow<ProductVariant?>
/**
* @param product [Product] to match the [ProductVariant] with
* @return list of [ProductVariant] matching [product] as flow
*/
fun byProductFlow(product: Product): Flow<List<ProductVariant>>
} | 0 | Kotlin | 0 | 4 | ff3f257a0604a6d9e5169dc47753094c9b0c9520 | 3,714 | Arru | BSD 3-Clause Clear License |
src/main/kotlin/org/teamvoided/dusk_autumn/block/DnDPumpkinBlock.kt | TeamVoided | 737,359,498 | false | {"Kotlin": 1129694, "Java": 28224} | package org.teamvoided.dusk_autumn.block
import net.minecraft.block.Block
import net.minecraft.block.BlockState
import net.minecraft.block.CarvedPumpkinBlock
import net.minecraft.entity.ItemEntity
import net.minecraft.entity.LivingEntity
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.item.Item
import net.minecraft.item.ItemStack
import net.minecraft.item.Items
import net.minecraft.sound.SoundCategory
import net.minecraft.sound.SoundEvents
import net.minecraft.stat.Stats
import net.minecraft.util.Hand
import net.minecraft.util.ItemInteractionResult
import net.minecraft.util.hit.BlockHitResult
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import net.minecraft.world.World
import net.minecraft.world.event.GameEvent
import org.teamvoided.dusk_autumn.DusksAndDungeons.log
open class DnDPumpkinBlock(private val carvedBlock: Block, settings: Settings) : Block(settings) {
private var seedsItem = Items.PUMPKIN_SEEDS
open val seeds = 4
override fun onInteract(
stack: ItemStack,
state: BlockState,
world: World,
pos: BlockPos,
entity: PlayerEntity,
hand: Hand,
hitResult: BlockHitResult
): ItemInteractionResult {
if (!stack.isOf(Items.SHEARS)) {
return super.onInteract(stack, state, world, pos, entity, hand, hitResult)
} else if (world.isClient) {
return ItemInteractionResult.success(world.isClient)
} else {
val direction = hitResult.side
val direction2 = if (direction.axis == Direction.Axis.Y) entity.horizontalFacing.opposite else direction
world.playSound(
null ,
pos,
SoundEvents.BLOCK_PUMPKIN_CARVE,
SoundCategory.BLOCKS,
1.0f,
1.0f
)
world.setBlockState(
pos,
carvedBlock.defaultState.with(CarvedPumpkinBlock.FACING, direction2),
11
)
val itemEntity = ItemEntity(
world,
pos.x.toDouble() + 0.5 + direction2.offsetX.toDouble() * 0.65, pos.y.toDouble() + 0.1,
pos.z.toDouble() + 0.5 + direction2.offsetZ.toDouble() * 0.65, ItemStack(seedsItem, seeds)
)
itemEntity.setVelocity(
0.05 * direction2.offsetX.toDouble() + world.random.nextDouble() * 0.02,
0.05,
0.05 * direction2.offsetZ.toDouble() + world.random.nextDouble() * 0.02
)
world.spawnEntity(itemEntity)
stack.damageEquipment(1, entity, LivingEntity.getHand(hand))
world.emitGameEvent(entity, GameEvent.SHEAR, pos)
entity.incrementStat(Stats.USED.getOrCreateStat(Items.SHEARS))
return ItemInteractionResult.success(world.isClient)
}
}
fun setSeeds(item: Item) {
seedsItem = item
}
companion object {
fun Block.setSeeds(item: Item) {
if (this is DnDPumpkinBlock) this.setSeeds(item)
else log.warn("Block [$this] is not a DnDPumpkinBlock")
}
}
} | 0 | Kotlin | 0 | 0 | 7df0896ea35a8f1c3a2676821629ff16de72d95e | 3,188 | DusksAndDungeons | MIT License |
server/src/main/kotlin/ru/itis/favein/controllers/AdminController.kt | martis-git | 245,149,911 | false | {"TypeScript": 107068, "Kotlin": 71951, "Java": 13525, "CSS": 9769, "HTML": 1718, "JavaScript": 286} | package ru.itis.favein.controllers
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Controller
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import ru.itis.favein.repository.*
import ru.itis.favein.services.CardService
@Controller
@RequestMapping("/admin")
class AdminController(
@Autowired
private val labelRepo: LabelRepository,
@Autowired
private val userRepo: UserRepository,
@Autowired
private val dashboardRepo: DashboardRepository,
@Autowired
private val listRepo: ListRepository,
@Autowired
private val cardRepo: CardRepository
) {
@GetMapping
fun index(model: Model): String {
model.addAttribute("labels", labelRepo.findAll())
model.addAttribute("users", userRepo.findAll())
model.addAttribute("boards", dashboardRepo.findAll())
model.addAttribute("lists", listRepo.findAll())
model.addAttribute("cards", cardRepo.findAll())
return "admin/index"
}
} | 2 | TypeScript | 0 | 1 | b06121e9c7c00a988232d9aa4a42f8dbd5b95ffd | 1,161 | favein | MIT License |
core/network/src/main/java/com/muammarahlnn/learnyscape/core/network/datasource/impl/QuizSessionNetworkDataSourceImpl.kt | muammarahlnn | 663,132,195 | false | {"Kotlin": 1073986} | package com.muammarahlnn.learnyscape.core.network.datasource.impl
import com.muammarahlnn.learnyscape.core.network.api.QuizzesApi
import com.muammarahlnn.learnyscape.core.network.datasource.QuizSessionNetworkDataSource
import com.muammarahlnn.learnyscape.core.network.model.request.SubmitMultipleChoiceAnswersRequest
import com.muammarahlnn.learnyscape.core.network.model.response.QuizMultipleChoiceProblemResponse
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject
import javax.inject.Singleton
/**
* @Author <NAME>
* @File QuizSessionNetworkDataSourceImpl, 09/02/2024 18.19
*/
@Singleton
class QuizSessionNetworkDataSourceImpl @Inject constructor(
private val quizzesApi: QuizzesApi,
) : QuizSessionNetworkDataSource {
override fun getQuizMultipleChoiceProblems(quizId: String): Flow<List<QuizMultipleChoiceProblemResponse>> =
flow {
emit(quizzesApi.getQuizMultipleChoiceProblems(quizId).data.problems)
}
override fun putMultipleChoiceAnswers(quizId: String, answers: List<String>): Flow<String> = flow {
emit(
quizzesApi.putMultipleChoiceAnswers(
quizId = quizId,
submitMultipleChoiceAnswersRequest = SubmitMultipleChoiceAnswersRequest(answers)
).data
)
}
} | 0 | Kotlin | 0 | 0 | c9c827aef5560504255cb62d72303a85cd393d2a | 1,331 | Learnyscape | Apache License 2.0 |
HTTPShortcuts/app/src/main/kotlin/ch/rmy/android/http_shortcuts/icons/BuiltInIconAdapter.kt | Waboodoo | 34,525,124 | false | null | package ch.rmy.android.http_shortcuts.icons
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import ch.rmy.android.http_shortcuts.databinding.IconListItemBinding
class BuiltInIconAdapter(
private val icons: List<ShortcutIcon.BuiltInIcon>,
private val listener: (ShortcutIcon.BuiltInIcon) -> Unit,
) : RecyclerView.Adapter<BuiltInIconAdapter.IconViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): IconViewHolder =
IconViewHolder(IconListItemBinding.inflate(LayoutInflater.from(parent.context), parent, false), listener)
override fun onBindViewHolder(holder: IconViewHolder, position: Int) {
holder.setIcon(icons[position])
}
override fun getItemCount() = icons.size
inner class IconViewHolder(
private val binding: IconListItemBinding,
listener: (ShortcutIcon.BuiltInIcon) -> Unit,
) : RecyclerView.ViewHolder(binding.root) {
private lateinit var icon: ShortcutIcon.BuiltInIcon
init {
itemView.setOnClickListener {
listener.invoke(icon)
}
}
fun setIcon(icon: ShortcutIcon.BuiltInIcon) {
this.icon = icon
binding.icon.setIcon(icon)
}
}
}
| 29 | Kotlin | 94 | 671 | b364dfef22569ad326ee92492079790eaef4399d | 1,314 | HTTP-Shortcuts | MIT License |
buildSrc/src/main/kotlin/Dependencies.kt | rickclephas | 456,219,938 | false | null | object Dependencies {
object Kotlin {
private const val version = "1.6.10"
const val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$version"
}
} | 0 | Kotlin | 0 | 23 | 167b4bd052a742a4d79fef9485399b0e31ef7ab1 | 181 | NSErrorKt | MIT License |
desktop/src/main/java/org/ergoplatform/desktop/transactions/SubmitTransactionComponent.kt | ergoplatform | 376,102,125 | false | null | package org.ergoplatform.desktop.transactions
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import com.arkivanov.decompose.ComponentContext
import com.arkivanov.decompose.router.push
import org.ergoplatform.Application
import org.ergoplatform.SigningSecrets
import org.ergoplatform.desktop.ui.PasswordDialog
import org.ergoplatform.desktop.ui.navigation.NavClientScreenComponent
import org.ergoplatform.desktop.ui.navigation.NavHostComponent
import org.ergoplatform.desktop.ui.navigation.ScreenConfig
import org.ergoplatform.desktop.ui.proceedAuthFlowWithPassword
import org.ergoplatform.desktop.wallet.addresses.ChooseAddressesListDialog
import org.ergoplatform.transactions.PromptSigningResult
import org.ergoplatform.transactions.TransactionResult
import org.ergoplatform.uilogic.STRING_ERROR_PREPARE_TRANSACTION
import org.ergoplatform.uilogic.STRING_ERROR_SEND_TRANSACTION
import org.ergoplatform.uilogic.transactions.SubmitTransactionUiLogic
abstract class SubmitTransactionComponent(
val componentContext: ComponentContext,
private val navHost: NavHostComponent,
) : NavClientScreenComponent(navHost), ComponentContext by componentContext {
protected abstract val uiLogic: SubmitTransactionUiLogic
private val passwordDialog = mutableStateOf(false)
private val chooseAddressDialog = mutableStateOf<Boolean?>(null)
private val signingPromptDialog = mutableStateOf<String?>(null)
private val signingPromptPagesScanned = mutableStateOf<Pair<Int, Int>?>(null)
@Composable
protected fun SubmitTransactionOverlays() {
if (passwordDialog.value) {
PasswordDialog(
onDismissRequest = { passwordDialog.value = false },
onPasswordEntered = {
proceedAuthFlowWithPassword(
it,
uiLogic.wallet!!.walletConfig,
::proceedFromAuthFlow
)
}
)
}
if (chooseAddressDialog.value != null) {
ChooseAddressesListDialog(
uiLogic.wallet!!,
chooseAddressDialog.value!!,
onAddressChosen = { walletAddress ->
chooseAddressDialog.value = null
onAddressChosen(walletAddress?.derivationIndex)
},
onDismiss = { chooseAddressDialog.value = null },
)
}
signingPromptDialog.value?.let { signingPrompt ->
SigningPromptDialog(
uiLogic.signingPromptDialogConfig!!,
onContinueClicked = ::doScanColdSigning,
pagesScanned = signingPromptPagesScanned.value?.first,
pagesToScan = signingPromptPagesScanned.value?.second,
onDismissRequest = { signingPromptDialog.value = null },
)
}
}
protected fun showSigningPrompt(signingPrompt: String) {
signingPromptDialog.value = signingPrompt
}
private fun doScanColdSigning() {
router.push(ScreenConfig.QrCodeScanner { qrCode ->
uiLogic.signingPromptDialogConfig?.responsePagesCollector?.let {
it.addPage(qrCode)
if (it.hasAllPages()) {
signingPromptDialog.value = null
uiLogic.sendColdWalletSignedTx(
Application.prefs,
Application.texts,
Application.database
)
} else {
signingPromptPagesScanned.value = Pair(it.pagesAdded, it.pagesCount)
}
}
})
}
protected fun startChooseAddress(withAllAddresses: Boolean) {
chooseAddressDialog.value = withAllAddresses
}
protected open fun onAddressChosen(derivationIndex: Int?) {
uiLogic.derivedAddressIdx = derivationIndex
}
protected fun startPayment() {
val walletConfig = uiLogic.wallet!!.walletConfig
walletConfig.secretStorage?.let {
passwordDialog.value = true
} ?: uiLogic.startColdWalletPayment(Application.prefs, Application.texts)
}
private fun proceedFromAuthFlow(signingSecrets: SigningSecrets) {
uiLogic.startPaymentWithMnemonicAsync(
signingSecrets,
Application.prefs,
Application.texts,
Application.database
)
}
protected fun getTransactionResultErrorMessage(result: TransactionResult): String {
val errorMsgPrefix = if (result is PromptSigningResult)
STRING_ERROR_PREPARE_TRANSACTION
else STRING_ERROR_SEND_TRANSACTION
return (Application.texts.getString(errorMsgPrefix)
+ (result.errorMsg?.let { "\n\n$it" } ?: ""))
}
} | 16 | Kotlin | 35 | 94 | b5f6e5176cf780a7437eb3c8447820bd9409c8ac | 4,842 | ergo-wallet-app | Apache License 2.0 |
app/src/main/java/com/radityarin/spacexinfo/data/model/rockets/CompositeFairing.kt | radityarin | 276,372,378 | false | null | package com.radityarin.spacexinfo.data.model.rockets
import com.google.gson.annotations.SerializedName
import java.io.Serializable
data class CompositeFairing(
@SerializedName("diameter")
val diameter: DiameterX,
@SerializedName("height")
val height: HeightX
): Serializable | 0 | Kotlin | 0 | 3 | a22126a732676db88d7da062528ad021fd61ea33 | 293 | SpaceXInfo | MIT License |
app/src/main/java/com/example/androiddevchallenge/HomeUI.kt | allenzhangp | 349,652,232 | false | null | package com.example.androiddevchallenge
import androidx.annotation.DrawableRes
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.paddingFromBaseline
import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.material.BottomNavigation
import androidx.compose.material.BottomNavigationItem
import androidx.compose.material.Divider
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.OutlinedTextField
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material.TextField
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.AccountCircle
import androidx.compose.material.icons.filled.Done
import androidx.compose.material.icons.filled.FavoriteBorder
import androidx.compose.material.icons.filled.FilterList
import androidx.compose.material.icons.filled.Home
import androidx.compose.material.icons.filled.Search
import androidx.compose.material.icons.filled.ShoppingCart
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.navigation.NavHostController
@Composable
fun Home(navController: NavHostController) {
var searchValue by remember { mutableStateOf("") }
Box(modifier = Modifier.fillMaxSize()) {
Column(
modifier = Modifier
.padding(bottom = 56.dp)
.fillMaxSize()
) {
OutlinedTextField(
leadingIcon = {
Icon(
imageVector = Icons.Filled.Search,
modifier = Modifier.requiredHeight(18.dp),
contentDescription = null
)
},
value = searchValue,
onValueChange = { searchValue = it },
placeholder = {
Text(
"Search",
style = MaterialTheme.typography.body1,
color = MaterialTheme.colors.onPrimary
)
},
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp)
.requiredHeight(48.dp)
.offset(y = 40.dp)
)
Text(
text = "Browse Theme",
style = MaterialTheme.typography.h1,
color = MaterialTheme.colors.onPrimary,
modifier = Modifier.paddingFromBaseline(32.dp),
)
LazyRow(modifier = Modifier.padding(top = 16.dp)) {
items(dataSource1) { itemData ->
BrowseItem(id = itemData.resourceId, title = itemData.title)
}
}
Row(modifier = Modifier.fillMaxWidth()) {
Text(
"Design your home garden",
style = MaterialTheme.typography.h1,
color = MaterialTheme.colors.onPrimary,
modifier = Modifier.fillMaxWidth()
)
Icon(
imageVector = Icons.Filled.FilterList,
contentDescription = null,
modifier = Modifier
.size(24.dp)
.weight(1f)
)
}
LazyRow() {
}
}
BottomNavigation(modifier = Modifier.requiredHeight(56.dp)) {
BottomNavigationItem(
selected = true,
onClick = { /*TODO*/ },
icon = { Icons.Filled.Home },
label = { Text(text = "Home") })
BottomNavigationItem(
selected = true,
onClick = { /*TODO*/ },
icon = { Icons.Filled.FavoriteBorder },
label = { Text(text = "Favorite") })
BottomNavigationItem(
selected = true,
onClick = { /*TODO*/ },
icon = { Icons.Filled.AccountCircle },
label = { Text(text = "Profile") })
BottomNavigationItem(
selected = true,
onClick = { /*TODO*/ },
icon = { Icons.Filled.ShoppingCart },
label = { Text(text = "Cart") })
}
}
}
@Composable
fun BrowseItem(@DrawableRes id: Int, title: String) {
Surface(shape = MaterialTheme.shapes.small) {
Column(modifier = Modifier.size(136.dp)) {
Image(painter = painterResource(id = id), contentDescription = title)
Text(
text = title,
style = MaterialTheme.typography.h2,
color = MaterialTheme.colors.onPrimary,
modifier = Modifier.padding(16.dp)
)
}
}
}
@Composable
fun GardenItem(itemData: ItemData, isDone: Boolean) {
Row {
Image(
painter = painterResource(id = itemData.resourceId),
contentDescription = itemData.title
)
Column {
Row {
Column() {
Text(
itemData.title,
style = MaterialTheme.typography.h2,
color = MaterialTheme.colors.onPrimary
)
itemData.subTitle?.run {
Text(
this,
style = MaterialTheme.typography.body1,
color = MaterialTheme.colors.onPrimary
)
}
}
if (isDone) {
}
}
Divider()
}
}
}
val dataSource1 = listOf(
ItemData(R.drawable.img1, "Desert chic"),
ItemData(R.drawable.img2, "Tiny terrarium"),
ItemData(R.drawable.img3, "Jungle"),
ItemData(R.drawable.img4, "Desert chic"),
ItemData(R.drawable.img5, "Desert chic"),
)
val dataSource2 = listOf(
ItemData(R.drawable.img6, "Desert chic", subTitle = "This is description"),
ItemData(R.drawable.img7, "Tiny terrarium", subTitle = "This is description"),
ItemData(R.drawable.img8, "Jungle", subTitle = "This is description"),
ItemData(R.drawable.img9, "Desert chic", subTitle = "This is description"),
ItemData(R.drawable.img10, "Desert chic", subTitle = "This is description"),
ItemData(R.drawable.img11, "Desert chic", subTitle = "This is description"),
) | 0 | Kotlin | 0 | 0 | 551b55a004998eaf399d8d6b94552a0b2e30724c | 7,493 | composechallenge-bloom | Apache License 2.0 |
examples/wrong_arguments.kt | kitty-lang | 189,934,614 | false | null | // NOTE: This is supposed to fail.
func print(print: str) {
printf(print);
}
func main() {
print();
}
| 2 | Rust | 0 | 1 | 5cb38e878682b9c0b9f283bc4c54fe636e4e9019 | 106 | shedder | MIT License |
kotlin-csstype/src/main/generated/csstype/Inherits.kt | JetBrains | 93,250,841 | false | null | // Automatically generated - do not modify!
package csstype
typealias Inherits = Boolean
| 10 | Kotlin | 145 | 983 | 7ef1028ba3e0982dc93edcdfa6ee1edb334ddf35 | 91 | kotlin-wrappers | Apache License 2.0 |
kotlin-csstype/src/main/generated/csstype/Inherits.kt | JetBrains | 93,250,841 | false | null | // Automatically generated - do not modify!
package csstype
typealias Inherits = Boolean
| 10 | Kotlin | 145 | 983 | 7ef1028ba3e0982dc93edcdfa6ee1edb334ddf35 | 91 | kotlin-wrappers | Apache License 2.0 |
core/src/main/kotlin/app/vercors/instance/mojang/data/MojangArgument.kt | vercorsapp | 738,624,116 | false | {"Kotlin": 429732} | package app.vercors.instance.mojang.data
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializable
import kotlinx.serialization.descriptors.buildClassSerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.*
@Serializable(ArgumentSerializer::class)
sealed class MojangArgument
@Serializable
data class BasicArgument(
val value: String
) : MojangArgument()
@Serializable
data class ConditionalArgument(
val rules: List<MojangVersionInfo.Rule>,
val value: List<String>
) : MojangArgument()
private class ArgumentSerializer : KSerializer<MojangArgument> {
override val descriptor = buildClassSerialDescriptor("Argument")
override fun deserialize(decoder: Decoder): MojangArgument {
val jsonDecoder = decoder as JsonDecoder
val element = jsonDecoder.decodeJsonElement()
return if (element is JsonPrimitive) BasicArgument(element.content)
else {
val obj = element.jsonObject
val rules = obj["rules"]?.jsonArray
?.map { jsonDecoder.json.decodeFromJsonElement(MojangVersionInfo.Rule.serializer(), it.jsonObject) }
val valueJson = obj["value"]
val value =
if (valueJson is JsonArray) valueJson.map { it.jsonPrimitive.content }
else listOf(valueJson!!.jsonPrimitive.content)
ConditionalArgument(rules!!, value)
}
}
override fun serialize(encoder: Encoder, value: MojangArgument) {
// Serialization of this type is not necessary
}
} | 0 | Kotlin | 0 | 0 | 1790c8a3c05372c8179acb0c88a430ef3976153b | 1,629 | launcher | MIT License |
base/processor-base/src/main/java/com/spirytusz/booster/processor/base/data/config/TypeAdapterClassGenConfig.kt | spirytusz | 392,160,927 | false | null | package com.spirytusz.booster.processor.base.data.config
data class TypeAdapterClassGenConfig(
val nullSafe: Boolean = false,
val strictType: Boolean = false
) | 1 | Kotlin | 4 | 27 | e2ede7bcece69832ae0267d1a34c4c6f2fdaac09 | 168 | GsonBooster | MIT License |
백준/숨바꼭질.kt | jisungbin | 382,889,087 | false | null | import java.io.BufferedReader
import java.io.BufferedWriter
import java.io.InputStreamReader
import java.io.OutputStreamWriter
import java.util.LinkedList
import java.util.Queue
private const val MAX = 100001
fun main() {
val br = BufferedReader(InputStreamReader(System.`in`))
val bw = BufferedWriter(OutputStreamWriter(System.out))
val (me, sister) = br.readLine()!!.split(" ").map { it.toInt() }
val bfsQueue: Queue<Int> = LinkedList()
val visitTimeAndCount = List(MAX) { mutableListOf(-1, 0) }
bfsQueue.offer(me)
visitTimeAndCount[me][0] = 0 // 방문 시간
visitTimeAndCount[me][1] = 1 // 방문 가능한 방법의 수
// sister 에 방문했을 때 멈추는게 아닌, 모든 곳에 다 방문하고 기록함
while (bfsQueue.isNotEmpty()) {
val _me = bfsQueue.poll()
val meVisitTimeAndCount = visitTimeAndCount[_me]
for (next in listOf(_me * 2, _me + 1, _me - 1)) {
if (next in 0 until MAX) {
if (visitTimeAndCount[next][0] == -1) { // 만약 방문한 적이 없다면
bfsQueue.offer(next)
visitTimeAndCount[next][0] = meVisitTimeAndCount[0] + 1
visitTimeAndCount[next][1] = meVisitTimeAndCount[1]
} else if (visitTimeAndCount[next][0] == meVisitTimeAndCount[0] + 1) { // 만약 방문한 적이 있다면
visitTimeAndCount[next][1] += meVisitTimeAndCount[1] // 방문 가능한 방법의 수 업데이트
}
}
}
}
bw.write(visitTimeAndCount[sister][0].toString())
br.close()
bw.flush()
bw.close()
}
| 0 | Kotlin | 1 | 9 | ee43375828ca7e748e7c79fbed63a3b4d27a7a2c | 1,521 | algorithm-code | MIT License |
api/src/test/kotlin/no/nav/helsearbeidsgiver/inntektsmelding/api/LocalApiApp.kt | navikt | 495,713,363 | false | null | package no.nav.helsearbeidsgiver.inntektsmelding.api
import no.nav.helsearbeidsgiver.felles.app.LocalApp
fun main() {
val env = LocalApp().setupEnvironment("im-api", 8081)
startServer(env)
}
| 11 | Kotlin | 0 | 2 | f48247186ae9623d1b353d461a2a3ef4529d7fe5 | 202 | helsearbeidsgiver-inntektsmelding | MIT License |
src/main/kotlin/ru/kosolapov/course/score/CourseScoreRoutes.kt | Zymik | 637,872,394 | false | null | package ru.kosolapov.course.score
import io.ktor.server.application.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
import org.koin.ktor.ext.inject
import ru.kosolapov.course.configuration.getUsername
import ru.kosolapov.course.course.getCourseId
import ru.kosolapov.course.course.service.CourseSecurityService
import ru.kosolapov.course.course.service.checkStudent
fun Route.courseScoreRouting() {
val courseSecurityService by inject<CourseSecurityService>()
val scoreService by inject<ScoreService>()
with(courseSecurityService) {
get("course/{courseId}/score") {
val username = getUsername()
val courseId = getCourseId()
checkStudent(username, courseId)
call.respond(scoreService.getScoreByCourseId(courseId))
}
get("course/{courseId}/score/user") {
val username = getUsername()
val courseId = getCourseId()
checkStudent(username, courseId)
call.respond(scoreService.getScoreByCourseId(username, courseId))
}
get("course/{courseId}/score/user/{username}") {
val username = getUsername()
val usernameParam = getUsernameParam()
val courseId = getCourseId()
checkStudent(usernameParam, courseId)
checkMember(username, courseId, ru.kosolapov.course.course.Role.TEACHER, ru.kosolapov.course.course.Role.ADMIN)
call.respond(scoreService.getScoreByCourseId(usernameParam, courseId))
}
}
} | 0 | Kotlin | 0 | 0 | de6beb0c5ee63c5afad164e6169bb3a6f8c7944a | 1,546 | course-api | MIT License |
src/test/kotlin/di/TestModule.kt | marius-brauterfallet | 818,308,765 | false | {"Kotlin": 28459, "HTML": 6953, "Dockerfile": 983} | package di
import io.ktor.client.*
import io.mockk.mockk
import kotlinx.coroutines.CoroutineScope
import org.koin.core.module.dsl.singleOf
import org.koin.dsl.bind
import org.koin.dsl.module
import org.slf4j.Logger
import services.LunchService
import services.LunchServiceImpl
val testModule = module {
single<Logger> { mockk(relaxed = true) }
single<HttpClient> { mockk(relaxed = true) }
single<CoroutineScope> { mockk(relaxed = true) }
singleOf(::LunchServiceImpl) bind LunchService::class
} | 2 | Kotlin | 0 | 0 | 482ae5e3a46b6afa040c2c4119155c4fc84afee0 | 512 | kbot | MIT License |
app/src/main/java/com/goiz/pokedex/model/ability/Generation.kt | gsesdras | 311,452,829 | false | {"Gradle": 3, "Java Properties": 2, "Shell": 1, "Text": 1, "Ignore List": 3, "Batchfile": 1, "Markdown": 1, "Proguard": 1, "Kotlin": 193, "XML": 45, "Java": 1, "JSON": 1} | package com.goiz.pokedex.model.ability
data class Generation(
val name: String,
val url: String
) | 1 | null | 1 | 1 | 3d36c4f787ff76be4d327c19b45608c253ebdca8 | 106 | afrodev_pokedex | MIT License |
core/src/main/java/at/guger/moneybook/core/ui/viewmodel/MessageEvent.kt | guger | 198,668,519 | false | null | package at.guger.moneybook.core.ui.viewmodel
import androidx.annotation.StringRes
class MessageEvent(@StringRes stringRes: Int, text: String? = null) : Event<Message>(Message(stringRes, text))
data class Message(@StringRes val stringRes: Int, val text: String? = null) | 17 | Kotlin | 1 | 13 | cc374cf434aad9db5a3fc8f336aaf3e4eb91100d | 271 | MoneyBook | Apache License 2.0 |
z2-core/src/commonMain/kotlin/hu/simplexion/z2/adaptive/types.kt | spxbhuhb | 665,463,766 | false | {"Kotlin": 1586446, "CSS": 166528, "Java": 12046, "HTML": 1560, "JavaScript": 975} | package hu.simplexion.z2.adaptive
typealias AdaptiveExternalPatchType<BT> = (it: AdaptiveFragment<BT>) -> Unit
typealias AdaptiveFragmentFactory<BT> = (parent: AdaptiveFragment<BT>, index : Int) -> AdaptiveFragment<BT>? | 5 | Kotlin | 0 | 1 | a7213ad95437796bc87674dd9530a95e1528901e | 221 | z2 | Apache License 2.0 |
kstore/src/commonMain/kotlin/io/github/xxfast/kstore/utils/FileSystem.kt | xxfast | 533,381,136 | false | null | package io.github.xxfast.kstore.utils
import okio.FileSystem
/***
* Okio file system for the given platform
*/
public expect val FILE_SYSTEM: FileSystem
| 2 | Kotlin | 4 | 115 | a1ab4df37b1a2409d1a4c579e93e9771f0c312a0 | 157 | KStore | Apache License 2.0 |
android/app/src/main/java/com/abbe/canary/flutter/FlutterContainerActivity.kt | zenozhengs | 371,353,651 | false | null | package com.abbe.canary.flutter
import android.content.Context
import android.content.Intent
import android.os.Bundle
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import org.jetbrains.annotations.NotNull
class FlutterContainerActivity(entrypoint: String = "main"): FlutterActivity(), EngineBindingsDelegate {
private val engineBindings: EngineBindings by lazy {
EngineBindings(activity = this, delegate = this, entrypoint = entrypoint)
}
companion object {
fun bootstrap(@NotNull context: Context) {
val intent = Intent(context, FlutterContainerActivity::class.java)
context.startActivity(intent)
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
engineBindings.attach()
}
override fun onDestroy() {
super.onDestroy()
engineBindings.detach()
}
override fun provideFlutterEngine(context: Context): FlutterEngine? {
return engineBindings.engine
}
override fun onNavigateTo() {
print("navigate to")
}
} | 0 | Kotlin | 0 | 0 | e11ffa681501d4d62be48fad72ee7daa9bb3291c | 1,150 | canary | MIT License |
kotysa-core/src/commonMain/kotlin/org/ufoss/kotysa/Table.kt | ufoss-org | 267,915,708 | false | null | package org.ufoss.kotysa
import org.ufoss.kotysa.columns.*
public interface Table<T : Any>
/**
* Represents a Table
*
* @param T Entity type associated with this table
*/
public abstract class AbstractTable<T : Any> internal constructor(internal val tableName: String?) : Table<T> {
internal lateinit var kotysaName: String
internal val kotysaColumns = mutableSetOf<AbstractColumn<T, *>>()
internal lateinit var kotysaPk: PrimaryKey<T>
internal val kotysaForeignKeys = mutableSetOf<ForeignKey<T, *>>()
internal val kotysaIndexes = mutableSetOf<Index<T>>()
protected fun primaryKey(
columns: Set<AbstractDbColumn<T, *>>,
pkName: String? = null,
): PrimaryKey<T> {
check(!::kotysaPk.isInitialized) {
"Table must not declare more than one Primary Key"
}
return PrimaryKey(pkName, columns).also { primaryKey -> kotysaPk = primaryKey }
}
protected fun primaryKey(vararg columns: AbstractDbColumn<T, *>): PrimaryKey<T> = primaryKey(columns.toSet())
protected fun <U> U.primaryKey(pkName: String? = null)
: U where U : AbstractDbColumn<T, *>,
U : ColumnNotNull<T, *> {
check(!isPkInitialized()) {
"Table must not declare more than one Primary Key"
}
kotysaPk = PrimaryKey(pkName, setOf(this))
return this
}
/*protected fun <V : Any> foreignKey(
referencedTable: H2Table<V>,
vararg columns: DbColumn<T, *>,
fkName: String? = null
) {
foreignKeys.add(ForeignKey(referencedTable, columns.toList(), fkName))
}*/
protected fun <U : AbstractDbColumn<T, *>, V : Any> U.foreignKey(
references: AbstractDbColumn<V, *>,
fkName: String? = null,
): U =
this.also {
kotysaForeignKeys.add(ForeignKey(mapOf(this to references), fkName))
}
protected fun index(
columns: Set<AbstractDbColumn<T, *>>,
type: IndexType? = null,
indexName: String? = null,
): Index<T> = Index(columns, type, indexName).apply { kotysaIndexes.add(this) }
protected fun index(vararg columns: AbstractDbColumn<T, *>): Index<T> = index(columns.toSet())
protected fun <U : AbstractDbColumn<T, *>> U.unique(indexName: String? = null): U =
this.also {
kotysaIndexes.add(Index(setOf(this), IndexType.UNIQUE, indexName))
}
internal fun addColumn(column: AbstractColumn<T, *>) {
if (column is AbstractDbColumn<T, *>) {
require(!kotysaColumns
.filterIsInstance<AbstractDbColumn<T, *>>()
.any { col -> col.entityGetter == column.entityGetter }) {
"Trying to map property \"${column.entityGetter}\" to multiple columns"
}
}
kotysaColumns += column
}
internal fun isPkInitialized() = ::kotysaPk.isInitialized
}
| 20 | null | 2 | 92 | bd16a40d140a72e54758a2929f4c543e62f3b8ea | 2,926 | kotysa | The Unlicense |
app/src/main/java/com/programmergabut/solatkuy/ui/fragmentquran/AllSurahAdapter.kt | jnkforks | 277,870,202 | true | {"Kotlin": 278346} | package com.programmergabut.solatkuy.ui.fragmentquran
import android.content.Context
import android.content.Intent
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.programmergabut.solatkuy.R
import com.programmergabut.solatkuy.data.remote.remoteentity.quranallsurahJson.Data
import com.programmergabut.solatkuy.ui.activityreadsurah.ReadSurahActivity
import kotlinx.android.synthetic.main.layout_all_surah.view.*
class AllSurahAdapter(private val c: Context): RecyclerView.Adapter<AllSurahAdapter.AllSurahViewHolder>() {
private var listData = mutableListOf<Data>()
fun setData(datas: List<Data>){
listData.clear()
listData.addAll(datas)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AllSurahViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.layout_all_surah, parent, false)
return AllSurahViewHolder(view)
}
override fun getItemCount(): Int = listData.size
override fun onBindViewHolder(holder: AllSurahViewHolder, position: Int) = holder.bind(listData[position])
inner class AllSurahViewHolder(itemView: View): RecyclerView.ViewHolder(itemView) {
fun bind(data: Data){
itemView.apply {
this.tv_allsurah_no.text = data.number.toString()
this.tv_allsurah_en.text = data.englishName
this.tv_allsurah_en_meaning.text = data.englishNameTranslation
this.tv_allsurah_ar.text = data.name
}
itemView.cc_allsurah.setOnClickListener {
val i = Intent(c, ReadSurahActivity::class.java)
i.apply {
this.putExtra(ReadSurahActivity.surahID, data.number.toString())
this.putExtra(ReadSurahActivity.surahName, data.englishName)
this.putExtra(ReadSurahActivity.surahTranslation, data.englishNameTranslation)
}
c.startActivities(arrayOf(i))
}
}
}
} | 0 | null | 0 | 0 | 0476c527a1f7e6b82ac968e1710ae2bce9154188 | 2,113 | Solat-Kuy-Android-MVVM-with-Coroutine | The Unlicense |
src/main/kotlin/me/deprilula28/discordproxykt/entities/Timestamp.kt | deprilula28 | 301,869,504 | false | null | package me.deprilula28.discordproxykt.entities
import java.text.SimpleDateFormat
import java.time.Instant
import java.time.OffsetDateTime
import java.time.ZoneId
import java.util.*
data class Timestamp(val unixMillis: Long) {
companion object {
private val format = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'")
init {
format.timeZone = TimeZone.getTimeZone("UTC")
}
}
val offsetDateTime: OffsetDateTime
get() = OffsetDateTime.ofInstant(
Instant.ofEpochMilli(unixMillis),
ZoneId.systemDefault(),
)
override fun toString(): String = format.format(Date())
} | 0 | Kotlin | 0 | 3 | eb33203d77e02638da9ff436d7d796202bb54188 | 660 | discord-proxy-kt | Apache License 2.0 |
src/main/kotlin/uk/gov/justice/digital/hmpps/visitscheduler/dto/ReserveVisitSlotDto.kt | ministryofjustice | 409,259,375 | false | null | package uk.gov.justice.digital.hmpps.visitscheduler.dto
import com.fasterxml.jackson.annotation.JsonProperty
import io.swagger.v3.oas.annotations.media.Schema
import uk.gov.justice.digital.hmpps.visitscheduler.controller.validators.VisitorContactValidation
import uk.gov.justice.digital.hmpps.visitscheduler.controller.validators.VisitorCountValidation
import uk.gov.justice.digital.hmpps.visitscheduler.model.VisitRestriction
import uk.gov.justice.digital.hmpps.visitscheduler.model.VisitType
import java.time.LocalDateTime
import javax.validation.Valid
import javax.validation.constraints.NotBlank
import javax.validation.constraints.NotEmpty
import javax.validation.constraints.NotNull
data class ReserveVisitSlotDto(
@Schema(description = "Prisoner Id", example = "AF34567G", required = true)
@field:NotBlank
val prisonerId: String,
@JsonProperty("prisonId")
@Schema(description = "Prison Id", example = "MDI", required = true)
@field:NotBlank
val prisonCode: String,
@Schema(description = "Visit Room", example = "A1", required = true)
@field:NotBlank
val visitRoom: String,
@Schema(description = "Visit Type", example = "SOCIAL", required = true)
@field:NotNull
val visitType: VisitType,
@Schema(description = "Visit Restriction", example = "OPEN", required = true)
@field:NotNull
val visitRestriction: VisitRestriction,
@Schema(description = "The date and time of the visit", example = "2018-12-01T13:45:00", required = true)
@field:NotNull
val startTimestamp: LocalDateTime,
@Schema(description = "The finishing date and time of the visit", example = "2018-12-01T13:45:00", required = true)
@field:NotNull
val endTimestamp: LocalDateTime,
@Schema(description = "Contact associated with the visit", required = false)
@field:Valid
val visitContact: ContactDto?,
@Schema(description = "List of visitors associated with the visit", required = true)
@field:NotEmpty
@field: VisitorCountValidation
@field:VisitorContactValidation
var visitors: Set<@Valid VisitorDto>,
@Schema(description = "List of additional support associated with the visit", required = false)
val visitorSupport: Set<@Valid VisitorSupportDto>? = setOf(),
)
| 3 | Kotlin | 2 | 6 | 01dcad3b0defb675a12da8d0f14cc130766410ff | 2,196 | visit-scheduler | MIT License |
features/image_viewer/src/test/java/es/littledavity/features/image/viewer/ImageViewerUiStateFactoryImplTest.kt | Benderinos | 260,322,264 | false | null | /*
* Copyright 2021 dalodev
*/
package es.littledavity.features.image.viewer
import org.assertj.core.api.Assertions.assertThat
import org.junit.Before
import org.junit.Test
import org.mockito.MockitoAnnotations
class ImageViewerUiStateFactoryImplTest {
private lateinit var factory: ImageViewerUiStateFactoryImpl
@Before
fun setup() {
MockitoAnnotations.openMocks(this)
factory = ImageViewerUiStateFactoryImpl()
}
@Test
fun createWithLoadingState_shouldReturnLoadingState() {
val result = factory.createWithLoadingState()
assertThat(result).isEqualTo(ImageViewerUiState.Loading)
}
@Test
fun createWithErrorState_shouldReturnErrorState() {
val expected = Exception()
val result = factory.createWithErrorState(expected)
assertThat(result).isEqualTo(ImageViewerUiState.Error(expected))
}
@Test
fun createWithResultState_shouldReturnResultState() {
val result = factory.createWithResultState(listOf(), 0)
assertThat(result).isEqualTo(
ImageViewerUiState.Result(
listOf(),
0
)
)
}
}
| 0 | Kotlin | 0 | 1 | 4f7f9d251c4da8e130a9f2b64879867bfecb44e8 | 1,175 | ChorboAgenda | Apache License 2.0 |
features/image_viewer/src/test/java/es/littledavity/features/image/viewer/ImageViewerUiStateFactoryImplTest.kt | Benderinos | 260,322,264 | false | null | /*
* Copyright 2021 dalodev
*/
package es.littledavity.features.image.viewer
import org.assertj.core.api.Assertions.assertThat
import org.junit.Before
import org.junit.Test
import org.mockito.MockitoAnnotations
class ImageViewerUiStateFactoryImplTest {
private lateinit var factory: ImageViewerUiStateFactoryImpl
@Before
fun setup() {
MockitoAnnotations.openMocks(this)
factory = ImageViewerUiStateFactoryImpl()
}
@Test
fun createWithLoadingState_shouldReturnLoadingState() {
val result = factory.createWithLoadingState()
assertThat(result).isEqualTo(ImageViewerUiState.Loading)
}
@Test
fun createWithErrorState_shouldReturnErrorState() {
val expected = Exception()
val result = factory.createWithErrorState(expected)
assertThat(result).isEqualTo(ImageViewerUiState.Error(expected))
}
@Test
fun createWithResultState_shouldReturnResultState() {
val result = factory.createWithResultState(listOf(), 0)
assertThat(result).isEqualTo(
ImageViewerUiState.Result(
listOf(),
0
)
)
}
}
| 0 | Kotlin | 0 | 1 | 4f7f9d251c4da8e130a9f2b64879867bfecb44e8 | 1,175 | ChorboAgenda | Apache License 2.0 |
examples/coffee-maker/src/main/kotlin/org/koin/example/ElectricHeater.kt | InsertKoinIO | 93,515,203 | false | null | package org.koin.example
class ElectricHeater : Heater {
private var heating: Boolean = false
override fun on() {
println("~ ~ ~ heating ~ ~ ~")
heating = true
}
override fun off() {
heating = false
}
override fun isHot(): Boolean = heating
} | 105 | null | 711 | 8,934 | f870a02fd32a2cf1ff8b69406ebf555c26ffe39f | 295 | koin | Apache License 2.0 |
app/src/main/java/zebrostudio/wallr100/data/mapper/DatabaseImageTypeMapper.kt | abhriyaroy | 119,387,578 | false | {"Gradle": 19, "Java Properties": 2, "Shell": 1, "Ignore List": 15, "Batchfile": 1, "Markdown": 1, "Proguard": 7, "XML": 126, "Kotlin": 228, "Java": 87, "AIDL": 1, "INI": 3, "C++": 2, "Makefile": 2, "C": 16, "CMake": 1} | package zebrostudio.wallr100.data.mapper
import zebrostudio.wallr100.data.database.DatabaseImageType
import zebrostudio.wallr100.domain.model.collectionsimages.CollectionsImageType
interface DatabaseImageTypeMapper {
fun mapToDatabaseImageType(imageType: CollectionsImageType): DatabaseImageType
}
class DatabaseImageTypeMapperImpl : DatabaseImageTypeMapper {
override fun mapToDatabaseImageType(imageType: CollectionsImageType) = when (imageType) {
CollectionsImageType.WALLPAPER -> DatabaseImageType.WALLPAPER
CollectionsImageType.SEARCH -> DatabaseImageType.SEARCH
CollectionsImageType.CRYSTALLIZED -> DatabaseImageType.CRYSTALLIZED
CollectionsImageType.EDITED -> DatabaseImageType.EDITED
CollectionsImageType.MINIMAL_COLOR -> DatabaseImageType.MINIMAL_COLOR
CollectionsImageType.EXTERNAL -> DatabaseImageType.EXTERNAL
}
} | 1 | null | 1 | 1 | ff76741976c2fe5b68360fc970531124a2ff516b | 859 | WallR2.0 | Apache License 2.0 |
Android/feature-dreams-impl/src/main/java/ru/iandreyshev/featureDreams/viewModel/IViewModelFactory.kt | iandreyshev | 149,519,715 | false | {"Markdown": 3, "Batchfile": 2, "Ignore List": 16, "Gradle": 14, "Java Properties": 2, "Shell": 1, "Proguard": 12, "Java": 19, "XML": 67, "Kotlin": 176, "JSON": 5, "YAML": 2, "Microsoft Visual Studio Solution": 1, "C#": 35, "Dockerfile": 1, "SQL": 1} | package ru.iandreyshev.featureDreams.viewModel
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
interface IViewModelFactory {
fun dreamViewModel(activity: AppCompatActivity, bundle: Bundle?): DreamViewModel
fun dreamEditorViewModel(activity: AppCompatActivity, bundle: Bundle?): DreamEditorViewModel
}
| 0 | Kotlin | 0 | 1 | 5791228f3d7568883058f414a7cbafff561d58d5 | 336 | Dreamland | MIT License |
android/store/src/main/java/com/smarttoni/store/MainActivity.kt | karthikv8058 | 359,537,229 | false | {"JSON with Comments": 3, "TSX": 71, "JSON": 18, "JavaScript": 15, "Text": 4, "Ignore List": 4, "Git Attributes": 1, "Markdown": 4, "Gradle": 8, "Java Properties": 2, "Shell": 1, "Batchfile": 1, "INI": 3, "Proguard": 4, "XML": 76, "Kotlin": 56, "Java": 290, "Starlark": 3, "Objective-C": 4, "OpenStep Property List": 4} | package com.smarttoni.store
import android.Manifest
import android.content.Context
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.AsyncTask
import android.util.Log
import android.view.View
import androidx.databinding.DataBindingUtil
import com.smarttoni.store.databinding.ActivityMainBinding
import java.io.BufferedInputStream
import java.io.FileOutputStream
import java.net.URL
import android.content.Intent
import android.net.Uri
import android.os.Environment
import java.io.File
import android.os.Build
import androidx.core.content.FileProvider
import android.content.pm.PackageManager
import android.view.MenuItem
import android.widget.Toast
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
private const val MIME_TYPE = "application/vnd.android.package-archive"
private const val PROVIDER_PATH = ".provider"
private const val APP_INSTALL_PATH = "application/vnd.android.package-archive"
class MainActivity : AppCompatActivity() {
private var binding: ActivityMainBinding? = null
private var releaseNotes: ActivityMainBinding? = null
private var currentVersionCode: Int = 0
private var currentVersionName: String = "1.0"
private var url: String? = ""
private var installing: Boolean = false
private var devCount: Int = 10
private var toast: Toast? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
binding?.executePendingBindings()
if(getSharedPreferences("store", Context.MODE_PRIVATE).getBoolean("DevOn",false)){
supportActionBar?.setDisplayHomeAsUpEnabled(true)
}
}
override fun onOptionsItemSelected(item: MenuItem):Boolean{
if(item.itemId == android.R.id.home){
startActivity(Intent(this,ListActivity::class.java))
finish()
return true
}
return super.onOptionsItemSelected(item);
// switch (item.getItemId()) {
// case android.R.id.home:
// NavUtils.navigateUpFromSameTask(this);
// return true;
// default:
// return super.onOptionsItemSelected(item);
// }
}
override fun onResume() {
super.onResume()
binding?.installing = installing
if (!installing) {
updateCurrentVersionCode()
binding?.isUpdate = currentVersionCode > 0
binding?.downloadAvailable = false
binding?.currentVersion = if (currentVersionCode > 0) "Current version " + currentVersionName else ""
var httpService : HttpService;
var dev = intent.getIntExtra("MODE",1);
if(dev == 3){
httpService =HttpClient().devHttpClient
}else if(dev == 2){
httpService =HttpClient().uatHttpClient
}else{
httpService =HttpClient().liveHttpClient
}
httpService.checkUpdate().enqueue(object : Callback<StoreRequest> {
override fun onResponse(call: Call<StoreRequest>, response: Response<StoreRequest>) {
binding?.releaseNotes = response.body()?.releaseNotes
if (response.body()?.latestVersionCode ?: 0 > currentVersionCode) {
binding?.currentVersion = (if (currentVersionCode > 0) "Current version " + currentVersionName else "") +
" Latest version " +
response.body()?.latestVersion
url = response.body()?.url
binding?.downloadAvailable = true
} else {
binding?.downloadAvailable = false
}
}
override fun onFailure(call: Call<StoreRequest>, t: Throwable) {
var a =10
}
})
}
}
fun install(v: View) {
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE),
1)
} else {
if (binding?.downloadAvailable ?: false) {
if (url != null && !url.equals("")) {
DownloadFileFromURL().execute(url);
}
}
}
}
private fun updateCurrentVersionCode() {
try {
var pkg = "com.smarttoni"
var dev = intent.getIntExtra("MODE",1);
if(dev == 3){
pkg= "com.smarttoni.dev"
}else if(dev == 2) {
pkg = "com.smarttoni.uat"
}
val pInfo = getPackageManager().getPackageInfo(pkg, 0)
currentVersionCode = pInfo.versionCode
currentVersionName = pInfo.versionName
} catch (e: PackageManager.NameNotFoundException) {
currentVersionCode = 0
currentVersionName = "0.0.0"
}
}
internal inner class DownloadFileFromURL : AsyncTask<String, Int, String>() {
override fun onPreExecute() {
super.onPreExecute()
binding?.downloadAvailable = false;
binding?.installing = true
installing = true
}
override fun doInBackground(vararg f_url: String): String? {
val storage = Environment.getExternalStorageDirectory().toString() + "/app.apk"
try {
val url = URL(f_url[0])
val conection = url.openConnection()
conection.connect()
val lenghtOfFile = conection.getContentLength()
val input = BufferedInputStream(url.openStream(), 8192)
val output = FileOutputStream(storage)
val data = ByteArray(1024)
var total: Long = 0
var count = input.read(data)
while (count != -1) {
total += count.toLong()
val pro = (total * 100 / lenghtOfFile);
publishProgress(pro.toInt())
output.write(data, 0, count)
count = input.read(data);
}
output.flush()
output.close()
input.close()
} catch (e: Exception) {
//Log.e("Error: ", e.message)
}
return storage
}
override fun onProgressUpdate(vararg pro: Int?) {
binding?.progressVal = pro[0]
binding?.invalidateAll()
}
override fun onPostExecute(file_url: String) {
installing = false
binding?.installing = false
binding?.downloadAvailable = false
val storage = Environment.getExternalStorageDirectory().toString() + "/app.apk"
val file = File(storage)
val uri: Uri
if (Build.VERSION.SDK_INT < 24) {
uri = Uri.fromFile(file)
} else {
uri = Uri.parse(file.path)
}
showInstallOption(storage, uri)
}
}
private fun showInstallOption(
destination: String,
uri: Uri
) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
val contentUri = FileProvider.getUriForFile(
this,
BuildConfig.APPLICATION_ID + PROVIDER_PATH,
File(destination)
)
val install = Intent(Intent.ACTION_VIEW)
install.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
install.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
install.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true)
install.data = contentUri
startActivity(install)
} else {
val install = Intent(Intent.ACTION_VIEW)
install.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
install.setDataAndType(
uri,
APP_INSTALL_PATH
)
startActivity(install)
}
}
public fun enableDeveloperMode(view:View){
devCount--;
if(devCount == 2){
toast = Toast.makeText(this,"You are 2 steps away from being a developer",Toast.LENGTH_SHORT)
toast?.show()
}else if(devCount == 1){
toast?.cancel()
toast = Toast.makeText(this,"You are 1 steps away from being a developer",Toast.LENGTH_SHORT)
toast?.show()
}else if(devCount == 0){
toast?.cancel()
toast = Toast.makeText(this,"You are developer now",Toast.LENGTH_SHORT)
toast?.show()
getSharedPreferences("store", Context.MODE_PRIVATE).edit().putBoolean("DevOn",true).apply();
// startActivity(Intent(this,ListActivity::class.java))
// finish()
supportActionBar?.setDisplayHomeAsUpEnabled(true)
}
}
}
| 1 | null | 1 | 1 | a2d21a019d8a67f0c3b52c102b6961e558219732 | 9,270 | kitchen-app | MIT License |
16/kotlin/src/main/kotlin/se/nyquist/Packet.kt | erinyq712 | 437,223,266 | false | null | package se.nyquist
interface Packet {
fun hasSubPackets() : Boolean
fun getSubPackets() : List<Packet> = listOf()
fun value() : Long
} | 0 | Kotlin | 0 | 0 | b463e53f5cd503fe291df692618ef5a30673ac6f | 147 | adventofcode2021 | Apache License 2.0 |
src/main/kotlin/de/solugo/oidc/ConfigurationProvider.kt | solugo | 783,943,109 | false | {"Kotlin": 25039} | package de.solugo.oidc
import org.springframework.web.util.UriComponentsBuilder
interface ConfigurationProvider {
fun provide(builder: UriComponentsBuilder): Map<String, Any>
} | 0 | Kotlin | 0 | 1 | eabd784f3ab68d9b0e19d8e67cdce50ca9e1f7ce | 182 | oidc-server | Apache License 2.0 |
lib/src/main/java/com/pmm/metro/lanuncher/LauncherFactory.kt | caoyanglee | 186,588,020 | false | null | package com.pmm.metro.lanuncher
import com.pmm.metro.StationMeta
import com.pmm.metro.StationType
import com.pmm.metro.Ticket
/**
* Author:你需要一台永动机
* Date:2019-11-13 11:50
* Description:简单工厂模式
*/
object LauncherFactory {
//静态创建方法
fun create(
type: StationType,
station: StationMeta?,
ticket: Ticket,
driver: Any
): AbstractLauncher {
return when (type) {
StationType.ACTIVITY -> ActivityLauncher(station, ticket, driver)
StationType.SERVICE -> ServiceLauncher(station, ticket, driver)
StationType.FRAGMENT -> FragmentLauncher(station, ticket, driver)
}
}
} | 1 | null | 1 | 5 | ff91503fc76d86050d32e09e17ada0859bcb69a3 | 663 | Metro | MIT License |
pokedex/src/main/kotlin/com/example/App.kt | strogo | 286,438,591 | true | {"Kotlin": 838368, "JavaScript": 84856, "HTML": 14861, "CSS": 3495, "TSQL": 1238} | package com.example
import kotlinx.serialization.builtins.list
import pl.treksoft.kvision.Application
import pl.treksoft.kvision.core.Container
import pl.treksoft.kvision.core.TextAlign
import pl.treksoft.kvision.form.text.Text
import pl.treksoft.kvision.form.text.text
import pl.treksoft.kvision.html.button
import pl.treksoft.kvision.html.div
import pl.treksoft.kvision.i18n.DefaultI18nManager
import pl.treksoft.kvision.i18n.I18n
import pl.treksoft.kvision.i18n.I18n.gettext
import pl.treksoft.kvision.i18n.I18n.tr
import pl.treksoft.kvision.panel.FlexAlignItems
import pl.treksoft.kvision.panel.FlexJustify
import pl.treksoft.kvision.panel.GridJustify
import pl.treksoft.kvision.panel.gridPanel
import pl.treksoft.kvision.panel.hPanel
import pl.treksoft.kvision.panel.root
import pl.treksoft.kvision.panel.vPanel
import pl.treksoft.kvision.redux.ActionCreator
import pl.treksoft.kvision.redux.createReduxStore
import pl.treksoft.kvision.require
import pl.treksoft.kvision.rest.RestClient
import pl.treksoft.kvision.startApplication
import pl.treksoft.kvision.state.bind
import pl.treksoft.kvision.toolbar.buttonGroup
import pl.treksoft.kvision.utils.auto
import pl.treksoft.kvision.utils.obj
import pl.treksoft.kvision.utils.perc
import pl.treksoft.kvision.utils.px
import kotlin.browser.document
class App : Application() {
private val store = createReduxStore(::pokedexReducer, Pokedex(false, null, listOf(), listOf(), null, 0, 1))
private val hammerjs = require("hammerjs")
override fun start() {
I18n.manager =
DefaultI18nManager(
mapOf(
"pl" to require("i18n/messages-pl.json"),
"en" to require("i18n/messages-en.json")
)
)
root("kvapp") {
vPanel(alignItems = FlexAlignItems.STRETCH) {
width = 100.perc
searchField()
vPanel(alignItems = FlexAlignItems.STRETCH) {
maxWidth = 1200.px
textAlign = TextAlign.CENTER
marginLeft = auto
marginRight = auto
}.bind(store) { state ->
informationText(state)
if (!state.downloading && state.errorMessage == null) {
pokemonGrid(state)
pagination(state)
}
}
}
}
store.dispatch(downloadPokemons())
val hammerjs = hammerjs(document.body)
hammerjs.on("swiperight") {
store.dispatch(PokeAction.PrevPage)
}
hammerjs.on("swipeleft") {
store.dispatch(PokeAction.NextPage)
}
}
private fun Container.searchField() {
text {
placeholder = tr("Enter pokemon name ...")
width = 300.px
marginLeft = auto
marginRight = auto
autofocus = true
setEventListener<Text> {
input = {
store.dispatch(PokeAction.SetSearchString(self.value))
}
}
}
}
private fun Container.informationText(state: Pokedex) {
if (state.downloading) {
div(tr("Loading ..."))
} else if (state.errorMessage != null) {
div(state.errorMessage)
}
}
private fun Container.pokemonGrid(state: Pokedex) {
gridPanel(
templateColumns = "repeat(auto-fill, minmax(250px, 1fr))",
justifyItems = GridJustify.CENTER
) {
state.visiblePokemons.forEach {
add(PokeBox(it))
}
}
}
private fun Container.pagination(state: Pokedex) {
hPanel(justify = FlexJustify.CENTER) {
margin = 30.px
buttonGroup {
button("<<") {
disabled = state.pageNumber == 0
onClick {
store.dispatch(PokeAction.PrevPage)
}
}
button(" ${state.pageNumber + 1} / ${state.numberOfPages} ", disabled = true)
button(">>") {
disabled = state.pageNumber == (state.numberOfPages - 1)
onClick {
store.dispatch(PokeAction.NextPage)
}
}
}
}
}
private fun downloadPokemons(): ActionCreator<dynamic, Pokedex> {
return { dispatch, _ ->
val restClient = RestClient()
dispatch(PokeAction.StartDownload)
restClient.remoteCall(
"https://pokeapi.co/api/v2/pokemon/", obj { limit = 800 },
deserializer = Pokemon.serializer().list
) {
it.results
}.then { list ->
dispatch(PokeAction.DownloadOk)
dispatch(PokeAction.SetPokemonList(list))
dispatch(PokeAction.SetSearchString(null))
}.catch { e ->
val info = if (!e.message.isNullOrBlank()) {
" (${e.message})"
} else {
""
}
dispatch(PokeAction.DownloadError(gettext("Service error!") + info))
}
}
}
}
fun main() {
startApplication(::App)
}
| 0 | null | 0 | 0 | 4a67859f7fb01fd0bfd50c1b52ff3af956636657 | 5,358 | kvision-examples | MIT License |
src/main/kotlin/dev/tricht/gamesense/events/EventProducer.kt | mtricht | 250,686,225 | false | null | package dev.tricht.gamesense.events
import dev.tricht.gamesense.*
import dev.tricht.gamesense.com.steelseries.ApiClient
import dev.tricht.gamesense.com.steelseries.model.Data
import dev.tricht.gamesense.com.steelseries.model.Event
import dev.tricht.gamesense.com.steelseries.model.Frame
import dev.tricht.gamesense.model.SongInformation
import java.text.DateFormat
import java.util.*
class EventProducer(
private val client: ApiClient,
private val dataFetcher: DataFetcher
) : TimerTask() {
private val dateFormat = DateFormat.getTimeInstance()
private var volume: Int? = null
private var waitTicks = 0
private var currentSong: SongInformation? = null
override fun run() {
val oldVolume = this.volume
this.volume = dataFetcher.getVolume()
if (oldVolume != null && this.volume != oldVolume) {
sendVolumeEvent()
return
}
if (waitTicks > 0) {
--waitTicks
return
}
val potentialSong = dataFetcher.getCurrentSong()
if (potentialSong != null && potentialSong != "") {
if (currentSong == null || potentialSong != currentSong!!.fullSongName) {
currentSong = SongInformation(potentialSong)
}
sendSongEvent()
return
}
sendClockEvent()
}
private fun sendClockEvent() {
if (!clockEnabled) {
return
}
client.sendEvent(
Event(
GAME_NAME,
CLOCK_EVENT,
Data(
dateFormat.format(Date())
)
)
).execute()
waitTicks = Tick.msToTicks(200)
}
private fun sendSongEvent() {
val songName = currentSong!!.song()
client.sendEvent(
Event(
GAME_NAME,
SONG_EVENT,
Data(
// This is unused, but Steelseries 'caches' the value. So we have to change it.
songName + System.currentTimeMillis(),
Frame(
songName,
currentSong!!.artist()
)
)
)
).execute()
waitTicks = Tick.msToTicks(200)
}
private fun sendVolumeEvent() {
if (this.volume == null || !volumeEnabled) {
return
}
waitTicks = Tick.msToTicks(1000)
client.sendEvent(
Event(
GAME_NAME,
VOLUME_EVENT,
Data(
this.volume!!
)
)
).execute()
}
} | 13 | Kotlin | 11 | 94 | bc2a3f764ac5b89ce6b8a4432d469a883065420a | 2,681 | gamesense-essentials | MIT License |
androidApp/src/androidMain/kotlin/com/mobear/fusion/utils/config/FusionRemoteConfig.kt | erenalpaslan | 717,514,967 | false | {"Kotlin": 148009, "Swift": 2671, "Shell": 228} | package com.mobear.fusion.utils.config
import android.util.Log
import com.google.firebase.ktx.Firebase
import com.google.firebase.remoteconfig.ktx.get
import com.google.firebase.remoteconfig.ktx.remoteConfig
import com.google.firebase.remoteconfig.ktx.remoteConfigSettings
import common.objects.RemoteConfigKeys
import entity.config.AndroidConfig
import entity.config.FusionConfig
import entity.config.OpenAIConfig
import entity.config.PaywallConfig
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.cancel
import kotlinx.coroutines.launch
import kotlinx.serialization.json.Json
import utils.eventbus.Event
import utils.eventbus.EventBus
import utils.eventbus.EventKeys
/**
* Created by erenalpaslan on 16.10.2023.
*/
class FusionRemoteConfig {
private val remoteConfig = Firebase.remoteConfig
fun fetchAndActivate() {
val configSettings = remoteConfigSettings {
minimumFetchIntervalInSeconds = 3_600
}
remoteConfig.setConfigSettingsAsync(configSettings)
remoteConfig.fetchAndActivate()
.addOnCompleteListener {
if (it.isSuccessful) {
CoroutineScope(Dispatchers.IO).launch {
EventBus.publish(Event(key = EventKeys.CONFIG_INIT, data = FusionConfig(
androidConfig = get<AndroidConfig>(RemoteConfigKeys.ANDROID_CONFIG),
openAIConfig = get<OpenAIConfig>(RemoteConfigKeys.OPENAI_CONFIG),
paywallConfig = get<PaywallConfig>(RemoteConfigKeys.PAYWALL_CONFIG)
)))
this.cancel()
}
}
}
}
inline fun <reified T> get(key: String): T? {
return try {
val config = Firebase.remoteConfig[key].asString()
Json.decodeFromString<T>(config)
}catch (e: Exception) {
Log.e("RemoteConfig", "=> ${e.localizedMessage}")
null
}
}
} | 0 | Kotlin | 0 | 1 | 88dee2a77bb41cc9ccd6dba294364c322d009932 | 2,054 | Fusion-Open | Apache License 2.0 |
Sushi/app/src/main/java/com/destructo/sushi/ui/user/mangaList/UserMangaReading.kt | destructo570 | 302,356,237 | false | null | package com.destructo.sushi.ui.user.mangaList
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ProgressBar
import androidx.core.os.bundleOf
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.RecyclerView
import com.destructo.sushi.LIST_SPACE_HEIGHT
import com.destructo.sushi.MANGA_ID_ARG
import com.destructo.sushi.R
import com.destructo.sushi.adapter.UserMangaListAdapter
import com.destructo.sushi.databinding.FragmentUserMangaListBinding
import com.destructo.sushi.enum.mal.UserMangaStatus
import com.destructo.sushi.listener.AddChapterListener
import com.destructo.sushi.listener.MalIdListener
import com.destructo.sushi.network.Status
import com.destructo.sushi.ui.base.BaseFragment
import com.destructo.sushi.util.ListItemVerticalDecor
import dagger.hilt.android.AndroidEntryPoint
import timber.log.Timber
@AndroidEntryPoint
class UserMangaReading : BaseFragment() {
private lateinit var binding: FragmentUserMangaListBinding
private val userMangaViewModel: UserMangaViewModel
by viewModels(ownerProducer = { requireParentFragment() })
private lateinit var userMangaAdapter: UserMangaListAdapter
private lateinit var userMangaRecycler: RecyclerView
private lateinit var userMangaProgress: ProgressBar
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
binding = FragmentUserMangaListBinding
.inflate(inflater, container, false).apply {
lifecycleOwner = viewLifecycleOwner
}
userMangaRecycler = binding.userMangaRecycler
userMangaRecycler.addItemDecoration(ListItemVerticalDecor(LIST_SPACE_HEIGHT))
userMangaRecycler.setHasFixedSize(true)
userMangaProgress = binding.userMangaListProgressbar
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
userMangaAdapter = UserMangaListAdapter(AddChapterListener { manga ->
val chapters = manga?.myMangaListStatus?.numChaptersRead
val totalChapters = manga?.numChapters
val mangaId = manga?.malId
mangaId?.let { userMangaViewModel.clearMangaDetail(it) }
if (chapters != null && mangaId != null && totalChapters != null && chapters.plus(1) == totalChapters) {
userMangaViewModel.addChapterManga(
mangaId.toString(),
chapters + 1,
UserMangaStatus.COMPLETED.value
)
} else if (chapters != null && mangaId != null) {
userMangaViewModel.addChapterManga(mangaId.toString(), chapters + 1, null)
}
}, MalIdListener { it?.let { navigateToMangaDetails(it) } }, true)
userMangaRecycler.adapter = userMangaAdapter
userMangaViewModel.userMangaList.observe(viewLifecycleOwner) {
userMangaViewModel.getMangaListByStatus(UserMangaStatus.READING.value)
}
userMangaViewModel.userMangaReading.observe(viewLifecycleOwner) {
userMangaAdapter.submitList(it.data)
}
userMangaViewModel.userMangaStatus.observe(viewLifecycleOwner) { resource ->
when (resource.status) {
Status.LOADING -> {
userMangaProgress.visibility = View.VISIBLE
}
Status.SUCCESS -> {
userMangaProgress.visibility = View.GONE
}
Status.ERROR -> {
Timber.e("Error: %s", resource.message)
}
}
}
}
private fun navigateToMangaDetails(mangaIdArg: Int) {
this.findNavController().navigate(
R.id.mangaDetailsFragment,
bundleOf(Pair(MANGA_ID_ARG, mangaIdArg)),
getAnimNavOptions()
)
}
} | 3 | Kotlin | 5 | 21 | 68317c04caa596103d3fd32b0f34fe43b189a721 | 4,042 | Sushi-Unofficial-MAL-Client | Apache License 2.0 |
foundry-math/src/main/kotlin/com/valaphee/foundry/math/Float3x3.kt | valaphee | 372,059,969 | false | null | /*
* Copyright (c) 2021-2022, Valaphee.
*
* 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.valaphee.foundry.math
import kotlin.math.cos
import kotlin.math.sin
import kotlin.math.sqrt
class Float3x3 {
val matrix = FloatArray(9)
init {
setIdentity()
}
operator fun get(index: Int) = matrix[index]
operator fun get(row: Int, column: Int) = matrix[column * 3 + row]
operator fun set(index: Int, value: Float) {
matrix[index] = value
}
operator fun set(row: Int, column: Int, value: Float) {
matrix[column * 3 + row] = value
}
fun set(value: Float3x3) = apply {
for (i in 0..8) this[i] = value[i]
}
fun set(value: List<Float>) {
for (i in 0..8) this[i] = value[i]
}
fun setColumn(column: Int, value: Float3) {
this[0, column] = value.x
this[1, column] = value.y
this[2, column] = value.z
}
fun getColumn(column: Int, result: MutableFloat3): MutableFloat3 {
result.x = this[0, column]
result.y = this[1, column]
result.z = this[2, column]
return result
}
fun setIdentity() = apply {
for (i in 1..8) this[i] = 0.0f
for (i in 0..8 step 4) this[i] = 1.0f
}
fun setRotate(x: Float, y: Float, z: Float) = apply {
val radX = x.toRad()
val radY = y.toRad()
val radZ = z.toRad()
val cosX = cos(radX)
val cosY = cos(radY)
val cosZ = cos(radZ)
val sinX = sin(radX)
val sinY = sin(radY)
val sinZ = sin(radZ)
val cosXZ = cosX * cosZ
val cosXSinZ = cosX * sinZ
val sinXCosZ = sinX * cosZ
val sinXZ = sinX * sinZ
matrix[0] = cosY * cosZ
matrix[3] = sinY * sinXCosZ - cosXSinZ
matrix[6] = sinY * cosXZ + sinXZ
matrix[1] = cosY * sinZ
matrix[4] = sinY * sinXZ + cosXZ
matrix[7] = sinY * cosXSinZ - sinXCosZ
matrix[2] = -sinY
matrix[5] = cosY * sinX
matrix[8] = cosY * cosX
}
fun setRotation(value: Float, axisX: Float, axisY: Float, axisZ: Float) = apply {
var axisXVar = axisX
var axisYVar = axisY
var axisZVar = axisZ
val length = sqrt(axisXVar * axisXVar + axisYVar * axisYVar + axisZVar * axisZVar)
if (!(1.0f - length).isZero()) {
val reciprocalLength = 1.0f / length
axisXVar *= reciprocalLength
axisYVar *= reciprocalLength
axisZVar *= reciprocalLength
}
val rad = value.toRad()
val sin = sin(rad)
val cos = cos(rad)
val vers = 1.0f - cos
val xy = axisXVar * axisYVar
val yz = axisYVar * axisZVar
val zx = axisZVar * axisXVar
val xs = axisXVar * sin
val ys = axisYVar * sin
val zs = axisZVar * sin
this[0] = axisXVar * axisXVar * vers + cos
this[3] = xy * vers - zs
this[6] = zx * vers + ys
this[1] = xy * vers + zs
this[4] = axisYVar * axisYVar * vers + cos
this[7] = yz * vers - xs
this[2] = zx * vers - ys
this[5] = yz * vers + xs
this[8] = axisZVar * axisZVar * vers + cos
}
fun setRotation(quaternion: Float4) = apply {
val r = quaternion.w
val i = quaternion.x
val j = quaternion.y
val k = quaternion.z
var s = sqrt(r * r + i * i + j * j + k * k)
s = 1.0f / (s * s)
this[0, 0] = 1.0f - 2.0f * s * (j * j + k * k)
this[0, 1] = 2.0f * s * (i * j - k * r)
this[0, 2] = 2.0f * s * (i * k + j * r)
this[1, 0] = 2.0f * s * (i * j + k * r)
this[1, 1] = 1.0f - 2.0f * s * (i * i + k * k)
this[1, 2] = 2.0f * s * (j * k - i * r)
this[2, 0] = 2.0f * s * (i * k - j * r)
this[2, 1] = 2.0f * s * (j * k + i * r)
this[2, 2] = 1.0f - 2.0f * s * (i * i + j * j)
}
fun getRotation(result: MutableFloat4): MutableFloat4 {
val trace = this[0, 0] + this[1, 1] + this[2, 2]
if (trace > 0.0f) {
var s = sqrt(trace + 1.0f)
result.w = s * 0.5f
s = 0.5f / s
result.x = (this[2, 1] - this[1, 2]) * s
result.y = (this[0, 2] - this[2, 0]) * s
result.z = (this[1, 0] - this[0, 1]) * s
} else {
val i = if (this[0, 0] < this[1, 1]) if (this[1, 1] < this[2, 2]) 2 else 1 else if (this[0, 0] < this[2, 2]) 2 else 0
val j = (i + 1) % 3
val k = (i + 2) % 3
var s = sqrt(this[i, i] - this[j, j] - this[k, k] + 1.0f)
result[i] = s * 0.5f
s = 0.5f / s
result.w = (this[k, j] - this[j, k]) * s
result[j] = (this[j, i] + this[i, j]) * s
result[k] = (this[k, i] + this[i, k]) * s
}
return result
}
fun transpose(): Float3x3 {
var swap = this[1]
this[1] = this[3]
this[3] = swap
swap = this[2]
this[2] = this[6]
this[6] = swap
swap = this[5]
this[5] = this[7]
this[7] = swap
return this
}
fun transpose(result: Float4x4): Float4x4 {
result[0] = this[0]
result[1] = this[3]
result[2] = this[6]
result[3] = this[1]
result[4] = this[4]
result[5] = this[7]
result[6] = this[2]
result[7] = this[5]
result[8] = this[8]
return result
}
fun invert(): Boolean {
val inverted = Float3x3()
return invert(inverted).also { if (it) set(inverted) }
}
fun invert(result: Float3x3): Boolean {
var determinant = 0.0f
for (i in 0..2) {
determinant += (this[i] * (this[3 + (i + 1) % 3] * this[6 + (i + 2) % 3] - this[3 + (i + 2) % 3] * this[6 + (i + 1) % 3]))
}
return if (determinant > 0.0f) {
determinant = 1.0f / determinant
for (i in 0..2) for (j in 0..2) result[j * 3 + i] = ((this[((i + 1) % 3) * 3 + (j + 1) % 3] * this[((i + 2) % 3) * 3 + (j + 2) % 3]) - (this[((i + 1) % 3) * 3 + (j + 2) % 3] * this[((i + 2) % 3) * 3 + (j + 1) % 3])) * determinant
true
} else false
}
fun mul(value: Float3x3) = mul(value, this)
fun mul(value: Float3x3, result: Float3x3): Float3x3 {
for (i in 0..2) for (j in 0..2) {
var x = 0.0f
for (k in 0..2) x += this[j + k * 3] * value[i * 3 + k]
result[i * 3 + j] = x
}
return result
}
fun rotate(x: Float, y: Float, z: Float) = set(mul(Float3x3().setRotate(x, y, z), Float3x3()))
fun rotate(value: Float, axisX: Float, axisY: Float, axisZ: Float) = mul(Float3x3().setRotation(value, axisX, axisY, axisZ), Float3x3())
fun rotate(value: Float, axis: Float3) = rotate(value, axis.x, axis.y, axis.z)
fun rotate(x: Float, y: Float, z: Float, result: Float3x3): Float3x3 {
result.set(this)
result.rotate(x, y, z)
return result
}
fun rotate(value: Float, axisX: Float, axisY: Float, axisZ: Float, result: Float3x3): Float3x3 {
result.set(this)
result.rotate(value, axisX, axisY, axisZ)
return result
}
fun rotate(value: Float, axis: Float3, result: Float3x3) = rotate(value, axis.x, axis.y, axis.z, result)
fun scale(x: Float, y: Float, z: Float) = apply {
for (i in 0..2) {
matrix[i] *= x
matrix[3 + i] *= y
matrix[6 + i] *= z
}
}
fun scale(value: Float3) = scale(value.x, value.y, value.z)
fun scale(x: Float, y: Float, z: Float, result: Float3x3): Float3x3 {
for (i in 0..2) {
result.matrix[i] = matrix[i] * x
result.matrix[3 + i] = matrix[3 + i] * y
result.matrix[6 + i] = matrix[6 + i] * z
}
return result
}
fun transform(value: MutableFloat3): MutableFloat3 {
val x = value.x * this[0, 0] + value.y * this[0, 1] + value.z * this[0, 2]
val y = value.x * this[1, 0] + value.y * this[1, 1] + value.z * this[1, 2]
val z = value.x * this[2, 0] + value.y * this[2, 1] + value.z * this[2, 2]
return value.set(x, y, z)
}
fun transform(value: Float3, result: MutableFloat3): MutableFloat3 {
result.x = value.x * this[0, 0] + value.y * this[0, 1] + value.z * this[0, 2]
result.y = value.x * this[1, 0] + value.y * this[1, 1] + value.z * this[1, 2]
result.z = value.x * this[2, 0] + value.y * this[2, 1] + value.z * this[2, 2]
return result
}
}
| 0 | Kotlin | 0 | 4 | 7e49a4507aa59cebefe928c4aa42f02182f95904 | 9,113 | foundry | Apache License 2.0 |
waypoint-core/src/main/java/com/squaredcandy/waypoint/core/Identifier.kt | squaredcandy | 638,860,321 | false | null | package com.squaredcandy.waypoint.core
import java.util.UUID
@Suppress("unused")
@JvmInline
value class Identifier<T>(val id: String)
fun <T> randomIdentifier() = Identifier<T>(UUID.randomUUID().toString())
| 0 | Kotlin | 0 | 0 | 014b43ec4a24a809f5a8be5ba4639a91c7bb04cc | 210 | waypoint | Apache License 2.0 |
app/src/main/java/com/wajahatkarim3/todo/mvvm/screens/taskslist/TasksListUI.kt | wajahatkarim3 | 312,335,087 | false | null | package com.wajahatkarim3.todo.mvvm.screens.taskslist
sealed class TasksListUI
object Loading : TasksListUI()
object Empty : TasksListUI()
object TasksList : TasksListUI() | 0 | Kotlin | 0 | 5 | aff292147297a62f2c09547423978976d2957bcb | 173 | ToDoMvvm | Apache License 2.0 |
app/src/main/java/com/sakuna63/tumbin/application/di/module/AuthenticationModule.kt | sakuna63 | 75,534,876 | false | null | package com.sakuna63.tumbin.application.di.module
import com.sakuna63.tumbin.BuildConfig
import com.sakuna63.tumbin.application.misc.AccountManager
import dagger.Module
import dagger.Provides
import oauth.signpost.OAuthConsumer
import oauth.signpost.OAuthProvider
import oauth.signpost.basic.DefaultOAuthProvider
import se.akerfeldt.okhttp.signpost.OkHttpOAuthConsumer
import javax.inject.Singleton
@Module
class AuthenticationModule {
@Provides
@Singleton
fun oAuthProvider(): OAuthProvider = DefaultOAuthProvider(
REQUEST_TOKEN_RESOURCE,
ACCESS_TOKEN_RESOURCE,
AUTHORIZE_URL)
@Provides
@Singleton
fun oAuthConsumer(accountManager: AccountManager): OAuthConsumer {
val consumer = OkHttpOAuthConsumer(BuildConfig.CONSUMER_KEY, BuildConfig.CONSUMER_KEY_SECRET)
if (accountManager.isLoggedIn) {
val token = accountManager.token ?: return consumer
//noinspection ConstantConditions
consumer.setTokenWithSecret(token.token, token.tokenSecret)
}
return consumer
}
@Singleton
@Provides
fun accountManager(): AccountManager = AccountManager()
companion object {
private val AUTHORIZE_URL = "https://www.tumblr.com/oauth/authorize?oauth_token=%s"
private val REQUEST_TOKEN_RESOURCE = "http://www.tumblr.com/oauth/request_token"
private val ACCESS_TOKEN_RESOURCE = "http://www.tumblr.com/oauth/access_token"
}
}
| 0 | Kotlin | 1 | 0 | 6d9992cbbcdf23fea218d362478545409dfead5c | 1,485 | tumbin | Apache License 2.0 |
paris-processor/src/main/java/com/airbnb/paris/processor/framework/SkyProcessor.kt | OlegKan | 129,674,316 | true | {"Kotlin": 248115, "Java": 81980, "Ruby": 3135} | package com.airbnb.paris.processor.framework
import javax.annotation.processing.*
import javax.lang.model.element.TypeElement
import javax.lang.model.util.Elements
import javax.lang.model.util.Types
abstract class SkyProcessor : AbstractProcessor() {
companion object {
lateinit var INSTANCE: SkyProcessor
}
lateinit var filer: Filer
lateinit var messager: Messager
lateinit var elements: Elements
lateinit var types: Types
@Synchronized
override fun init(processingEnv: ProcessingEnvironment) {
super.init(processingEnv)
filer = processingEnv.filer
messager = processingEnv.messager
elements = processingEnv.elementUtils
types = processingEnv.typeUtils
INSTANCE = this
}
override fun process(annotations: Set<TypeElement>, roundEnv: RoundEnvironment): Boolean {
processRound(annotations, roundEnv)
if (roundEnv.processingOver()) {
processingOver()
}
return claimAnnotations(annotations, roundEnv)
}
abstract fun processRound(annotations: Set<TypeElement>, roundEnv: RoundEnvironment)
abstract fun claimAnnotations(annotations: Set<TypeElement>, roundEnv: RoundEnvironment): Boolean
abstract fun processingOver()
}
| 0 | Kotlin | 0 | 0 | 43bdbe3916a0426b32d689360df8b5a642922808 | 1,284 | paris | Apache License 2.0 |
backend/src/main/kotlin/dev/gusriil/mindfullconnect/backend/common/security/UserInfo.kt | gusriil | 462,092,296 | false | null | package dev.gusriil.mindfullconnect.backend.common.security
import io.ktor.server.auth.jwt.*
object UserInfo {
fun getId(principal: JWTPrincipal?): Long {
return principal?.payload!!.getClaim("id").asLong()
}
} | 0 | Kotlin | 0 | 2 | e67415e2dda0121911cbd2a41852ac44411570d8 | 228 | MindfullConnect | Apache License 2.0 |
dsl/src/main/kotlin/com/faendir/awscdkkt/generated/services/greengrass/CfnFunctionDefinitionDsl.kt | F43nd1r | 643,016,506 | false | null | package com.faendir.awscdkkt.generated.services.greengrass
import com.faendir.awscdkkt.AwsCdkDsl
import javax.`annotation`.Generated
import kotlin.String
import kotlin.Unit
import software.amazon.awscdk.services.greengrass.CfnFunctionDefinition
import software.amazon.awscdk.services.greengrass.CfnFunctionDefinitionProps
import software.constructs.Construct
@Generated
public fun Construct.cfnFunctionDefinition(id: String, props: CfnFunctionDefinitionProps):
CfnFunctionDefinition = CfnFunctionDefinition(this, id, props)
@Generated
public fun Construct.cfnFunctionDefinition(
id: String,
props: CfnFunctionDefinitionProps,
initializer: @AwsCdkDsl CfnFunctionDefinition.() -> Unit,
): CfnFunctionDefinition = CfnFunctionDefinition(this, id, props).apply(initializer)
@Generated
public fun Construct.buildCfnFunctionDefinition(id: String, initializer: @AwsCdkDsl
CfnFunctionDefinition.Builder.() -> Unit): CfnFunctionDefinition =
CfnFunctionDefinition.Builder.create(this, id).apply(initializer).build()
| 1 | Kotlin | 0 | 0 | a1cf8fbfdfef9550b3936de2f864543edb76348b | 1,027 | aws-cdk-kt | Apache License 2.0 |
lecture01/src/test/kotlin/io/rybalkinsd/kotlinbootcamp/basics/WhenKtTest.kt | rybalkinsd | 143,287,871 | false | null | package io.rybalkinsd.kotlinbootcamp.basics
import junit.framework.TestCase.assertEquals
import org.junit.Test
class WhenKtTest {
@Test
fun `check one digit`() {
assertEquals("1 digit", countDigits("1"))
assertEquals("1 digit", countDigitsSimplified("6"))
}
@Test
fun `check two digits`() {
assertEquals("2 digits", countDigits("12"))
assertEquals("2 digits", countDigitsSimplified("56"))
}
@Test
fun `check multiple digits`() {
assertEquals("many digits", countDigits("15546345"))
assertEquals("many digits", countDigitsSimplified("122233511"))
}
}
| 69 | Kotlin | 37 | 49 | 687f918f7eef2faf86fdcb4cdfde6e2f9e3faec1 | 639 | kotlin-boot-camp | MIT License |
백준/절대값 힙.kt | jisungbin | 382,889,087 | false | null | import java.io.BufferedReader
import java.io.BufferedWriter
import java.io.InputStreamReader
import java.io.OutputStreamWriter
import java.util.PriorityQueue
import kotlin.math.abs
fun main() {
val br = BufferedReader(InputStreamReader(System.`in`))
val bw = BufferedWriter(OutputStreamWriter(System.out))
val priorityQueue = PriorityQueue<Long> { o1, o2 ->
val o1Abs = abs(o1)
val o2Abs = abs(o2)
if (o1Abs != o2Abs) {
o1Abs.compareTo(o2Abs)
} else {
o1.compareTo(o2)
}
}
val numberCount = br.readLine()!!.toInt()
repeat(numberCount) {
val number = br.readLine()!!.toLong()
if (number == 0L) {
bw.write("${priorityQueue.poll() ?: 0}\n")
} else {
priorityQueue.offer(number)
}
}
br.close()
bw.flush()
bw.close()
}
| 0 | Kotlin | 1 | 9 | ee43375828ca7e748e7c79fbed63a3b4d27a7a2c | 877 | algorithm-code | MIT License |
module_recorder/src/main/java/top/littlefogcat/clickerx/recorder/Ext.kt | LittleFogCat | 336,808,357 | false | null | package top.littlefogcat.clickerx.recorder
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.graphics.PixelFormat
import android.net.Uri
import android.os.Build
import android.provider.Settings
import android.view.LayoutInflater
import android.view.View
import android.view.WindowManager
import androidx.appcompat.app.AlertDialog
const val TAG = "GlobalFloatingWindow"
typealias LP = WindowManager.LayoutParams
/**
* 显示悬浮窗
*/
fun Context.showGlobalFloatingWindow(layoutId: Int): View {
val windowManager = getSystemService(Context.WINDOW_SERVICE) as WindowManager
val rootView = LayoutInflater.from(this).inflate(layoutId, null)
val layoutParams = WindowManager.LayoutParams().apply {
width = WindowManager.LayoutParams.WRAP_CONTENT
height = WindowManager.LayoutParams.WRAP_CONTENT
type = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
else WindowManager.LayoutParams.TYPE_PHONE
flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL or
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
format = PixelFormat.RGBA_8888
}
windowManager.addView(rootView, layoutParams)
return rootView
}
fun Context.checkFloatingWindowPermission() = Build.VERSION.SDK_INT < Build.VERSION_CODES.M
|| Settings.canDrawOverlays(this)
/**
* 检查悬浮窗权限。
*
* 可选参数[actionIfNoPermission]:如果检查到没有悬浮窗权限的话,那么[actionIfNoPermission]将被执行。
* 如果没有设置[actionIfNoPermission],默认弹出跳转到悬浮窗设置的对话框。
*/
fun Activity.ensureFloatingPermission(
actionIfNoPermission: (() -> Unit)? = null
) {
if (checkFloatingWindowPermission()) return
if (actionIfNoPermission != null) actionIfNoPermission()
else {
AlertDialog.Builder(this)
.setTitle("需要悬浮窗权限")
.setMessage("点击确定跳转到权限设置")
.setPositiveButton("确定") { _, _ ->
val intent = Intent().apply {
action = Settings.ACTION_MANAGE_OVERLAY_PERMISSION
data = Uri.parse("package:$packageName")
}
startActivityForResult(intent, 0)
}
.show()
}
} | 1 | null | 2 | 6 | 8a04e32df68dfc45d7fed84c9c715cb0066f3e72 | 2,287 | ClickerX | Apache License 2.0 |
app/src/androidTest/java/com/stevesoltys/seedvault/e2e/screen/impl/RecoveryCodeScreen.kt | seedvault-app | 104,299,796 | false | null | package com.stevesoltys.seedvault.e2e.screen.impl
import com.stevesoltys.seedvault.e2e.screen.UiDeviceScreen
object RecoveryCodeScreen : UiDeviceScreen<RecoveryCodeScreen>() {
val confirmCodeButton = findObject { text("Confirm code") }
val verifyCodeButton = findObject { text("Verify") }
fun wordTextField(index: Int) = findObject { text("Word ${index + 1}") }
}
| 98 | null | 71 | 998 | 2bbeece7b7a09e1b3d19f15cb037b197e7e032c6 | 381 | seedvault | Apache License 2.0 |
sample/src/main/java/ru/tinkoff/acquiring/sample/models/Cart.kt | TinkoffCreditSystems | 268,528,392 | false | null | /*
* Copyright © 2020 Tinkoff Bank
*
* 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 ru.tinkoff.acquiring.sample.models
import ru.tinkoff.acquiring.sdk.utils.Money
import java.util.*
/**
* @author <NAME>
*/
object Cart : ArrayList<Cart.CartEntry>() {
data class CartEntry(val bookId: Int) {
var count: Int = 1
private set
private var price: Money? = null
constructor(bookId: Int, price: Money) : this(bookId) {
this.price = price
this.count = 1
}
fun increase() {
count++
}
fun decrease(): Boolean {
count--
return count != 0
}
fun getPrice(): Money {
return Money.ofCoins((price?.coins ?: 0) * count)
}
}
override fun add(element: CartEntry): Boolean {
for (entry in this) {
if (entry == element) {
entry.increase()
return true
}
}
return super.add(element)
}
override fun remove(element: CartEntry): Boolean {
var forDelete: CartEntry? = null
for (entry in this) {
if (entry == element) {
forDelete = entry
break
}
}
if (forDelete == null) {
return false
}
return if (!forDelete.decrease()) {
super.remove(element)
} else true
}
}
| 26 | null | 16 | 23 | 6deb46fa37a41292e8065a3d7b944acb2e3eac26 | 1,978 | AcquiringSdkAndroid | Apache License 2.0 |
app/src/main/java/com/ezetap/ezetapassignmentappmodule/ui/screens/FormReviewScreen.kt | SachinRupani | 596,274,906 | false | null | package com.ezetap.ezetapassignmentappmodule.ui.screens
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.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.ElevatedCard
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.ezetap.ezetapassignmentappmodule.R
import com.ezetap.ezetapassignmentnetworkmodule.model.UiType
@OptIn(ExperimentalLifecycleComposeApi::class)
@Composable
fun FormReviewScreen(
formViewModel: FormViewModel,
onNavigateBack: () -> Unit
) {
val uiStateCustomUi by formViewModel.uiState.collectAsStateWithLifecycle()
// UI Data List
val listUiData = remember {
uiStateCustomUi.dataOrNull()?.listUiData?.filter {
//Only label or Text Field UI type should be a part of the list
it.getUiTypeEnum == UiType.Label || it.getUiTypeEnum == UiType.TextField
} ?: emptyList()
}
Column(modifier = Modifier.padding(32.dp)) {
// Back Icon
Icon(
modifier = Modifier.clickable {
onNavigateBack.invoke()
},
painter = painterResource(id = R.drawable.ic_back), contentDescription = stringResource(
id = R.string.icon_navigate_back
)
)
// Title
Text(
modifier = Modifier
.fillMaxWidth()
.padding(top = 16.dp),
text = stringResource(id = R.string.review_screen_title),
textAlign = TextAlign.Center,
style = MaterialTheme.typography.headlineMedium
)
// Card Content
ElevatedCard(
shape = RoundedCornerShape(12.dp),
modifier = Modifier.padding(vertical = 24.dp),
) {
// List of UI Elements
LazyColumn(
modifier = Modifier.padding(top = 16.dp, bottom = 20.dp, start = 24.dp, end = 24.dp)
) {
items(listUiData.size) { index ->
val uiDataElement = listUiData[index]
Column(
modifier = Modifier
.fillMaxWidth()
) {
when (uiDataElement.getUiTypeEnum) {
// Title
UiType.Label -> {
Text(
modifier = Modifier.padding(top = 16.dp),
text = uiDataElement.valueText,
color = MaterialTheme.colorScheme.outline
)
}
// Value
UiType.TextField -> {
Text(
text = uiDataElement.valueText,
modifier = Modifier.padding(top = 2.dp)
)
}
else -> {}
}
}
}
}
}
}
} | 0 | Kotlin | 0 | 0 | 6ef381256d906a92f04fcdcae43def3932de3b2d | 3,860 | Ezetap-Assignment | Apache License 2.0 |
app/src/main/java/com/puutaro/commandclick/proccess/edit/edit_text_support_view/lib/EditableListContentsSelectGridViewProducer.kt | puutaro | 596,852,758 | false | {"Kotlin": 1472142, "JavaScript": 147417, "HTML": 19619} | package com.puutaro.commandclick.proccess.edit.edit_text_support_view.lib
import android.app.Dialog
import android.text.Editable
import android.text.TextWatcher
import android.view.Gravity
import android.view.ViewGroup
import android.widget.Button
import android.widget.EditText
import android.widget.GridView
import android.widget.LinearLayout
import androidx.appcompat.widget.AppCompatEditText
import androidx.fragment.app.Fragment
import com.puutaro.commandclick.common.variable.edit.EditParameters
import com.puutaro.commandclick.component.adapter.ImageAdapter
import com.puutaro.commandclick.proccess.edit.edit_text_support_view.lib.ListContentsSelectSpinnerViewProducer.getElsbMap
import com.puutaro.commandclick.proccess.edit.edit_text_support_view.lib.ListContentsSelectSpinnerViewProducer.getLimitNum
import com.puutaro.commandclick.proccess.edit.edit_text_support_view.lib.ListContentsSelectSpinnerViewProducer.getListPath
import com.puutaro.commandclick.proccess.edit.edit_text_support_view.lib.ListContentsSelectSpinnerViewProducer.getSelectJsPath
import com.puutaro.commandclick.proccess.edit.edit_text_support_view.lib.lib.SelectJsExecutor
import com.puutaro.commandclick.proccess.edit.lib.ButtonSetter
import com.puutaro.commandclick.util.FileSystems
import com.puutaro.commandclick.util.Keyboard
import com.puutaro.commandclick.util.ReadText
import java.io.File
object EditableListContentsSelectGridViewProducer {
private var gridDialogObj: Dialog? = null
private val defaultListLimit = 100
private val gridButtonLabel = "GSL"
fun make (
insertEditText: EditText,
editParameters: EditParameters,
currentComponentIndex: Int,
weight: Float,
): Button {
val currentFragment = editParameters.currentFragment
val context = editParameters.context
val linearParamsForGridButton = LinearLayout.LayoutParams(
0,
LinearLayout.LayoutParams.MATCH_PARENT,
)
linearParamsForGridButton.weight = weight
val elcbMap = getElsbMap(
editParameters,
currentComponentIndex
)
val listContentsFilePath = getListPath(
elcbMap,
)
val gridButtonView = Button(context)
gridButtonView.text = gridButtonLabel
ButtonSetter.set(
context,
gridButtonView
)
gridButtonView.setOnClickListener {
buttonView ->
val buttonContext = buttonView.context
gridDialogObj = Dialog(
buttonContext
)
gridDialogObj?.setContentView(
com.puutaro.commandclick.R.layout.grid_dialog_layout
)
setGridListView(
currentFragment,
insertEditText,
listContentsFilePath,
elcbMap
)
gridDialogObj?.setOnCancelListener {
gridDialogObj?.dismiss()
}
gridDialogObj?.window?.setLayout(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
)
gridDialogObj?.window?.setGravity(Gravity.BOTTOM)
gridDialogObj?.show()
}
gridButtonView.layoutParams = linearParamsForGridButton
return gridButtonView
}
private fun setGridListView(
currentFragment: Fragment,
insertEditText: EditText,
listContentsFilePath: String,
elcbMap: Map<String, String>?
) {
val context = currentFragment.context
?: return
val listDialogSearchEditText = gridDialogObj?.findViewById<AppCompatEditText>(
com.puutaro.commandclick.R.id.grid_dialog_search_edit_text
) ?: return
listDialogSearchEditText.hint = "search selectable list"
val editableSpinnerList =
makeGridList(listContentsFilePath)
val gridView =
gridDialogObj?.findViewById<GridView>(
com.puutaro.commandclick.R.id.grid_dialog_grid_view
) ?: return
val imageAdapter = ImageAdapter(
context,
)
imageAdapter.clear()
imageAdapter.addAll(
editableSpinnerList.toMutableList()
)
gridView.adapter = imageAdapter
makeSearchEditText(
gridView,
listDialogSearchEditText,
editableSpinnerList.joinToString("\n"),
)
setGridViewItemClickListener(
currentFragment,
insertEditText,
listDialogSearchEditText,
gridView,
elcbMap,
)
}
private fun makeGridList(
listContentsFilePath: String,
): List<String> {
val fileObj = File(listContentsFilePath)
val parentDir = fileObj.parent ?: String()
val listFileName = fileObj.name
FileSystems.createDirs(parentDir)
return ReadText(
parentDir,
listFileName
).textToList().filter {
it.trim().isNotEmpty()
}
}
private fun setGridViewItemClickListener(
currentFragment: Fragment,
insertEditText: EditText,
searchText: EditText,
gridView: GridView,
elcbMap: Map<String, String>?,
){
val listContentsFilePath = getListPath(
elcbMap,
)
val listLimit = getLimitNum(
elcbMap,
defaultListLimit,
)
val selectJsPath = getSelectJsPath(
elcbMap
)
val fileObj = File(listContentsFilePath)
val parentDir = fileObj.parent ?: String()
val listFileName = fileObj.name
gridView.setOnItemClickListener {
parent, View, pos, id
->
Keyboard.hiddenKeyboardForFragment(
currentFragment
)
gridDialogObj?.dismiss()
val currentGridList = ReadText(
parentDir,
listFileName
).textToList()
val selectedItem = currentGridList.filter {
Regex(
searchText.text.toString()
.lowercase()
.replace("\n", "")
).containsMatchIn(
it.lowercase()
)
}.filter {
it.trim().isNotEmpty()
}.get(pos)
val updateListContents =
listOf(selectedItem) +
currentGridList.filter {
it != selectedItem
}
FileSystems.writeFile(
parentDir,
listFileName,
updateListContents
.take(listLimit)
.joinToString("\n")
)
val selectUpdatedGridList = listOf(
selectedItem,
) + currentGridList.filter {
it != selectedItem
}
val imageAdapter = gridView.adapter as ImageAdapter
imageAdapter.clear()
imageAdapter.addAll(selectUpdatedGridList.toMutableList())
imageAdapter.notifyDataSetChanged()
gridView.setSelection(0)
insertEditText.setText(selectedItem)
SelectJsExecutor.exec(
currentFragment,
selectJsPath,
selectedItem
)
}
}
private fun makeSearchEditText(
fannelListGridView: GridView,
searchText: AppCompatEditText,
listCon: String,
) {
val imageAdapter =
fannelListGridView.adapter as ImageAdapter
searchText.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {}
override fun afterTextChanged(s: Editable?) {
if (!searchText.hasFocus()) return
val filteredList = listCon.split("\n").filter {
Regex(
searchText.text.toString()
.lowercase()
.replace("\n", "")
).containsMatchIn(
it.lowercase()
)
}
imageAdapter.clear()
imageAdapter.addAll(filteredList.toMutableList())
imageAdapter.notifyDataSetChanged()
}
})
}
} | 2 | Kotlin | 3 | 54 | 000db311f5780b2861a2143f7985507b06cae5f1 | 8,627 | CommandClick | MIT License |
app/src/main/java/com/example/sitiosturisticos/Lista_poi.kt | JuanEsteban05 | 427,503,303 | false | {"Kotlin": 14219, "Java": 1159} | package com.example.sitiosturisticos
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import android.widget.RatingBar
import androidx.recyclerview.widget.RecyclerView
import com.example.sitiosturisticos.model.PoiItem
import com.squareup.picasso.Picasso
class Lista_poi (private val poiList :ArrayList<PoiItem>,
private val onItemClicked:(PoiItem)->Unit
)
: RecyclerView.Adapter<Lista_poi.ViewHolder> (){
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view= LayoutInflater.from(parent.context).inflate(R.layout.activity_sitio_turistico,parent,false)
return ViewHolder(view)
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val lugar=poiList[position]
holder.itemView.setOnClickListener{onItemClicked(poiList[position])}
holder.bind(lugar)
}
override fun getItemCount(): Int {
return poiList.size
}
fun appendItems(newItems: ArrayList<PoiItem>){
poiList.clear()
poiList.addAll(newItems)
notifyDataSetChanged()
}
class ViewHolder(itemview: View):RecyclerView.ViewHolder(itemview){
private var nameTextView: TextView = itemview.findViewById(R.id.textView_titulo)
private var descripcionTextView: TextView = itemview.findViewById(R.id.textView_descripcion)
private var puntajeTextView: RatingBar = itemview.findViewById(R.id.ratingBar2)
private var pictureView: ImageView = itemview.findViewById(R.id.pictureImageView)
fun bind(lugar: PoiItem){
nameTextView.text=lugar.titulo
descripcionTextView.text=lugar.pDescripcion
puntajeTextView.rating= lugar.puntuacion.toFloat()
Picasso.get().load(lugar.imagen).into(pictureView)
/*
itemView.setOnClickListener{
val intent = Intent(itemView.context, DatosPoi::class.java)
val bundle = Bundle()
bundle.putSerializable("datos", lugar)
intent.putExtras(bundle)
itemView.context.startActivity(intent)
}*/
}
}
} | 0 | Kotlin | 0 | 0 | de02909467ba5408d239f12836a8af0f8352e87c | 2,251 | SitiosTuristicos | MIT License |
src/main/kotlin/canon/parser/map/strategy/UploadStrategy.kt | leftshiftone | 205,671,409 | false | null | package canon.parser.map.strategy
import canon.api.IRenderable
import canon.model.Upload
class UploadStrategy : AbstractParseStrategy<Upload>() {
override fun parse(map: Map<String, Any>, factory: (Map<String, Any>) -> List<IRenderable>): Upload {
return Upload(map["id"]?.toString()?.ifEmpty { null },
map["class"]?.toString()?.ifEmpty { null },
map["ariaLabel"]?.toString()?.ifEmpty { null },
map["accept"]?.toString()?.ifEmpty { null },
map["name"]?.toString()?.ifEmpty { null },
map["text"]?.toString()?.ifEmpty { null },
map["maxSize"]?.toString()?.ifEmpty { null }?.toDouble(),
map["maxCompressSize"]?.toString()?.ifEmpty { null }?.toDouble(),
map["required"]?.toString()?.ifEmpty { null }?.toBoolean()
)
}
} | 0 | Kotlin | 1 | 0 | 5babc577eeca5655cf92e64dd2693c591c72eb50 | 836 | canon | MIT License |
server-api/src/main/kotlin/io/github/oleksivio/tl/kbot/server/api/objects/std/CallbackQuery.kt | oleksivio | 145,889,451 | false | null | package io.github.oleksivio.tl.kbot.server.api.objects.std
import com.fasterxml.jackson.annotation.JsonProperty
import io.github.oleksivio.tl.kbot.server.api.model.objects.IUserFrom
/**
* [CallbackQuery](https://core.telegram.org/bots/api/#callbackquery)
*/
data class CallbackQuery(
/**
* id String Unique identifier for this query
*/
@JsonProperty("id")
var id: String? = null,
/**
* To setup filter:
*
* UserFilter from from User Sender
*/
@JsonProperty("from")
override var from: User?,
/**
* To setup filter:
*
* MessageFilter message message Message Optional. Message with the callback button that originated the query.
* Note that message content and message date will not be available if the message is too old
*/
@JsonProperty("message")
var message: Message? = null,
/**
* To setup filter:
*
* StringFilter inlineMessageId inline_message_id [String] Optional. Identifier of the message sent via the bot in
* inline mode, that originated the query.
*/
@JsonProperty("inline_message_id")
var inlineMessageId: String? = null,
/**
* To setup filter:
*
* StringFilter chatInstance chat_instance String Global identifier, uniquely corresponding to the chat to which
* the message with the callback button was sent. Useful for high scores in games.
*/
@JsonProperty("chat_instance")
var chatInstance: String? = null,
/**
* To setup filter:
*
* StringFilter data data [String] Optional. Data associated with the callback button. Be aware that a bad client
* can send arbitrary data in this field.
*/
@JsonProperty("data")
var data: String? = null,
/**
* To setup filter:
*
* StringFilter gameShortName game_short_name [String] Optional. Short name of a Game to be returned, serves as the
* unique identifier for the game
*/
@JsonProperty("game_short_name")
var gameShortName: String? = null
) : IUserFrom
| 0 | Kotlin | 0 | 5 | d38b5be33c5217a3f91e44394995f112fd6b0ab9 | 2,057 | tl-kbot | Apache License 2.0 |
server-api/src/main/kotlin/io/github/oleksivio/tl/kbot/server/api/objects/std/CallbackQuery.kt | oleksivio | 145,889,451 | false | null | package io.github.oleksivio.tl.kbot.server.api.objects.std
import com.fasterxml.jackson.annotation.JsonProperty
import io.github.oleksivio.tl.kbot.server.api.model.objects.IUserFrom
/**
* [CallbackQuery](https://core.telegram.org/bots/api/#callbackquery)
*/
data class CallbackQuery(
/**
* id String Unique identifier for this query
*/
@JsonProperty("id")
var id: String? = null,
/**
* To setup filter:
*
* UserFilter from from User Sender
*/
@JsonProperty("from")
override var from: User?,
/**
* To setup filter:
*
* MessageFilter message message Message Optional. Message with the callback button that originated the query.
* Note that message content and message date will not be available if the message is too old
*/
@JsonProperty("message")
var message: Message? = null,
/**
* To setup filter:
*
* StringFilter inlineMessageId inline_message_id [String] Optional. Identifier of the message sent via the bot in
* inline mode, that originated the query.
*/
@JsonProperty("inline_message_id")
var inlineMessageId: String? = null,
/**
* To setup filter:
*
* StringFilter chatInstance chat_instance String Global identifier, uniquely corresponding to the chat to which
* the message with the callback button was sent. Useful for high scores in games.
*/
@JsonProperty("chat_instance")
var chatInstance: String? = null,
/**
* To setup filter:
*
* StringFilter data data [String] Optional. Data associated with the callback button. Be aware that a bad client
* can send arbitrary data in this field.
*/
@JsonProperty("data")
var data: String? = null,
/**
* To setup filter:
*
* StringFilter gameShortName game_short_name [String] Optional. Short name of a Game to be returned, serves as the
* unique identifier for the game
*/
@JsonProperty("game_short_name")
var gameShortName: String? = null
) : IUserFrom
| 0 | Kotlin | 0 | 5 | d38b5be33c5217a3f91e44394995f112fd6b0ab9 | 2,057 | tl-kbot | Apache License 2.0 |
src/main/kotlin/xyz/l7ssha/emr/validation/ValueOfEnum.kt | tokioemr | 454,506,546 | false | null | package xyz.l7ssha.emr.validation
import javax.validation.Constraint
import kotlin.reflect.KClass
@Target(AnnotationTarget.FIELD, AnnotationTarget.TYPE)
@Retention(AnnotationRetention.RUNTIME)
@Constraint(validatedBy = [ValueOfEnumValidator::class])
annotation class ValueOfEnum(
val enumClass: KClass<out Enum<*>>,
val message: String = "must be any of enum {enumClass}",
val groups: Array<KClass<*>> = [],
val payload: Array<KClass<*>> = []
)
| 0 | Kotlin | 0 | 0 | c28c86941439836c7474a0695e03197c778b6d7d | 464 | emr | Apache License 2.0 |
app/src/main/java/com/kilomobi/cosmo/data/di/CosmoModule.kt | fkistner-dev | 751,512,153 | false | {"Kotlin": 52569} | package com.kilomobi.cosmo.data.di
import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothManager
import android.content.Context
import com.kilomobi.cosmo.data.remote.CosmoApiService
import com.kilomobi.cosmo.domain.BluetoothRepository
import com.kilomobi.cosmo.data.CosmoBluetoothScanner
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
object RetrofitModule {
@Singleton
@Provides
fun provideRetrofit(): Retrofit {
return Retrofit.Builder()
.baseUrl("https://cosmo-api.develop-sr3snxi-x6u2x52ooksf4.de-2.platformsh.site/")
.addConverterFactory(MoshiConverterFactory.create())
.client(OkHttpClient.Builder().build())
.build()
}
@Singleton
@Provides
fun provideCosmoApi(retrofit: Retrofit): CosmoApiService =
retrofit.create(CosmoApiService::class.java)
}
@Module
@InstallIn(SingletonComponent::class)
object BluetoothModule {
@Provides
@Singleton
fun provideBluetoothAdapter(@ApplicationContext appContext: Context): BluetoothAdapter? {
return (appContext.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager).adapter
}
@Provides
@Singleton
fun provideBluetoothScanner(
bluetoothAdapter: BluetoothAdapter?
): BluetoothRepository {
return CosmoBluetoothScanner(bluetoothAdapter)
}
} | 0 | Kotlin | 0 | 0 | 45c83a53728516ea5db78c9c23ba88bb075f4a4f | 1,686 | cosmo-android | MIT License |
src/main/kotlin/Navigation.kt | spbu-coding-2023 | 791,480,179 | false | {"Kotlin": 102030} |
import androidx.compose.runtime.Composable
import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navArgument
import view.screens.*
import viewmodel.MainScreenViewModel
@Composable
fun Navigation() {
val navController = rememberNavController()
val mainScreenViewModel = MainScreenViewModel()
NavHost(navController = navController,
startDestination = Screen.MainScreen.route) {
composable(route = Screen.MainScreen.route){
MainScreen(navController = navController, mainScreenViewModel)
}
composable(
route = "${Screen.UndirectedGraphScreen.route}/{graphId}",
arguments = listOf(navArgument("graphId") { type = NavType.IntType })
){ navBackStackEntry ->
val graphId = navBackStackEntry.arguments?.getInt("graphId")
graphId?.let{
UndirectedGraphScreen(navController, mainScreenViewModel, graphId)
}
}
composable(
route = "${Screen.DirectedGraphScreen.route}/{graphId}",
arguments = listOf(navArgument("graphId") { type = NavType.IntType })
){ navBackStackEntry ->
val graphId = navBackStackEntry.arguments?.getInt("graphId")
graphId?.let{
DirectedGraphScreen(navController, mainScreenViewModel, graphId)
}
}
composable(route = Screen.SettingsScreen.route){
SettingsScreen(navController = navController)
}
}
}
| 2 | Kotlin | 0 | 4 | af2956ded1ed04428c4f299e121df746c7319f9d | 1,642 | graphs-graphs-8 | The Unlicense |
app/src/main/java/ru/maxim/unsplash/network/exception/UnauthorizedException.kt | maximborodkin | 406,747,572 | false | {"Kotlin": 242939} | package ru.maxim.unsplash.network.exception
import retrofit2.HttpException
import retrofit2.Response
/**
* Exception class for represent 401 HTTP code
**/
class UnauthorizedException(response: Response<*>) : HttpException(response) | 0 | Kotlin | 0 | 2 | 06a7d3fb24badae12d42d1a6c45666434ec34d73 | 235 | kts-android-unsplash | MIT License |
app/src/main/java/com/sduduzog/slimlauncher/ui/main/model/AppRoomDatabase.kt | maxdevjs | 161,930,030 | true | {"Gradle": 3, "Java Properties": 2, "Shell": 1, "Text": 1, "Ignore List": 2, "Batchfile": 1, "Markdown": 1, "Proguard": 1, "Java": 1, "XML": 33, "Kotlin": 23, "YAML": 1} | package com.sduduzog.slimlauncher.ui.main.model
import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase
@Database(entities = [App::class, HomeApp::class], version = 2, exportSchema = false)
abstract class AppRoomDatabase : RoomDatabase() {
abstract fun appDao(): AppDao
companion object {
@Volatile
@JvmStatic
private var INSTANCE: AppRoomDatabase? = null
fun getDatabase(context: Context): AppRoomDatabase? {
synchronized(AppRoomDatabase::class.java) {
if (INSTANCE == null) {
INSTANCE = Room.databaseBuilder(context.applicationContext,
AppRoomDatabase::class.java, "app_database")
.addMigrations(MIGRATION_1_2)
.build()
}
return INSTANCE
}
}
private val MIGRATION_1_2 = object: Migration(1, 2){
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE home_apps ADD COLUMN sorting_index INTEGER NOT NULL DEFAULT 0")
val cursor = database.query("SELECT package_name FROM home_apps")
cursor.moveToFirst()
var index = 0
while (!cursor.isAfterLast){
val column = cursor.getString(cursor.getColumnIndex("package_name"))
database.execSQL("UPDATE home_apps SET sorting_index=$index WHERE package_name='$column'")
cursor.moveToNext()
index++
}
}
}
}
}
| 0 | Kotlin | 0 | 0 | 3ddffb44868ad45b095f05cddbd07996f3cd94e8 | 1,779 | slim-launcher | MIT License |
orca-queue/src/main/kotlin/com/netflix/spinnaker/orca/q/handler/StartExecutionHandler.kt | simonlord | 129,107,811 | false | {"Gradle": 32, "Slim": 1, "YAML": 55, "TOML": 1, "Dockerfile": 1, "Java Properties": 1, "Shell": 6, "Ignore List": 1, "Batchfile": 1, "EditorConfig": 1, "Text": 3, "Markdown": 18, "Groovy": 579, "Kotlin": 130, "JSON": 48, "Java": 309, "INI": 1, "XML": 2, "desktop": 1} | /*
* Copyright 2017 Netflix, 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.netflix.spinnaker.orca.q.handler
import com.netflix.spinnaker.orca.ExecutionStatus.*
import com.netflix.spinnaker.orca.events.ExecutionComplete
import com.netflix.spinnaker.orca.events.ExecutionStarted
import com.netflix.spinnaker.orca.ext.initialStages
import com.netflix.spinnaker.orca.pipeline.model.Execution
import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository
import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository.ExecutionCriteria
import com.netflix.spinnaker.orca.q.CancelExecution
import com.netflix.spinnaker.orca.q.StartExecution
import com.netflix.spinnaker.orca.q.StartStage
import com.netflix.spinnaker.q.Queue
import net.logstash.logback.argument.StructuredArguments.value
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.context.ApplicationEventPublisher
import org.springframework.stereotype.Component
import java.time.Clock
import java.time.Instant
@Component
class StartExecutionHandler(
override val queue: Queue,
override val repository: ExecutionRepository,
@Qualifier("queueEventPublisher") private val publisher: ApplicationEventPublisher,
private val clock: Clock
) : OrcaMessageHandler<StartExecution> {
override val messageType = StartExecution::class.java
private val log: Logger get() = LoggerFactory.getLogger(javaClass)
override fun handle(message: StartExecution) {
message.withExecution { execution ->
if (execution.status == NOT_STARTED && !execution.isCanceled) {
if (execution.shouldQueue()) {
log.info("Queueing {} {} {}", execution.application, execution.name, execution.id)
} else {
start(execution)
}
} else {
terminate(execution)
}
}
}
private fun start(execution: Execution) {
if (execution.isAfterStartTimeExpiry()) {
log.warn("Execution (type ${execution.type}, id {}, application: {}) start was canceled because" +
"start time would be after defined start time expiry (now: ${clock.millis()}, expiry: ${execution.startTimeExpiry})",
value("executionId", execution.id),
value("application", execution.application))
queue.push(CancelExecution(
execution.type,
execution.id,
execution.application,
"spinnaker",
"Could not begin execution before start time expiry"
))
} else {
val initialStages = execution.initialStages()
if (initialStages.isEmpty()) {
log.warn("No initial stages found (executionId: ${execution.id})")
repository.updateStatus(execution.id, TERMINAL)
publisher.publishEvent(ExecutionComplete(this, execution.type, execution.id, TERMINAL))
} else {
repository.updateStatus(execution.id, RUNNING)
initialStages.forEach { queue.push(StartStage(it)) }
publisher.publishEvent(ExecutionStarted(this, execution.type, execution.id))
}
}
}
private fun terminate(execution: Execution) {
if (execution.status == CANCELED || execution.isCanceled) {
publisher.publishEvent(ExecutionComplete(this, execution.type, execution.id, execution.status))
} else {
log.warn("Execution (type: ${execution.type}, id: {}, status: ${execution.status}, application: {})" +
" cannot be started unless state is NOT_STARTED. Ignoring StartExecution message.",
value("executionId", execution.id),
value("application", execution.application))
}
}
private fun Execution.shouldQueue(): Boolean {
if (!isLimitConcurrent) {
return false
}
return pipelineConfigId?.let { configId ->
val criteria = ExecutionCriteria().setLimit(1).setStatuses(RUNNING)
!repository
.retrievePipelinesForPipelineConfigId(configId, criteria)
.isEmpty
.toBlocking()
.first()
} == true
}
private fun Execution.isAfterStartTimeExpiry() =
startTimeExpiry
?.let { Instant.ofEpochMilli(it) }
?.isBefore(clock.instant()) ?: false
}
| 1 | null | 1 | 1 | 651001f8f321dfe699da0a17de86984974de8ab3 | 4,683 | orca | Apache License 2.0 |
game/plugin/chat/private-messaging/src/ignores.plugin.kts | Subby | 145,592,872 | true | {"YAML": 3, "Groovy": 3, "Gradle": 42, "EditorConfig": 1, "Markdown": 2, "Text": 1, "Ignore List": 2, "Kotlin": 120, "Java": 664, "XML": 46, "Ruby": 83, "INI": 1} | import org.apollo.game.message.impl.AddIgnoreMessage
import org.apollo.game.message.impl.RemoveIgnoreMessage
on { AddIgnoreMessage::class }
.then { it.addIgnore(username) }
on { RemoveIgnoreMessage::class }
.then { it.removeIgnore(username) } | 0 | Java | 0 | 3 | 2080e1e700551c929099e4f9817d64598ad15d58 | 260 | apollo | ISC License |
buildSrc/src/main/kotlin/Config.kt | huunam1108 | 264,809,943 | false | {"Kotlin": 8015} | object Versions {
const val kotlin = "1.3.71"
const val android_gradle_plugin = "3.5.0"
const val compile_sdk_version = 29
const val build_tools_version = "29.0.2"
const val min_sdk_version = 21
const val target_sdk_version = 29
const val appcompat = "1.1.0"
const val androidx_test = "1.2.0"
const val core_ktx = "1.1.0"
const val espresso = "3.2.0"
const val junit = "4.12"
const val constraint_layout = "1.1.3"
const val material = "1.2.0-alpha02"
const val ktlint = "0.36.0"
const val detekt = "1.9.1"
}
object ClassPaths {
const val android_gradle_plugin = "com.android.tools.build:gradle:${Versions.android_gradle_plugin}"
const val kotlin_gradle_plugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}"
}
object Plugins {
const val androidApp = "com.android.application"
const val kotlinAndroid = "android"
const val kotlinExt = "android.extensions"
const val kotlinApt = "kapt"
const val detekt = "io.gitlab.arturbosch.detekt"
}
object Deps {
const val support_app_compat = "androidx.appcompat:appcompat:${Versions.appcompat}"
const val support_design = "com.google.android.material:material:${Versions.material}"
const val support_core_ktx = "androidx.core:core-ktx:${Versions.core_ktx}"
const val espresso_core = "androidx.test.espresso:espresso-core:${Versions.espresso}"
const val atsl_runner = "androidx.test:runner:${Versions.androidx_test}"
const val kotlin_stdlib = "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${Versions.kotlin}"
const val constraint_layout = "androidx.constraintlayout:constraintlayout:${Versions.constraint_layout}"
const val junit = "junit:junit:${Versions.junit}"
const val ktlint = "com.pinterest:ktlint:${Versions.ktlint}"
}
| 4 | Kotlin | 2 | 1 | 402f409acd3e05857a2daa5d9894edec4eb5d61e | 1,809 | AndroidSetup | Apache License 2.0 |
src/main/kotlin/com/igorini/mrdrafty/card/PitFighterOfQuoidge.kt | igorini | 159,063,909 | false | null | package com.igorini.mrdrafty.card
/** Represents a card "Pit Fighter Of Quoidge" */
class PitFighterOfQuoidge : Card() {
override fun name() = "Pit Fighter Of Quoidge"
override fun imageUrl() = ""
override fun color() = CardColor.BLACK
override fun type() = CardType.CREEP
override fun rarity() = CardRarity.RARE
override fun baseScore() = 97.1
} | 0 | Kotlin | 0 | 1 | 6e59b9a1073788311b69210b05b8fe0ebb2a7e95 | 371 | mr-drafty | Apache License 2.0 |
gateway/src/test/kotlin/de/roamingthings/workbench/graphql/WorkbenchGraphqlApplicationTests.kt | roamingthings | 293,346,213 | false | null | package de.roamingthings.workbench.graphql
import org.junit.jupiter.api.Test
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT
@SpringBootTest(webEnvironment = RANDOM_PORT)
class WorkbenchGraphqlApplicationTests {
@Test
fun contextLoads() {
}
}
| 0 | Kotlin | 0 | 0 | 1f81e2eec21b378f19089b69965c1a0efaf9f2cc | 349 | workbench-graphql | Apache License 2.0 |
app/src/main/java/com/spaceapp/data/datasource/remote/mars_photos/MarsPhotoRemoteDataSource.kt | AhmetOcak | 552,274,999 | false | {"Kotlin": 385521} | package com.spaceapp.data.datasource.remote.mars_photos
import com.spaceapp.data.datasource.remote.mars_photos.entity.MarsPhotoDto
interface MarsPhotoRemoteDataSource {
suspend fun getLatestMarsPhotos() : MarsPhotoDto
} | 0 | Kotlin | 1 | 2 | faac912d41d8decca902f79d725aa560d1e6a7bf | 226 | Explore-Universe | MIT License |
app/src/main/java/com/mburakcakir/taketicket/ui/home/HomeFragment.kt | mburakcakir | 319,590,139 | false | null | package com.mburakcakir.taketicket.ui.home
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import com.google.android.material.tabs.TabLayoutMediator
import com.mburakcakir.taketicket.databinding.FragmentHomeBinding
import com.mburakcakir.taketicket.ui.MainActivity
import com.mburakcakir.taketicket.util.navigate
class HomeFragment : Fragment() {
private lateinit var homeViewModel: HomeViewModel
private var _binding: FragmentHomeBinding? = null
private val binding get() = _binding!!
lateinit var homeEventPagerAdapter: HomeEventPagerAdapter
private val tabTitles = arrayOf("Yerel", "Yabancı", "Filmler")
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = FragmentHomeBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
homeViewModel = ViewModelProvider(this).get(HomeViewModel::class.java)
checkIfUserLoggedIn()
}
override fun onDestroyView() {
_binding = null
super.onDestroyView()
}
private fun checkIfUserLoggedIn() {
if (!homeViewModel.sessionManager.ifUserLoggedIn()) {
(requireActivity() as MainActivity).changeToolbarVisibility(View.GONE)
this.navigate(HomeFragmentDirections.actionHomeFragmentToLoginFragment())
} else
init()
}
private fun init() {
(requireActivity() as MainActivity).changeToolbarVisibility(View.VISIBLE)
homeEventPagerAdapter = HomeEventPagerAdapter(this)
homeEventPagerAdapter.apply {
setOnEventClickListener { eventModel ->
[email protected](
HomeFragmentDirections.actionHomeFragmentToDetailDialog(
eventModel
)
)
}
}
binding.vpEvent.adapter = homeEventPagerAdapter
TabLayoutMediator(binding.tabEvent, binding.vpEvent) { tab, position ->
tab.text = tabTitles[position]
binding.vpEvent.setCurrentItem(tab.position, true)
}.attach()
}
} | 0 | Kotlin | 2 | 3 | d8f1c95a6acac306d349d82c2d1fe91fcb739f09 | 2,434 | TakeTicket | Apache License 2.0 |
data/src/main/kotlin/ir/fallahpoor/releasetracker/data/exceptions/Exceptions.kt | MasoudFallahpour | 298,668,650 | false | {"Kotlin": 209271} | package ir.fallahpoor.releasetracker.data.exceptions
class LibraryDoesNotExistException : RuntimeException()
class InternetNotConnectedException : RuntimeException()
class UnknownException : RuntimeException() | 6 | Kotlin | 0 | 7 | 65f8c958f8bae1dee7fe96ed4113b8fd4fbfe4e4 | 210 | ReleaseTracker | Apache License 2.0 |
app/src/main/java/com/cvillaseca/spotifykt/domain/repository/AlbumRepository.kt | godiLabs | 197,490,008 | true | {"Kotlin": 124402, "Java": 1684} | package com.cvillaseca.spotifykt.domain.repository
import com.cvillaseca.spotifykt.domain.Messenger
import com.cvillaseca.spotifykt.domain.dto.AlbumDto
import io.reactivex.Observable
interface AlbumRepository : Repository {
fun getAlbumById(albumId: String, messenger: Messenger): Observable<AlbumDto>
fun getAlbumsByArtist(artistId: String, messenger: Messenger): Observable<List<AlbumDto>>
} | 0 | Kotlin | 0 | 0 | 38c8fbba666c04f28147a244f26af9f1ed2eead9 | 403 | SpotifyKt | Apache License 2.0 |
geo-starter/src/main/kotlin/com/labijie/application/geo/CoordinateSystem.kt | hongque-pro | 309,874,586 | false | {"Kotlin": 1058711, "Java": 72766} | package com.labijie.application.geo
enum class CoordinateSystem {
GCJ02,
WGS84
} | 0 | Kotlin | 0 | 8 | ce2275d9af9413affdb9c3c6a37422b084cc2abf | 89 | application-framework | Apache License 2.0 |
src/main/kotlin/me/melijn/melijnbot/commands/music/MoveCommand.kt | J3ermuda | 262,919,578 | false | {"Gradle": 2, "INI": 2, "Text": 2, "Ignore List": 1, "Markdown": 5, "Java": 2, "XML": 1, "JSON": 1, "GraphQL": 4, "Kotlin": 416} | package me.melijn.melijnbot.commands.music
import com.sedmelluq.discord.lavaplayer.track.AudioTrack
import me.melijn.melijnbot.objects.command.AbstractCommand
import me.melijn.melijnbot.objects.command.CommandCategory
import me.melijn.melijnbot.objects.command.CommandContext
import me.melijn.melijnbot.objects.command.RunCondition
import me.melijn.melijnbot.objects.utils.getIntegerFromArgNMessage
import me.melijn.melijnbot.objects.utils.sendMsg
import me.melijn.melijnbot.objects.utils.sendSyntax
import net.dv8tion.jda.api.utils.MarkdownSanitizer
class MoveCommand : AbstractCommand("command.move") {
init {
id = 155
name = "move"
runConditions = arrayOf(RunCondition.VC_BOT_ALONE_OR_USER_DJ, RunCondition.PLAYING_TRACK_NOT_NULL)
commandCategory = CommandCategory.MUSIC
}
override suspend fun execute(context: CommandContext) {
val player = context.guildMusicPlayer
val trackManager = player.guildTrackManager
if (context.args.size < 2) {
sendSyntax(context)
return
}
val index1 = (getIntegerFromArgNMessage(context, 0, 1, trackManager.trackSize()) ?: return) - 1
val index2 = (getIntegerFromArgNMessage(context, 1, 1, trackManager.trackSize()) ?: return) - 1
if (index1 == index2) {
val msg = context.getTranslation("$root.sameindex")
sendMsg(context, msg)
return
}
val trackList = trackManager.tracks.toList().toMutableList()
val track = trackList[index1]
trackList.removeAt(index1)
val lastPart = trackList.subList(index2, trackList.size)
val firstPart = mutableListOf<AudioTrack>()
firstPart.addAll(trackList.subList(0, index2))
firstPart.add(track)
firstPart.addAll(lastPart)
trackManager.tracks.clear()
firstPart.forEach { trck -> trackManager.tracks.offer(trck) }
val msg = context.getTranslation("$root.moved")
.replace("%pos1%", "${index1 + 1}")
.replace("%pos2%", "${index2 + 1}")
.replace("%track%", MarkdownSanitizer.escape(track.info.title))
sendMsg(context, msg)
}
} | 1 | null | 1 | 1 | 24834c6226d1e7f315056f224f2daaab5a66ff06 | 2,198 | Melijn | MIT License |
src/main/kotlin/de/tobiasgies/ootr/draftbot/drafts/Season7TournamentFullAutoDraft.kt | tobiasgies | 702,804,530 | false | {"Kotlin": 56359} | package de.tobiasgies.ootr.draftbot.drafts
import de.tobiasgies.ootr.draftbot.client.ConfigSource
import de.tobiasgies.ootr.draftbot.client.SeedGenerator
import de.tobiasgies.ootr.draftbot.data.DraftPool
import de.tobiasgies.ootr.draftbot.data.Preset
import io.micrometer.core.instrument.MeterRegistry
import io.micrometer.core.instrument.Metrics
import io.opentelemetry.instrumentation.annotations.WithSpan
import net.dv8tion.jda.api.events.interaction.command.GenericCommandInteractionEvent
class Season7TournamentFullAutoDraft(
draftPool: DraftPool,
settingsPreset: Preset,
seedGenerator: SeedGenerator,
meterRegistry: MeterRegistry = Metrics.globalRegistry
) : AbstractSeason7Draft(settingsPreset, seedGenerator, Season7TournamentFullAutoDraft::class, meterRegistry) {
override val draftState = Season7TournamentFullAutoDraftState.randomize(draftPool)
@WithSpan
override suspend fun start(slashCommand: GenericCommandInteractionEvent) {
displayFinalDraft(slashCommand)
}
class Factory(
private val configSource: ConfigSource,
private val seedGenerator: SeedGenerator,
private val meterRegistry: MeterRegistry = Metrics.globalRegistry
) : DraftFactory<Season7TournamentFullAutoDraft> {
override val identifier = Season7TournamentFullAutoDraft::class.simpleName!!
override val friendlyName = "Season 7 Tournament, 1v1 full-auto (bot picks all settings - 2 major, 2 minor)"
override fun createDraft(): Season7TournamentFullAutoDraft {
return Season7TournamentFullAutoDraft(
configSource.draftPool,
configSource.presets["S7 Tournament"]!!,
seedGenerator,
meterRegistry
)
}
}
} | 0 | Kotlin | 0 | 1 | 23184298d42a2d3f164727ccb6d8627e170daacb | 1,776 | ootr-draftbot | MIT License |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.