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/sxiaozhi/fragment/core/constant/Constant.kt | imifeng | 727,622,187 | false | {"Kotlin": 79884} | package com.sxiaozhi.fragment.core.constant
import com.sxiaozhi.fragment.R
object Constant {
const val DELAY_SHORT = 200L
const val DELAY_MIDDLE = 500L
const val DELAY_LONG = 1000L
const val DELAY_TOO_LONG = 2000L
const val DELAY_TO_TIMER_SECOND = 1
const val ALPHA_NUM_REGEX_PATTERN = "^[a-zA-Z0-9]+$"
const val QQ = "3627719320"
// 广告开关
const val isADAvailable = true
// 微信:
const val Weixin_AppID = "wx71f4c7f8beaad146"
val tabNavigationList: List<Int>
get() = listOf(
R.id.navigation_home,
R.id.navigation_tools,
R.id.navigation_science,
R.id.navigation_profile,
)
}
| 0 | Kotlin | 0 | 1 | 55867cbbb59da53135a1b73c4c3548e10f589a39 | 695 | MVVM-Project-Navigation | Apache License 2.0 |
src/main/kotlin/com/github/subtixx/omnicraft/menu/block/energy/EnergyStorageMenu.kt | Subtixx | 850,089,269 | false | {"Kotlin": 217619} | package com.github.subtixx.omnicraft.menu.block.energy
import com.github.subtixx.omnicraft.energy.block.entity.EnergyStorageBlockEntity
import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.entity.player.Player
import net.minecraft.world.inventory.AbstractContainerMenu
import net.minecraft.world.inventory.ContainerLevelAccess
import net.minecraft.world.inventory.MenuType
import net.minecraft.world.inventory.Slot
import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block
abstract class EnergyStorageMenu<T : EnergyStorageBlockEntity<*>>
protected constructor(
menuType: MenuType<*>,
id: Int, playerInventory: Inventory,
var blockEntity: T,
protected val blockType: Block,
playerInventoryX: Int = 8,
playerInventoryY: Int = 84
) : AbstractContainerMenu(menuType, id),
IEnergyStorageMenu {
protected val level: Level = playerInventory.player.level()
init {
addPlayerInventorySlots(playerInventory, playerInventoryX, playerInventoryY)
}
override val energy: Int
get() = blockEntity.energy
override val capacity: Int
get() = blockEntity.capacity
override fun stillValid(player: Player): Boolean {
return stillValid(
ContainerLevelAccess.create(level, blockEntity.blockPos), player,
blockType
)
}
private fun addPlayerInventorySlots(playerInventory: Inventory, x: Int, y: Int) {
//Player Inventory
for (i in 0..2) for (j in 0..8) addSlot(Slot(playerInventory, j + i * 9 + 9, x + j * 18, y + i * 18))
//Player Hotbar
for (i in 0..8) addSlot(Slot(playerInventory, i, x + i * 18, y + 58))
}
} | 33 | Kotlin | 0 | 0 | 5a9602bc59afe1a2bf9e3f09c8418f99e5693316 | 1,706 | OmniCraft | MIT License |
telegram-bot/src/commonMain/kotlin/eu/vendeli/tgbot/types/media/PaidMediaPurchased.kt | vendelieu | 496,567,172 | false | {"Kotlin": 1040778, "Python": 12809, "Shell": 1249, "CSS": 356} | package eu.vendeli.tgbot.types.media
import eu.vendeli.tgbot.types.User
import kotlinx.serialization.Serializable
/**
* This object contains information about a paid media purchase.
*
* [Api reference](https://core.telegram.org/bots/api#paidmediapurchased)
* @property from User who purchased the media
* @property paidMediaPayload Bot-specified paid media payload
*/
@Serializable
data class PaidMediaPurchased(
val from: User,
val paidMediaPayload: String,
)
| 2 | Kotlin | 14 | 176 | 41d50ea8fd014cb31b61eb5c2f4a4bebf4736b45 | 477 | telegram-bot | Apache License 2.0 |
omni-mvi-queue/src/main/java/net/asere/omni/mvi/QueueContainer.kt | martppa | 561,509,000 | false | null | package net.asere.omni.mvi
import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.Job
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.consumeEach
open class QueueContainer<State, Effect> internal constructor(
override val container: Container<State, Effect>,
) : ContainerDecorator<State, Effect>(
container
), Container<State, Effect>,
QueueContainerHost<State, Effect> {
private lateinit var intentQueue: Channel<Job>
private lateinit var consumeJob: Job
init {
startIntentQueue()
}
private fun startIntentQueue() {
intentQueue = Channel(capacity = Channel.UNLIMITED)
consumeJob = intent {
intentQueue.consumeEach { consumeIntent(it).join() }
}
}
private fun consumeIntent(job: Job) = intent { job.join() }
internal fun clearQueue() = intent {
consumeJob.cancel()
consumeJob.join()
intentQueue.cancel()
}
internal fun enqueue(
block: suspend IntentScope<State, Effect>.() -> Unit
) = intent {
if (intentQueue.isClosed()) startIntentQueue()
intentQueue.send(
intent(start = CoroutineStart.LAZY) { block() }
)
}
}
fun <State, Effect> queueContainer(
container: Container<State, Effect>
) = QueueContainer(container)
fun <State, Effect> Container<State, Effect>
.buildQueueContainer() = queueContainer(this)
internal fun <State, Effect>
Container<State, Effect>.asQueueContainer() =
seek<QueueContainer<State, Effect>> { it is QueueContainer<*, *> } | 0 | Kotlin | 0 | 2 | 172e165c7ee9887b10fcd4cb4a2ed61f9230479b | 1,597 | omni-mvi | MIT License |
bloom-tool/src/main/kotlin/io/nixer/bloom/cli/FilterOperations.kt | smifun | 221,179,973 | true | {"Gradle Kotlin DSL": 9, "INI": 2, "Shell": 1, "Text": 2, "Ignore List": 1, "Batchfile": 1, "Markdown": 7, "JSON": 8, "Java": 218, "PLSQL": 1, "Java Properties": 2, "YAML": 1, "Kotlin": 9, "HTML": 4, "TOML": 1, "Python": 1} | package io.nixer.bloom.cli
import com.google.common.base.Charsets
import com.google.common.hash.Hashing
import io.nixer.bloom.BloomFilter
import io.nixer.bloom.check.BloomFilterCheck
import io.nixer.bloom.FileBasedBloomFilter
import io.nixer.bloom.HexFunnel
import java.io.InputStream
import java.io.InputStreamReader
import java.nio.file.Files
import java.nio.file.Paths
import java.util.function.Predicate
/**
* Created on 26/09/2019.
*
* @author gcwiak
*/
fun createFilter(name: String, size: Long, fpp: Double): BloomFilter<CharSequence> = FileBasedBloomFilter.create(
Paths.get(name).also { require(Files.notExists(it)) { "Bloom filter metadata file '$it' already exist" } },
HexFunnel(),
size,
fpp
)
fun openFilter(name: String): BloomFilter<CharSequence> = FileBasedBloomFilter.open(
Paths.get(name).also { require(Files.exists(it)) { "Bloom filter metadata file '$it' does not exist" } },
HexFunnel()
)
fun openFilterForCheck(name: String, hashInputBeforeCheck: Boolean): Predicate<String> {
val filterFilePath = Paths.get(name).also { require(Files.exists(it)) { "Bloom filter metadata file '$it' does not exist" } }
return when {
hashInputBeforeCheck -> BloomFilterCheck.hashingBeforeCheck(filterFilePath)
else -> BloomFilterCheck.notHashingBeforeCheck(filterFilePath)
}
}
fun insertIntoFilter(targetFilter: BloomFilter<CharSequence>,
entryTransformer: (String) -> String,
entriesStream: InputStream) {
InputStreamReader(entriesStream, Charsets.UTF_8.newDecoder()).buffered().use { reader ->
reader.lines().forEach {
targetFilter.put(entryTransformer(it))
}
}
}
fun checkAgainstFilter(bloomFilter: Predicate<String>,
entryTransformer: (String) -> String,
entriesStream: InputStream) {
InputStreamReader(entriesStream, Charsets.UTF_8.newDecoder()).buffered().use { reader ->
reader.lines()
.filter { bloomFilter.test(entryTransformer(it)) }
.forEach { println(it) }
}
}
fun fieldExtractor(separator: String, fieldNumber: Int): (String) -> String = { line: String -> line.split(separator)[fieldNumber] }
private val sha1HashFunction = Hashing.sha1()
fun sha1(entry: String): String {
return sha1HashFunction.hashString(entry, kotlin.text.Charsets.UTF_8).toString().toUpperCase()
}
| 0 | Java | 0 | 0 | b323866583bc40f1f75829186df30d24c34d1582 | 2,456 | nixer-spring-plugin | Apache License 2.0 |
sdk/src/main/java/com/exponea/sdk/telemetry/storage/TelemetryStorage.kt | exponea | 134,699,893 | false | {"Kotlin": 1773395, "Java": 206} | package com.exponea.sdk.telemetry.storage
import com.exponea.sdk.telemetry.model.CrashLog
internal interface TelemetryStorage {
fun saveCrashLog(log: CrashLog)
fun deleteCrashLog(log: CrashLog)
fun getAllCrashLogs(): List<CrashLog>
}
| 0 | Kotlin | 16 | 17 | 150999cffec54fa2266e0d9db07c16143dc17a26 | 248 | exponea-android-sdk | MIT License |
app/src/main/java/com/motiapps/melodify/domain/usecases/GetUserUseCase.kt | MotiElitzur | 661,282,488 | false | null | package com.motiapps.melodify.domain.usecases
import com.motiapps.melodify.domain.model.User
import com.motiapps.melodify.domain.repository.UserRepository
class GetUserUseCase(
private val repository: UserRepository
) {
suspend operator fun invoke(
userId: String,
): User? {
return repository.getUserById(userId)
}
} | 0 | Kotlin | 0 | 0 | 699fb026af3b2ee5130916a2662fb399dadfabae | 351 | Melodify | Apache License 2.0 |
client_taxi_driver/shared/src/commonMain/kotlin/util/PlatformUtil.kt | TheChance101 | 671,967,732 | false | {"Kotlin": 2473455, "Ruby": 8872, "HTML": 6083, "Swift": 4726, "JavaScript": 3082, "CSS": 1436, "Dockerfile": 1407, "Shell": 1140} | package util
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.runtime.Composable
import io.ktor.client.engine.HttpClientEngine
expect class PlatformContext
@Composable
expect fun getPlatformContext(): PlatformContext
@Composable
expect fun SetInsetsController(isDark: Boolean)
@Composable
expect fun getNavigationBarPadding(): PaddingValues
expect fun getEngine(): HttpClientEngine | 4 | Kotlin | 55 | 572 | 1d2e72ba7def605529213ac771cd85cbab832241 | 419 | beep-beep | Apache License 2.0 |
app/src/main/java/com/example/wanAndroid/ui/adapter/SearchHistoryAdapter.kt | SaltedFish-Extreme | 458,692,555 | false | {"Kotlin": 476520, "Java": 9830} | package com.example.wanAndroid.ui.adapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.wanAndroid.R
import com.example.wanAndroid.ui.base.BaseAdapter
/**
* Created by 咸鱼至尊 on 2022/2/17
*
* desc: 搜索历史适配器
*/
class SearchHistoryAdapter(dataList: MutableList<String>) : BaseAdapter<String>(R.layout.item_search_history_list, dataList) {
init {
setAnimationWithDefault(AnimationType.ScaleIn)
}
override fun convert(holder: BaseViewHolder, item: String) {
holder.setText(R.id.item_history_text, item)
}
} | 0 | Kotlin | 6 | 36 | 2ce81daeedee3f0df94dfc6b474f65356d6fd64a | 575 | WanAndroid | Apache License 2.0 |
src/main/kotlin/com/example/recorder/domain/impl/RecorderUseCaseImpl.kt | grigory9 | 328,468,644 | false | null | package com.example.recorder.domain.impl
import com.example.recorder.domain.RecorderUseCase
import com.example.recorder.model.RecordDevice
import com.example.recorder.repository.RecordDeviceRepository
import com.example.recorder.repository.UdpRecordAddressRepository
import com.example.recorder.model.UdpPacket
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.newSingleThreadContext
import org.pcap4j.core.*
import org.pcap4j.packet.Packet
import org.springframework.stereotype.Component
import java.io.IOException
import java.util.*
@Component
class RecorderUseCaseImpl(
val udpRecordAddressRepository: UdpRecordAddressRepository,
val udpRecordDeviceRepository: RecordDeviceRepository
): RecorderUseCase {
override var packetCatchHandler: ((UdpPacket) -> Unit)? = null
private var handler: PcapHandle? = null
private var dispatcher = newSingleThreadContext("Recorder thread")
override suspend fun start() {
var currentDeviceName = udpRecordDeviceRepository.findAll().findLast { it.isPrimary == true }
var selectedDevice: PcapNetworkInterface? = try {
Pcaps
.findAllDevs()
.find { (it.name == currentDeviceName?.deviceName) }
} catch (e: PcapNativeException) {
throw IOException(e.message)
}
if (handler == null ) {
handler = selectedDevice?.openLive(65536,
PcapNetworkInterface.PromiscuousMode.PROMISCUOUS,
10)
}
setFilters()
launchHandler()
}
override suspend fun stop(): Unit = coroutineScope {
handler?.breakLoop()
handler = null
}
override suspend fun configurationDidChange() = coroutineScope {
if (handler != null) {
stop()
start()
}
}
override fun findHardwareDevices(): List<RecordDevice> =
Pcaps
.findAllDevs()
.filterNotNull()
.map { RecordDevice(null, it.name) }
fun setFilters() {
val udpAddresses = udpRecordAddressRepository.findAll()
val filter = udpAddresses.joinToString(separator = " or ") { "(dst ${it.listeningIp} and port ${it.listeningPort})" }
try {
handler?.setFilter(filter, BpfProgram.BpfCompileMode.OPTIMIZE)
} catch (e: PcapNativeException) {
throw IOException(e.message)
}
}
suspend fun launchHandler() = coroutineScope {
launch(dispatcher) {
handler?.loop(
-1,
) { packet: Packet ->
val udpPacket = UdpPacket.create(packet, Date())
packetCatchHandler?.let { it(udpPacket) }
}
}
}
} | 0 | Kotlin | 0 | 0 | edd426910eb2d1f2a4e553403554f83a27c2c3a3 | 2,768 | atc-recorder | The Unlicense |
core/src/commonMain/kotlin/com.chrynan.graphkl/language/parser/usecase/ParseUnionMemberTypesUseCase.kt | chRyNaN | 230,310,677 | false | null | package com.chrynan.graphkl.language.parser.usecase
import com.chrynan.graphkl.language.node.NamedTypeNode
class ParseUnionMemberTypesUseCase {
operator fun invoke(): List<NamedTypeNode> = TODO()
} | 0 | Kotlin | 0 | 2 | 2526cedddc0a5b5777dea0ec7fc67bc2cd16fe05 | 204 | graphkl | Apache License 2.0 |
app/src/main/kotlin/com/zj/weather/widget/utils/ConfigureWidget.kt | zhujiang521 | 422,904,634 | false | {"Kotlin": 288676} | @file:OptIn(ExperimentalFoundationApi::class)
package com.zj.weather.widget.utils
import android.content.Context
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Card
import androidx.compose.material.Divider
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.core.content.edit
import com.google.gson.Gson
import com.zj.utils.view.HorizontalPagerIndicator
import com.zj.model.room.PlayWeatherDatabase
import com.zj.model.room.entity.CityInfo
import com.zj.utils.lce.NoContent
import com.zj.weather.R
import com.zj.weather.view.city.viewmodel.CityListViewModel
import com.zj.weather.widget.week.PREF_PREFIX_KEY
import kotlinx.coroutines.runBlocking
@Composable
fun ConfigureWidget(
viewModel: CityListViewModel,
onCancelListener: () -> Unit,
onConfirmListener: (CityInfo) -> Unit
) {
val cityList by viewModel.cityInfoList.collectAsState(initial = arrayListOf())
val buttonHeight = 45.dp
val pagerState = rememberPagerState(
initialPage = 0,
initialPageOffsetFraction = 0f
) {
cityList.size
}
Column(
modifier = Modifier
.fillMaxSize()
.statusBarsPadding()
.navigationBarsPadding()
) {
Spacer(modifier = Modifier.height(80.dp))
Text(
text = stringResource(id = R.string.widget_city_choose),
modifier = Modifier.fillMaxWidth(),
textAlign = TextAlign.Center,
fontSize = 26.sp,
color = Color(red = 53, green = 128, blue = 186)
)
if (cityList.isEmpty()) {
NoContent("请进入应用添加城市")
} else {
Box(modifier = Modifier.weight(1f)) {
HorizontalPager(
modifier = Modifier.fillMaxSize(),
state = pagerState,
key = { cityList[it].locationId },
pageContent = { page ->
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
Card(
shape = RoundedCornerShape(10.dp),
backgroundColor = MaterialTheme.colors.onSecondary,
modifier = Modifier.size(300.dp)
) {
val cityInfo = cityList[page]
Column(
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
) {
Text(text = cityInfo.name, fontSize = 30.sp)
}
}
}
}
)
HorizontalPagerIndicator(
pagerState = pagerState,
pageCount = cityList.size,
modifier = Modifier
.align(Alignment.BottomCenter)
.padding(16.dp),
)
}
Spacer(modifier = Modifier.height(50.dp))
Divider(
modifier = Modifier
.fillMaxWidth()
.height(1.dp)
)
Row {
TextButton(
modifier = Modifier
.weight(1f)
.height(buttonHeight),
onClick = {
onCancelListener()
}
) {
Text(
text = stringResource(id = R.string.city_dialog_cancel),
fontSize = 16.sp,
color = Color(red = 53, green = 128, blue = 186)
)
}
Divider(
modifier = Modifier
.width(1.dp)
.height(buttonHeight)
)
TextButton(
modifier = Modifier
.weight(1f)
.height(buttonHeight),
onClick = {
onConfirmListener(cityList[pagerState.currentPage])
}
) {
Text(
text = stringResource(id = R.string.city_dialog_confirm),
fontSize = 16.sp,
color = Color(red = 53, green = 128, blue = 186)
)
}
}
}
}
}
// Write the prefix to the SharedPreferences object for this widget
internal fun saveCityInfoPref(
context: Context,
appWidgetId: Int,
cityInfo: CityInfo,
prefsName: String
) {
context.getSharedPreferences(prefsName, 0).edit {
putString(PREF_PREFIX_KEY + appWidgetId, Gson().toJson(cityInfo))
}
}
// Read the prefix from the SharedPreferences object for this widget.
// If there is no preference saved, get the default from a resource
internal fun loadCityInfoPref(context: Context, appWidgetId: Int, prefsName: String): CityInfo? {
val prefs = context.getSharedPreferences(prefsName, 0)
val cityString = prefs.getString(PREF_PREFIX_KEY + appWidgetId, null) ?: ""
if (cityString.isEmpty()) {
val cityInfoDao = PlayWeatherDatabase.getDatabase(context = context).cityInfoDao()
val cityInfo = runBlocking { cityInfoDao.getIsLocationList() }
return cityInfo.getOrNull(0)
}
return Gson().fromJson(cityString, CityInfo::class.java)
}
internal fun deleteCityInfoPref(context: Context, appWidgetId: Int, prefsName: String) {
context.getSharedPreferences(prefsName, 0).edit {
remove(PREF_PREFIX_KEY + appWidgetId)
}
} | 5 | Kotlin | 78 | 479 | a731e0b502fc22baf832307bb60b263c16376dab | 7,270 | PlayWeather | MIT License |
src/main/kotlin/dev/monosoul/jooq/codegen/ConfigurationProvider.kt | monosoul | 497,003,599 | false | null | package dev.monosoul.jooq.codegen
import dev.monosoul.jooq.migration.SchemaVersion
import dev.monosoul.jooq.settings.DatabaseCredentials
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.FileContents
import org.gradle.api.provider.ListProperty
import org.gradle.api.provider.MapProperty
import org.gradle.api.provider.Property
import org.gradle.api.provider.SetProperty
import org.jooq.codegen.GenerationTool
import org.jooq.codegen.JavaGenerator
import org.jooq.meta.jaxb.Configuration
import org.jooq.meta.jaxb.Database
import org.jooq.meta.jaxb.Generate
import org.jooq.meta.jaxb.Generator
import org.jooq.meta.jaxb.Jdbc
import org.jooq.meta.jaxb.Logging
import org.jooq.meta.jaxb.MatcherRule
import org.jooq.meta.jaxb.MatcherTransformType.AS_IS
import org.jooq.meta.jaxb.Matchers
import org.jooq.meta.jaxb.MatchersCatalogType
import org.jooq.meta.jaxb.MatchersSchemaType
import org.jooq.meta.jaxb.SchemaMappingType
import org.jooq.meta.jaxb.Strategy
import org.jooq.meta.jaxb.Target
import java.io.InputStream
internal class ConfigurationProvider(
private val basePackageName: Property<String>,
private val outputDirectory: DirectoryProperty,
private val outputSchemaToDefault: SetProperty<String>,
private val schemaToPackageMapping: MapProperty<String, String>,
private val schemas: ListProperty<String>,
private val logLevel: Logging,
) {
fun fromXml(file: FileContents) = file.asBytes.map { it.inputStream().use(::load).applyCommonConfiguration() }
fun defaultConfiguration() = Generator()
.withName(JavaGenerator::class.qualifiedName)
.withDatabase(
Database()
.withSchemata(schemas.get().map(this::toSchemaMappingType))
.withIncludes(".*")
.withExcludes("")
)
.withGenerate(Generate())
.let {
Configuration().withGenerator(it)
}
.applyCommonConfiguration()
private fun Configuration.applyCommonConfiguration() = also { config ->
config.withLogging(logLevel)
config.generator.apply {
withTarget(codeGenTarget())
nonNullStrategy.apply(schemaToPackageMapping.get().toMappingApplier())
}
}
private val Generator.nonNullStrategy get() = strategy ?: Strategy().also(::withStrategy)
private val Strategy.nonNullMatchers get() = matchers ?: Matchers().also(::withMatchers)
private fun codeGenTarget() = Target()
.withPackageName(basePackageName.get())
.withDirectory(outputDirectory.asFile.get().toString())
.withEncoding("UTF-8")
.withClean(true)
private fun toSchemaMappingType(schemaName: String): SchemaMappingType {
return SchemaMappingType()
.withInputSchema(schemaName)
.withOutputSchemaToDefault(outputSchemaToDefault.get().contains(schemaName))
}
private fun Map<String, String>.toMappingApplier(): (Strategy) -> Unit = { strategy ->
if (isNotEmpty()) {
strategy
.nonNullMatchers
.withSchemas(*toSchemasMatchers())
.withCatalogs(*toCatalogMatchers())
}
}
private fun Map<String, String>.toSchemasMatchers() = map { (schema, pkg) ->
MatchersSchemaType()
.withExpression(schema)
.withSchemaIdentifier(
MatcherRule()
.withTransform(AS_IS)
.withExpression(pkg)
)
}.toTypedArray()
private fun Map<String, String>.toCatalogMatchers() = map { (schema, pkg) ->
MatchersCatalogType()
.withExpression(schema)
.withCatalogIdentifier(
MatcherRule()
.withTransform(AS_IS)
.withExpression(pkg)
)
}.toTypedArray()
internal companion object {
private fun load(inputStream: InputStream): Configuration = GenerationTool.load(inputStream)
private fun Generator.addExcludes(excludes: List<String>) {
database.withExcludes(
listOfNotNull(database.excludes, *excludes.toTypedArray())
.filterNot(String::isBlank)
.joinToString("|")
)
}
fun Configuration.postProcess(
schemaVersion: SchemaVersion,
credentials: DatabaseCredentials,
extraTableExclusions: List<String> = emptyList(),
) = apply {
generator.also {
it.addExcludes(extraTableExclusions)
it.database.schemaVersionProvider = schemaVersion.value
}
withJdbc(
Jdbc()
.withDriver(credentials.jdbcDriverClassName)
.withUrl(credentials.jdbcUrl)
.withUser(credentials.username)
.withPassword(<PASSWORD>)
)
}
}
}
| 4 | Kotlin | 5 | 9 | f3cc5cbaf77e3a2a22c767fee75de4f809cea477 | 4,935 | jooq-gradle-plugin | Apache License 2.0 |
web-ui/src/main/java/com/radiuswallet/uniweb/interceptor/UrlInterceptor.kt | z-chu | 507,885,693 | false | {"Kotlin": 235647, "HTML": 35730, "Java": 2730} | package com.radiuswallet.uniweb.interceptor
import com.tencent.smtt.sdk.WebView
interface UrlInterceptor {
fun intercept(
view: WebView,
requestCompat: WebResourceRequestCompat,
): Boolean
} | 0 | Kotlin | 0 | 0 | ff68a80e02e19cecb8bf76243932639635df9fb5 | 218 | UniWeb | Apache License 2.0 |
app/src/main/java/ru/trushkina/kinopoiskbase/presentation/more/MoreFragment.kt | AgnaWiese | 590,180,596 | false | null | package ru.trushkina.kinopoiskbase.presentation.more
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import ru.trushkina.kinopoiskbase.R
import ru.trushkina.kinopoiskbase.databinding.FragmentMoreBinding
import ru.trushkina.kinopoiskbase.presentation.utils.showBottomNav
class MoreFragment : Fragment() {
private var _binding: FragmentMoreBinding? = null
private val binding get() = _binding!!
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = FragmentMoreBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
showBottomNav()
with(binding) {
toolbar.title = getString(R.string.title_more)
itemViewCode.setOnClickListener { showSourceCode() }
itemAbout.setOnClickListener { showAboutDialog() }
}
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
private fun showSourceCode() =
startActivity(Intent(Intent.ACTION_VIEW).apply {
data = Uri.parse(getString(R.string.url_project_github))
})
private fun showAboutDialog() {
MaterialAlertDialogBuilder(requireContext())
.setTitle(resources.getString(R.string.about_kinopoisk))
.setMessage(resources.getString(R.string.about_kinopoisk_message))
.setPositiveButton(resources.getString(android.R.string.ok)) { dialog, _ ->
dialog.dismiss()
}
.show()
}
} | 0 | Kotlin | 0 | 0 | 2a301a882f9c7009e1bf5d8723fa77e43bd9cce2 | 1,938 | KinopoiskBase | Apache License 2.0 |
src/main/kotlin/me/ckho/scriptscompose/service/impl/DataCache.kt | Hochikong | 427,597,241 | false | {"HTML": 58536, "Kotlin": 57524, "JavaScript": 10189, "CSS": 2171, "Python": 272} | package me.ckho.scriptscompose.service.impl
import org.springframework.stereotype.Service
/**
* Share data between spring components
* */
@Service
class DataCache {
// interrupt only cancel tasks has same TaskHash
val needToInterruptTasks = mutableListOf<String>()
// halt will cancel all groups which contain running task with the same TaskHash
val needToHaltTasks = mutableListOf<String>()
} | 0 | HTML | 0 | 0 | b51fe890d6c742562bac0a9129ac1b71c13e599d | 413 | ScriptsCompose | Apache License 2.0 |
src/main/kotlin/one/krake/flashtime/SettpsCommand.kt | jD91mZM2 | 230,939,784 | false | {"Java": 16217, "Kotlin": 4121} | package one.krake.flashtime
import com.mojang.brigadier.Command
import com.mojang.brigadier.CommandDispatcher
import com.mojang.brigadier.arguments.FloatArgumentType
import com.mojang.brigadier.arguments.FloatArgumentType.floatArg
import com.mojang.brigadier.exceptions.CommandSyntaxException
import net.minecraft.network.packet.s2c.play.TitleS2CPacket
import net.minecraft.server.command.CommandManager
import net.minecraft.server.command.ServerCommandSource
import net.minecraft.text.TranslatableText
enum class Target {
Player,
World,
}
object SettpsCommand {
private val TICKSPEED = CommandManager.argument("ticks per second", floatArg(0.1f, 100.0f));
/**
* Registers the SettpsCommmand to the specified dispatcher.
* @param dispatcher The dispatcher gotten from CommandRegistry.INSTANCE.register
*/
fun register(dispatcher: CommandDispatcher<ServerCommandSource>) {
dispatcher.register(
CommandManager.literal("settickspeed")
.then(
CommandManager.literal("player")
.then(TICKSPEED.executes() { ctx ->
executeSet(ctx.source, Target.Player, FloatArgumentType.getFloat(ctx, "ticks per second"))
})
)
.then(
CommandManager.literal("world")
.then(TICKSPEED.executes() { ctx ->
executeSet(ctx.source, Target.World, FloatArgumentType.getFloat(ctx, "ticks per second"))
})
)
.then(
CommandManager.literal("superhot")
.executes() { ctx ->
executeHot(ctx.source)
}
)
);
}
private fun executeSet(source: ServerCommandSource, target: Target, tps: Float): Int {
FlashTimeState.superHot = false
try {
when (target) {
Target.Player -> FlashTimeState.playerTimer.tps = tps
Target.World -> FlashTimeState.worldTimer.tps = tps
}
} catch (err: Exception) {
err.printStackTrace();
throw err;
}
source.sendFeedback(TranslatableText("command.settickspeed.feedback"), true);
return Command.SINGLE_SUCCESS;
}
private fun executeHot(source: ServerCommandSource): Int {
FlashTimeState.superHot = true
try {
source.player.networkHandler.sendPacket(
TitleS2CPacket(
TitleS2CPacket.Action.TITLE,
TranslatableText("command.settickspeed.superhot.title")
)
)
} catch (_err: CommandSyntaxException) {
// This is just for effect, I don't want the command to fail if source isn't a player
source.sendFeedback(TranslatableText("command.settickspeed.superhot.feedback"), false)
}
return Command.SINGLE_SUCCESS;
}
} | 1 | null | 1 | 1 | e2804e75f81799fd58c63174f1af0a4422510ebe | 3,044 | FlashTime-Fabric | MIT License |
app/src/main/java/com/sakethh/linkora/customComposables/AddANewShelfDialogBox.kt | sakethpathike | 648,784,316 | false | null | package com.sakethh.linkora.ui.commonComposables
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.sp
data class AddANewShelfDTO(
val isDialogBoxVisible: MutableState<Boolean>,
val onCreateClick: (shelfName: String, shelfIconName: String) -> Unit
)
@Composable
fun AddANewShelfDialogBox(addANewShelfDTO: AddANewShelfDTO) {
if (addANewShelfDTO.isDialogBoxVisible.value) {
val customShelfName = rememberSaveable {
mutableStateOf("")
}
val customShelfIconName = rememberSaveable {
mutableStateOf("")
}
AlertDialog(title = {
Text(
text = "Create a new Shelf row", style = MaterialTheme.typography.titleMedium,
fontSize = 22.sp,
lineHeight = 28.sp
)
}, onDismissRequest = {
addANewShelfDTO.isDialogBoxVisible.value = false
}, text = {
Column {
OutlinedTextField(
modifier = Modifier.fillMaxWidth(),
maxLines = 1,
label = {
Text(
text = "Shelf name",
style = MaterialTheme.typography.titleSmall,
fontSize = 12.sp
)
},
textStyle = MaterialTheme.typography.titleSmall,
singleLine = true,
value = customShelfName.value,
onValueChange = {
customShelfName.value = it
})
}
}, confirmButton = {
Button(modifier = Modifier
.fillMaxWidth()
.pulsateEffect(), onClick = {
addANewShelfDTO.onCreateClick(customShelfName.value, customShelfIconName.value)
addANewShelfDTO.isDialogBoxVisible.value = false
}) {
Text(
text = "Create",
style = MaterialTheme.typography.titleSmall,
fontSize = 16.sp
)
}
}, dismissButton = {
androidx.compose.material3.OutlinedButton(modifier = Modifier
.fillMaxWidth()
.pulsateEffect(),
onClick = {
addANewShelfDTO.isDialogBoxVisible.value = false
}) {
Text(
text = "Cancel",
style = MaterialTheme.typography.titleSmall,
fontSize = 16.sp
)
}
})
}
} | 1 | null | 1 | 7 | 16c71c4eac2b9b028029b25b6ed64fdc49da4018 | 3,174 | Linkora | MIT License |
benchmark/src/androidTest/java/io/realm/benchmark/Benchmarks.kt | realm | 58,049,078 | false | null | /*
* Copyright 2019 Realm 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 io.realm.benchmark
import androidx.benchmark.BenchmarkRule
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
/**
* Base class for all benchmarks to ensure that we are running all tests for all libraries
* being benchmarked.
*
* It is still up to each implementation to use `size` correctly.
*/
@RunWith(Parameterized::class)
abstract class Benchmarks(val size: Long) {
companion object {
@JvmStatic
@Parameterized.Parameters(name = "size={0}")
fun data(): Array<Long> {
return arrayOf(10, 100, 1000);
}
}
@get:Rule
val benchmarkRule = BenchmarkRule()
val dataGenerator = DataGenerator()
@Before abstract fun before()
@After abstract fun after()
@Test abstract fun simpleQuery()
@Test abstract fun simpleWrite()
@Test abstract fun batchWrite()
@Test abstract fun fullScan()
@Test abstract fun delete()
@Test abstract fun sum()
@Test abstract fun count()
} | 0 | Kotlin | 5 | 17 | 8c7eceaa5aaf5a5d885221e8eb15233b324ed053 | 1,675 | realm-java-benchmarks | Apache License 2.0 |
preferences-annotation/src/main/java/io/androidalatan/datastore/preference/annotations/getter/GetLong.kt | android-alatan | 462,405,374 | false | null | package io.androidalatan.datastore.preference.annotations.getter
@Retention(AnnotationRetention.RUNTIME)
@Target(AnnotationTarget.FUNCTION)
annotation class GetLong(
val name: String,
val defaultValue: Long = 0L,
val disable: Boolean = false,
val disableValue: Long = 0L
) | 0 | Kotlin | 1 | 2 | 20dc6bc2d685d71dbab8d89eaec22ba810fc82b9 | 289 | Preferences | MIT License |
data/src/main/java/eu/benayoun/androidmoviedatabase/data/repository/DefaultTmdbRepository.kt | BenayounP | 525,430,424 | false | null | package eu.benayoun.androidmoviedatabase.data.repository
import eu.benayoun.androidmoviedatabase.data.model.TmdbMovie
import eu.benayoun.androidmoviedatabase.data.model.api.TmdbAPIResponse
import eu.benayoun.androidmoviedatabase.data.model.meta.TmdbMetadata
import eu.benayoun.androidmoviedatabase.data.model.meta.TmdbSourceStatus
import eu.benayoun.androidmoviedatabase.data.model.meta.TmdbUpdateStatus
import eu.benayoun.androidmoviedatabase.data.source.local.TmdbCache
import eu.benayoun.androidmoviedatabase.data.source.network.TmdbDataSource
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
internal class DefaultTmdbRepository(private val tmdbDataSource: TmdbDataSource,
private val tmdbCache: TmdbCache,
private val externalScope: CoroutineScope,
private val dispatcher: CoroutineDispatcher
) : TmdbRepository {
private val popularMoviesMutex = Mutex()
private val _updateFlow = MutableStateFlow<TmdbUpdateStatus>(TmdbUpdateStatus.Off)
override suspend fun getTmdbMetaDataFlow(): Flow<TmdbMetadata> = tmdbCache.getTmdbMetaDataFlow()
override suspend fun getPopularMovieListFlow(): Flow<List<TmdbMovie>> {
return tmdbCache.getTmdbMovieListFlow()
}
override suspend fun getTmdbUpdateStatusFlow(): Flow<TmdbUpdateStatus> = _updateFlow
override fun updateTmdbMovies() {
externalScope.launch(dispatcher) {
popularMoviesMutex.withLock() {
// we are updating and we say it!
_updateFlow.value=TmdbUpdateStatus.Updating
var lastInternetSuccessTimeStamp: Long = TmdbMetadata.INVALID_TIMESTAMP
var tmdbSourceStatus: TmdbSourceStatus
var tmdbPopularMovieList: List<TmdbMovie>
// Step 1: try to get data on TMDB Server
var tmdbAPIResponse = tmdbDataSource.getPopularMovies()
// Step 2 Success : save films in db and update metadata
if (tmdbAPIResponse is TmdbAPIResponse.Success) {
tmdbSourceStatus = TmdbSourceStatus.Internet
lastInternetSuccessTimeStamp = System.currentTimeMillis()
tmdbPopularMovieList = tmdbAPIResponse.tmdbMovieList
tmdbCache.saveTmdbMovieList(tmdbPopularMovieList)
saveMetaData(tmdbSourceStatus, lastInternetSuccessTimeStamp)
}
//Step 2 failure : No data from Internet, just update metadate
else {
val tmdbAPIError = (tmdbAPIResponse as TmdbAPIResponse.Error).tmdbAPIError
tmdbSourceStatus = TmdbSourceStatus.Cache(tmdbAPIError)
saveMetaData(tmdbSourceStatus, lastInternetSuccessTimeStamp)
}
// we stop updating and we say it!
_updateFlow.value=TmdbUpdateStatus.Off
}
}
}
private suspend fun saveMetaData(tmdbSourceStatus: TmdbSourceStatus,lastInternetSuccessTimeStamp: Long){
tmdbCache.saveTmdbMetaData(
TmdbMetadata(
tmdbSourceStatus,
lastInternetSuccessTimeStamp
)
)
}
} | 0 | Kotlin | 0 | 21 | d45a7c7bec90f75075fa6c90b4a71e981a2caf8b | 3,506 | AndroidMovieDataBase | Apache License 2.0 |
buildSrc/src/main/java/Versions.kt | ytam | 428,447,176 | false | {"Kotlin": 50179} | object Versions {
object Gradle {
const val GRADLE_VERSION = "8.1.1"
const val KOTLIN = "1.8.10"
const val DAGGER_HILT = "2.48"
const val DETEKT = "1.23.1"
const val KTLINT = "11.0.0"
const val GRADLE_VERSIONS_PLUGIN = "0.38.0"
}
object Kotlin {
const val JDK = Gradle.KOTLIN
}
object Google {
object Androidx {
const val APP_COMPAT = "1.6.1"
const val CORE_KTX = "1.12.0"
const val LIFECYCLE = "2.4.0"
const val NAVIGATION_COMPOSE = "2.7.3"
const val CONSTRAINT_LAYOUT_COMPOSE = "1.0.0-rc01"
}
object Material {
const val DESIGN = "1.4.0"
}
object Accompanist {
const val FLOW_LAYOUT = "0.20.0"
}
object Compose {
const val COMPOSE = "1.5.2"
}
object Activity {
const val ACTIVITY_COMPOSE = "1.7.2"
}
}
object Square {
const val OK_HTTP = "5.0.0-alpha.2"
const val RETROFIT = "2.9.0"
const val RETROFIT_CONVERTER_GSON = "2.8.7"
const val GSON = "2.10.1"
}
object Coroutines {
const val CORE = "1.7.3"
const val ANDROID = "1.7.3"
}
object Hilt {
const val HILT_ANDROID = "2.48"
const val HILT_ANDROID_COMPILER = "2.48"
const val HILT_NAVIGATION_COMPOSE = "1.0.0-alpha03"
const val HILT_COMPILER = "1.0.0"
}
object Lottie {
const val COMPOSE = "6.1.0"
}
object Coil {
const val COIL = "2.4.0"
}
object SplashScreen {
const val SPLASH_API = "1.0.1"
}
} | 0 | Kotlin | 5 | 20 | a9c0b2994018005dc230c359b4933d5d54c50ee7 | 1,684 | Jet-CoinList | Apache License 2.0 |
ecosedkit/src/main/kotlin/io/ecosed/engine/EcosedEngine.kt | ecosed | 691,936,131 | false | {"Kotlin": 71136, "AIDL": 641, "C++": 311, "CMake": 225, "Batchfile": 34} | /**
* Copyright EcosedDroid
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.ecosed.droid.engine
import android.app.Application
import android.content.Context
import android.content.ContextWrapper
import android.os.Bundle
import android.util.Log
import io.ecosed.droid.app.EcosedHost
import io.ecosed.droid.app.IEcosedApplication
import io.ecosed.droid.client.EcosedClient
import io.ecosed.droid.plugin.BasePlugin
import io.ecosed.droid.plugin.PluginBinding
import io.flutter.embedding.engine.plugins.FlutterPlugin
/**
* 作者: wyq0918dev
* 仓库: https://github.com/ecosed/plugin
* 时间: 2023/09/02
* 描述: 插件引擎
* 文档: https://github.com/ecosed/plugin/blob/master/README.md
*/
internal class EcosedEngine private constructor() : ContextWrapper(null), FlutterPlugin {
/** 应用程序全局类. */
private lateinit var mApp: Application
/** 基础上下文. */
private lateinit var mBase: Context
/** 客户端组件. */
private lateinit var mHost: EcosedHost
/** 应用程序全局上下文, 非UI上下文. */
private lateinit var mContext: Context
/** */
private lateinit var mClient: EcosedClient
/** 插件绑定器. */
private var mBinding: PluginBinding? = null
/** 插件列表. */
private var mPluginList: ArrayList<BasePlugin>? = null
override fun attachBaseContext(base: Context?) {
super.attachBaseContext(base)
}
/**
* 将引擎附加到应用.
*/
private fun attach() {
when {
(mPluginList == null) or (mBinding == null) -> apply {
// 引擎附加基本上下文
attachBaseContext(
base = mBase
)
// 初始化客户端组件
mClient = EcosedClient.build()
// 初始化插件绑定器.
mBinding = PluginBinding(
context = mContext, debug = mHost.isDebug()
)
// 初始化插件列表.
mPluginList = arrayListOf()
// 加载框架
mClient.let { ecosed ->
mBinding?.let { binding ->
ecosed.apply {
try {
onEcosedAdded(binding = binding)
if (mHost.isDebug()) {
Log.d(tag, "框架已加载")
}
} catch (e: Exception) {
if (mHost.isDebug()) {
Log.e(tag, "框架加载失败!", e)
}
}
}
}.run {
mPluginList?.add(element = ecosed)
if (mHost.isDebug()) {
Log.d(tag, "框架已添加到插件列表")
}
}
}
// 添加所有插件.
mHost.getPluginList()?.let { plugins ->
mBinding?.let { binding ->
plugins.forEach { plugin ->
plugin.apply {
try {
onEcosedAdded(binding = binding)
if (mHost.isDebug()) {
Log.d(tag, "插件${plugin.javaClass.name}已加载")
}
} catch (e: Exception) {
if (mHost.isDebug()) {
Log.e(tag, "插件添加失败!", e)
}
}
}
}
}.run {
plugins.forEach { plugin ->
mPluginList?.add(element = plugin)
if (mHost.isDebug()) {
Log.d(tag, "插件${plugin.javaClass.name}已添加到插件列表")
}
}
}
}
}
else -> if (mHost.isDebug()) {
Log.e(tag, "请勿重复执行attach!")
}
}
}
/**
* 调用插件代码的方法.
* @param channel 要调用的插件的通道.
* @param method 要调用的插件中的方法.
* @param bundle 通过Bundle传递参数.
* @return 返回方法执行后的返回值,类型为Any?.
*/
internal fun <T> execMethodCall(
channel: String,
method: String,
bundle: Bundle?,
): T? {
var result: T? = null
try {
mPluginList?.forEach { plugin ->
plugin.getPluginChannel.let { pluginChannel ->
when (pluginChannel.getChannel()) {
channel -> {
result = pluginChannel.execMethodCall<T>(
name = channel, method = method, bundle = bundle
)
if (mHost.isDebug()) {
Log.d(
tag,
"插件代码调用成功!\n通道名称:${channel}.\n方法名称:${method}.\n返回结果:${result}."
)
}
}
}
}
}
} catch (e: Exception) {
if (mHost.isDebug()) {
Log.e(tag, "插件代码调用失败!", e)
}
}
return result
}
/**
* 用于构建引擎的接口.
*/
internal interface Builder {
/**
* 引擎构建函数.
* @param application 传入Application.
* @param host
* @return 返回已构建的引擎.
*/
fun create(
application: Application,
host: EcosedHost,
): EcosedEngine
}
internal companion object : Builder {
/** 用于打印日志的标签. */
private const val tag: String = "PluginEngine"
/**
* 引擎构建函数.
* @param application 传入Application.
* * @param host
* @return 返回已构建的引擎.
*/
override fun create(
application: Application,
host: EcosedHost,
): EcosedEngine = EcosedEngine().let { engine ->
return@let engine.apply {
if (application is IEcosedApplication) {
application.apply {
mApp = application
mBase = baseContext
mContext = applicationContext
mHost = host
}.run {
attach()
}
} else error(
message = "错误:EcosedApplication接口未实现.\n" + "提示1:可能未在应用的Application全局类实现EcosedApplication接口.\n" + "提示2:应用的Application全局类可能未在AndroidManifest.xml中注册."
)
}
}
}
override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) {
}
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
}
} | 0 | Kotlin | 0 | 2 | eef80b0a5d57f510eae194d158e4c5d5cd8c872d | 7,473 | EcosedKit | Apache License 2.0 |
payroll-kotlin/src/main/kotlin/com/dctewi/payrollkotlin/EmployeeNotFoundAdvice.kt | DCTewi | 424,877,982 | false | {"Kotlin": 12323} | package com.dctewi.payrollkotlin
import org.springframework.http.HttpStatus
import org.springframework.web.bind.annotation.ControllerAdvice
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.ResponseBody
import org.springframework.web.bind.annotation.ResponseStatus
@ControllerAdvice
class EmployeeNotFoundAdvice {
@ResponseBody
@ExceptionHandler(EmployeeNotFoundException::class)
@ResponseStatus(HttpStatus.NOT_FOUND)
fun employeeNotFoundHandler(ex: EmployeeNotFoundException) = ex.message
}
| 0 | Kotlin | 0 | 0 | f9fb9fc6940a0edaf5fa314e04b0b097afe143ce | 571 | SoftwareHomework | MIT License |
app/src/main/java/com/andreapivetta/blu/ui/custom/EditedViewPager.kt | ziggy42 | 59,509,988 | false | null | package com.andreapivetta.blu.ui.custom
import android.content.Context
import android.support.v4.view.ViewPager
import android.util.AttributeSet
import android.view.MotionEvent
/**
* Created by andrea on 28/05/16.
*/
class EditedViewPager : ViewPager {
constructor(context: Context) : super(context)
constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet)
override fun onTouchEvent(ev: MotionEvent?) = try {
super.onTouchEvent(ev)
} catch(err: IllegalArgumentException) {
err.printStackTrace()
false
}
override fun onInterceptTouchEvent(ev: MotionEvent?) = try {
super.onInterceptTouchEvent(ev)
} catch(err: IllegalArgumentException) {
err.printStackTrace()
false
}
} | 2 | Kotlin | 16 | 78 | 2443e47e0af3d89424a93d264782f7e3e7c44a47 | 789 | Blum | Apache License 2.0 |
app-components/src/main/java/ru/shafran/common/main/SplashComponent.kt | SuLG-ik | 384,238,863 | false | null | package ru.shafran.common.main
class SplashComponent: Splash | 0 | Kotlin | 0 | 1 | aef4a3083c87e2bd2de1eaff2b9925a5dc226fe2 | 61 | ShafranCards | Apache License 2.0 |
commonkt-javafx/src/main/kotlin/io/github/dylmeadows/commonkt/javafx/beans/property/PropertyExtensions.kt | dylmeadows | 194,884,404 | false | null | package io.github.dylmeadows.commonkt.javafx.beans.property
import javafx.beans.property.*
import javafx.beans.value.*
import kotlin.reflect.KProperty
operator fun <T> ObservableValue<T>.getValue(thisRef: Any, property: KProperty<*>): T = this.value!!
operator fun <T> Property<T>.setValue(thisRef: Any, property: KProperty<*>, value: T?) = setValue(value)
operator fun ObservableIntegerValue.getValue(thisRef: Any, property: KProperty<*>) = get()
operator fun IntegerProperty.setValue(thisRef: Any, property: KProperty<*>, value: Int) = set(value)
operator fun ObservableLongValue.getValue(thisRef: Any, property: KProperty<*>) = get()
operator fun LongProperty.setValue(thisRef: Any, property: KProperty<*>, value: Long) = set(value)
operator fun ObservableFloatValue.getValue(thisRef: Any, property: KProperty<*>) = get()
operator fun FloatProperty.setValue(thisRef: Any, property: KProperty<*>, value: Float) = set(value)
operator fun ObservableDoubleValue.getValue(thisRef: Any, property: KProperty<*>) = get()
operator fun DoubleProperty.setValue(thisRef: Any, property: KProperty<*>, value: Double) = set(value)
operator fun ObservableBooleanValue.getValue(thisRef: Any, property: KProperty<*>) = get()
operator fun BooleanProperty.setValue(thisRef: Any, property: KProperty<*>, value: Boolean) = set(value)
fun ObjectProperty<Int>.bindBidirectional(
property: IntegerProperty
) {
bindBidirectional(property.asObject())
}
fun ObjectProperty<Long>.bindBidirectional(
property: LongProperty
) {
bindBidirectional(property.asObject())
}
fun ObjectProperty<Float>.bindBidirectional(
property: FloatProperty
) {
bindBidirectional(property.asObject())
}
fun ObjectProperty<Double>.bindBidirectional(
property: DoubleProperty
) {
bindBidirectional(property.asObject())
}
fun IntegerProperty.bindBidirectional(
property: ObjectProperty<Int>
) {
asObject().bindBidirectional(property)
}
fun LongProperty.bindBidirectional(
property: ObjectProperty<Long>
) {
asObject().bindBidirectional(property)
}
fun FloatProperty.bindBidirectional(
property: ObjectProperty<Float>
) {
asObject().bindBidirectional(property)
}
fun DoubleProperty.bindBidirectional(
property: ObjectProperty<Double>
) {
asObject().bindBidirectional(property)
} | 0 | Kotlin | 0 | 0 | ae340d94ae9bcc4feca21fd46fa0ba5bdbcfb638 | 2,305 | commonkt | MIT License |
bio_auth_service/src/main/kotlin/fingerprint/FingerprintRoutes.kt | michelleinez | 371,788,978 | true | {"Kotlin": 187346, "PLpgSQL": 3501, "Shell": 2571} | package org.kiva.bioauthservice.fingerprint
import common.errors.impl.InvalidFilterException
import datadog.trace.api.Trace
import fingerprint.dtos.TemplatizerDto
import io.ktor.application.call
import io.ktor.request.receive
import io.ktor.response.respond
import io.ktor.routing.Route
import io.ktor.routing.get
import io.ktor.routing.post
import io.ktor.routing.route
import io.ktor.util.KtorExperimentalAPI
import kotlinx.serialization.ExperimentalSerializationApi
import org.kiva.bioauthservice.common.utils.requestIdHeader
import org.kiva.bioauthservice.fingerprint.dtos.BulkSaveRequestDto
import org.kiva.bioauthservice.fingerprint.dtos.PositionsDto
import org.kiva.bioauthservice.fingerprint.dtos.VerifyRequestDto
/**
* Statically defined paths for Fingerprint routes
*/
private object Paths {
const val apiV1 = "/api/v1"
const val templatizer = "/templatizer/bulk/template"
const val getPositions = "/positions/template"
const val save = "/save"
const val verify = "/verify"
const val positions = "/positions"
}
/*
* Route definitions
*/
@ExperimentalSerializationApi
@KtorExperimentalAPI
fun Route.fingerprintRoutes(fingerprintService: FingerprintService) {
route(Paths.apiV1) {
// TODO: Remove this deprecated route. Use POST /save instead
post(Paths.templatizer) @Trace(operationName = Paths.templatizer) {
val dtos = call.receive<List<TemplatizerDto>>()
val bulkSaveDto = BulkSaveRequestDto(dtos.map { it.toSaveRequestDto() })
val numSaved = fingerprintService.save(bulkSaveDto, call.requestIdHeader())
call.respond(numSaved)
}
// TODO: Remove this deprecated route. Use POST /positions instead
get("${Paths.getPositions}/{filter}") @Trace(operationName = Paths.getPositions) {
val filters = call.parameters["filter"]?.split("=") ?: emptyList()
if (filters.size != 2) {
throw InvalidFilterException("One of your filters is invalid or missing. Filter has to be in the format 'dids=123,abc'")
}
if (filters[0] != "dids") {
throw InvalidFilterException("${filters[0]} is an invalid filter type")
}
val dto = PositionsDto(filters[1])
val result = fingerprintService.positions(dto)
call.respond(result)
}
post(Paths.save) @Trace(operationName = Paths.save) {
val dto = call.receive<BulkSaveRequestDto>()
val numSaved = fingerprintService.save(dto, call.requestIdHeader())
call.respond(numSaved)
}
post(Paths.verify) @Trace(operationName = Paths.verify) {
val dto = call.receive<VerifyRequestDto>()
val result = fingerprintService.verify(dto, call.requestIdHeader())
call.respond(result)
}
post(Paths.positions) @Trace(operationName = Paths.positions) {
val dto = call.receive<PositionsDto>()
val result = fingerprintService.positions(dto)
call.respond(result)
}
}
}
| 0 | null | 0 | 0 | 347c59f8c76b2644db853b86b819f8d62d4274ca | 3,099 | guardian-bio-auth | Apache License 2.0 |
data/src/main/java/com/pp/moviefy/data/mappers/titles/ApiTitlesMapper.kt | pauloaapereira | 356,418,263 | false | null | /*
* Copyright 2021 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.pp.moviefy.data.mappers.titles
import com.pp.moviefy.data.mappers.ApiMapper
import com.pp.moviefy.data.remote.model.common.ApiTitles
import com.pp.moviefy.domain.model.Titles
import javax.inject.Inject
class ApiTitlesMapper @Inject constructor(
private val apiTitleMapper: ApiTitleMapper
) : ApiMapper<ApiTitles, Titles> {
override fun mapToDomain(obj: ApiTitles): Titles {
return Titles(
id = obj.id ?: 0,
titles = obj.titles?.map { apiTitleMapper.mapToDomain(it) }.orEmpty(),
success = obj.success == true
)
}
}
| 0 | Kotlin | 0 | 0 | e174b88ab2397720c47f81c06603794e142bd91f | 1,183 | Moviefy | Apache License 2.0 |
src/main/kotlin/no/nav/syfo/esyfovarsel/kafka/KafkaConfig.kt | navikt | 476,213,064 | false | {"Kotlin": 84787, "Dockerfile": 200} | package no.nav.syfo.esyfovarsel.kafka
import no.nav.syfo.kafka.KafkaEnvironment
import no.nav.syfo.kafka.commonKafkaAivenProducerConfig
import org.apache.kafka.clients.producer.ProducerConfig
import java.util.*
fun kafkaEsyfovarselHendelseProducerConfig(
kafkaEnvironment: KafkaEnvironment,
): Properties {
return Properties().apply {
putAll(commonKafkaAivenProducerConfig(kafkaEnvironment))
this[ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG] = KafkaEsyfovarselHendelseSerializer::class.java.canonicalName
}
}
| 0 | Kotlin | 0 | 1 | 6087415342e0638c3f9cd7ccf951a87f6ff80799 | 540 | isyfomock | MIT License |
api/src/main/kotlin/de/jnkconsulting/e3dc/easyrscp/api/service/model/manual-charge.kt | jnk-cons | 691,762,451 | false | {"Kotlin": 918056} | package de.jnkconsulting.e3dc.easyrscp.api.service.model
import java.time.Instant
data class ManualChargeState(
val active: Boolean,
val chargedEnergyWh: Double,
val lastRun: Instant
)
| 5 | Kotlin | 0 | 1 | 8627cdddb76e29624ec4d186f063dd05ff9489da | 199 | easy-rscp | MIT License |
app/src/main/java/io/github/aafactory/sample/adapters/ShowcaseViewHolder.kt | ShahbazExpress | 360,755,825 | true | {"JavaScript": 2389470, "Kotlin": 880810, "Java": 372870, "HTML": 28241, "CSS": 21881, "GLSL": 11815, "Handlebars": 8883, "Less": 8172, "Shell": 4309, "Makefile": 668, "Batchfile": 264} | package io.github.aafactory.sample.adapters
import android.view.View
import io.github.aafactory.sample.models.Showcase
import kotlinx.android.synthetic.main.item_showcase.*
/**
* Created by <NAME> on 2018-04-19.
*/
class ShowcaseViewHolder(containerView: View) : BaseViewHolder<Showcase>(containerView) {
override fun bindData(data: Showcase) {
title.text = data.displayName
description.text = data.description
starsAll.text = "${data.stargazersCount}"
forks.text = "${data.forksCount}"
owner.text = "Built by ${data.owner}"
}
} | 0 | null | 0 | 0 | b3ed9b6e27e670b596be487117b56f94c78eee83 | 581 | aafactory-commons | Apache License 2.0 |
app/src/main/java/microteam/ui/screens/unread/UnreadScreen.kt | yugal-nandurkar | 876,869,030 | false | {"Kotlin": 114257} |
package microteam.ui.screens.unread
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import microteam.R
import microteam.domain.model.ArticleUi
import microteam.domain.model.ArticlesUiState
import microteam.ui.screens.common.ArticlesScreen
@Composable
fun UnreadScreen(
viewModel: UnreadArticlesViewModel,
navigateToArticle: (ArticleUi) -> Unit,
) {
val searchQuery by viewModel.searchQuery.collectAsStateWithLifecycle()
val isSearching by viewModel.isSearching.collectAsStateWithLifecycle()
val articles by viewModel.articles.collectAsStateWithLifecycle()
if (articles != null) {
val uiState: ArticlesUiState by viewModel.uiState.collectAsStateWithLifecycle()
ArticlesScreen(
articleUis = articles!!,
noArticlesDescStrResId = R.string.no_unread_articles_desc,
isRefreshing = (uiState is ArticlesUiState.Loading),
searchQuery = searchQuery,
isSearching = isSearching,
navigateToArticle = navigateToArticle,
onRefresh = viewModel::refresh,
onBookmarkClick = viewModel::onBookmarkClick,
onReadClick = viewModel::onReadClick,
)
}
}
| 0 | Kotlin | 0 | 0 | 1a68295d839ec5bbd9ce131fe139d4fe63a6ea13 | 1,291 | microteam-android-news | MIT License |
printer/src/main/java/com/tabesto/printer/utils/Constants.kt | Tabesto | 339,833,685 | false | null | package com.tabesto.printer.utils
typealias EposPrinter = com.epson.epos2.printer.Printer
object Constants {
const val PRINTER_UNKNOWN_CODE = "UNKNOWN_CODE"
const val PRINTER_UNKNOWN_ACTION = "Unknown action"
const val UNKNOWN_VALUE = "UNKNOWN"
// 46 its our own custom code that is not present in EposException, in EposException last int is 45 and 255
const val PRINTER_ERR_UNKNOWN = 46
// For Device Manager
const val PRINTER_DATA_NOT_MANAGED = "Printer is not managed by the device manager, please connect it"
const val MAIN_JOB_IS_RUNNING = "A main job is already running"
const val CONNECT_TIMEOUT_MIN = 1000
const val PRINT_TIMEOUT_MIN = 5000
}
| 0 | Kotlin | 0 | 2 | b423b830e99f8b2250678d43be876de322502d06 | 698 | android-pos-printer | MIT License |
korge-core/src@darwin/korlibs/io/net/DarwinSSLSocket.kt | korlibs | 80,095,683 | false | {"WebAssembly": 14293935, "Kotlin": 9728800, "C": 77092, "C++": 20878, "TypeScript": 12397, "HTML": 6043, "Python": 4296, "Swift": 1371, "JavaScript": 328, "Shell": 254, "CMake": 202, "CSS": 66, "Batchfile": 41} | package korlibs.io.net
import cnames.structs.SSLContext
import korlibs.io.async.*
import korlibs.io.posix.*
import kotlinx.cinterop.*
import kotlinx.cinterop.ByteVar
import kotlinx.coroutines.*
import platform.CoreFoundation.*
import platform.Security.*
import platform.darwin.*
import platform.posix.*
import platform.posix.sockaddr_in
import kotlin.ByteArray
import kotlin.Int
import kotlin.String
import kotlin.TODO
import kotlin.UByte
import kotlin.UShort
import kotlin.error
import kotlin.native.concurrent.*
import kotlin.toUShort
class DarwinSSLSocket {
val arena = Arena()
var sockfd: Int = -1
var ctx: CPointer<SSLContext>? = null
var endpoint: NativeSocket.Endpoint = NativeSocket.Endpoint(NativeSocket.IP(0, 0, 0, 0), 0); private set
suspend fun connect(host: String, port: Int) {
close()
val socketVar = arena.alloc<LongVar>()
ctx = SSLCreateContext(null, SSLProtocolSide.kSSLClientSide, SSLConnectionType.kSSLStreamType)
withContext(Dispatchers.CIO) {
memScoped {
val sockfd = socket(AF_INET, SOCK_STREAM, 0)
val timeout = alloc<timeval>()
timeout.tv_sec = 10 // seconds
timeout.tv_usec = 500000 // micro seconds ( 0.5 seconds)
setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, timeout.ptr, sizeOf<timeval>().convert())
setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, timeout.ptr, sizeOf<timeval>().convert())
//fcntl(sockfd, F_SETFL, O_NONBLOCK)
socketVar.value = sockfd.convert()
SSLSetConnection(ctx, socketVar.ptr)
SSLSetIOFuncs(ctx, staticCFunction(::SSL_recv_callback), staticCFunction(::SSL_send_callback))
SSLSetPeerDomainName(ctx, host)
//println("Socket...")
val hname = gethostbyname(host)
//println("hname=$hname")
val inetaddr: CPointer<UByteVarOf<UByte>> = hname!!.pointed.h_addr_list!![0]!!.reinterpret()
val endpoint = NativeSocket.Endpoint(
NativeSocket.IP(inetaddr[0].toInt(), inetaddr[1].toInt(), inetaddr[2].toInt(), inetaddr[3].toInt()),
port
)
val servaddr = alloc<sockaddr_in>()
servaddr.sin_family = AF_INET.convert()
//println("addr=$addr")
servaddr.sin_addr.s_addr = inet_addr(endpoint.ip.str)
servaddr.sin_port = swapBytes(endpoint.port.toUShort()).convert()
//println("Connecting...")
val result = connect(sockfd, servaddr.ptr.reinterpret(), sizeOf<sockaddr_in>().convert())
/*
if (errno != EINPROGRESS) {
error("Error connecting to socket errno=$errno, EINPROGRESS=$EINPROGRESS")
} else {
loop@while (true) {
val rc = memScoped {
val timeout = alloc<timeval>()
val writeFDs = alloc<fd_set>()
timeout.tv_sec = 0
timeout.tv_usec = 1000
__darwin_fd_set(sockfd, writeFDs.ptr)
select(1, writeFDs.ptr, writeFDs.ptr, writeFDs.ptr, timeout.ptr)
}
if (rc == 0 || rc == -1) {
println(" Timed out -- Not connected even after 3 secs wait")
} else {
println(" connected and written")
break@loop
}
}
}
*/
//println("connected: $result, sockfd=$sockfd, errno=$errno")
if (result != 0) error("Error connecting to socket result=$result, sockfd=$sockfd, errno=$errno")
[email protected] = sockfd
[email protected] = endpoint
}
}
}
val connected: Boolean get() {
if (sockfd < 0 || ctx == null) return false
return when (SSLGetSessionState(ctx)) {
SSLSessionState.kSSLClosed, SSLSessionState.kSSLAborted -> false
else -> ioctlSocketFionRead(sockfd) >= 0
}
}
suspend fun write(data: ByteArray, offset: Int = 0, size: Int = data.size - offset) {
SSLWrite(ctx, data, offset, size)
}
suspend fun read(data: ByteArray, offset: Int = 0, size: Int = data.size - offset): Int {
return SSLRead(ctx, data, offset, size)
}
suspend fun read(size: Int): ByteArray {
val out = ByteArray(size)
return out.copyOf(read(out))
}
suspend fun close() {
if (ctx != null) SSLClose(ctx)
if (sockfd >= 0) close(sockfd)
ctx = null
sockfd = -1
arena.clear()
}
companion object {
private fun SSLSetPeerDomainName(ctx: SSLContextRef?, name: String) {
val status = SSLSetPeerDomainName(ctx, name, name.length.convert())
//println("SSLSetPeerDomainName: " + SecCopyErrorMessageString(status, null)?.toKString())
}
private fun SSLGetSessionState(ctx: SSLContextRef?): SSLSessionState = memScoped {
val state = alloc<SSLSessionState.Var>()
SSLGetSessionState(ctx, state.ptr)
state.value
}
private fun swapBytes(v: UShort): UShort =
(((v.toInt() and 0xFF) shl 8) or ((v.toInt() ushr 8) and 0xFF)).toUShort()
private suspend fun SSLEnsure(ctx: SSLContextRef?): Boolean {
while (true) {
val state = SSLGetSessionState(ctx)
//println("state=$state")
when (state) {
SSLSessionState.kSSLIdle -> SSLHandshake(ctx)
SSLSessionState.kSSLHandshake -> {
memScoped {
val data = allocArray<ByteVar>(0)
val processed = alloc<size_tVar>()
SSLWrite(ctx, data, 0.convert(), processed.ptr)
}
//SSLHandshake(ctx)
kotlinx.coroutines.delay(1L)
}
SSLSessionState.kSSLClosed -> return false
SSLSessionState.kSSLAborted -> return false
SSLSessionState.kSSLConnected -> break
else -> Unit
}
}
return true
//println("state=${SSLGetSessionState(ctx)}")
}
private suspend fun SSLRead(
ctx: SSLContextRef?,
data: ByteArray,
offset: Int = 0,
size: Int = data.size - offset
): Int {
if (data.isEmpty() || size == 0) return 0
if (!SSLEnsure(ctx)) return -1
memScoped {
val processed = alloc<size_tVar>()
while (true) {
val result = data.usePinned { dataPin ->
SSLRead(ctx, dataPin.addressOf(offset), size.convert(), processed.ptr)
}
when (result) {
0 -> {
return processed.value.toInt()
}
errSSLWouldBlock -> {
kotlinx.coroutines.delay(1L)
continue
}
errSSLClosedGraceful -> {
return 0
}
else -> {
error("SSLRead: ${SecCopyErrorMessageString(result, null)?.toKString()}")
}
}
//val resultString = SecCopyErrorMessageString(result, null)?.toKString()
//println("SSLRead.result=$result, resultString=$resultString")
//println("SSLRead.processed=${processed.value}")
}
}
TODO()
}
private suspend fun SSLWrite(
ctx: SSLContextRef?,
data: ByteArray,
offset: Int = 0,
size: Int = data.size - offset
) {
if (data.isEmpty() || size == 0) return
if (!SSLEnsure(ctx)) return
memScoped {
val processed = alloc<size_tVar>()
data.usePinned { dataPin ->
val result = SSLWrite(ctx, dataPin.addressOf(offset), size.convert(), processed.ptr)
//println("SSLWrite.result=$result, resultString=$resultString")
//println("SSLWrite.processed=${processed.value}")
if (result != 0) error("SSLWrite: ${SecCopyErrorMessageString(result, null)?.toKString()}")
}
}
}
private fun CFStringRef.toKString(): String {
val len = CFStringGetLength(this).toInt()
val data = ByteArray(len + 1)
data.usePinned {
CFStringGetCString(this@toKString, it.addressOf(0), (len + 1).convert(), kCFStringEncodingUTF8)
}
return data.sliceArray(0 until len).decodeToString()
}
}
}
private val ioErr: OSStatus = (-36).convert()
/*
* https://github.com/karosLi/offlineH5/blob/0bf84d9baea37016d73fab70e3005ef0e3453975/node_modules/.0.19.0%40nodegit/vendor/libgit2/src/stransport_stream.c#L170
*
* Contrary to typical network IO callbacks, Secure Transport read callback is
* expected to read *exactly* the requested number of bytes, not just as much
* as it can, and any other case would be considered a failure.
*
* This behavior is actually not specified in the Apple documentation, but is
* required for things to work correctly (and incidentally, that's also how
* Apple implements it in its projects at opensource.apple.com).
*/
private fun SSL_recv_callback(
connection: SSLConnectionRef?,
ptr: COpaquePointer?,
size: CPointer<size_tVar>?
): OSStatus {
val sockfd = connection?.reinterpret<LongVar>()?.get(0) ?: error("No socket provided")
//println("SSL_recv_callback: sockfd=$sockfd, size=${size?.get(0)}")
val readSize = size?.get(0)?.toInt() ?: 0
size?.set(0, 0.convert())
var currentPtr = ptr?.reinterpret<ByteVar>()
var pendingSize: Int = readSize
var totalReadSize = 0
var error: OSStatus = noErr.convert()
memScoped {
//val availableRead = alloc<size_tVar>()
val availableRead: Int = ioctlSocketFionRead(sockfd.convert()).convert()
//println("ioctlResult=$ioctlResult, availableRead.value=${availableRead.value}")
//if (ioctlResult != 0) return errSSLWouldBlock
//if (availableRead.value < pendingSize.convert()) return errSSLWouldBlock
if (availableRead < pendingSize) return errSSLWouldBlock
}
while (pendingSize > 0) {
val recvBytes = recv(sockfd.convert(), currentPtr, pendingSize.convert(), 0).toInt()
if (recvBytes < 0) {
error = ioErr.convert()
break
}
if (recvBytes == 0) {
error = errSSLClosedGraceful
break
}
currentPtr += recvBytes
pendingSize -= recvBytes
totalReadSize += recvBytes
//println(" --> $recvBytes")
}
size?.set(0, totalReadSize.convert())
return error.convert()
}
private fun SSL_send_callback(
connection: SSLConnectionRef?,
ptr: COpaquePointer?,
size: CPointer<size_tVar>?
): OSStatus {
val sockfd = connection?.reinterpret<LongVar>()?.get(0) ?: error("No socket provided")
//println("SSL_send_callback: sockfd=$sockfd, size=${size?.get(0)}")
val writeBytes: size_t = size?.get(0) ?: 0.convert()
val sentBytes = send(sockfd.convert(), ptr, writeBytes, 0)
size?.set(0, sentBytes.convert())
//println(" --> $sentBytes")
return if (sentBytes.toInt() != writeBytes.toInt()) ioErr.convert() else noErr.convert()
}
| 444 | WebAssembly | 121 | 2,207 | dc3d2080c6b956d4c06f4bfa90a6c831dbaa983a | 12,127 | korge | Apache License 2.0 |
spring/cassandra/src/test/kotlin/io/bluetape4k/spring/cassandra/async/AsyncOptimisticLockingTest.kt | debop | 625,161,599 | false | {"Kotlin": 7504333, "HTML": 502995, "Java": 2273, "JavaScript": 1351, "Shell": 1301, "CSS": 444, "Dockerfile": 121, "Mustache": 82} | package io.bluetape4k.spring.cassandra.async
import com.datastax.oss.driver.api.core.CqlSession
import io.bluetape4k.junit5.coroutines.runSuspendTest
import io.bluetape4k.logging.KLogging
import io.bluetape4k.spring.cassandra.domain.DomainTestConfiguration
import io.bluetape4k.spring.cassandra.domain.model.VersionedEntity
import kotlinx.coroutines.future.await
import kotlinx.coroutines.runBlocking
import org.amshove.kluent.shouldBeEqualTo
import org.amshove.kluent.shouldBeNull
import org.amshove.kluent.shouldNotBeNull
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.dao.OptimisticLockingFailureException
import org.springframework.data.cassandra.core.AsyncCassandraOperations
import org.springframework.data.cassandra.core.AsyncCassandraTemplate
import org.springframework.data.cassandra.core.query.Query
import org.springframework.data.cassandra.core.selectOne
import org.springframework.data.cassandra.core.truncate
import kotlin.test.assertFailsWith
@SpringBootTest(classes = [DomainTestConfiguration::class])
class AsyncOptimisticLockingTest(
@Autowired private val cqlSession: CqlSession,
): io.bluetape4k.spring.cassandra.AbstractCassandraCoroutineTest("coroutines-optimistic-locking") {
companion object: KLogging()
// NOTE: AsyncCassandraTemplate 는 직접 Injection 받을 수 없고, 이렇게 생성해야 한다.
private val operations: AsyncCassandraOperations by lazy {
AsyncCassandraTemplate(cqlSession)
}
@BeforeEach
fun beforeEach() {
runBlocking {
operations.truncate<VersionedEntity>().await()
}
}
@Test
fun `context loading`() {
operations.shouldNotBeNull()
}
@Test
fun `versioned entity 삽입 시 version이 올라간다`() = runSuspendTest {
val entity = VersionedEntity(42L)
val saved = operations.insert(entity).await()!!
val loaded = operations.selectOne<VersionedEntity>(Query.empty()).await()
saved.version shouldBeEqualTo 1
loaded.shouldNotBeNull()
loaded.version shouldBeEqualTo 1
}
@Test
fun `중복된 insert 는 실패한다`() = runSuspendTest {
operations.insert(VersionedEntity(42L)).await()
assertFailsWith<OptimisticLockingFailureException> {
operations.insert(VersionedEntity(42L, 12)).await()
}
}
@Test
fun `versioned entity를 update하면 version이 올라간다`() = runSuspendTest {
val entity = VersionedEntity(42L)
val saved = operations.insert(entity).await()!!
val updated = operations.update(saved).await()!!
val loaded = operations.selectOne<VersionedEntity>(Query.empty()).await()
saved.version shouldBeEqualTo 1
updated.version shouldBeEqualTo 2
loaded.shouldNotBeNull()
loaded.version shouldBeEqualTo 2
}
@Test
fun `outdated entity를 갱신하려면 예외가 발생한다`() = runSuspendTest {
val entity = VersionedEntity(42L)
operations.insert(entity).await()!!
assertFailsWith<OptimisticLockingFailureException> {
operations.update(entity.copy(version = 42, name = faker.name().name())).await()
}
}
@Test
fun `versioned entity 삭제하기`() = runSuspendTest {
val entity = VersionedEntity(42L)
val saved = operations.insert(entity).await()!!
operations.delete(saved).await()
val loaded = operations.selectOne<VersionedEntity>(Query.empty()).await()
loaded.shouldBeNull()
}
@Test
fun `outdated versioned entity를 삭제하려면 예외가 발생한다`() = runSuspendTest {
val entity = VersionedEntity(42L)
val saved = operations.insert(entity).await()!!
assertFailsWith<OptimisticLockingFailureException> {
operations.delete(VersionedEntity(42L)).await()
}
val loaded = operations.selectOne<VersionedEntity>(Query.empty()).await()
loaded.shouldNotBeNull() shouldBeEqualTo saved
}
}
| 0 | Kotlin | 0 | 1 | ce3da5b6bddadd29271303840d334b71db7766d2 | 4,057 | bluetape4k | MIT License |
booster-build/src/main/kotlin/com/didiglobal/booster/build/BoosterServiceLoader.kt | Chumfuchiu | 263,555,881 | false | {"Gradle": 55, "INI": 3, "Markdown": 33, "Shell": 2, "Ignore List": 1, "Batchfile": 1, "Text": 7, "YAML": 1, "Java": 116, "Kotlin": 175, "Protocol Buffer": 4, "JavaScript": 1} | package com.didiglobal.booster.build
import java.util.ServiceLoader
/**
* @author johnsonlee
*/
class BoosterServiceLoader {
companion object {
fun <S : Any> load(service: Class<S>, classLoader: ClassLoader): List<S> = listOf(
ServiceLoader.load(service),
ServiceLoader.load(service, classLoader)
).flatten().distinctBy {
it.javaClass
}
}
} | 1 | null | 1 | 1 | e1424246b4db27b1240e4584ffb81ea747443578 | 424 | booster | Apache License 2.0 |
vk-api/src/main/kotlin/name/alatushkin/api/vk/generated/utils/StatsCountry.kt | alatushkin | 156,866,851 | false | null | package name.alatushkin.api.vk.generated.utils
open class StatsCountry(
val countryId: Long? = null,
val views: Long? = null
) | 2 | Kotlin | 3 | 10 | 123bd61b24be70f9bbf044328b98a3901523cb1b | 136 | kotlin-vk-api | MIT License |
kontroller/src/main/kotlin/no/ssb/kostra/validation/rule/regnskap/kostra/Rule055KombinasjonInvesteringKontoklasseArt.kt | statisticsnorway | 414,216,275 | false | {"Kotlin": 1530707, "TypeScript": 66662, "HTML": 694, "SCSS": 139, "Dockerfile": 137} | package no.ssb.kostra.validation.rule.regnskap.kostra
import no.ssb.kostra.area.regnskap.RegnskapConstants.FIELD_ART
import no.ssb.kostra.area.regnskap.RegnskapConstants.FIELD_BELOP
import no.ssb.kostra.program.KostraRecord
import no.ssb.kostra.validation.report.Severity
import no.ssb.kostra.validation.rule.AbstractNoArgsRule
import no.ssb.kostra.validation.rule.regnskap.kostra.extensions.isBevilgningInvesteringRegnskap
class Rule055KombinasjonInvesteringKontoklasseArt(
private val illogicalInvesteringArtList: List<String>
) : AbstractNoArgsRule<List<KostraRecord>>(
"Kontroll 055 : Ugyldig kombinasjon i investeringsregnskapet, kontoklasse og art",
Severity.INFO
) {
override fun validate(context: List<KostraRecord>) = context.filter { kostraRecord ->
kostraRecord.isBevilgningInvesteringRegnskap()
&& kostraRecord[FIELD_ART] in illogicalInvesteringArtList
&& kostraRecord.fieldAsIntOrDefault(FIELD_BELOP) != 0
}.map { kostraRecord ->
createValidationReportEntry(
messageText = "Kun advarsel, hindrer ikke innsending: (${kostraRecord[FIELD_ART]}) regnes å være ulogisk " +
"art i investeringsregnskapet. Vennligst vurder å postere på annen art eller om posteringen " +
"hører til i driftsregnskapet.",
lineNumbers = listOf(kostraRecord.lineNumber)
)
}.ifEmpty { null }
} | 1 | Kotlin | 0 | 1 | 5284f4627cd30748e23310eedb8a962c6da9d146 | 1,424 | kostra-kontrollprogram | MIT License |
app/src/main/java/org/miaowo/miaowo/util/ImageUtil.kt | luiqn2007 | 91,064,384 | false | {"Gradle": 3, "Java Properties": 2, "Shell": 1, "Text": 1, "Ignore List": 2, "Batchfile": 1, "Markdown": 1, "Proguard": 1, "JSON": 1, "Java": 4, "XML": 53, "Kotlin": 66} | package org.miaowo.miaowo.util
import android.graphics.Color
import android.graphics.drawable.Drawable
import android.text.TextUtils
import com.amulyakhare.textdrawable.TextDrawable
import org.miaowo.miaowo.App
import org.miaowo.miaowo.data.config.TextIconConfig
/**
* 图形处理类
* Created by luqin on 17-1-27.
*/
object ImageUtil {
fun textIcon(config: TextIconConfig?, text: String? = null): Drawable? =
if (!text.isNullOrBlank() && config != null) {
TextDrawable.builder()
.beginConfig()
.textColor(config.textColor)
.toUpperCase()
.endConfig()
.buildRound(text, config.bgColor)
} else if (config?.icon != null) {
TextDrawable.builder()
.beginConfig()
.textColor(config.textColor)
.useFont(config.icon.typeface.getTypeface(App.i))
.toUpperCase()
.endConfig()
.buildRound(config.icon.character.toString(), config.bgColor)
} else null
fun colorFromUser(color: String) =
if (TextUtils.isEmpty(color) || color.length < 6) -1
else Color.rgb(Integer.parseInt(color.substring(color.length - 6, color.length - 4), 16),
Integer.parseInt(color.substring(color.length - 4, color.length - 2), 16),
Integer.parseInt(color.substring(color.length - 2, color.length), 16))
}
| 1 | null | 1 | 1 | bea81deb7e755a47aa2dd7edd56fc17708231bee | 1,569 | miaowo | Apache License 2.0 |
app/src/main/java/com/ieeevit/enigma7/utils/PrefManager.kt | IEEE-VIT | 290,277,773 | false | null | package com.ieeevit.enigma7.utils
import android.content.Context
import android.content.SharedPreferences
class PrefManager(val context: Context) {
private val prefName = "com.ieeevit.enigma7"
private val sharedPref: SharedPreferences = context.getSharedPreferences(prefName, Context.MODE_PRIVATE)
private val authorizationCode: String = "AuthorizationCode"
private val username: String = "Username"
private val userNameExist: String = "userStatus"
private val hint: String = "hintString"
private val isFirstTimeLaunch = "IsFirstTimeLaunch"
private val gameStarted: String = "IsGameStarted"
private val xP = "xP"
private val editor: SharedPreferences.Editor = sharedPref.edit()
private val loggedIN = "IsLoggedIn"
private val enigmaStatus = "EnigmaStatus"
private val canShowHintDialog = "CanShowHintDialog"
fun setAuthCode(text: String) {
editor.putString(authorizationCode, text)
editor.apply()
}
fun setUserStatus(text: Boolean) {
editor.putBoolean(userNameExist, text)
editor.apply()
}
fun setFirstTimeInstruction(text: Boolean) {
editor.putBoolean(isFirstTimeLaunch, text)
editor.apply()
}
fun isFirstTimeInstruction(): Boolean {
return sharedPref.getBoolean(isFirstTimeLaunch, true)
}
fun setHuntStarted(text: Boolean) {
editor.putBoolean(gameStarted, text)
editor.apply()
}
fun isHuntStarted(): Boolean {
return sharedPref.getBoolean(gameStarted, false)
}
fun setIsLoggedIn(text: Boolean) {
editor.putBoolean(loggedIN, text)
editor.apply()
}
fun isLoggedIn(): Boolean {
return sharedPref.getBoolean(loggedIN, false)
}
fun getAuthCode(): String? {
return sharedPref.getString(authorizationCode, null)
}
fun getUserStaus(): Boolean? {
return sharedPref.getBoolean(userNameExist, false)
}
fun setHint(text: String?) {
editor.putString(hint, text)
editor.apply()
}
fun getHintString(): String? {
return sharedPref.getString(hint, null)
}
fun setQuestionFlag(boolean: Boolean){
editor.putBoolean("Question Flag", boolean)
editor.apply()
}
fun getQuestionFlag(): Boolean{
return sharedPref.getBoolean("Question Flag", false)
}
fun clearSharedPreference() {
editor.clear()
editor.apply()
}
fun setXp(text: Int) {
editor.putInt(xP, text)
editor.apply()
}
fun getXp(): Int {
return sharedPref.getInt(xP, 0)
}
fun setEnigmaStatus(text: Boolean) {
editor.putBoolean(enigmaStatus, text)
editor.apply()
}
fun getEnigmaStatus(): Boolean {
return sharedPref.getBoolean(enigmaStatus, false)
}
fun setIsShowHintDialog(text: Boolean) {
editor.putBoolean(canShowHintDialog, text)
editor.apply()
}
fun isShowHintDialog(): Boolean {
return sharedPref.getBoolean(canShowHintDialog, false)
}
fun setUsername(text: String?) {
editor.putString(username, text)
editor.apply()
}
fun getUsername(): String? {
return sharedPref.getString(username, null)
}
} | 0 | Kotlin | 1 | 2 | 6f530829c6bfd28cbfdee93569f20cff45920cec | 3,278 | enigma7-android | MIT License |
multiple-stores/ui/src/main/java/com/dladukedev/random_generator/ui/App.kt | dladukedev | 245,312,038 | false | null | package com.dladukedev.random_generator.ui
import androidx.compose.Composable
import androidx.ui.material.MaterialTheme
import com.dladukedev.random_generator.store.Message
import com.dladukedev.random_generator.store.RootStore
import oolong.Dispatch
@Composable
fun App(store: RootStore.Props, dispatch: Dispatch<Message>) {
MaterialTheme {
Router(store = store, dispatch = dispatch)
}
} | 0 | Kotlin | 0 | 0 | 6584d304bb5ace64deb531d4d64829cc36952a02 | 406 | Oolong-Exploration | MIT License |
src/main/kotlin/org/xbery/artbeams/users/service/CmsAuthenticationProvider.kt | beranradek | 354,546,253 | false | {"Kotlin": 289853, "JavaScript": 286267, "FreeMarker": 93300, "CSS": 12808, "Procfile": 100} | package org.xbery.artbeams.users.service
import org.springframework.security.authentication.AuthenticationProvider
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken
import org.springframework.security.core.Authentication
import org.springframework.security.core.authority.SimpleGrantedAuthority
import org.springframework.stereotype.Service
/**
* Spring Security {@link AuthenticationProvider} for logging users into CMS.
*
* @author <NAME>
*/
@Service
open class CmsAuthenticationProvider(private val loginService: LoginService) : AuthenticationProvider {
override fun authenticate(authentication: Authentication): Authentication? {
val username = authentication.name
val password = authentication.credentials.toString()
val user = loginService.login(username, password)
return if (user != null) {
UsernamePasswordAuthenticationToken(user.id + PrincipalSeparator + user.login, user.password, user.roles.map { role -> SimpleGrantedAuthority(role.name) })
} else {
null
}
}
override fun supports(authentication: Class<*>): Boolean {
return authentication.equals(UsernamePasswordAuthenticationToken::class.java)
}
companion object {
const val PrincipalSeparator: String = ":"
}
}
| 0 | Kotlin | 1 | 2 | 749096291c475c2546df8ff557f6666949936add | 1,335 | artbeams | Apache License 2.0 |
mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/model/Processor.kt | feilfeilundfeil | 206,069,014 | false | null | package de.jensklingenberg.mpapt.model
interface Processor {
/**
* The list of Annotations that should be detected by the processor.
*
*/
fun getSupportedAnnotationTypes(): Set<String>
/**
* TODO: Implement check for source version
*/
fun getSupportedSourceVersion(): SourceVersion
/**
* This gets triggered when a new module(jvmMain,jsMain,..) is getting parsed by the processor
*/
fun initProcessor()
/**
* This gets triggered when a new annotation was found
* */
fun process(roundEnvironment: RoundEnvironment)
/**
* This get triggered when the last class of a module was parsed.
*/
fun processingOver()
fun isTargetPlatformSupported() : Boolean
}
| 3 | Kotlin | 4 | 32 | 10aa7bd48f9a6d5f31bdae84bc9a68d29e3e3e97 | 760 | kotlin-native-suspend-function-callback | Apache License 2.0 |
kotlin/gradle/assets/basic_class.kt | yrsegal | 132,512,860 | false | null | package ${mod_group}
import net.minecraftforge.fml.common.Mod
@Mod(modid = ${mod_class}.MOD_ID, name = ${mod_class}.MOD_NAME, version = ${mod_class}.VERSION, dependencies = ${mod_class}.DEPENDENCIES)
class ${mod_class} {
companion object {
const val MOD_ID = "${mod_id}"
const val MOD_NAME = "${mod_name}"
const val VERSION = "%VERSION%"
const val DEPENDENCIES = "required-after:forgelin"
}
}
| 1 | null | 1 | 1 | 8dbe2f42714fc74d52279babdcc82755b5522253 | 435 | ModdingStarter | MIT License |
exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/statements/StatementInterceptor.kt | rollin505 | 243,797,561 | true | {"Kotlin": 686746} | package org.jetbrains.exposed.sql.statements
import org.jetbrains.exposed.sql.Transaction
import org.jetbrains.exposed.sql.statements.api.PreparedStatementApi
interface StatementInterceptor {
fun beforeExecution(transaction: Transaction, context: StatementContext) {}
fun afterExecution(transaction: Transaction, contexts: List<StatementContext>, executedStatement: PreparedStatementApi) {}
fun beforeCommit(transaction: Transaction) {}
fun afterCommit() {}
fun beforeRollback(transaction: Transaction) {}
fun afterRollback() {}
}
interface GlobalStatementInterceptor : StatementInterceptor
| 0 | null | 0 | 2 | d91825f544552ce2f343d63f585eeb93c02ef894 | 620 | Exposed | Apache License 2.0 |
src/main/kotlin/com/example/coreweb/scheduling/templates/reminder.template.kt | teambankrupt | 292,072,114 | false | {"Kotlin": 287703, "Java": 61650, "HTML": 22230} | package com.example.coreweb.scheduling.templates
fun reminderTemplate(subject: String, message: String) = """
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Reminder: ${subject}</title>
<style>
body {
font-family: sans-serif;
margin: 0;
padding: 20px;
text-align: center;
}
.container {
width: 80%;
max-width: 600px;
margin: 0 auto;
}
h1 {
font-size: 24px;
margin-bottom: 15px;
}
.reminder-msg {
font-size: 20px;
font-weight: bold;
background-color: #f0f0f0;
padding: 10px 20px;
border-radius: 5px;
margin-bottom: 20px;
}
p {
font-size: 16px;
line-height: 1.5;
}
</style>
</head>
<body>
<div class="container">
<h1>$subject</h1>
<div class="reminder-msg">$message</div>
<p>Thanks</p>
</div>
</body>
</html>
""" | 3 | Kotlin | 0 | 2 | e6613a4ac6cac29a67029d9073b53c1a2aa3767f | 1,155 | coreweb | Apache License 2.0 |
framework/src/main/kotlin/dev/alpas/queue/console/stubs/Stubs.kt | deye9 | 230,527,304 | true | {"Kotlin": 381118, "Shell": 1497, "JavaScript": 622, "CSS": 402} | package dev.alpas.queue.console.stubs
internal class Stubs {
companion object {
fun jobStub(): String {
return """
package StubPackageName
import dev.alpas.Container
import dev.alpas.queue.job.Job
class StubClazzName : Job() {
override fun invoke(container: Container) {
}
}
""".trimIndent()
}
fun queueTablesStub(): String {
return """
package StubPackageName
import dev.alpas.ozone.migration.Migration
import dev.alpas.queue.database.FailedJobRecords
import dev.alpas.queue.database.JobRecords
class StubClazzName : Migration() {
override fun up() {
createTable(JobRecords)
createTable(FailedJobRecords)
}
override fun down() {
dropTable(FailedJobRecords)
dropTable(JobRecords)
}
}
""".trimIndent()
}
}
}
| 0 | Kotlin | 0 | 0 | 8793b5e6667ab1003f9972042ea764c00dd98326 | 1,193 | alpas | MIT License |
app/src/main/java/com/miw/dsdm/miwlibrary/ui/activities/BookActivity.kt | TaniaAlvarezDiaz | 260,258,199 | false | null | package com.miw.dsdm.miwlibrary.ui.activities
import android.app.AlertDialog
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.View
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.bumptech.glide.Glide
import com.miw.dsdm.miwlibrary.R
import com.miw.dsdm.miwlibrary.data.storage.local.Settings
import com.miw.dsdm.miwlibrary.model.Book
import dmax.dialog.SpotsDialog
import kotlinx.android.synthetic.main.activity_book.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import splitties.alertdialog.appcompat.alertDialog
import splitties.alertdialog.appcompat.message
import splitties.alertdialog.appcompat.okButton
import splitties.alertdialog.appcompat.onShow
class BookActivity : AppCompatActivity() {
companion object {
const val BOOK = "BookActivity:book"
}
private lateinit var loadingDialog: AlertDialog
lateinit var book: Book
private var userEmail: String = ""
private var favorite: Boolean = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_book)
initialize()
}
override fun onSupportNavigateUp(): Boolean {
onBackPressed()
return true
}
/**
* Function to initialize components
*/
private fun initialize() {
//User logged
userEmail = Settings(this).userLoggedIn.toString()
//Loading
loadingDialog = SpotsDialog.Builder().setContext(this).setTheme(R.style.dialog).setCancelable(false).build()
//Toolbar
setSupportActionBar(book_toolbar)
//Get book from Intent
book = intent.getParcelableExtra(BOOK)
if (book != null) fillFields()
//Button
book_btn_add_favorites.setOnClickListener {
if (favorite) deleteFavoriteBook(book)
else addFavoriteBook(book)
}
//Check if the book is favorite or not
isFavorite()
}
/**
* Function to fill fields with the information from the book
*/
private fun fillFields() {
with(book) {
//Image
Glide.with(this@BookActivity).load(imagePath).error(R.drawable.book_cover_not_available).into(book_image)
//Title
showHideComponents(book_title, book_title_value, title)
//Author
showHideComponents(book_author, book_author_value, author)
//Publisher
showHideComponents(book_publisher, book_publisher_value, publisher)
//Publication year
showHideComponents(book_publication_year, book_publication_year_value, publicationYear)
//Language
showHideComponents(book_language, book_language_value, language)
//Summary
showHideComponents(book_summary, book_summary_value, summary)
//Content
showHideComponents(book_content, book_content_value, content)
//Details url
book_more_information.visibility = if (detailsUrl.isNullOrEmpty()) View.GONE else View.VISIBLE
book_more_information.setOnClickListener { goToUrl() }
}
}
/**
* Function to hide components if value that is passed by parameter is empty, otherwise the value is assigned
*/
private fun showHideComponents(componentLabel: TextView, componentValue: TextView, value: String?) {
componentLabel.visibility = if (value.isNullOrEmpty()) View.GONE else View.VISIBLE
componentValue.visibility = if (value.isNullOrEmpty()) View.GONE else View.VISIBLE
if (!value.isNullOrEmpty()) componentValue.text = value
}
/**
* Function to go to the book link
*/
private fun goToUrl() {
val webpage = Uri.parse(if (book.detailsUrl?.substring(0..3) == "http") book.detailsUrl else "http://$this")
val intent = Intent(Intent.ACTION_VIEW, webpage)
if (intent.resolveActivity(packageManager) != null) startActivity(intent)
}
/**
* Function to check if the book is favorite or not
*/
private fun isFavorite() {
loadingDialog.show()
CoroutineScope(Dispatchers.IO).launch {
val result = Book.isFavoriteBook(userEmail, book)
if (result != null) {
favorite = result
withContext(Dispatchers.Main) {
loadingDialog.dismiss()
changeButtonName()
}
} else {
withContext(Dispatchers.Main) {
loadingDialog.dismiss()
changeButtonName()
}
}
}
}
/**
* Function to change button name
*/
private fun changeButtonName() {
book_btn_add_favorites.text = if (favorite) getString(R.string.book_btn_delete_favorites) else getString(R.string.book_btn_add_favorites)
}
/**
* Delete favorite book
*/
fun deleteFavoriteBook(book: Book) {
loadingDialog.show()
CoroutineScope(Dispatchers.IO).launch {
Book.deleteFavoriteBook(userEmail, book)
withContext(Dispatchers.Main) {
favorite = false
loadingDialog.dismiss()
showDialog(getString(R.string.book_delete_favorite_alert_message))
}
}
}
/**
* Add favorite book
*/
fun addFavoriteBook(book: Book) {
loadingDialog.show()
CoroutineScope(Dispatchers.IO).launch {
Book.saveFavoriteBook(userEmail, book)
withContext(Dispatchers.Main) {
favorite = true
loadingDialog.dismiss()
showDialog(getString(R.string.book_save_favorite_alert_message))
}
}
}
/**
* Function to show an alert dialog
*/
private fun showDialog(m: String) {
alertDialog {
message = m
okButton { changeButtonName() }
}.onShow {
setCancelable(false)
}.show()
}
}
| 0 | Kotlin | 0 | 0 | 12882e4043e8bf26a6aa40ac34d674f1d0d44d35 | 6,222 | MIWLibrary | MIT License |
smash-ranks-android/app/src/main/java/com/garpr/android/features/player/PlayerActivity.kt | charlesmadere | 41,832,700 | true | null | package com.garpr.android.features.player
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.lifecycle.Observer
import androidx.palette.graphics.Palette
import androidx.recyclerview.widget.RecyclerView
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.garpr.android.R
import com.garpr.android.data.models.AbsPlayer
import com.garpr.android.data.models.FavoritePlayer
import com.garpr.android.data.models.Region
import com.garpr.android.extensions.layoutInflater
import com.garpr.android.extensions.putOptionalExtra
import com.garpr.android.extensions.requireStringExtra
import com.garpr.android.extensions.showAddOrRemoveFavoritePlayerDialog
import com.garpr.android.extensions.verticalPositionInWindow
import com.garpr.android.features.common.activities.BaseActivity
import com.garpr.android.features.common.views.NoResultsItemView
import com.garpr.android.features.headToHead.HeadToHeadActivity
import com.garpr.android.features.player.PlayerViewModel.ListItem
import com.garpr.android.features.tournament.TournamentActivity
import com.garpr.android.features.tournaments.TournamentDividerView
import com.garpr.android.misc.ColorListener
import com.garpr.android.misc.Refreshable
import com.garpr.android.misc.RegionHandleUtils
import com.garpr.android.misc.Searchable
import com.garpr.android.misc.ShareUtils
import kotlinx.android.synthetic.main.activity_player.*
import org.koin.android.ext.android.inject
import org.koin.androidx.viewmodel.ext.android.viewModel
class PlayerActivity : BaseActivity(), ColorListener, MatchItemView.Listeners,
PlayerProfileItemView.Listeners, Refreshable, Searchable,
SwipeRefreshLayout.OnRefreshListener, TournamentDividerView.Listener {
private val adapter = Adapter(this, this, this, this)
private val playerId: String by lazy { intent.requireStringExtra(EXTRA_PLAYER_ID) }
override val activityName = TAG
private val viewModel: PlayerViewModel by viewModel()
protected val regionHandleUtils: RegionHandleUtils by inject()
protected val shareUtils: ShareUtils by inject()
private fun checkNameAndRegionViewScrollStates() {
val view = recyclerView.getChildAt(0) as? PlayerProfileItemView?
if (view == null) {
toolbar.fadeInTitleAndSubtitle()
return
}
val ratingVerticalPositionInWindow = view.ratingVerticalPositionInWindow
val toolbarVerticalPositionInWindow = toolbar.verticalPositionInWindow + toolbar.height
if (ratingVerticalPositionInWindow <= toolbarVerticalPositionInWindow) {
toolbar.fadeInTitleAndSubtitle()
} else {
toolbar.fadeOutTitleAndSubtitle()
}
}
private fun fetchPlayer() {
viewModel.fetchPlayer()
}
private fun initListeners() {
viewModel.stateLiveData.observe(this, Observer {
refreshState(it)
})
}
override fun onBackPressed() {
if (toolbar.isSearchFieldExpanded) {
toolbar.closeSearchField()
} else {
super.onBackPressed()
}
}
override fun onClick(v: MatchItemView) {
val player = viewModel.player ?: return
startActivity(HeadToHeadActivity.getLaunchIntent(
context = this,
player = player,
match = v.match,
region = regionHandleUtils.getRegion(this)
))
}
override fun onClick(v: TournamentDividerView) {
startActivity(TournamentActivity.getLaunchIntent(
context = this,
tournament = v.tournament,
region = regionHandleUtils.getRegion(this)
))
}
override fun onCompareClick(v: PlayerProfileItemView) {
startActivity(HeadToHeadActivity.getLaunchIntent(
context = this,
player = v.identity,
opponent = v.player,
region = regionHandleUtils.getRegion(this)
))
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
viewModel.initialize(regionHandleUtils.getRegion(this), playerId)
setContentView(R.layout.activity_player)
initListeners()
fetchPlayer()
}
override fun onFavoriteOrUnfavoriteClick(v: PlayerProfileItemView) {
viewModel.addOrRemoveFromFavorites()
}
override fun onLongClick(v: MatchItemView) {
supportFragmentManager.showAddOrRemoveFavoritePlayerDialog(
player = v.match.opponent,
region = regionHandleUtils.getRegion(this)
)
}
override fun onPaletteBuilt(palette: Palette?) {
if (isAlive) {
toolbar.onPaletteBuilt(palette)
}
}
override fun onRefresh() {
refresh()
}
override fun onShareClick(v: PlayerProfileItemView) {
shareUtils.sharePlayer(this, v.player)
}
private val onScrollListener = object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
checkNameAndRegionViewScrollStates()
}
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
super.onScrollStateChanged(recyclerView, newState)
checkNameAndRegionViewScrollStates()
}
}
override fun onUrlClick(v: PlayerProfileItemView, url: String?) {
shareUtils.openUrl(this, url)
}
override fun onViewsBound() {
super.onViewsBound()
toolbar.searchable = this
refreshLayout.setOnRefreshListener(this)
recyclerView.setHasFixedSize(true)
recyclerView.addOnScrollListener(onScrollListener)
recyclerView.adapter = adapter
}
override fun refresh() {
fetchPlayer()
}
private fun refreshState(state: PlayerViewModel.State) {
toolbar.titleText = state.titleText
toolbar.subtitleText = state.subtitleText
toolbar.showSearchIcon = if (toolbar.isSearchFieldExpanded) false else state.showSearchIcon
if (state.hasError) {
adapter.clear()
recyclerView.visibility = View.GONE
error.visibility = View.VISIBLE
} else {
adapter.set(state.searchResults ?: state.list)
error.visibility = View.GONE
recyclerView.visibility = View.VISIBLE
}
refreshLayout.isRefreshing = state.isFetching
}
override fun search(query: String?) {
viewModel.searchQuery = query
}
companion object {
private const val TAG = "PlayerActivity"
private val CNAME = PlayerActivity::class.java.canonicalName
private val EXTRA_PLAYER_ID = "$CNAME.PlayerId"
fun getLaunchIntent(context: Context, player: AbsPlayer, region: Region? = null): Intent {
var regionCopy = region
if (player is FavoritePlayer) {
regionCopy = player.region
}
return getLaunchIntent(context, player.id, regionCopy)
}
fun getLaunchIntent(context: Context, playerId: String, region: Region? = null): Intent {
return Intent(context, PlayerActivity::class.java)
.putExtra(EXTRA_PLAYER_ID, playerId)
.putOptionalExtra(EXTRA_REGION, region)
}
}
private class Adapter(
private val colorListener: ColorListener,
private val matchItemViewListeners: MatchItemView.Listeners,
private val playerProfileItemViewListeners: PlayerProfileItemView.Listeners,
private val tournamentDividerViewListener: TournamentDividerView.Listener
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
private val list = mutableListOf<ListItem>()
init {
setHasStableIds(true)
}
private fun bindMatch(holder: MatchViewHolder, item: ListItem.Match) {
holder.matchItemView.setContent(
match = item.match,
isIdentity = item.isIdentity
)
}
private fun bindNoResults(holder: NoResultsViewHolder, item: ListItem.NoResults) {
holder.noResultsItemView.setContent(item.query)
}
private fun bindPlayer(holder: PlayerViewHolder, item: ListItem.Player) {
holder.playerProfileItemView.setContent(
identity = item.identity,
region = item.region,
isFavorited = item.isFavorited,
player = item.player,
smashCompetitor = item.smashCompetitor
)
}
private fun bindTournament(holder: TournamentViewHolder, item: ListItem.Tournament) {
holder.tournamentDividerView.setContent(item.tournament)
}
internal fun clear() {
list.clear()
notifyDataSetChanged()
}
override fun getItemCount(): Int = list.size
override fun getItemId(position: Int): Long = list[position].listId
override fun getItemViewType(position: Int): Int {
return when (list[position]) {
is ListItem.Match -> VIEW_TYPE_MATCH
is ListItem.NoMatches -> VIEW_TYPE_NO_MATCHES
is ListItem.NoResults -> VIEW_TYPE_NO_RESULTS
is ListItem.Player -> VIEW_TYPE_PLAYER
is ListItem.Tournament -> VIEW_TYPE_TOURNAMENT
}
}
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
when (val item = list[position]) {
is ListItem.Match -> bindMatch(holder as MatchViewHolder, item)
is ListItem.NoMatches -> { /* intentionally empty */ }
is ListItem.NoResults -> bindNoResults(holder as NoResultsViewHolder, item)
is ListItem.Player -> bindPlayer(holder as PlayerViewHolder, item)
is ListItem.Tournament -> bindTournament(holder as TournamentViewHolder, item)
else -> throw RuntimeException("unknown item: $item, position: $position")
}
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
val inflater = parent.layoutInflater
return when (viewType) {
VIEW_TYPE_MATCH -> MatchViewHolder(matchItemViewListeners,
inflater.inflate(R.layout.item_match, parent, false))
VIEW_TYPE_NO_MATCHES -> NoMatchesViewHolder(
parent.context.getString(R.string.no_matches),
inflater.inflate(R.layout.item_string, parent, false))
VIEW_TYPE_NO_RESULTS -> NoResultsViewHolder(inflater.inflate(
R.layout.item_no_results, parent, false))
VIEW_TYPE_PLAYER -> PlayerViewHolder(colorListener, playerProfileItemViewListeners,
inflater.inflate(R.layout.item_player_profile, parent, false))
VIEW_TYPE_TOURNAMENT -> TournamentViewHolder(tournamentDividerViewListener,
inflater.inflate(R.layout.divider_tournament, parent, false))
else -> throw IllegalArgumentException("unknown viewType: $viewType")
}
}
internal fun set(list: List<ListItem>?) {
this.list.clear()
if (!list.isNullOrEmpty()) {
this.list.addAll(list)
}
notifyDataSetChanged()
}
companion object {
private const val VIEW_TYPE_MATCH = 0
private const val VIEW_TYPE_NO_MATCHES = 1
private const val VIEW_TYPE_NO_RESULTS = 2
private const val VIEW_TYPE_PLAYER = 3
private const val VIEW_TYPE_TOURNAMENT = 4
}
}
private class MatchViewHolder(
listeners: MatchItemView.Listeners,
itemView: View
) : RecyclerView.ViewHolder(itemView) {
internal val matchItemView: MatchItemView = itemView as MatchItemView
init {
matchItemView.listeners = listeners
}
}
private class NoMatchesViewHolder(
text: CharSequence,
itemView: View
) : RecyclerView.ViewHolder(itemView) {
init {
(itemView as TextView).text = text
}
}
private class NoResultsViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
internal val noResultsItemView: NoResultsItemView = itemView as NoResultsItemView
}
private class PlayerViewHolder(
colorListener: ColorListener,
listeners: PlayerProfileItemView.Listeners,
itemView: View
) : RecyclerView.ViewHolder(itemView) {
internal val playerProfileItemView: PlayerProfileItemView = itemView as PlayerProfileItemView
init {
playerProfileItemView.colorListener = colorListener
playerProfileItemView.listeners = listeners
}
}
private class TournamentViewHolder(
listener: TournamentDividerView.Listener,
itemView: View
) : RecyclerView.ViewHolder(itemView) {
internal val tournamentDividerView: TournamentDividerView = itemView as TournamentDividerView
init {
tournamentDividerView.listener = listener
}
}
}
| 0 | Kotlin | 0 | 9 | 151b2a0f9b4d38be60c3f73344ca444f17810bfd | 13,604 | smash-ranks-android | The Unlicense |
app/src/main/kotlin/com/myweatherapp/data/datasource/database/weather/WeatherDAO.kt | uniflow-kt | 215,817,717 | false | null | package com.myweatherapp.data.datasource.database.weather
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import java.util.*
@Dao
interface WeatherDAO {
@Insert
fun saveAll(entities: List<WeatherEntity>)
@Query("SELECT * FROM weather WHERE id = :id")
fun findWeatherById(id: String): WeatherEntity
@Query("SELECT * FROM weather WHERE location = :location AND date = :date")
fun findAllBy(location: String, date: Date): List<WeatherEntity>
@Query("SELECT * FROM weather ORDER BY date DESC")
fun findLatestWeather(): List<WeatherEntity>
} | 0 | Kotlin | 3 | 13 | 4d4aa55e3a784f261d4c5711376f9435e04d2718 | 606 | weatherapp-uniflow | Apache License 2.0 |
src/Composite/GroupOfShapes.kt | ahmedsamir9 | 289,471,137 | false | null | package Composite
class GroupOfShapes (val groupName: String): Shape {
private val list = ArrayList<Shape>()
fun addShape(shape: Shape){
list.add(shape)
}
override fun render() {
println("this is $groupName")
for (shape in list){
shape.render()
}
}
} | 0 | Kotlin | 3 | 11 | 6eaffe8a65e401934a2412ee4847b48aef0b8c12 | 317 | DesignPatternsInkotlin- | MIT License |
src/main/kotlin/dev/sterner/common/item/equipment/ichor/IchoriumVorpal.kt | mrsterner | 854,711,582 | false | {"Kotlin": 689799, "Java": 29898, "GLSL": 3356} | package dev.sterner.common.item.equipment.ichor
import com.mojang.datafixers.util.Pair
import dev.sterner.api.item.ItemAbility
import dev.sterner.api.util.VoidBoundItemUtils
import dev.sterner.common.item.equipment.GalesEdgeItem.Companion.ascend
import dev.sterner.mixin.HoeItemTillablesAccessor
import net.minecraft.core.BlockPos
import net.minecraft.core.NonNullList
import net.minecraft.server.level.ServerLevel
import net.minecraft.sounds.SoundEvents
import net.minecraft.sounds.SoundSource
import net.minecraft.tags.BlockTags
import net.minecraft.world.Containers
import net.minecraft.world.InteractionHand
import net.minecraft.world.InteractionResult
import net.minecraft.world.InteractionResultHolder
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Tier
import net.minecraft.world.item.context.UseOnContext
import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.phys.BlockHitResult
import team.lodestar.lodestone.systems.item.tools.magic.MagicSwordItem
import java.util.function.Consumer
import java.util.function.Predicate
class IchoriumVorpal(
tier: Tier,
attackDamageModifier: Int,
attackSpeedModifier: Float,
magicDamage: Float,
properties: Properties
) : MagicSwordItem(
tier, attackDamageModifier,
attackSpeedModifier,
magicDamage,
properties
) {
override fun getUseDuration(stack: ItemStack): Int {
return 72000
}
override fun use(level: Level, player: Player, usedHand: InteractionHand): InteractionResultHolder<ItemStack> {
if (VoidBoundItemUtils.getActiveAbility(player.mainHandItem) != ItemAbility.HARVEST) {
player.startUsingItem(usedHand)
}
return super.use(level, player, usedHand)
}
override fun useOn(context: UseOnContext): InteractionResult {
val player = context.player
if (player!!.isShiftKeyDown) {
return super.useOn(context)
}
if (VoidBoundItemUtils.getActiveAbility(player.mainHandItem) == ItemAbility.HARVEST) {
for (xx in -1..1) {
for (zz in -1..1) {
useHoeOn(
UseOnContext(
player, player.usedItemHand,
BlockHitResult(
context.clickLocation,
context.horizontalDirection,
context.clickedPos.offset(xx, 0, zz),
context.isInside
)
)
)
}
}
return InteractionResult.SUCCESS
}
return InteractionResult.PASS
}
fun useHoeOn(context: UseOnContext): InteractionResult {
val level = context.level
val blockPos = context.clickedPos
val pair =
HoeItemTillablesAccessor.getTILLABLES()[level.getBlockState(blockPos).block] as Pair<Predicate<UseOnContext>, Consumer<UseOnContext>>?
if (pair == null) {
return InteractionResult.PASS
} else {
val predicate = pair.first
val consumer = pair.second
if (predicate.test(context)) {
val player = context.player
level.playSound(player, blockPos, SoundEvents.HOE_TILL, SoundSource.BLOCKS, 1.0f, 1.0f)
if (!level.isClientSide) {
consumer.accept(context)
if (player != null) {
context.itemInHand.hurtAndBreak(
1, player
) { playerx: Player ->
playerx.broadcastBreakEvent(
context.hand
)
}
}
}
return InteractionResult.sidedSuccess(level.isClientSide)
} else {
return InteractionResult.PASS
}
}
}
override fun mineBlock(
stack: ItemStack,
level: Level,
state: BlockState,
pos: BlockPos,
miningEntity: LivingEntity
): Boolean {
if (level is ServerLevel && state.`is`(BlockTags.CROPS)) {
val list = NonNullList.create<ItemStack>()
list.addAll(Block.getDrops(state, level, pos, null, miningEntity, stack))
Containers.dropContents(level, pos, list)
}
return super.mineBlock(stack, level, state, pos, miningEntity)
}
override fun onUseTick(level: Level, player: LivingEntity, stack: ItemStack, remainingUseDuration: Int) {
if (VoidBoundItemUtils.getActiveAbility(player.mainHandItem) != ItemAbility.HARVEST) {
ascend(player, stack, this.getUseDuration(stack) - remainingUseDuration)
}
super.onUseTick(level, player, stack, remainingUseDuration)
}
} | 0 | Kotlin | 0 | 1 | 6ae8ea7a62e6deb2326662e9498c7d31466db9e4 | 5,119 | voidbound | MIT License |
app/src/main/java/com/deevvdd/pomelofashion/features/main/MainViewModel.kt | HeinXtet | 375,643,967 | false | null | package com.deevvdd.pomelofashion.features.main
import android.content.Context
import android.location.Location
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import androidx.lifecycle.viewModelScope
import com.deevvdd.domain.model.result.Pickup
import com.deevvdd.domain.repository.PickupLocationRepository
import com.deevvdd.pomelofashion.base.BaseViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject
import kotlinx.coroutines.launch
import timber.log.Timber
/**
* Created by heinhtet <EMAIL> on 08,June,2021
*/
@HiltViewModel
class MainViewModel @Inject constructor(
@ApplicationContext context: Context,
private val repository: PickupLocationRepository
) : BaseViewModel<MainEvent>() {
private val _pickupLocations = MutableLiveData<List<Pickup>>()
private val _loading = MutableLiveData<Boolean>()
private val _errorFetchingPickupLocation = MutableLiveData<String?>()
val errorFetchingPickupLocation: LiveData<String?>
get() {
return _errorFetchingPickupLocation
}
val loading: LiveData<Boolean>
get() {
return _loading
}
val pickupLocations =
Transformations.map(_pickupLocations) {
it
}
init {
fetchPickupLocation()
}
fun fetchPickupLocation() {
_errorFetchingPickupLocation.value = null
viewModelScope.launch {
_loading.value = true
repository.fetchPickupLocation().collect({
_loading.value = false
_errorFetchingPickupLocation.value = it.message
}, {
_errorFetchingPickupLocation.value = null
_loading.value = false
_pickupLocations.value = it
Timber.d("data list $it")
})
}
}
fun filterLocation(location: Location) {
viewModelScope.launch {
repository.filterByLocation(location).let {
_pickupLocations.value = it
}
}
}
}
| 0 | Kotlin | 0 | 0 | bbe2c07506c95d3c55a3a57f49c283e1e0879e39 | 2,177 | Pomelo-Test | Apache License 2.0 |
app/src/main/java/org/rakulee/buup/fragments/employer/EmployerSaved.kt | rakuleethomas | 392,158,334 | false | null | package org.rakulee.buup.fragments.employer
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.activityViewModels
import androidx.navigation.NavDirections
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.DividerItemDecoration
import dagger.hilt.android.AndroidEntryPoint
import org.rakulee.buup.R
import org.rakulee.buup.adapters.EmployerSavedJobSeekersAdapter
import org.rakulee.buup.adapters.EmployerSavedListAdapter
import org.rakulee.buup.databinding.FragmentEmployerSavedBinding
import org.rakulee.buup.model.BuupJobSeekerProfile
import org.rakulee.buup.model.EmployerSavedListItem
import org.rakulee.buup.viewmodel.EmployerViewModel
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private const val ARG_PARAM1 = "param1"
private const val ARG_PARAM2 = "param2"
/**
* A simple [Fragment] subclass.
* Use the [EmployerSaved.newInstance] factory method to
* create an instance of this fragment.
*/
@AndroidEntryPoint
class EmployerSaved : Fragment() {
// TODO: Rename and change types of parameters
private var param1: String? = null
private var param2: String? = null
lateinit var binding : FragmentEmployerSavedBinding
val viewModel : EmployerViewModel by activityViewModels()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.let {
param1 = it.getString(ARG_PARAM1)
param2 = it.getString(ARG_PARAM2)
}
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_employer_saved, container, false)
val list : ArrayList<BuupJobSeekerProfile> = viewModel.jobSeekerList.value!!
val adapter = EmployerSavedJobSeekersAdapter()
adapter.update(list)
binding.rvSavedJob.adapter = adapter
binding.rvSavedJob.addItemDecoration(DividerItemDecoration(context, DividerItemDecoration.VERTICAL))
return binding.root
}
fun showDetail(){
val directions : NavDirections = EmployerSavedDirections.actionMainEmpSavedToEmployerJobDetail()
findNavController().navigate(directions)
}
companion object {
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment EmployerSaved.
*/
// TODO: Rename and change types and number of parameters
@JvmStatic
fun newInstance(param1: String, param2: String) =
EmployerSaved().apply {
arguments = Bundle().apply {
putString(ARG_PARAM1, param1)
putString(ARG_PARAM2, param2)
}
}
}
} | 0 | Kotlin | 0 | 1 | 25cd37e90bd8539f1735b2cc8f28f27b62471973 | 3,253 | Bu-up | MIT License |
src/main/kotlin/org/rust/ide/fixes/ConvertToUnsuffixedIntegerFix.kt | intellij-rust | 42,619,487 | false | null | /*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package org.rust.ide.fixes
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElement
import org.rust.lang.core.psi.RsLitExpr
import org.rust.lang.core.psi.RsLiteralKind
import org.rust.lang.core.psi.RsPsiFactory
import org.rust.lang.core.psi.kind
class ConvertToUnsuffixedIntegerFix private constructor(
element: RsLitExpr,
private val textTemplate: String
): RsQuickFixBase<RsLitExpr>(element) {
override fun getFamilyName(): String = "Convert to unsuffixed integer"
override fun getText(): String {
return String.format(textTemplate, convertToUnsuffixedInteger(myStartElement.element))
}
override fun invoke(project: Project, editor: Editor?, element: RsLitExpr) {
val integer = convertToUnsuffixedInteger(element) ?: return
val psiFactory = RsPsiFactory(project)
element.replace(psiFactory.createExpression(integer))
}
companion object {
fun createIfCompatible(element: RsLitExpr, textTemplate: String): ConvertToUnsuffixedIntegerFix? {
if (convertToUnsuffixedInteger(element) != null) {
return ConvertToUnsuffixedIntegerFix(element, textTemplate)
}
return null
}
private fun convertToUnsuffixedInteger(element: PsiElement?): String? {
if (element == null) return null
if (element !is RsLitExpr) return null
val value = when (val kind = element.kind) {
is RsLiteralKind.Integer -> kind.value
is RsLiteralKind.Boolean -> null
is RsLiteralKind.Float -> kind.value?.toLong()
is RsLiteralKind.String -> kind.value?.toLongOrNull()
is RsLiteralKind.Char -> kind.value?.toLongOrNull()
null -> null
} ?: return null
return value.toString()
}
}
}
| 1,789 | Kotlin | 369 | 4,410 | 3037c1a1b4f71432eba5f88b94b4fadb907f9be7 | 2,030 | intellij-rust | MIT License |
src/main/kotlin/Client.kt | wafiahartono | 357,696,812 | false | null | import org.json.JSONObject
import java.security.*
import java.security.spec.X509EncodedKeySpec
import javax.crypto.Cipher
import javax.crypto.KeyAgreement
import javax.crypto.spec.SecretKeySpec
class Client(
private val serverResponseListener: (Client, Message) -> Unit
) {
private val server = Server()
private lateinit var messageEncryptionKey: Key
private var _user: User? = null
val user get() = _user
init {
verifyServer()
exchangeEncryptionKey()
}
private fun verifyServer() {
val signature = Signature.getInstance("SHA256withRSA")
val certificatePublicKey = KeyFactory.getInstance("RSA").generatePublic(
X509EncodedKeySpec(server.certificate.publicKey)
)
signature.initVerify(certificatePublicKey)
signature.update(server.certificate.content)
if (signature.verify(server.certificate.signature)) println("Server verified")
else throw IllegalStateException("Server cannot be verified")
}
private fun exchangeEncryptionKey() {
val keyPair = KeyPairGenerator.getInstance("DH").run {
initialize(4096)
return@run generateKeyPair()
}
val serverPublicKey = KeyFactory.getInstance("DH").generatePublic(
X509EncodedKeySpec(server.exchangeEncryptionKey(keyPair.public.encoded))
)
val sharedKey = KeyAgreement.getInstance("DH").apply {
init(keyPair.private)
doPhase(serverPublicKey, true)
}.generateSecret()
println("Client encryption key: ${sharedKey.toHexString()}")
messageEncryptionKey = SecretKeySpec(sharedKey, 0, 16, "AES")
}
private var signUpUserCache: User? = null
fun signUp(user: User) {
signUpUserCache = user.copy()
sendMessageToServer(Message(Command.SIGN_UP, user.toJSON()))
}
fun signIn(user: User) = sendMessageToServer(Message(Command.SIGN_IN, user.toJSON()))
fun getUser() = _user?.username?.let { sendMessageToServer(Message(Command.GET_USER, it)) }
fun signOut() {
_user = null
}
fun addBalance(amount: Int) = _user?.accountId?.let {
sendMessageToServer(
Message(Command.ADD_BALANCE, JSONObject().put("account_id", it).put("amount", amount))
)
}
fun checkAccountId(accountId: String) = sendMessageToServer(Message(Command.CHECK_ACCOUNT_ID, accountId))
fun doTransaction(destAccountId: String, amount: Int) = _user?.let {
sendMessageToServer(
Message(
Command.DO_TRANSACTION, Transaction(
from = it, to = User(accountId = destAccountId), amount = amount
).toJSON()
)
)
}
fun getTransactions() = _user?.accountId?.let { sendMessageToServer(Message(Command.GET_TRANSACTIONS, it)) }
private fun sendMessageToServer(message: Message) {
println("Send to server: $message")
val cipher = Cipher.getInstance("AES/CBC/PKCS5Padding")
cipher.init(Cipher.ENCRYPT_MODE, messageEncryptionKey)
val response = server.sendEncryptedData(
EncryptedData(cipher.doFinal(message.toJSON().toString().toByteArray()), cipher.parameters.encoded)
)
println("Server response: $response")
cipher.init(
Cipher.DECRYPT_MODE,
messageEncryptionKey,
AlgorithmParameters.getInstance("AES").apply { init(response.algorithmParameters) }
)
processServerMessage(Message(JSONObject(String(cipher.doFinal(response.data)))))
}
private fun processServerMessage(message: Message) {
println("Process server message: $message")
when (message.command) {
Command.SIGN_UP -> {
_user = if (message.data as Boolean) signUpUserCache!!.copy() else null
signUpUserCache = null
}
Command.SIGN_IN,
Command.GET_USER -> {
_user = if (message.data == null) null else User(message.data as JSONObject)
}
Command.ADD_BALANCE -> (message.data as? Int)?.let { _user = _user?.copy(balance = it) }
Command.CHECK_ACCOUNT_ID,
Command.DO_TRANSACTION,
Command.GET_TRANSACTIONS -> Unit
}
serverResponseListener(this, message)
}
}
| 0 | Kotlin | 0 | 0 | 091b0db587ac441f9e519ec7cb56565cbb78d07e | 4,362 | simple-internet-banking | MIT License |
presentation/src/main/java/com/mvi/presentation/contract/SplashContract.kt | saurabhomi | 807,760,015 | false | {"Kotlin": 107997} | package com.mvi.presentation.contract
import com.mvi.base.UiEvent
import com.mvi.base.UiState
class SplashContract {
sealed class Event : UiEvent {
data object Close : Event()
}
sealed class State : UiState {
data object Idle : State()
data object Loading : State()
}
} | 0 | Kotlin | 0 | 0 | e17a9fcce38b64ddc5ae32f4ad99a607b0c56ff8 | 315 | DummyApp | Apache License 2.0 |
app/src/main/java/com/allever/app/virtual/call/ui/IncomeCallActivity.kt | devallever | 242,982,031 | false | null | package com.allever.app.virtual.call.ui
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.os.SystemClock
import android.view.View
import android.view.WindowManager
import android.widget.Chronometer
import android.widget.ImageView
import android.widget.TextView
import com.allever.app.virtual.call.R
import com.allever.app.virtual.call.app.BaseActivity
import com.allever.app.virtual.call.app.Global
import com.allever.app.virtual.call.function.SettingHelper
import com.allever.app.virtual.call.service.VirtualCallService
import com.allever.app.virtual.call.ui.mvp.presenter.IncomeCallPresenter
import com.allever.app.virtual.call.ui.mvp.view.IncomeCallView
import com.allever.app.virtual.call.util.SystemUtils
import com.allever.lib.common.util.log
import java.util.*
class IncomeCallActivity : BaseActivity<IncomeCallView, IncomeCallPresenter>(),
IncomeCallView,
View.OnClickListener {
private lateinit var mInComeCallContainer: View
private lateinit var mCommunicateContainer: View
private lateinit var mBtnReject: View
private lateinit var mBtnAccept: View
private lateinit var mBtnMessage: View
private lateinit var mChronometer: Chronometer
private lateinit var mTvCommunicate: TextView
private lateinit var mIvAvatar: ImageView
private lateinit var mIvAvatarAccept: ImageView
override fun getContentView(): Any = R.layout.activity_in_come_call
override fun onCreate(savedInstanceState: Bundle?) {
window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED)
// setShowWhenLocked(true)
super.onCreate(savedInstanceState)
}
override fun initView() {
mPresenter.initInComeCall()
mInComeCallContainer = findViewById(R.id.in_come_container)
mCommunicateContainer = findViewById(R.id.communicate_container)
mBtnReject = findViewById<View>(R.id.in_come_iv_reject)
mBtnReject.setOnClickListener(this)
mBtnAccept = findViewById<View>(R.id.in_come_iv_accept)
mBtnAccept.setOnClickListener(this)
mBtnMessage = findViewById<View>(R.id.in_come_iv_send_message)
mBtnMessage.setOnClickListener(this)
mChronometer = findViewById(R.id.in_come_tv_time)
mTvCommunicate = findViewById(R.id.in_come_tv_communicate_to)
findViewById<TextView>(R.id.in_come_tv_local).text = SettingHelper.getLocal()
var contact = SettingHelper.getContact()
var phone = SettingHelper.getPhone()
try {
if (SettingHelper.getRandomContact() && !SettingHelper.getRepeat() && Global.contactList.isNotEmpty()) {
val random = Random()
val randomContact = Global.contactList[random.nextInt(Global.contactList.size)]
contact = randomContact.name
phone = randomContact.phone
}
} catch (e: Exception) {
e.printStackTrace()
}
findViewById<TextView>(R.id.in_come_tv_phone_number).text = phone
findViewById<TextView>(R.id.in_come_tv_name).text = contact
findViewById<View>(R.id.in_come_bg).setBackgroundResource(
Global.wallPagerItemMap[SettingHelper.getWallPagerTitle()]?.resId
?: R.drawable.default_bg
)
if (!SettingHelper.getRandomContact()) {
mIvAvatar = findViewById(R.id.ivAvatar)
mIvAvatarAccept = findViewById(R.id.ivAvatarAccept)
loadAvatar(mIvAvatar)
loadAvatar(mIvAvatarAccept)
}
mPresenter.play()
}
override fun initData() { }
override fun createPresenter(): IncomeCallPresenter =
IncomeCallPresenter()
override fun onDestroy() {
mPresenter.stop()
mPresenter.destroy()
super.onDestroy()
}
override fun onClick(v: View?) {
when (v?.id) {
R.id.in_come_iv_reject -> {
mChronometer.stop()
if (SettingHelper.getRepeat()) {
if (Global.leftRepeatCount > 0) {
VirtualCallService.start(this, true)
Global.leftRepeatCount --
}
}
finish()
}
R.id.in_come_iv_accept -> {
mPresenter.stop()
mBtnMessage.visibility = View.GONE
mBtnAccept.visibility = View.GONE
mBtnReject.visibility = View.VISIBLE
mInComeCallContainer.visibility = View.GONE
mCommunicateContainer.visibility = View.VISIBLE
mTvCommunicate.text = "与 ${SettingHelper.getContact()} 通话中"
mChronometer.base = SystemClock.elapsedRealtime()
mChronometer.start()
Global.leftRepeatCount = 0
}
R.id.in_come_iv_send_message -> {
Global.leftRepeatCount = 0
finish()
}
}
}
override fun onBackPressed() { }
private fun loadAvatar(imageView: ImageView) {
val uriString = SettingHelper.getAvatarPath()
if (uriString.isNotEmpty()) {
val uri = Uri.parse(uriString)
imageView.setImageURI(uri)
} else {
imageView.setImageResource(R.drawable.ic_contact)
}
}
companion object {
fun start(context: Context) {
val intent = Intent(context, IncomeCallActivity::class.java)
SystemUtils.wakeUpAndUnlock(context)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(intent)
}
}
} | 3 | Kotlin | 7 | 24 | 2881e1d2285d5ee459f40dffeed105c101bcafff | 5,687 | VirtualCallOpenSource | Apache License 2.0 |
android/src/main/java/org/ergoplatform/android/transactions/ErgoPaySigningFragment.kt | ergoplatform | 376,102,125 | false | null | package org.ergoplatform.android.transactions
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import org.ergoplatform.transactions.MessageSeverity
import org.ergoplatform.android.AppDatabase
import org.ergoplatform.android.Preferences
import org.ergoplatform.android.R
import org.ergoplatform.android.RoomWalletDbProvider
import org.ergoplatform.android.databinding.FragmentErgoPaySigningBinding
import org.ergoplatform.android.ui.AndroidStringProvider
import org.ergoplatform.android.ui.navigateSafe
import org.ergoplatform.transactions.reduceBoxes
import org.ergoplatform.uilogic.transactions.ErgoPaySigningUiLogic
import org.ergoplatform.wallet.addresses.getAddressLabel
import org.ergoplatform.wallet.getNumOfAddresses
class ErgoPaySigningFragment : SubmitTransactionFragment() {
private var _binding: FragmentErgoPaySigningBinding? = null
private val binding get() = _binding!!
private val args: ErgoPaySigningFragmentArgs by navArgs()
override val viewModel: ErgoPaySigningViewModel
get() = ViewModelProvider(this).get(ErgoPaySigningViewModel::class.java)
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = FragmentErgoPaySigningBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val viewModel = this.viewModel
val context = requireContext()
viewModel.uiLogic.init(
args.request,
args.walletId,
args.derivationIdx,
RoomWalletDbProvider(AppDatabase.getInstance(context)),
Preferences(context),
AndroidStringProvider(context)
)
viewModel.uiStateRefresh.observe(viewLifecycleOwner) { state ->
binding.layoutTransactionInfo.visibility =
visibleWhen(state, ErgoPaySigningUiLogic.State.WAIT_FOR_CONFIRMATION)
binding.layoutProgress.visibility =
visibleWhen(state, ErgoPaySigningUiLogic.State.FETCH_DATA)
binding.layoutDoneInfo.visibility =
visibleWhen(state, ErgoPaySigningUiLogic.State.DONE)
binding.layoutChooseAddress.visibility =
visibleWhen(state, ErgoPaySigningUiLogic.State.WAIT_FOR_ADDRESS)
when (state) {
ErgoPaySigningUiLogic.State.WAIT_FOR_ADDRESS -> {
// nothing to do
}
ErgoPaySigningUiLogic.State.FETCH_DATA -> showFetchData()
ErgoPaySigningUiLogic.State.WAIT_FOR_CONFIRMATION -> showTransactionInfo()
ErgoPaySigningUiLogic.State.DONE -> showDoneInfo()
null -> {} // impossible
}
}
viewModel.addressChosen.observe(viewLifecycleOwner) {
val walletLabel = viewModel.uiLogic.wallet?.walletConfig?.displayName ?: ""
val addressLabel =
it?.getAddressLabel(AndroidStringProvider(requireContext()))
?: getString(
R.string.label_all_addresses,
viewModel.uiLogic.wallet?.getNumOfAddresses()
)
binding.addressLabel.text =
getString(R.string.label_sign_with, addressLabel, walletLabel)
}
// Click listeners
binding.transactionInfo.buttonSignTx.setOnClickListener {
startAuthFlow(viewModel.uiLogic.wallet!!.walletConfig)
}
binding.buttonDismiss.setOnClickListener {
findNavController().popBackStack()
}
binding.buttonChooseAddress.setOnClickListener {
showChooseAddressList(false)
}
}
override fun onAddressChosen(addressDerivationIdx: Int?) {
super.onAddressChosen(addressDerivationIdx)
// redo the request - can't be done within uilogic because the context is needed
val uiLogic = viewModel.uiLogic
uiLogic.lastRequest?.let {
val context = requireContext()
uiLogic.hasNewRequest(
it,
Preferences(context),
AndroidStringProvider(context)
)
}
}
private fun visibleWhen(
state: ErgoPaySigningUiLogic.State?,
visibleWhen: ErgoPaySigningUiLogic.State
) =
if (state == visibleWhen) View.VISIBLE else View.GONE
private fun showFetchData() {
// nothing special to do yet
}
private fun showDoneInfo() {
// use normal tx done message in case of success
val uiLogic = viewModel.uiLogic
binding.tvMessage.text = uiLogic.getDoneMessage(AndroidStringProvider(requireContext()))
binding.tvMessage.setCompoundDrawablesRelativeWithIntrinsicBounds(
0,
getSeverityDrawableResId(uiLogic.getDoneSeverity()),
0, 0
)
}
private fun getSeverityDrawableResId(severity: MessageSeverity) =
when (severity) {
MessageSeverity.NONE -> 0
MessageSeverity.INFORMATION -> R.drawable.ic_info_24
MessageSeverity.WARNING -> R.drawable.ic_warning_amber_24
MessageSeverity.ERROR -> R.drawable.ic_error_outline_24
}
private fun showTransactionInfo() {
val uiLogic = viewModel.uiLogic
binding.transactionInfo.bindTransactionInfo(
uiLogic.transactionInfo!!.reduceBoxes(),
{ tokenId ->
findNavController().navigateSafe(
ErgoPaySigningFragmentDirections.actionErgoPaySigningToTokenInformation(tokenId)
)
},
layoutInflater
)
binding.layoutTiMessage.visibility = uiLogic.epsr?.message?.let {
binding.tvTiMessage.text = getString(R.string.label_message_from_dapp, it)
val severityResId = getSeverityDrawableResId(
uiLogic.epsr?.messageSeverity ?: MessageSeverity.NONE
)
binding.imageTiMessage.setImageResource(severityResId)
binding.imageTiMessage.visibility = if (severityResId == 0) View.GONE else View.VISIBLE
View.VISIBLE
} ?: View.GONE
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
} | 20 | Kotlin | 21 | 58 | 810bcb3c9cad0cf6c28b405ec001ef6a0466ec62 | 6,623 | ergo-wallet-android | Apache License 2.0 |
implementation/src/test/kotlin/com/aoc/maze/donut/planar/portal/Portal2DTest.kt | TomPlum | 227,887,094 | false | null | package com.aoc.maze.donut.planar.portal
import assertk.assertThat
import assertk.assertions.isEqualTo
import assertk.assertions.isFalse
import assertk.assertions.isTrue
import com.aoc.math.Point2D
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
class Portal2DTest {
@Test
fun hasEntrancePositive() {
val first = PortalEntrance2D(WarpCode2D('F', Point2D(4, 11), 'G', Point2D(4, 10)), Point2D(4, 12))
val second = PortalEntrance2D(WarpCode2D('F', Point2D(8, 0), 'G', Point2D(8, -1)), Point2D(8, 1))
assertThat(Portal2D(Pair(first, second)).hasEntrance(Point2D(8,1))).isTrue()
}
@Test
fun hasEntranceNegative() {
val first = PortalEntrance2D(WarpCode2D('F', Point2D(4, 11), 'G', Point2D(4, 10)), Point2D(4, 12))
val second = PortalEntrance2D(WarpCode2D('F', Point2D(8, 0), 'G', Point2D(8, -1)), Point2D(8, 1))
assertThat(Portal2D(Pair(first, second)).hasEntrance(Point2D(45,5))).isFalse()
}
@Test
fun warpWithValidEntrance() {
val first = PortalEntrance2D(WarpCode2D('F', Point2D(4, 11), 'G', Point2D(4, 10)), Point2D(4, 12))
val second = PortalEntrance2D(WarpCode2D('F', Point2D(8, 0), 'G', Point2D(8, -1)), Point2D(8, 1))
assertThat(Portal2D(Pair(first, second)).warpFrom(Point2D(4,12))).isEqualTo(Point2D(8,1))
}
@Test
fun warpWithInvalidEntrance() {
val first = PortalEntrance2D(WarpCode2D('F', Point2D(4, 11), 'G', Point2D(4, 10)), Point2D(4, 12))
val second = PortalEntrance2D(WarpCode2D('F', Point2D(8, 0), 'G', Point2D(8, -1)), Point2D(8, 1))
val e = assertThrows<IllegalArgumentException> { Portal2D(Pair(first, second)).warpFrom(Point2D(67, 34)) }
assertThat(e.message).isEqualTo("FG(4, 12)<->(8, 1) does not warp to or from (67, 34)")
}
@Test
fun toStringTest() {
val first = PortalEntrance2D(WarpCode2D('F', Point2D(4, 11), 'G', Point2D(4, 10)), Point2D(4, 12))
val second = PortalEntrance2D(WarpCode2D('F', Point2D(8, 0), 'G', Point2D(8, -1)), Point2D(8, 1))
assertThat(Portal2D(Pair(first, second)).toString()).isEqualTo("FG(4, 12)<->(8, 1)")
}
} | 7 | null | 1 | 2 | 12d47cc9c50aeb9e20bcf110f53d097d8dc3762f | 2,184 | advent-of-code-2019 | Apache License 2.0 |
ds3-autogen-go/src/test/kotlin/com/spectralogic/ds3autogen/go/generators/client/command/ReaderPayloadCommandGeneratorTest.kt | SpectraLogic | 43,916,943 | false | {"Gradle": 13, "Markdown": 8, "Shell": 1, "Ignore List": 1, "Batchfile": 1, "YAML": 1, "Java": 486, "JSON": 7, "Git Attributes": 9, "XML": 182, "Kotlin": 89, "FreeMarker": 19, "Fluent": 151, "Java Properties": 2} | /*
* ******************************************************************************
* Copyright 2014-2017 Spectra Logic Corporation. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
* this file except in compliance with the License. A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file.
* This file 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.spectralogic.ds3autogen.go.generators.client.command;
import com.spectralogic.ds3autogen.go.models.client.ReaderBuildLine
import com.spectralogic.ds3autogen.go.models.client.RequestBuildLine
import org.assertj.core.api.Assertions
import org.junit.Test
class ReaderPayloadCommandGeneratorTest {
private val generator = ReaderPayloadCommandGenerator()
@Test
fun toReaderBuildLineTest() {
Assertions.assertThat<RequestBuildLine>(generator.toReaderBuildLine())
.isNotEmpty
.contains(ReaderBuildLine("request.Content"))
}
}
| 0 | Java | 4 | 4 | 9c94ab811c002cbc978e27735512adaf543cd58e | 1,350 | ds3_autogen | Apache License 2.0 |
ds3-autogen-go/src/test/kotlin/com/spectralogic/ds3autogen/go/generators/client/command/ReaderPayloadCommandGeneratorTest.kt | SpectraLogic | 43,916,943 | false | {"Gradle": 13, "Markdown": 8, "Shell": 1, "Ignore List": 1, "Batchfile": 1, "YAML": 1, "Java": 486, "JSON": 7, "Git Attributes": 9, "XML": 182, "Kotlin": 89, "FreeMarker": 19, "Fluent": 151, "Java Properties": 2} | /*
* ******************************************************************************
* Copyright 2014-2017 Spectra Logic Corporation. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
* this file except in compliance with the License. A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file.
* This file 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.spectralogic.ds3autogen.go.generators.client.command;
import com.spectralogic.ds3autogen.go.models.client.ReaderBuildLine
import com.spectralogic.ds3autogen.go.models.client.RequestBuildLine
import org.assertj.core.api.Assertions
import org.junit.Test
class ReaderPayloadCommandGeneratorTest {
private val generator = ReaderPayloadCommandGenerator()
@Test
fun toReaderBuildLineTest() {
Assertions.assertThat<RequestBuildLine>(generator.toReaderBuildLine())
.isNotEmpty
.contains(ReaderBuildLine("request.Content"))
}
}
| 0 | Java | 4 | 4 | 9c94ab811c002cbc978e27735512adaf543cd58e | 1,350 | ds3_autogen | Apache License 2.0 |
app/src/main/java/org/stepic/droid/di/storage/StorageModule.kt | hkh412 | 96,096,662 | true | {"Java": 1639224, "Kotlin": 676177, "CSS": 3721, "Shell": 663} | package org.stepic.droid.di.storage
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteOpenHelper
import dagger.Binds
import dagger.Module
import dagger.Provides
import org.stepic.droid.di.qualifiers.EnrolledCoursesDaoQualifier
import org.stepic.droid.di.qualifiers.FeaturedCoursesDaoQualifier
import org.stepic.droid.model.*
import org.stepic.droid.model.Unit
import org.stepic.droid.notifications.model.Notification
import org.stepic.droid.storage.DatabaseHelper
import org.stepic.droid.storage.dao.*
import org.stepic.droid.storage.structure.DbStructureEnrolledAndFeaturedCourses
import org.stepic.droid.web.ViewAssignment
@Module
abstract class StorageModule {
@StorageSingleton
@Binds
internal abstract fun provideSqlOpenHelper(databaseHelper: DatabaseHelper): SQLiteOpenHelper
@StorageSingleton
@Binds
internal abstract fun provideSectionDao(sectionDao: SectionDaoImpl): IDao<Section>
@StorageSingleton
@Binds
internal abstract fun provideUnitDao(unitDao: UnitDaoImpl): IDao<Unit>
@StorageSingleton
@Binds
internal abstract fun provideProgressDao(progressDao: ProgressDaoImpl): IDao<Progress>
@Binds
internal abstract fun provideAssignmentDao(assignmentDao: AssignmentDaoImpl): IDao<Assignment>
@Binds
internal abstract fun provideCertificateDao(certificateViewItemDao: CertificateViewItemDaoImpl): IDao<CertificateViewItem>
@Binds
internal abstract fun provideLessonDao(lessonDao: LessonDaoImpl): IDao<Lesson>
@StorageSingleton
@Binds
internal abstract fun provideViewAssignment(viewAssignmentDao: ViewAssignmentDaoImpl): IDao<ViewAssignment>
@StorageSingleton
@Binds
internal abstract fun provideDownloadEntity(downloadEntityDao: DownloadEntityDaoImpl): IDao<DownloadEntity>
@StorageSingleton
@Binds
internal abstract fun provideCalendarSection(calendarSectionDao: CalendarSectionDaoImpl): IDao<CalendarSection>
@StorageSingleton
@Binds
internal abstract fun provideCachedVideo(persistentVideoDao: PersistentVideoDaoImpl): IDao<CachedVideo>
@StorageSingleton
@Binds
internal abstract fun provideBlockWrapper(blockDao: BlockDaoImpl): IDao<BlockPersistentWrapper>
@StorageSingleton
@Binds
internal abstract fun provideStep(stepDao: StepDaoImpl): IDao<Step>
@StorageSingleton
@Binds
internal abstract fun provideNotification(notificationDao: NotificationDaoImpl): IDao<Notification>
@Binds
@StorageSingleton
internal abstract fun provideVideoTimeStamp(videoTimestampDao: VideoTimestampDaoImpl): IDao<VideoTimestamp>
@Binds
@StorageSingleton
internal abstract fun provideLastStepDao(persistentLastStepDao: PersistentLastStepDaoImpl): IDao<PersistentLastStep>
@Binds
@StorageSingleton
internal abstract fun provideCourseInteractionDao(courseLastInteractionDao: CourseLastInteractionDaoImpl): IDao<CourseLastInteraction>
@Binds
@StorageSingleton
internal abstract fun provideExternalVideoUrlDao(videoUrlDao: VideoUrlDaoImpl): IDao<DbVideoUrl>
@Module
companion object {
@StorageSingleton
@Provides
@JvmStatic
internal fun provideWritableDatabase(helper: SQLiteOpenHelper): SQLiteDatabase {
return helper.writableDatabase
}
@StorageSingleton
@Provides
@JvmStatic
@EnrolledCoursesDaoQualifier
internal fun provideEnrolledCoursesDao(writeableDatabase: SQLiteDatabase, cachedVideo: IDao<CachedVideo>, externalVideos: IDao<DbVideoUrl>): IDao<Course> {
return CourseDaoImpl(writeableDatabase, cachedVideo, externalVideos, DbStructureEnrolledAndFeaturedCourses.ENROLLED_COURSES)
}
@StorageSingleton
@Provides
@JvmStatic
@FeaturedCoursesDaoQualifier
internal fun provideFeaturedCoursesDao(writeableDatabase: SQLiteDatabase, cachedVideo: IDao<CachedVideo>, externalVideos: IDao<DbVideoUrl>): IDao<Course> {
return CourseDaoImpl(writeableDatabase, cachedVideo, externalVideos, DbStructureEnrolledAndFeaturedCourses.FEATURED_COURSES)
}
}
}
| 0 | Java | 0 | 0 | 8dc965cbd975bf2ec64220acc78930c5a6b9a7e8 | 4,175 | stepik-android | Apache License 2.0 |
app/src/main/java/jp/zuikou/system/redditprojectsample1/presentation/ui/BaseFragment.kt | rooneyviet | 228,741,478 | false | {"Gradle": 3, "Java Properties": 2, "Shell": 1, "Text": 1, "Ignore List": 2, "Batchfile": 1, "Markdown": 1, "Proguard": 1, "Kotlin": 109, "XML": 40, "Java": 2} | package jp.zuikou.system.redditprojectsample1.presentation.ui
import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import jp.zuikou.system.redditprojectsample1.presentation.data.datasource.NetworkState
import jp.zuikou.system.redditprojectsample1.presentation.viewmodel.LoginViewModel
import jp.zuikou.system.redditprojectsample1.util.SharedPreferenceSingleton
import kotlinx.android.synthetic.main.include_posts_list.*
import kotlinx.android.synthetic.main.list_item_network_state.*
import timber.log.Timber
abstract class BaseFragment: Fragment() {
lateinit var loginViewModel: LoginViewModel
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
SharedPreferenceSingleton.isLoggedInLivePreference().observe(this, Observer<Boolean> { loggedIn ->
Timber.d("LOGSTATUS $loggedIn")
//refreshFragment()
})
activity?.let {
loginViewModel = ViewModelProviders.of(it).get(LoginViewModel::class.java)
loginViewModel.authenticationState.observe(this, Observer { authenticationState ->
when {
authenticationState == LoginViewModel.AuthenticationState.AUTHENTICATED -> {
//Toast.makeText(context, "Login Success", Toast.LENGTH_SHORT).show()
//refreshFragment()
}
authenticationState == LoginViewModel.AuthenticationState.INVALID_AUTHENTICATION -> {
//Toast.makeText(context, "Login failed", Toast.LENGTH_SHORT).show()
}
authenticationState == LoginViewModel.AuthenticationState.UNAUTHENTICATED -> {
//refreshFragment()
}
}
})
}
}
abstract fun refreshFragment(isReset: Boolean)
open fun setInitialLoadingState(networkState: NetworkState?) {
buttonRetry.visibility = if (networkState == NetworkState.NO_INTERNET) View.VISIBLE else View.GONE
progressBarLoading.visibility = if (networkState == NetworkState.LOADING) View.VISIBLE else View.GONE
recyclerView.visibility = if (networkState == NetworkState.SUCCESS) View.VISIBLE else View.GONE
}
} | 1 | null | 1 | 1 | c712f265b239d69d977ea2a12d95a35718f36922 | 2,384 | reddit_sync | MIT License |
node/src/main/kotlin/com/syiyi/convoy/node/zk/ZKit.kt | s949492225 | 280,293,994 | false | null | package com.syiyi.convoy.node.zk
import com.syiyi.convoy.node.config.AppConfig
import org.I0Itec.zkclient.ZkClient
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component
@Component
class ZKit {
@Autowired
private lateinit var zkClient: ZkClient
@Autowired
private lateinit var appConfig: AppConfig
fun createRootNode(){
val exits=zkClient.exists(appConfig.zkRoot)
if (exits){
return
}
zkClient.createPersistent(appConfig.zkRoot)
}
fun createNode(path:String){
zkClient.createEphemeral(path)
}
} | 0 | Kotlin | 0 | 0 | 33382e4925b90bc3358681ea793cdde6fa65b8c5 | 639 | convoy | MIT License |
src/test/java/org/mapdb/BTreeMap_ConcurrentSkipListSubMapTest_JSR166Test.kt | aping-fo | 75,033,218 | true | {"Markdown": 1, "Java Properties": 1, "Kotlin": 92, "Java": 172} | package org.mapdb.tree
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import org.mapdb.tree.jsr166Tests.ConcurrentSkipListSubMapTest
import java.util.concurrent.ConcurrentNavigableMap
@RunWith(Parameterized::class)
class BTreeMap_ConcurrentSkipListSubMapTest_JSR166Test(
val mapMaker:(generic:Boolean)-> ConcurrentNavigableMap<Int, String>
) : ConcurrentSkipListSubMapTest()
{
override fun emptyMap(): ConcurrentNavigableMap<Int, String>? {
return mapMaker(false)
}
companion object {
@Parameterized.Parameters
@JvmStatic
fun params(): Iterable<Any> {
return BTreeMap_ConcurrentMap_GuavaTest.params()
}
}
}
| 0 | Java | 1 | 1 | ad7102c643e1d0f31629446dc6e5ea89c52c7190 | 713 | mapdb | Apache License 2.0 |
stack/src/main/kotlin/sssemil/com/net/packet/types/IpProtocol.kt | sssemil | 151,985,946 | false | null | /*
* Copyright 2019 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sssemil.com.net.packet.types
/**
* IP-Protocol field representation
*
* @author <NAME> (<EMAIL>)
*/
class IpProtocol private constructor(val ipProtocolNumber: Short) {
override fun toString(): String {
return "0x" + Integer.toHexString(ipProtocolNumber.toInt())
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as IpProtocol
if (ipProtocolNumber != other.ipProtocolNumber) return false
return true
}
override fun hashCode(): Int {
return ipProtocolNumber.toInt()
}
companion object {
val FULL_MASK = IpProtocol(0x0000.toShort())
internal val MAX_PROTO: Short = 0xFF
internal val LENGTH = 1
internal val NUM_HOPOPT: Short = 0x00
val HOPOPT =
IpProtocol(IpProtocol.Companion.NUM_HOPOPT)
val NONE = IpProtocol.Companion.HOPOPT
val NO_MASK = IpProtocol.Companion.HOPOPT
internal val NUM_ICMP: Short = 0x01
val ICMP = IpProtocol(IpProtocol.Companion.NUM_ICMP)
internal val NUM_IGMP: Short = 0x02
val IGMP = IpProtocol(IpProtocol.Companion.NUM_IGMP)
internal val NUM_GGP: Short = 0x03
val GGP = IpProtocol(IpProtocol.Companion.NUM_GGP)
internal val NUM_IPv4: Short = 0x04
val IPv4 = IpProtocol(IpProtocol.Companion.NUM_IPv4)
internal val NUM_ST: Short = 0x05
val ST = IpProtocol(IpProtocol.Companion.NUM_ST)
internal val NUM_TCP: Short = 0x06
val TCP = IpProtocol(IpProtocol.Companion.NUM_TCP)
internal val NUM_CBT: Short = 0x07
val CBT = IpProtocol(IpProtocol.Companion.NUM_CBT)
internal val NUM_EGP: Short = 0x08
val EGP = IpProtocol(IpProtocol.Companion.NUM_EGP)
internal val NUM_IGP: Short = 0x09
val IGP = IpProtocol(IpProtocol.Companion.NUM_IGP)
internal val NUM_BBN_RCC_MON: Short = 0x0A
val BBN_RCC_MON =
IpProtocol(IpProtocol.Companion.NUM_BBN_RCC_MON)
internal val NUM_NVP_II: Short = 0x0B
val NVP_II =
IpProtocol(IpProtocol.Companion.NUM_NVP_II)
internal val NUM_PUP: Short = 0x0C
val PUP = IpProtocol(IpProtocol.Companion.NUM_PUP)
internal val NUM_ARGUS: Short = 0x0D
val ARGUS = IpProtocol(IpProtocol.Companion.NUM_ARGUS)
internal val NUM_EMCON: Short = 0x0E
val EMCON = IpProtocol(IpProtocol.Companion.NUM_EMCON)
internal val NUM_XNET: Short = 0x0F
val XNET = IpProtocol(IpProtocol.Companion.NUM_XNET)
internal val NUM_CHAOS: Short = 0x10
val CHAOS = IpProtocol(IpProtocol.Companion.NUM_CHAOS)
internal val NUM_UDP: Short = 0x11
val UDP = IpProtocol(IpProtocol.Companion.NUM_UDP)
internal val NUM_MUX: Short = 0x12
val MUX = IpProtocol(IpProtocol.Companion.NUM_MUX)
internal val NUM_DCN_MEAS: Short = 0x13
val DCN_MEAS =
IpProtocol(IpProtocol.Companion.NUM_DCN_MEAS)
internal val NUM_HMP: Short = 0x14
val HMP = IpProtocol(IpProtocol.Companion.NUM_HMP)
internal val NUM_PRM: Short = 0x15
val PRM = IpProtocol(IpProtocol.Companion.NUM_PRM)
internal val NUM_XNS_IDP: Short = 0x16
val XNS_IDP =
IpProtocol(IpProtocol.Companion.NUM_XNS_IDP)
internal val NUM_TRUNK_1: Short = 0x17
val TRUNK_1 =
IpProtocol(IpProtocol.Companion.NUM_TRUNK_1)
internal val NUM_TRUNK_2: Short = 0x18
val TRUNK_2 =
IpProtocol(IpProtocol.Companion.NUM_TRUNK_2)
internal val NUM_LEAF_1: Short = 0x19
val LEAF_1 =
IpProtocol(IpProtocol.Companion.NUM_LEAF_1)
internal val NUM_LEAF_2: Short = 0x1A
val LEAF_2 =
IpProtocol(IpProtocol.Companion.NUM_LEAF_2)
internal val NUM_RDP: Short = 0x1B
val RDP = IpProtocol(IpProtocol.Companion.NUM_RDP)
internal val NUM_IRTP: Short = 0x1C
val IRTP = IpProtocol(IpProtocol.Companion.NUM_IRTP)
internal val NUM_ISO_TP4: Short = 0x1D
val ISO_TP4 =
IpProtocol(IpProtocol.Companion.NUM_ISO_TP4)
internal val NUM_NETBLT: Short = 0x1E
val NETBLT =
IpProtocol(IpProtocol.Companion.NUM_NETBLT)
internal val NUM_MFE_NSP: Short = 0x1F
val MFE_NSP =
IpProtocol(IpProtocol.Companion.NUM_MFE_NSP)
internal val NUM_MERIT_INP: Short = 0x20
val MERIT_INP =
IpProtocol(IpProtocol.Companion.NUM_MERIT_INP)
internal val NUM_DCCP: Short = 0x21
val DCCP = IpProtocol(IpProtocol.Companion.NUM_DCCP)
internal val NUM_3PC: Short = 0x22
val _3PC = IpProtocol(IpProtocol.Companion.NUM_3PC)
internal val NUM_IDPR: Short = 0x23
val IDPR = IpProtocol(IpProtocol.Companion.NUM_IDPR)
internal val NUM_XTP: Short = 0x24
val XTP = IpProtocol(IpProtocol.Companion.NUM_XTP)
internal val NUM_DDP: Short = 0x25
val DDP = IpProtocol(IpProtocol.Companion.NUM_DDP)
internal val NUM_IDPR_CMTP: Short = 0x26
val IDPR_CMTP =
IpProtocol(IpProtocol.Companion.NUM_IDPR_CMTP)
internal val NUM_TP_PP: Short = 0x27
val TP_PP = IpProtocol(IpProtocol.Companion.NUM_TP_PP)
internal val NUM_IL: Short = 0x28
val IL = IpProtocol(IpProtocol.Companion.NUM_IL)
internal val NUM_IPv6: Short = 0x29
val IPv6 = IpProtocol(IpProtocol.Companion.NUM_IPv6)
internal val NUM_SDRP: Short = 0x2A
val SDRP = IpProtocol(IpProtocol.Companion.NUM_SDRP)
internal val NUM_IPv6_ROUTE: Short = 0x2B
val IPv6_ROUTE =
IpProtocol(IpProtocol.Companion.NUM_IPv6_ROUTE)
internal val NUM_IPv6_FRAG: Short = 0x2C
val IPv6_FRAG =
IpProtocol(IpProtocol.Companion.NUM_IPv6_FRAG)
internal val NUM_IDRP: Short = 0x2D
val IDRP = IpProtocol(IpProtocol.Companion.NUM_IDRP)
internal val NUM_RSVP: Short = 0x2E
val RSVP = IpProtocol(IpProtocol.Companion.NUM_RSVP)
internal val NUM_GRE: Short = 0x2F
val GRE = IpProtocol(IpProtocol.Companion.NUM_GRE)
internal val NUM_MHRP: Short = 0x30
val MHRP = IpProtocol(IpProtocol.Companion.NUM_MHRP)
internal val NUM_BNA: Short = 0x31
val BNA = IpProtocol(IpProtocol.Companion.NUM_BNA)
internal val NUM_ESP: Short = 0x32
val ESP = IpProtocol(IpProtocol.Companion.NUM_ESP)
internal val NUM_AH: Short = 0x33
val AH = IpProtocol(IpProtocol.Companion.NUM_AH)
internal val NUM_I_NLSP: Short = 0x34
val I_NLSP =
IpProtocol(IpProtocol.Companion.NUM_I_NLSP)
internal val NUM_SWIPE: Short = 0x35
val SWIPE = IpProtocol(IpProtocol.Companion.NUM_SWIPE)
internal val NUM_NARP: Short = 0x36
val NARP = IpProtocol(IpProtocol.Companion.NUM_NARP)
internal val NUM_MOBILE: Short = 0x37
val MOBILE =
IpProtocol(IpProtocol.Companion.NUM_MOBILE)
internal val NUM_TLSP: Short = 0x38
val TLSP = IpProtocol(IpProtocol.Companion.NUM_TLSP)
internal val NUM_SKIP: Short = 0x39
val SKIP = IpProtocol(IpProtocol.Companion.NUM_SKIP)
internal val NUM_IPv6_ICMP: Short = 0x3A
val IPv6_ICMP =
IpProtocol(IpProtocol.Companion.NUM_IPv6_ICMP)
internal val NUM_IPv6_NO_NXT: Short = 0x3B
val IPv6_NO_NXT =
IpProtocol(IpProtocol.Companion.NUM_IPv6_NO_NXT)
internal val NUM_IPv6_OPTS: Short = 0x3C
val IPv6_OPTS =
IpProtocol(IpProtocol.Companion.NUM_IPv6_OPTS)
internal val NUM_HOST_INTERNAL: Short = 0x3D
val HOST_INTERNAL =
IpProtocol(IpProtocol.Companion.NUM_HOST_INTERNAL)
internal val NUM_CFTP: Short = 0x3E
val CFTP = IpProtocol(IpProtocol.Companion.NUM_CFTP)
internal val NUM_LOCAL_NET: Short = 0x3F
val LOCAL_NET =
IpProtocol(IpProtocol.Companion.NUM_LOCAL_NET)
internal val NUM_SAT_EXPAK: Short = 0x40
val SAT_EXPAK =
IpProtocol(IpProtocol.Companion.NUM_SAT_EXPAK)
internal val NUM_KRYPTOLAN: Short = 0x41
val KRYPTOLAN =
IpProtocol(IpProtocol.Companion.NUM_KRYPTOLAN)
internal val NUM_RVD: Short = 0x42
val RVD = IpProtocol(IpProtocol.Companion.NUM_RVD)
internal val NUM_IPPC: Short = 0x43
val IPPC = IpProtocol(IpProtocol.Companion.NUM_IPPC)
internal val NUM_DIST_FS: Short = 0x44
val DIST_FS =
IpProtocol(IpProtocol.Companion.NUM_DIST_FS)
internal val NUM_SAT_MON: Short = 0x45
val SAT_MON =
IpProtocol(IpProtocol.Companion.NUM_SAT_MON)
internal val NUM_VISA: Short = 0x46
val VISA = IpProtocol(IpProtocol.Companion.NUM_VISA)
internal val NUM_IPCV: Short = 0x47
val IPCV = IpProtocol(IpProtocol.Companion.NUM_IPCV)
internal val NUM_CPNX: Short = 0x48
val CPNX = IpProtocol(IpProtocol.Companion.NUM_CPNX)
internal val NUM_CPHB: Short = 0x49
val CPHB = IpProtocol(IpProtocol.Companion.NUM_CPHB)
internal val NUM_WSN: Short = 0x4A
val WSN = IpProtocol(IpProtocol.Companion.NUM_WSN)
internal val NUM_PVP: Short = 0x4B
val PVP = IpProtocol(IpProtocol.Companion.NUM_PVP)
internal val NUM_BR_SAT_MON: Short = 0x4C
val BR_SAT_MON =
IpProtocol(IpProtocol.Companion.NUM_BR_SAT_MON)
internal val NUM_SUN_ND: Short = 0x4D
val SUN_ND =
IpProtocol(IpProtocol.Companion.NUM_SUN_ND)
internal val NUM_WB_MON: Short = 0x4E
val WB_MON =
IpProtocol(IpProtocol.Companion.NUM_WB_MON)
internal val NUM_WB_EXPAK: Short = 0x4F
val WB_EXPAK =
IpProtocol(IpProtocol.Companion.NUM_WB_EXPAK)
internal val NUM_ISO_IP: Short = 0x50
val ISO_IP =
IpProtocol(IpProtocol.Companion.NUM_ISO_IP)
internal val NUM_VMTP: Short = 0x51
val VMTP = IpProtocol(IpProtocol.Companion.NUM_VMTP)
internal val NUM_SECURE_VMTP: Short = 0x52
val SECURE_VMTP =
IpProtocol(IpProtocol.Companion.NUM_SECURE_VMTP)
internal val NUM_VINES: Short = 0x53
val VINES = IpProtocol(IpProtocol.Companion.NUM_VINES)
internal val NUM_TTP_IPTM: Short = 0x54
val TTP_IPTM =
IpProtocol(IpProtocol.Companion.NUM_TTP_IPTM)
internal val NUM_NSFNET_IGP: Short = 0x55
val NSFNET_IGP =
IpProtocol(IpProtocol.Companion.NUM_NSFNET_IGP)
internal val NUM_DGP: Short = 0x56
val DGP = IpProtocol(IpProtocol.Companion.NUM_DGP)
internal val NUM_TCF: Short = 0x57
val TCF = IpProtocol(IpProtocol.Companion.NUM_TCF)
internal val NUM_EIGRP: Short = 0x58
val EIGRP = IpProtocol(IpProtocol.Companion.NUM_EIGRP)
internal val NUM_OSPF: Short = 0x59
val OSPF = IpProtocol(IpProtocol.Companion.NUM_OSPF)
internal val NUM_Sprite_RPC: Short = 0x5A
val Sprite_RPC =
IpProtocol(IpProtocol.Companion.NUM_Sprite_RPC)
internal val NUM_LARP: Short = 0x5B
val LARP = IpProtocol(IpProtocol.Companion.NUM_LARP)
internal val NUM_MTP: Short = 0x5C
val MTP = IpProtocol(IpProtocol.Companion.NUM_MTP)
internal val NUM_AX_25: Short = 0x5D
val AX_25 = IpProtocol(IpProtocol.Companion.NUM_AX_25)
internal val NUM_IPIP: Short = 0x5E
val IPIP = IpProtocol(IpProtocol.Companion.NUM_IPIP)
internal val NUM_MICP: Short = 0x5F
val MICP = IpProtocol(IpProtocol.Companion.NUM_MICP)
internal val NUM_SCC_SP: Short = 0x60
val SCC_SP =
IpProtocol(IpProtocol.Companion.NUM_SCC_SP)
internal val NUM_ETHERIP: Short = 0x61
val ETHERIP =
IpProtocol(IpProtocol.Companion.NUM_ETHERIP)
internal val NUM_ENCAP: Short = 0x62
val ENCAP = IpProtocol(IpProtocol.Companion.NUM_ENCAP)
internal val NUM_PRIVATE_ENCRYPT: Short = 0x63
val PRIVATE_ENCRYPT =
IpProtocol(IpProtocol.Companion.NUM_PRIVATE_ENCRYPT)
internal val NUM_GMTP: Short = 0x64
val GMTP = IpProtocol(IpProtocol.Companion.NUM_GMTP)
internal val NUM_IFMP: Short = 0x65
val IFMP = IpProtocol(IpProtocol.Companion.NUM_IFMP)
internal val NUM_PNNI: Short = 0x66
val PNNI = IpProtocol(IpProtocol.Companion.NUM_PNNI)
internal val NUM_PIM: Short = 0x67
val PIM = IpProtocol(IpProtocol.Companion.NUM_PIM)
internal val NUM_ARIS: Short = 0x68
val ARIS = IpProtocol(IpProtocol.Companion.NUM_ARIS)
internal val NUM_SCPS: Short = 0x69
val SCPS = IpProtocol(IpProtocol.Companion.NUM_SCPS)
internal val NUM_QNX: Short = 0x6A
val QNX = IpProtocol(IpProtocol.Companion.NUM_QNX)
internal val NUM_A_N: Short = 0x6B
val A_N = IpProtocol(IpProtocol.Companion.NUM_A_N)
internal val NUM_IP_COMP: Short = 0x6C
val IP_COMP =
IpProtocol(IpProtocol.Companion.NUM_IP_COMP)
internal val NUM_SNP: Short = 0x6D
val SNP = IpProtocol(IpProtocol.Companion.NUM_SNP)
internal val NUM_COMPAQ_PEER: Short = 0x6E
val COMPAQ_PEER =
IpProtocol(IpProtocol.Companion.NUM_COMPAQ_PEER)
internal val NUM_IPX_IN_IP: Short = 0x6F
val IPX_IN_IP =
IpProtocol(IpProtocol.Companion.NUM_IPX_IN_IP)
internal val NUM_VRRP: Short = 0x70
val VRRP = IpProtocol(IpProtocol.Companion.NUM_VRRP)
internal val NUM_PGM: Short = 0x71
val PGM = IpProtocol(IpProtocol.Companion.NUM_PGM)
internal val NUM_ZERO_HOP: Short = 0x72
val ZERO_HOP =
IpProtocol(IpProtocol.Companion.NUM_ZERO_HOP)
internal val NUM_L2TP: Short = 0x73
val L2TP = IpProtocol(IpProtocol.Companion.NUM_L2TP)
internal val NUM_DDX: Short = 0x74
val DDX = IpProtocol(IpProtocol.Companion.NUM_DDX)
internal val NUM_IATP: Short = 0x75
val IATP = IpProtocol(IpProtocol.Companion.NUM_IATP)
internal val NUM_STP: Short = 0x76
val STP = IpProtocol(IpProtocol.Companion.NUM_STP)
internal val NUM_SRP: Short = 0x77
val SRP = IpProtocol(IpProtocol.Companion.NUM_SRP)
internal val NUM_UTI: Short = 0x78
val UTI = IpProtocol(IpProtocol.Companion.NUM_UTI)
internal val NUM_SMP: Short = 0x79
val SMP = IpProtocol(IpProtocol.Companion.NUM_SMP)
internal val NUM_SM: Short = 0x7A
val SM = IpProtocol(IpProtocol.Companion.NUM_SM)
internal val NUM_PTP: Short = 0x7B
val PTP = IpProtocol(IpProtocol.Companion.NUM_PTP)
internal val NUM_IS_IS_OVER_IPv4: Short = 0x7C
val IS_IS_OVER_IPv4 =
IpProtocol(IpProtocol.Companion.NUM_IS_IS_OVER_IPv4)
internal val NUM_FIRE: Short = 0x7D
val FIRE = IpProtocol(IpProtocol.Companion.NUM_FIRE)
internal val NUM_CRTP: Short = 0x7E
val CRTP = IpProtocol(IpProtocol.Companion.NUM_CRTP)
internal val NUM_CRUDP: Short = 0x7F
val CRUDP = IpProtocol(IpProtocol.Companion.NUM_CRUDP)
internal val NUM_SSCOPMCE: Short = 0x80
val SSCOPMCE =
IpProtocol(IpProtocol.Companion.NUM_SSCOPMCE)
internal val NUM_IPLT: Short = 0x81
val IPLT = IpProtocol(IpProtocol.Companion.NUM_IPLT)
internal val NUM_SPS: Short = 0x82
val SPS = IpProtocol(IpProtocol.Companion.NUM_SPS)
internal val NUM_PIPE: Short = 0x83
val PIPE = IpProtocol(IpProtocol.Companion.NUM_PIPE)
internal val NUM_SCTP: Short = 0x84
val SCTP = IpProtocol(IpProtocol.Companion.NUM_SCTP)
internal val NUM_FC: Short = 0x85
val FC = IpProtocol(IpProtocol.Companion.NUM_FC)
internal val NUM_RSVP_E2E_IGNORE: Short = 0x86
val RSVP_E2E_IGNORE =
IpProtocol(IpProtocol.Companion.NUM_RSVP_E2E_IGNORE)
internal val NUM_MOBILITY_HEADER: Short = 0x87
val MOBILITY_HEADER =
IpProtocol(IpProtocol.Companion.NUM_MOBILITY_HEADER)
internal val NUM_UDP_LITE: Short = 0x88
val UDP_LITE =
IpProtocol(IpProtocol.Companion.NUM_UDP_LITE)
internal val NUM_MPLS_IN_IP: Short = 0x89
val MPLS_IN_IP =
IpProtocol(IpProtocol.Companion.NUM_MPLS_IN_IP)
internal val NUM_MANET: Short = 0x8A
val MANET = IpProtocol(IpProtocol.Companion.NUM_MANET)
internal val NUM_HIP: Short = 0x8B
val HIP = IpProtocol(IpProtocol.Companion.NUM_HIP)
internal val NUM_SHIM6: Short = 0x8C
val SHIM6 = IpProtocol(IpProtocol.Companion.NUM_SHIM6)
fun of(proto: Short): IpProtocol {
when (proto) {
IpProtocol.Companion.NUM_HOPOPT -> return IpProtocol.Companion.HOPOPT
IpProtocol.Companion.NUM_ICMP -> return IpProtocol.Companion.ICMP
IpProtocol.Companion.NUM_IGMP -> return IpProtocol.Companion.IGMP
IpProtocol.Companion.NUM_GGP -> return IpProtocol.Companion.GGP
IpProtocol.Companion.NUM_IPv4 -> return IpProtocol.Companion.IPv4
IpProtocol.Companion.NUM_ST -> return IpProtocol.Companion.ST
IpProtocol.Companion.NUM_TCP -> return IpProtocol.Companion.TCP
IpProtocol.Companion.NUM_CBT -> return IpProtocol.Companion.CBT
IpProtocol.Companion.NUM_EGP -> return IpProtocol.Companion.EGP
IpProtocol.Companion.NUM_IGP -> return IpProtocol.Companion.IGP
IpProtocol.Companion.NUM_BBN_RCC_MON -> return IpProtocol.Companion.BBN_RCC_MON
IpProtocol.Companion.NUM_NVP_II -> return IpProtocol.Companion.NVP_II
IpProtocol.Companion.NUM_PUP -> return IpProtocol.Companion.PUP
IpProtocol.Companion.NUM_ARGUS -> return IpProtocol.Companion.ARGUS
IpProtocol.Companion.NUM_EMCON -> return IpProtocol.Companion.EMCON
IpProtocol.Companion.NUM_XNET -> return IpProtocol.Companion.XNET
IpProtocol.Companion.NUM_CHAOS -> return IpProtocol.Companion.CHAOS
IpProtocol.Companion.NUM_UDP -> return IpProtocol.Companion.UDP
IpProtocol.Companion.NUM_MUX -> return IpProtocol.Companion.MUX
IpProtocol.Companion.NUM_DCN_MEAS -> return IpProtocol.Companion.DCN_MEAS
IpProtocol.Companion.NUM_HMP -> return IpProtocol.Companion.HMP
IpProtocol.Companion.NUM_PRM -> return IpProtocol.Companion.PRM
IpProtocol.Companion.NUM_XNS_IDP -> return IpProtocol.Companion.XNS_IDP
IpProtocol.Companion.NUM_TRUNK_1 -> return IpProtocol.Companion.TRUNK_1
IpProtocol.Companion.NUM_TRUNK_2 -> return IpProtocol.Companion.TRUNK_2
IpProtocol.Companion.NUM_LEAF_1 -> return IpProtocol.Companion.LEAF_1
IpProtocol.Companion.NUM_LEAF_2 -> return IpProtocol.Companion.LEAF_2
IpProtocol.Companion.NUM_RDP -> return IpProtocol.Companion.RDP
IpProtocol.Companion.NUM_IRTP -> return IpProtocol.Companion.IRTP
IpProtocol.Companion.NUM_ISO_TP4 -> return IpProtocol.Companion.ISO_TP4
IpProtocol.Companion.NUM_NETBLT -> return IpProtocol.Companion.NETBLT
IpProtocol.Companion.NUM_MFE_NSP -> return IpProtocol.Companion.MFE_NSP
IpProtocol.Companion.NUM_MERIT_INP -> return IpProtocol.Companion.MERIT_INP
IpProtocol.Companion.NUM_DCCP -> return IpProtocol.Companion.DCCP
IpProtocol.Companion.NUM_3PC -> return IpProtocol.Companion._3PC
IpProtocol.Companion.NUM_IDPR -> return IpProtocol.Companion.IDPR
IpProtocol.Companion.NUM_XTP -> return IpProtocol.Companion.XTP
IpProtocol.Companion.NUM_DDP -> return IpProtocol.Companion.DDP
IpProtocol.Companion.NUM_IDPR_CMTP -> return IpProtocol.Companion.IDPR_CMTP
IpProtocol.Companion.NUM_TP_PP -> return IpProtocol.Companion.TP_PP
IpProtocol.Companion.NUM_IL -> return IpProtocol.Companion.IL
IpProtocol.Companion.NUM_IPv6 -> return IpProtocol.Companion.IPv6
IpProtocol.Companion.NUM_SDRP -> return IpProtocol.Companion.SDRP
IpProtocol.Companion.NUM_IPv6_ROUTE -> return IpProtocol.Companion.IPv6_ROUTE
IpProtocol.Companion.NUM_IPv6_FRAG -> return IpProtocol.Companion.IPv6_FRAG
IpProtocol.Companion.NUM_IDRP -> return IpProtocol.Companion.IDRP
IpProtocol.Companion.NUM_RSVP -> return IpProtocol.Companion.RSVP
IpProtocol.Companion.NUM_GRE -> return IpProtocol.Companion.GRE
IpProtocol.Companion.NUM_MHRP -> return IpProtocol.Companion.MHRP
IpProtocol.Companion.NUM_BNA -> return IpProtocol.Companion.BNA
IpProtocol.Companion.NUM_ESP -> return IpProtocol.Companion.ESP
IpProtocol.Companion.NUM_AH -> return IpProtocol.Companion.AH
IpProtocol.Companion.NUM_I_NLSP -> return IpProtocol.Companion.I_NLSP
IpProtocol.Companion.NUM_SWIPE -> return IpProtocol.Companion.SWIPE
IpProtocol.Companion.NUM_NARP -> return IpProtocol.Companion.NARP
IpProtocol.Companion.NUM_MOBILE -> return IpProtocol.Companion.MOBILE
IpProtocol.Companion.NUM_TLSP -> return IpProtocol.Companion.TLSP
IpProtocol.Companion.NUM_SKIP -> return IpProtocol.Companion.SKIP
IpProtocol.Companion.NUM_IPv6_ICMP -> return IpProtocol.Companion.IPv6_ICMP
IpProtocol.Companion.NUM_IPv6_NO_NXT -> return IpProtocol.Companion.IPv6_NO_NXT
IpProtocol.Companion.NUM_IPv6_OPTS -> return IpProtocol.Companion.IPv6_OPTS
IpProtocol.Companion.NUM_HOST_INTERNAL -> return IpProtocol.Companion.HOST_INTERNAL
IpProtocol.Companion.NUM_CFTP -> return IpProtocol.Companion.CFTP
IpProtocol.Companion.NUM_LOCAL_NET -> return IpProtocol.Companion.LOCAL_NET
IpProtocol.Companion.NUM_SAT_EXPAK -> return IpProtocol.Companion.SAT_EXPAK
IpProtocol.Companion.NUM_KRYPTOLAN -> return IpProtocol.Companion.KRYPTOLAN
IpProtocol.Companion.NUM_RVD -> return IpProtocol.Companion.RVD
IpProtocol.Companion.NUM_IPPC -> return IpProtocol.Companion.IPPC
IpProtocol.Companion.NUM_DIST_FS -> return IpProtocol.Companion.DIST_FS
IpProtocol.Companion.NUM_SAT_MON -> return IpProtocol.Companion.SAT_MON
IpProtocol.Companion.NUM_VISA -> return IpProtocol.Companion.VISA
IpProtocol.Companion.NUM_IPCV -> return IpProtocol.Companion.IPCV
IpProtocol.Companion.NUM_CPNX -> return IpProtocol.Companion.CPNX
IpProtocol.Companion.NUM_CPHB -> return IpProtocol.Companion.CPHB
IpProtocol.Companion.NUM_WSN -> return IpProtocol.Companion.WSN
IpProtocol.Companion.NUM_PVP -> return IpProtocol.Companion.PVP
IpProtocol.Companion.NUM_BR_SAT_MON -> return IpProtocol.Companion.BR_SAT_MON
IpProtocol.Companion.NUM_SUN_ND -> return IpProtocol.Companion.SUN_ND
IpProtocol.Companion.NUM_WB_MON -> return IpProtocol.Companion.WB_MON
IpProtocol.Companion.NUM_WB_EXPAK -> return IpProtocol.Companion.WB_EXPAK
IpProtocol.Companion.NUM_ISO_IP -> return IpProtocol.Companion.ISO_IP
IpProtocol.Companion.NUM_VMTP -> return IpProtocol.Companion.VMTP
IpProtocol.Companion.NUM_SECURE_VMTP -> return IpProtocol.Companion.SECURE_VMTP
IpProtocol.Companion.NUM_VINES -> return IpProtocol.Companion.VINES
IpProtocol.Companion.NUM_TTP_IPTM -> return IpProtocol.Companion.TTP_IPTM
IpProtocol.Companion.NUM_NSFNET_IGP -> return IpProtocol.Companion.NSFNET_IGP
IpProtocol.Companion.NUM_DGP -> return IpProtocol.Companion.DGP
IpProtocol.Companion.NUM_TCF -> return IpProtocol.Companion.TCF
IpProtocol.Companion.NUM_EIGRP -> return IpProtocol.Companion.EIGRP
IpProtocol.Companion.NUM_OSPF -> return IpProtocol.Companion.OSPF
IpProtocol.Companion.NUM_Sprite_RPC -> return IpProtocol.Companion.Sprite_RPC
IpProtocol.Companion.NUM_LARP -> return IpProtocol.Companion.LARP
IpProtocol.Companion.NUM_MTP -> return IpProtocol.Companion.MTP
IpProtocol.Companion.NUM_AX_25 -> return IpProtocol.Companion.AX_25
IpProtocol.Companion.NUM_IPIP -> return IpProtocol.Companion.IPIP
IpProtocol.Companion.NUM_MICP -> return IpProtocol.Companion.MICP
IpProtocol.Companion.NUM_SCC_SP -> return IpProtocol.Companion.SCC_SP
IpProtocol.Companion.NUM_ETHERIP -> return IpProtocol.Companion.ETHERIP
IpProtocol.Companion.NUM_ENCAP -> return IpProtocol.Companion.ENCAP
IpProtocol.Companion.NUM_PRIVATE_ENCRYPT -> return IpProtocol.Companion.PRIVATE_ENCRYPT
IpProtocol.Companion.NUM_GMTP -> return IpProtocol.Companion.GMTP
IpProtocol.Companion.NUM_IFMP -> return IpProtocol.Companion.IFMP
IpProtocol.Companion.NUM_PNNI -> return IpProtocol.Companion.PNNI
IpProtocol.Companion.NUM_PIM -> return IpProtocol.Companion.PIM
IpProtocol.Companion.NUM_ARIS -> return IpProtocol.Companion.ARIS
IpProtocol.Companion.NUM_SCPS -> return IpProtocol.Companion.SCPS
IpProtocol.Companion.NUM_QNX -> return IpProtocol.Companion.QNX
IpProtocol.Companion.NUM_A_N -> return IpProtocol.Companion.A_N
IpProtocol.Companion.NUM_IP_COMP -> return IpProtocol.Companion.IP_COMP
IpProtocol.Companion.NUM_SNP -> return IpProtocol.Companion.SNP
IpProtocol.Companion.NUM_COMPAQ_PEER -> return IpProtocol.Companion.COMPAQ_PEER
IpProtocol.Companion.NUM_IPX_IN_IP -> return IpProtocol.Companion.IPX_IN_IP
IpProtocol.Companion.NUM_VRRP -> return IpProtocol.Companion.VRRP
IpProtocol.Companion.NUM_PGM -> return IpProtocol.Companion.PGM
IpProtocol.Companion.NUM_ZERO_HOP -> return IpProtocol.Companion.ZERO_HOP
IpProtocol.Companion.NUM_L2TP -> return IpProtocol.Companion.L2TP
IpProtocol.Companion.NUM_DDX -> return IpProtocol.Companion.DDX
IpProtocol.Companion.NUM_IATP -> return IpProtocol.Companion.IATP
IpProtocol.Companion.NUM_STP -> return IpProtocol.Companion.STP
IpProtocol.Companion.NUM_SRP -> return IpProtocol.Companion.SRP
IpProtocol.Companion.NUM_UTI -> return IpProtocol.Companion.UTI
IpProtocol.Companion.NUM_SMP -> return IpProtocol.Companion.SMP
IpProtocol.Companion.NUM_SM -> return IpProtocol.Companion.SM
IpProtocol.Companion.NUM_PTP -> return IpProtocol.Companion.PTP
IpProtocol.Companion.NUM_IS_IS_OVER_IPv4 -> return IpProtocol.Companion.IS_IS_OVER_IPv4
IpProtocol.Companion.NUM_FIRE -> return IpProtocol.Companion.FIRE
IpProtocol.Companion.NUM_CRTP -> return IpProtocol.Companion.CRTP
IpProtocol.Companion.NUM_CRUDP -> return IpProtocol.Companion.CRUDP
IpProtocol.Companion.NUM_SSCOPMCE -> return IpProtocol.Companion.SSCOPMCE
IpProtocol.Companion.NUM_IPLT -> return IpProtocol.Companion.IPLT
IpProtocol.Companion.NUM_SPS -> return IpProtocol.Companion.SPS
IpProtocol.Companion.NUM_PIPE -> return IpProtocol.Companion.PIPE
IpProtocol.Companion.NUM_SCTP -> return IpProtocol.Companion.SCTP
IpProtocol.Companion.NUM_FC -> return IpProtocol.Companion.FC
IpProtocol.Companion.NUM_RSVP_E2E_IGNORE -> return IpProtocol.Companion.RSVP_E2E_IGNORE
IpProtocol.Companion.NUM_MOBILITY_HEADER -> return IpProtocol.Companion.MOBILITY_HEADER
IpProtocol.Companion.NUM_UDP_LITE -> return IpProtocol.Companion.UDP_LITE
IpProtocol.Companion.NUM_MPLS_IN_IP -> return IpProtocol.Companion.MPLS_IN_IP
IpProtocol.Companion.NUM_MANET -> return IpProtocol.Companion.MANET
IpProtocol.Companion.NUM_HIP -> return IpProtocol.Companion.HIP
IpProtocol.Companion.NUM_SHIM6 -> return IpProtocol.Companion.SHIM6
else -> return if (proto >= IpProtocol.Companion.MAX_PROTO) {
throw IllegalArgumentException("Illegal IP protocol number: $proto")
} else {
IpProtocol(proto)
}
}
}
}
}
| 1 | null | 1 | 1 | 175e073481ebb84b1fae796f19243e6a334bd98b | 29,772 | cjdns_bridge | Apache License 2.0 |
app/src/main/java/com/kieronquinn/app/taptap/services/TapForegroundService.kt | s1l2 | 323,706,363 | true | {"Kotlin": 382099, "Java": 18636} | package com.kieronquinn.app.taptap.services
import android.app.*
import android.content.*
import android.net.Uri
import android.os.*
import android.provider.Settings
import android.util.Log
import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.lifecycle.LifecycleService
import androidx.lifecycle.Observer
import com.kieronquinn.app.taptap.R
import com.kieronquinn.app.taptap.TapTapApplication
import com.kieronquinn.app.taptap.activities.SettingsActivity
import com.kieronquinn.app.taptap.utils.*
class TapForegroundService : LifecycleService(), ServiceConnection, SharedPreferences.OnSharedPreferenceChangeListener {
companion object {
private const val TAG = "TFS"
private const val MESSAGE_START = 1001
}
private var serviceLooper: Looper? = null
private var serviceHandler: ServiceHandler? = null
private val tapSharedComponent by lazy {
TapSharedComponent.getInstance(this)
}
private val application by lazy {
applicationContext as TapTapApplication
}
private inner class ServiceHandler(looper: Looper) : Handler(looper) {
override fun handleMessage(msg: Message) {
if(msg.arg1 == MESSAGE_START) {
tapSharedComponent.startTap()
}
}
}
override fun onServiceConnected(p0: ComponentName?, p1: IBinder?) {
Log.d(TAG, "onServiceConnected")
tapSharedComponent.accessibilityService = application.accessibilityService.value!!
application.accessibilityService.observe(this, Observer {
if(it != null) {
tapSharedComponent.accessibilityService = it
}
})
serviceHandler?.obtainMessage()?.also { msg ->
msg.arg1 = MESSAGE_START
serviceHandler?.sendMessage(msg)
}
}
override fun onServiceDisconnected(p0: ComponentName?) {
Log.d(TAG, "onServiceDisconnected")
}
@RequiresApi(Build.VERSION_CODES.O)
override fun onCreate() {
super.onCreate()
HandlerThread("TapService", Process.THREAD_PRIORITY_BACKGROUND).apply {
start()
serviceLooper = looper
serviceHandler = ServiceHandler(looper)
}
Log.d(TAG, "onCreate")
val intent = Intent(this, TapAccessibilityService::class.java)
bindService(intent, this, Context.BIND_AUTO_CREATE)
sharedPreferences.registerOnSharedPreferenceChangeListener(this)
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
super.onStartCommand(intent, flags, startId)
val notificationManager = NotificationManagerCompat.from(this)
val channelId = "background_notification"
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(channelId, getString(R.string.tap_notification_channel_title), NotificationManager.IMPORTANCE_LOW)
channel.description = getString(R.string.tap_notification_channel_description)
notificationManager.createNotificationChannel(channel)
}
val intent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
.putExtra(Settings.EXTRA_APP_PACKAGE, packageName)
.putExtra(Settings.EXTRA_CHANNEL_ID, channelId)
} else {
Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
.setData(Uri.parse("package:$packageName"))
}
val notification = NotificationCompat.Builder(this, channelId)
.setSmallIcon(R.drawable.ic_taptap_logo)
.setStyle(NotificationCompat.BigTextStyle())
.setContentTitle(getString(R.string.tap_notification_title))
.setContentText(getString(R.string.tap_notification_content))
.setContentIntent(PendingIntent.getActivity(this, 0, intent, 0))
.setAutoCancel(true)
.build()
startForeground(1, notification)
Log.d(TAG, "startForeground called")
return START_STICKY
}
fun getCurrentPackageName(): String {
return tapSharedComponent.getCurrentPackageName()
}
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
if(key == SHARED_PREFERENCES_KEY_SPLIT_SERVICE){
if(!isSplitService){
Log.d(TAG, "Stopping self")
tapSharedComponent.stopTap()
stopSelf()
}
}else if(key == SHARED_PREFERENCES_KEY_MAIN_SWITCH){
if(!isMainEnabled){
tapSharedComponent.stopTap()
stopSelf()
}
}
}
override fun onDestroy() {
super.onDestroy()
unbindService(this)
tapSharedComponent.stopTap()
}
} | 1 | null | 0 | 0 | f87129e75c61ee975d82e029339e2a9a6f8dc4b8 | 4,943 | TapTap | Apache License 2.0 |
compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/ClickTestRuleTest.kt | RikkaW | 389,105,112 | false | null | /*
* Copyright 2021 The Android Open Source Project
*
* 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 androidx.compose.ui.test
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Column
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.junit4.createComposeRule
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
class ClickCounterActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Counter()
}
}
}
class EmptyActivity : ComponentActivity()
@Composable
fun Counter() {
var counter by remember { mutableStateOf(0) }
Column {
Button(onClick = { counter++ }) {
Text("Increment counter")
}
Text(text = "Clicks: $counter")
}
}
@RunWith(Parameterized::class)
class ClickTestRuleTest(private val config: TestConfig) {
data class TestConfig(
val activityClass: Class<out ComponentActivity>?,
val setContentInTest: Boolean
) {
override fun toString(): String =
"activity=${activityClass?.simpleName}, rule.setContent=$setContentInTest"
}
companion object {
@JvmStatic
@Parameterized.Parameters(name = "{0}")
fun parameters() =
listOf(
TestConfig(ClickCounterActivity::class.java, false),
TestConfig(EmptyActivity::class.java, true),
TestConfig(null, true),
)
}
@Suppress("DEPRECATION")
@get:Rule
val composeTestRule = when (config.activityClass) {
null -> createComposeRule()
else -> createAndroidComposeRule(config.activityClass)
}
@Test
fun testClick() {
if (config.setContentInTest) {
composeTestRule.setContent {
Counter()
}
}
composeTestRule.onNodeWithText("Increment counter").performClick()
composeTestRule.onNodeWithText("Clicks: 1").assertExists()
}
}
| 29 | null | 937 | 7 | 6d53f95e5d979366cf7935ad7f4f14f76a951ea5 | 3,027 | androidx | Apache License 2.0 |
kotlin-maven-spring-data-jdbc-static/src/main/kotlin/pl/exsio/querydsl/entityql/examples/spring_data_jdbc/entity/OrderItem.kt | eXsio | 233,100,956 | false | {"Groovy": 371558, "Java": 368368, "Kotlin": 341394, "TSQL": 52112} | package pl.exsio.querydsl.entityql.examples.spring_data_jdbc.entity
import org.springframework.data.annotation.Id
import org.springframework.data.relational.core.mapping.Column
import pl.exsio.querydsl.entityql.examples.spring_data_jdbc.entity.Book
import pl.exsio.querydsl.entityql.examples.spring_data_jdbc.entity.Order
class OrderItem(@Id @Column("ORDER_ITEM_ID") var id: Long,
@Column("BOOK_ID") var book: Book,
@Column("ITEM_ORDER_ID") var order: Order,
@Column("QTY") var quantity: Long
)
| 18 | Groovy | 2 | 5 | fea1a3cac04947b78d5be7abc0517c0286bc2b75 | 546 | querydsl-entityql-examples | MIT License |
mutant-naive-router/src/main/org/droba/mutantNaiveRouter/NaiveRouter.kt | statikowsky | 82,596,567 | false | null | package org.droba.mutantNaiveRouter
import org.droba.mutant.*
import org.droba.mutant.pluggables.MutantRouter
import org.slf4j.LoggerFactory
import java.util.*
class NaiveRouter : MutantRouter {
data class MutantRoute(
val method: Method,
val route: String,
val pathParamNames: List<String>? = null
)
private val log = LoggerFactory.getLogger(MutantRouter::class.java)
private val routes = LinkedHashMap<MutantRoute, Action>()
override fun registerRoute(method: Method, route: String, action: Action) {
val mutantRoute = mapToMutantRoute(method, route)
routes.put(mutantRoute, action)
}
override fun matchToAction(req: MutantRequest): Action
= checkStaticRoutes(req)
?: checkDynamicRoutes(req)
fun checkStaticRoutes(req: MutantRequest) : Action? {
val method = req.method
val route = req.path
val match = routes[MutantRoute(method, route)]
if (match != null) {
log.info("Found static handle {}.", route)
return match
}
log.debug("No static handle found.")
return null
}
fun checkDynamicRoutes(req: MutantRequest) : Action {
val method = req.method
val route = req.path
for ((mutantRoute, action) in routes) {
log.trace("checking dynamic: {}", mutantRoute.route)
val routeRegex = mutantRoute.route.toRegex()
if (method == mutantRoute.method
&& route.matches(routeRegex)) {
log.info("Found dynamic handle {}", mutantRoute.route)
// get dynamic pathParamsWithValues
val pathParamsWithValues = linkedMapOf<String, String>()
routeRegex.findAll(route, 0).forEach {
for(i in 1..it.groups.size-1) {
val bindingName = mutantRoute.pathParamNames?.get(i-1)
val bindingValue = it.groups[i]?.value
if (bindingName != null && bindingValue != null) {
log.trace("Found binding: [{},{}]", bindingName, bindingValue)
pathParamsWithValues.put(bindingName, bindingValue)
}
}
}
req.pathParams = pathParamsWithValues
return action
}
}
log.debug("No dynamic handle found.")
throw MutantRouteNotFound(route)
}
private fun mapToMutantRoute(method: Method, route: String) : MutantRoute {
if (!route.contains(":")) {
log.trace("Route type: static")
return MutantRoute(method, route)
}
else {
log.trace("Route type: dynamic")
val m = ":(\\w+)".toRegex().toPattern().matcher(route)
val pathParamNames = ArrayList<String>()
while(m.find()) {
pathParamNames.add(m.group())
log.trace("Found path param: {}", m.group())
}
return MutantRoute(
method,
route.replace(":(\\w+)".toRegex(), """([^/]+)"""),
pathParamNames)
}
}
}
| 1 | null | 1 | 2 | 1eda11cdd759724d708078f59657743fa2b1072c | 3,261 | mutant | MIT License |
app/src/main/java/hbs/com/snackb/models/AroundBank.kt | hakzzang | 193,452,994 | false | {"Gradle": 4, "Java Properties": 2, "Shell": 1, "Text": 1, "Ignore List": 3, "Batchfile": 1, "Markdown": 1, "Proguard": 2, "Java": 6, "XML": 38, "Kotlin": 43, "JSON": 5, "Wavefront Object": 1, "Wavefront Material": 1} | package hbs.com.snackb.models
import java.io.Serializable
data class AroundBank(
val appIcon: String = "",
val appTitle: String= "",
val appPackageName: String= "",
val appPublishName:String= "",
val appHitCnt: Int = 0,
val appRegistDate: String= "",
val appPoint : String= ""
) | 3 | Kotlin | 0 | 1 | 523aa01696acfb6d22e5c0b1c5ea82f96399d621 | 308 | SnacKB | Apache License 2.0 |
js/js.translator/testData/incremental/invalidation/companionConstVal/main/m.kt | JetBrains | 3,432,266 | false | {"Kotlin": 78963920, "Java": 6943075, "Swift": 4063829, "C": 2609498, "C++": 1947933, "Objective-C++": 170573, "JavaScript": 106044, "Python": 59695, "Shell": 32949, "Objective-C": 22132, "Lex": 21352, "Batchfile": 11382, "CSS": 11368, "Ruby": 10470, "Dockerfile": 9907, "Groovy": 7092, "EJS": 5241, "CMake": 4473, "HTML": 2699, "Pascal": 1698, "FreeMarker": 1393, "Roff": 725, "Scala": 80} | fun box(stepId: Int): String {
val expected = if (stepId == 5) stepId - 1 else stepId
var got = simpleFunction()
if (got != "$expected") return "Fail simpleFunction: '$got' != '$expected'"
got = inlineFunctionProxy()
if (got != "$expected") return "Fail inlineFunctionProxy: '$got' != '$expected'"
got = SimpleChild().simpleMethod()
if (got != "$expected") return "Fail SimpleChild.simpleMethod: '$got' != '$expected'"
got = inlineChildProxy()
if (got != "$expected") return "Fail inlineChildProxy: '$got' != '$expected'"
return "OK"
}
| 184 | Kotlin | 5691 | 48,625 | bb25d2f8aa74406ff0af254b2388fd601525386a | 581 | kotlin | Apache License 2.0 |
app/src/androidTest/java/org/simple/clinic/storage/migrations/Migration104AndroidTest.kt | simpledotorg | 132,515,649 | false | null | package org.simple.clinic.storage.migrations
import org.junit.Test
import org.simple.clinic.assertIndexDoesNotExist
import org.simple.clinic.assertIndexExists
class Migration104AndroidTest : BaseDatabaseMigrationTest(103, 104) {
@Test
fun migration_should_create_facility_uuid_index_for_appointment_table() {
before.assertIndexDoesNotExist("index_Appointment_facilityUuid")
after.assertIndexExists("index_Appointment_facilityUuid")
}
}
| 13 | null | 73 | 236 | ff699800fbe1bea2ed0492df484777e583c53714 | 454 | simple-android | MIT License |
151004/Burbouski/appLab5/publisher/src/main/kotlin/com/github/hummel/dc/lab5/controller/routing/MessagesRouting.kt | rinrisha | 793,718,783 | true | {"Markdown": 13, "Text": 10, "Ignore List": 133, "Maven POM": 167, "Shell": 52, "Batchfile": 49, "Java": 5175, "INI": 150, "XML": 426, "JSON": 460, "YAML": 132, "JSON with Comments": 4, "SQL": 18, "Microsoft Visual Studio Solution": 80, "Dockerfile": 59, "C#": 3959, "HTTP": 57, "Go Checksums": 2, "Go Module": 2, "Go": 33, "Java Properties": 36, "HTML": 8, "Git Attributes": 3, "Gradle": 16, "PHP": 177, "JavaScript": 5, "Gradle Kotlin DSL": 37, "Kotlin": 596, "OASv3-yaml": 1, "TOML": 1, "Java Server Pages": 23, "CSS": 5, "EditorConfig": 6, "HTML+Razor": 6} | package com.github.hummel.dc.lab4.controller.routing
import com.github.hummel.dc.lab4.dto.request.MessageRequestTo
import com.github.hummel.dc.lab4.dto.request.MessageRequestToId
import com.github.hummel.dc.lab4.sendViaKafka
import io.ktor.client.*
import io.ktor.client.engine.cio.*
import io.ktor.client.plugins.contentnegotiation.*
import io.ktor.client.request.*
import io.ktor.client.statement.*
import io.ktor.http.*
import io.ktor.serialization.kotlinx.json.*
import io.ktor.server.application.*
import io.ktor.server.request.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
internal fun Route.messagesRouting() {
val client = HttpClient(CIO) {
install(ContentNegotiation) {
json()
}
}
route("/messages") {
checkMessages(client)
createMessage(client)
deleteMessage(client)
updateMessage(client)
getMessage(client)
}
}
private fun Route.checkMessages(client: HttpClient) {
get {
call.respond(
client.get("http://0.0.0.0:24130/api/v1.0/messages").bodyAsText()
)
sendViaKafka("From Publisher: Messages GET [redirect]")
}
}
private fun Route.createMessage(client: HttpClient) {
post {
val body = call.receive<MessageRequestTo>()
val result = client.post("http://localhost:24130/api/v1.0/messages") {
contentType(ContentType.Application.Json)
setBody(body)
}
call.respond(
status = result.status, message = result.bodyAsText()
)
sendViaKafka("From Publisher: Messages POST [redirect]")
}
}
private fun Route.getMessage(client: HttpClient) {
get("/{id?}") {
val id = call.parameters["id"]
val result = client.get("http://localhost:24130/api/v1.0/messages/$id")
call.respond(
status = result.status, message = result.bodyAsText()
)
sendViaKafka("From Publisher: Messages GET ID [redirect]")
}
}
private fun Route.deleteMessage(client: HttpClient) {
delete("/{id?}") {
val id = call.parameters["id"]
val result = client.delete("http://localhost:24130/api/v1.0/messages/$id")
call.respond(
status = result.status, message = result.bodyAsText()
)
sendViaKafka("From Publisher: Messages DELETE ID [redirect]")
}
}
private fun Route.updateMessage(client: HttpClient) {
put {
val body = call.receive<MessageRequestToId>()
val result = client.put("http://localhost:24130/api/v1.0/messages") {
contentType(ContentType.Application.Json)
setBody(body)
}
call.respond(
status = result.status, message = result.bodyAsText()
)
sendViaKafka("From Publisher: Messages PUT [redirect]")
}
} | 0 | Java | 113 | 0 | cd2d48e9c6bbc2464b86be1116ec86cdce805bc5 | 2,513 | DC2024-01-27 | MIT License |
desk360/src/main/java/com/teknasyon/desk360/themev2/Desk360PreScreenFooter.kt | Teknasyon-Teknoloji | 188,395,069 | false | null | package com.teknasyon.desk360.themev2
import android.content.Context
import android.graphics.Color
import android.util.AttributeSet
import android.view.View
import androidx.appcompat.widget.AppCompatTextView
import com.teknasyon.desk360.helper.Desk360SDK
class Desk360PreScreenFooter : AppCompatTextView {
init {
Desk360SDK.config?.data?.let { data ->
this.setTextColor(Color.parseColor(data.general_settings?.bottom_note_color))
this.textSize = data.general_settings?.bottom_note_font_size!!.toFloat()
this.text = data.create_pre_screen?.bottom_note_text
this.visibility =
if (!data.create_pre_screen?.bottom_note_is_hidden!!) View.INVISIBLE else View.VISIBLE
}
}
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(
context,
attrs,
defStyle
)
} | 2 | Kotlin | 1 | 14 | d5cc69331db57812f2d053c6b09a24bd0eb4b7ea | 1,024 | desk360-android-sdk | MIT License |
SingleModuleApp/app/src/main/java/com/github/yamamotoj/singlemoduleapp/package61/Foo06100.kt | yamamotoj | 163,851,411 | false | null | package com.github.yamamotoj.singlemoduleapp.package61
import com.github.yamamotoj.singlemoduleapp.package60.Foo06099
class Foo06100 {
fun method0() {
Foo06099().method5()
}
fun method1() {
method0()
}
fun method2() {
method1()
}
fun method3() {
method2()
}
fun method4() {
method3()
}
fun method5() {
method4()
}
}
| 0 | Kotlin | 0 | 9 | 2a771697dfebca9201f6df5ef8441578b5102641 | 419 | android_multi_module_experiment | Apache License 2.0 |
src/test/kotlin/com/github/fnunezkanut/endpoint/v1/CoursesFetchTest.kt | fnunezkanut | 314,544,995 | false | null | package com.github.fnunezkanut.endpoint.v1
import com.github.fnunezkanut.model.Course
import com.github.fnunezkanut.service.CoursesService
import io.mockk.every
import io.mockk.mockk
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
class CoursesFetchTest {
private val coursesService = mockk<CoursesService>()
//under test
private val controller = CoursesFetch(
coursesService = coursesService
)
@Test
fun `main(), normal run, 200 on success`() {
//given
val uid = "a8632959-de2b-4ce3-8e40-2febe4736483"
val course = Course(
uid = uid,
code = "EE-130",
name = "Fundamentals Electronic Eng"
)
every { coursesService.fetch(uid) } returns course
//when
val actual = controller.main(
courseUid = uid
)
//then
assertThat(actual.statusCodeValue).isEqualTo(200)
assertThat(actual.body?.uid).isEqualTo(uid)
}
} | 0 | Kotlin | 0 | 0 | 63ba022af1eb4b178c256ce696d4e75c94fa751b | 1,020 | acr | MIT License |
app/src/main/java/com/company/elverano/data/historyWeather/HistoryWeatherResponse.kt | mobile-pablo | 408,588,102 | false | {"Kotlin": 71158} | package com.company.elverano.data.historyWeather
import androidx.room.Entity
import androidx.room.PrimaryKey
import com.google.gson.annotations.SerializedName
@Entity(tableName = "history_weather_response")
data class HistoryWeatherResponse(
@SerializedName("id") @PrimaryKey(autoGenerate = true) val id: Int = 0,
@SerializedName("data") val data: MutableList<HistoryWeather>? = null
)
| 0 | Kotlin | 0 | 3 | 841565b2f3116ac063eb344239a59d4fc3f5fe21 | 396 | Weather-Forecast | MIT License |
i18n4k-core/src/commonMain/kotlin/de/comahe/i18n4k/messages/NameToIndexMapperNumbersFrom1.kt | comahe-de | 340,499,429 | false | {"Kotlin": 657212} | package de.comahe.i18n4k.messages
/** For message strings that only contain numbers as parameter names starting at 1 */
object NameToIndexMapperNumbersFrom1 : NameToIndexMapper {
override fun getNameIndex(name: CharSequence): Int {
if(name == "10")
return 9;
if (name.length != 1)
throw IllegalArgumentException("One digit or '10' expected, but got: $name")
val char0: Char = name[0]
if (char0 < '1' || char0 > '9')
throw IllegalArgumentException("Digit between '1' and '9' or '10' expected, but got: $name")
return char0 - '1'
}
} | 4 | Kotlin | 9 | 70 | b5b5b3751f22da683682bd4464494e00e7db67b3 | 616 | i18n4k | Apache License 2.0 |
bones/src/main/java/pro/horovodovodo4ka/bones/Wrist.kt | horovodovodo4ka | 123,154,278 | false | null | package pro.horovodovodo4ka.bones
import pro.horovodovodo4ka.bones.Wrist.TransitionType.Decrementing
import pro.horovodovodo4ka.bones.Wrist.TransitionType.Incrementing
import pro.horovodovodo4ka.bones.Wrist.TransitionType.None
/**
* Represents navigation concept called **tabs**. It means that bone have children bones called **fingers**.
* Bone realize mechanics to switch between that fingers. Only one finger is active at a time.
*
* @constructor Creates new instance with tabs passed as parameter
*/
abstract class Wrist(
/**
* Bones which represents tabs. Can not be modified after construction.
*/
vararg finger: Bone
) : Bone() {
sealed class TransitionType {
object None : TransitionType()
data class Incrementing(val from: Bone?, val to: Bone?) : TransitionType()
data class Decrementing(val from: Bone?, val to: Bone?) : TransitionType()
}
/**
* Used to determine which type of changes is going now on stack.
*/
var transitionType: TransitionType = None
private set
/**
* Bones which represents tabs. Can not be modified after construction.
*/
val fingers: List<Bone> = finger.asList()
init {
fingers.forEach { add(it) }
activeBone.isPrimary = true
}
/**
* Index of currently active tab.
*
* @see [Wrist.activeBone]
*/
var activeBoneIndex: Int = 0
set(value) {
if (field == value) return
val oldIndex = activeBoneIndex
val oldBone = activeBone
activeBone.isPrimary = false
activeBone.isActive = false
field = value
activeBone.isActive = isActive
activeBone.isPrimary = true
transitionType = if (oldIndex > value) Decrementing(oldBone, activeBone) else Incrementing(oldBone, activeBone)
sibling?.refreshUI()
listeners.forEach { it.fingerSwitched(transitionType) }
transitionType = None
}
/**
* Currently active bone
*
* @see [Wrist.activeBoneIndex]
*/
var activeBone: Bone
get() = fingers[activeBoneIndex]
set(value) {
activeBoneIndex = fingers.indexOf(value)
}
/**
* marks wrist and it's active finger as active
*
* @see [Bone.isActive]
*/
override var isActive: Boolean = false
set(value) {
if (field == value) return
field = value
syncSibling()
activeBone.isActive = value
descendantsStore
.subtract(fingers)
.filter { !it.ignoreAutoActivation || !value }
.forEach { it.isActive = value }
}
// region Interactive
/**
* Used to notify parent bones about active tab changes.
*/
interface Listener {
fun fingerSwitched(transition: TransitionType)
}
private val listeners: List<Listener>
get() = (parents + this).mapNotNull { it as? Listener }
// endregion
} | 0 | null | 2 | 12 | dcf5e6349ecb11871e3706c3087113c85b49d402 | 3,062 | bones | The Unlicense |
data/src/main/java/com/mrtckr/livecoding/data/model/FeltTemperatureEntity.kt | Mrtckr008 | 747,623,658 | false | {"Kotlin": 136414} | package com.mrtckr.livecoding.data.model
import kotlinx.serialization.Serializable
@Serializable
data class FeltTemperatureEntity(
val degree: Int,
val description: String
)
| 0 | Kotlin | 0 | 3 | 0dd9a6cce5180b706d56f7e437e1ef5e7f79385f | 183 | Sample-Android-Clean-Architecture | The Unlicense |
app/src/main/java/pl/bydgoszcz/guideme/podlewacz/views/fragments/adapters/PourFrequencyAdapterFactory.kt | mniami | 130,084,279 | false | null | package pl.bydgoszcz.guideme.podlewacz.views.fragments.adapters
import android.content.Context
import android.widget.ArrayAdapter
import pl.bydgoszcz.guideme.podlewacz.R as PodlewaczR
import android.R
object PourFrequencyAdapterFactory {
fun create(context: Context): ArrayAdapter<SpinnerItem> {
val range = (1..30)
val daysString = context.getString(PodlewaczR.string.days)
val dayString = context.getString(PodlewaczR.string.day)
val repeatDaysValues = range.map {
SpinnerItem("%d %s".format(it, if (it == 1) dayString else daysString), it)
}.toTypedArray()
return ArrayAdapter(context, R.layout.simple_list_item_1, repeatDaysValues)
}
}
class SpinnerItem (val name: String, val value:Int) {
override fun toString(): String {
return name
}
} | 6 | Kotlin | 0 | 0 | 34f690ae4020df4080b7b7e59d0f10a757e8207e | 830 | pourtheflowers | MIT License |
shared/src/main/kotlin/io/github/aplcornell/viaduct/syntax/values/IOValue.kt | apl-cornell | 169,159,978 | false | {"Kotlin": 1117382, "Java": 43793, "C++": 13898, "Lex": 12293, "Python": 11983, "Dockerfile": 1951, "Makefile": 1762, "SWIG": 1212, "Shell": 950} | package edu.cornell.cs.apl.viaduct.syntax.values
import edu.cornell.cs.apl.viaduct.syntax.types.BooleanType
import edu.cornell.cs.apl.viaduct.syntax.types.IOValueType
import edu.cornell.cs.apl.viaduct.syntax.types.IntegerType
import edu.cornell.cs.apl.viaduct.syntax.types.UnitType
sealed class IOValue : Value()
/** An integer. */
data class IntegerValue(val value: Int) : IOValue() {
override val type: IOValueType
get() = IntegerType
override fun toString(): String {
return value.toString()
}
}
/** A boolean value. */
data class BooleanValue(val value: Boolean) : IOValue() {
override val type: IOValueType
get() = BooleanType
override fun toString(): String {
return value.toString()
}
}
/** The unique value of type [UnitType]. */
object UnitValue : IOValue() {
override val type: IOValueType
get() = UnitType
override fun toString(): String {
return "unit"
}
}
| 31 | Kotlin | 4 | 20 | 567491fdcfd313bf287b8cdd374e80f1e005ac62 | 961 | viaduct | MIT License |
app/src/main/java/com/alpdroid/huGen10/obdUtil/DtcPowertrain.kt | MyAlpDroid | 471,609,989 | false | {"Kotlin": 535306, "Java": 217295, "C++": 48013, "HTML": 7042, "C": 1394, "CMake": 990} | package com.alpdroid.huGen10.obdUtil
enum class DtcPowertrain (val dtc:String) {
P0000("No trouble code"),
P0001("Fuel Volume Regulator Control Circuit / Open"),
P0002("Fuel Volume Regulator Control Circuit Range/Performance"),
P0003("Fuel Volume Regulator Control Circuit Low"),
P0004("Fuel Volume Regulator Control Circuit High"),
P0005("FUEL SHUTOFF VALVE A"),
P0006("Fuel Shutoff Valve Control Circuit Low"),
P0007("Fuel Shutoff Valve Control Circuit High"),
P0008("Engine Position System Performance - Bank 2"),
P0009("Engine Position System Performance - Bank 2"),
P0010("Intake Camshaft Position Actuator Circuit / Open (Bank 2)"),
P0011("INT/V TIM CONT-B1"),
P0012("Intake Camshaft Position Timing - Over-Retarded (Bank 2)"),
P0013("Exhaust Camshaft Position Actuator Circuit / Open (Bank 2)"),
P0014("EXH/V TIM CONT-B1"),
P0015("Exhaust Camshaft Position Timing - Over-Retarded (Bank 2)"),
P0016("Crankshaft Position Camshaft Position Correlation Bank 2 Sensor A"),
P0017("Crankshaft Position Camshaft Position Correlation Bank 2 Sensor B"),
P0018("Crankshaft Position Camshaft Position Correlation Bank 2 Sensor A"),
P0019("Crankshaft Position Camshaft Position Correlation Bank 2 Sensor B"),
P0020("Intake Camshaft Position Actuator Circuit / Open (Bank 2)"),
P0021("INT/V TIM CONT-B2"),
P0022("Intake Camshaft Position Timing - Over-Retarded (Bank 2)"),
P0023("Exhaust Camshaft Position Actuator Circuit / Open (Bank 2)"),
P0024("EXH/V TIM CONT-B2"),
P0025("Exhaust Camshaft Position Timing - Over-Retarded (Bank 2)"),
P0026("Intake Valve Control Solenoid Circuit Range/Performance (Bank 2)"),
P0027("Exhaust Valve Control Solenoid Circuit Range/Performance (Bank 2)"),
P0028("Intake Valve Control Solenoid Circuit Range/Performance (Bank 2)"),
P0029("Exhaust Valve Control Solenoid Circuit Range/Performance (Bank 2)"),
P0030("HO2S1 HTR B1"),
P0031("Heated Oxygen Sensor (HO2S) Heater Circuit Low Voltage Bank 2 Sensor 1"),
P0032("Heated Oxygen Sensor (HO2S) Heater Circuit High Voltage Bank 2 Sensor 1"),
P0033("Turbo/Super Charger Bypass Valve Control Circuit / Open"),
P0034("SCB/V CONT SOL/V"),
P0035("Turbo/Super Charger Bypass Valve Control Circuit High"),
P0036("HO2S2 HTR (B1)"),
P0037("HO2S2 HTR (B1)"),
P0038("HO2S2 HTR (B1)"),
P0039("TC/SC BYPASS VALVE"),
P0040("Oxygen Sensor Signals Swapped Bank 2 Sensor 1 / Bank 2 Sensor 1"),
P0041("Oxygen Sensor Signals Swapped Bank 2 Sensor 2 / Bank 2 Sensor 2"),
P0042("HO2S Heater Control Circuit (Bank 2, Sensor 3)"),
P0043("HO2S3 HTR (B1)"),
P0044("HO2S3 HTR (B1)"),
P0045("TC BOOST SOL/V"),
P0046("Turbocharger/Supercharger Boost Control Circuit Range/Performance"),
P0047("TC/SC BOOST CONT A"),
P0048("TC/SC BOOST CONT A"),
P0049("Turbo/Super Charger Turbine Overspeed"),
P004A("TC BOOST SOL/CIRC-B2"),
P004B("Turbocharger/Supercharger Boost Control Circuit Range/Performance"),
P004C("TC BOOST SOL/CIRC-B2"),
P004D("TC BOOST SOL/CIRC-B2"),
P0050("Heated Oxygen Sensor (HO2S) Heater Circuit Bank 2 Sensor 1"),
P0051("Heated Oxygen Sensor (HO2S) Heater Circuit Low Voltage Bank 2 Sensor 1"),
P0052("Heated Oxygen Sensor (HO2S) Heater Circuit High Voltage Bank 2 Sensor 1"),
P0053("HO2S1 HTR B1"),
P0054("HO2S1 HTR B1"),
P0055("HO2S Heater Resistance Bank 2 Sensor 3 (PCM)"),
P0056("Heated Oxygen Sensor (HO2S) Heater Circuit Bank 2 Sensor 2"),
P0057("HO2S2 HTR (B2)"),
P0058("HO2S2 HTR (B2)"),
P0059("HO2S Heater Resistance (Bank 2, Sensor 1)"),
P0060("HO2S Heater Resistance (Bank 2, Sensor 2)"),
P0061("HO2S Heater Resistance (Bank 2, Sensor 3)"),
P0062("HO2S Heater Control Circuit (Bank 2, Sensor 3)"),
P0063("HO2S3 HTR (B2)"),
P0064("HO2S3 HTR (B2)"),
P0065("Air Assisted Injector Control Range/Performance"),
P0066("Air Assisted Injector Control Circuit or Circuit Low"),
P0067("Air Assisted Injector Control Circuit or Circuit High"),
P0068("MAP / MAF - Throttle Position Correlation"),
P0069("MAP - Barometric Pressure Correlation"),
P006A("MAP-MAF CORELTION-B1"),
P0070("Ambient Air Temperature Sensor Circuit"),
P0071("Ambient Air Temperature Sensor Range/Performance"),
P0072("Ambient Air Temperature Sensor Circuit Low Input"),
P0073("Ambient Air Temperature Sensor Circuit High Input"),
P0074("Ambient Air Temperature Sensor Circuit Intermittent/Erratic"),
P0075("INT/V TIM V/CIR-B1"),
P0076("Intake Valve Control Circuit Low (Bank 2)"),
P0077("Intake Valve Control Circuit High (Bank 2)"),
P0078("EX V/T ACT/CIRC-B1"),
P0079("Exhaust Valve Control Circuit Low (Bank 2)"),
P007A("CHARGE AIR COOLER TEMP SEN B1"),
P007B("CHARGE AIR COOLER TEMP SEN B1"),
P007C("CHARGE AIR COOLER TEMP SEN B1"),
P007D("CHARGE AIR COOLER TEMP SEN B1"),
P007E("CHARGE AIR COOLER TEMP SEN B1"),
P0080("Exhaust Valve Control Circuit High (Bank 2)"),
P0081("INT/V TIM V/CIR-B2"),
P0082("Intake Valve Control Circuit Low (Bank 2)"),
P0083("Intake Valve Control Circuit High (Bank 2)"),
P0084("EX V/T ACT/CIRC-B2"),
P0085("Exhaust Valve Control Circuit Low (Bank 2)"),
P0086("Exhaust Valve Control Circuit High (Bank 2)"),
P0087("LOW FUEL PRES"),
P0088("HIGH FUEL PRES"),
P0089("Fuel Pressure Regulator Performance"),
P008A("LOW FUEL PRES SYS"),
P008B("LOW FUEL PRES SYS"),
P0090("FUEL PUMP"),
P0091("Fuel Pressure Regulator Control Circuit Low"),
P0092("Fuel Pressure Regulator Control Circuit High"),
P0093("Fuel System Leak Detected - Large Leak"),
P0094("Fuel System Leak Detected - Small Leak"),
P0095("Intake Air Temperature Sensor 2 Circuit"),
P0096("IAT SENSOR 2 B1"),
P0097("IAT SENSOR 2 B1"),
P0098("IAT SENSOR 2 B1"),
P0099("Intake Air Temperature Sensor 2 Circuit Intermittent/Erratic"),
P00B3("P00B3"),
P00B4("P00B4"),
P0100("MAF SEN/CIRCUIT"),
P0101("MAF SEN/CIRCUIT-B1"),
P0102("MAF SEN/CIRCUIT-B1"),
P0103("MAF SEN/CIRCUIT-B1"),
P0104("Mass or Volume Air Flow Circuit Intermittent"),
P0105("ABSL PRES SEN/CIRC"),
P0106("ABSL PRES SEN/CIRC"),
P0107("ABSL PRES SEN/CIRC"),
P0108("ABSL PRES SEN/CIRC"),
P0109("Manifold Absolute Pressure/Barometric Pressure Circuit Intermittent"),
P010A("ABSL PRES SEN/CIRC"),
P010B("MAF SEN/CIRCUIT-B2"),
P010C("MAF SEN/CIRCUIT-B2"),
P010D("MAF SEN/CIRCUIT-B2"),
P0110("AIR TEMP SEN/CIRC"),
P0111("IAT SENSOR 1 B1"),
P0112("IAT SEN/CIRCUIT-B1"),
P0113("IAT SEN/CIRCUIT-B1"),
P0114("Intake Air Temperature Circuit Intermittent"),
P0115("ECT SEN/CIRC"),
P0116("ECT SENSOR"),
P0117("ECT SEN/CIRC"),
P0118("ECT SEN/CIRC"),
P0119("Engine Coolant Temperature Circuit Intermittent"),
P011C("CAT/IAT CRRLTN B1"),
P0120("THRTL POS SEN/CIRC"),
P0121("Throttle Position Sensor/Switch A Circuit Range/Performance Problem"),
P0122("Throttle Position Sensor/Switch A Circuit Low Input"),
P0123("Throttle Position Sensor/Switch A Circuit High Input"),
P0124("Throttle Position Sensor/Switch A Circuit Intermittent"),
P0125("ECT SENSOR"),
P0126("ECT Excessive Time to Closed Loop Fuel Control"),
P0127("IAT SENSOR-B1"),
P0128("THERMSTAT FNCTN"),
P0130("Coolant Thermostat Malfunction"),
P0131("O2 Sensor Circuit Malfunction (Bank 1 Sensor 1)"),
P0132("O2 Sensor Circuit Low Voltage (Bank 1 Sensor 1)"),
P0133("O2 Sensor Circuit High Voltage (Bank 1 Sensor 1)"),
P0134("HO2S1 (B1)"),
P0135("HO2S1 HTR (B1)"),
P0136("HO2S2 (B1)"),
P0137("HO2S2 (B1)"),
P0138("HO2S2 (B1)"),
P0139("HO2S2 (B1)"),
P0140("HO2S2 (B1)"),
P0141("HO2S2 HTR (B1)"),
P0142("O2 Sensor Heater Circuit Malfunction (Bank 1 Sensor 2)"),
P0143("HO2S3 (B1)"),
P0144("HO2S3 (B1)"),
P0145("HO2S3 (B1)"),
P0146("HO2S3 (B1)"),
P0147("HO2S3 HTR (B1)"),
P014C("A/F SENSOR1 (B1)"),
P014D("A/F SENSOR1 (B1)"),
P014E("A/F SENSOR1 (B2)"),
P014F("A/F SENSOR1 (B2)"),
P0150("O2 Sensor Heater Circuit Malfunction (Bank 1 Sensor 3)"),
P0151("O2 Sensor Circuit Malfunction (Bank 2 Sensor 1)"),
P0152("O2 Sensor Circuit Low Voltage (Bank 2 Sensor 1)"),
P0153("O2 Sensor Circuit High Voltage (Bank 2 Sensor 1)"),
P0154("HO2S1 (B2)"),
P0155("HO2S1 HTR (B2)"),
P0156("HO2S2 (B2)"),
P0157("HO2S2 (B2)"),
P0158("HO2S2 (B2)"),
P0159("HO2S2 (B2)"),
P015A("A/F SENSOR1 (B1)"),
P015B("A/F SENSOR1 (B1)"),
P015C("A/F SENSOR1 (B2)"),
P015D("A/F SENSOR1 (B2)"),
P0160("HO2S2 (B2)"),
P0161("HO2S2 HTR (B2)"),
P0162("O2 Sensor Heater Circuit Malfunction (Bank 2 Sensor 2)"),
P0163("HO2S3 (B2)"),
P0164("HO2S3 (B2)"),
P0165("HO2S3 (B2)"),
P0166("HO2S3 (B2)"),
P0167("O2 Sensor Circuit No Activity Detected (Bank 2 Sensor 3)"),
P0170("FUEL INJ SYSTEM-B1"),
P0171("FUEL SYS-LEAN-B1"),
P0172("FUEL SYS-RICH-B1"),
P0173("FUEL INJ SYSTEM-B2"),
P0174("FUEL SYS-LEAN-B2"),
P0175("FUEL SYS-RICH-B2"),
P0176("Fuel Trim too Rich (Bank 2)"),
P0177("Fuel Composition Sensor Circuit Malfunction"),
P0178("Fuel Composition Sensor Circuit Range/Performance"),
P0179("Fuel Composition Sensor Circuit Low Input"),
P0180("FUEL TEMP SEN/CIRC"),
P0181("FTT SENSOR"),
P0182("FTT SEN/CIRCUIT"),
P0183("FTT SEN/CIRCUIT"),
P0184("Fuel Temperature Sensor A Circuit High Input"),
P0185("FUEL TEMP SEN B"),
P0186("Fuel Temperature Sensor B Circuit Malfunction"),
P0187("FUEL TEMP SEN B"),
P0188("FUEL TEMP SEN B"),
P0189("Fuel Temperature Sensor B Circuit High Input"),
P0190("FUEL PRES SEN/CIRC"),
P0191("FRP SENSOR A"),
P0192("FRP SEN/CIRC"),
P0193("FRP SEN/CIRC"),
P0194("Fuel Rail Pressure Sensor Circuit High Input"),
P0195("Fuel Rail Pressure Sensor Circuit Intermittent"),
P0196("EOT SENSOR"),
P0197("EOT SEN/CIRK"),
P0198("EOT SEN/CIRK"),
P0199("Engine Oil Temperature Sensor High"),
P0200("INJECTOR CIRC-CYL"),
P0201("INJECTOR CIRC-CYL1"),
P0202("INJECTOR CIRC-CYL2"),
P0203("INJECTOR CIRC-CYL3"),
P0204("INJECTOR CIRC-CYL4"),
P0205("INJECTOR CIRC-CYL5"),
P0206("INJECTOR CIRC-CYL6"),
P0207("INJECTOR CIRC-CYL7"),
P0208("INJECTOR CIRC-CYL8"),
P0209("Injector Circuit Malfunction - Cylinder 8"),
P0210("Injector Circuit Malfunction - Cylinder 9"),
P0211("Injector Circuit Malfunction - Cylinder 10"),
P0212("Injector Circuit Malfunction - Cylinder 11"),
P0213("Injector Circuit Malfunction - Cylinder 12"),
P0214("Cold Start Injector 1 Malfunction"),
P0215("Cold Start Injector 2 Malfunction"),
P0216("Engine Shutoff Solenoid Malfunction"),
P0217("ENG OVER TEMP"),
P0218("TM FLUID OVER TEMP"),
P0219("Transmission Over Temperature Condition"),
P0220("Engine Overspeed Condition"),
P0221("TP SENSOR"),
P0222("TP SEN 1/CIRC-B1"),
P0223("TP SEN 1/CIRC-B1"),
P0224("Throttle/Petal Position Sensor/Switch B Circuit High Input"),
P0225("Throttle/Petal Position Sensor/Switch B Circuit Intermittent"),
P0226("APP SENSOR"),
P0227("Throttle/Petal Position Sensor/Switch C Circuit Range/Performance Problem"),
P0228("Throttle/Petal Position Sensor/Switch C Circuit Low Input"),
P0229("Throttle/Petal Position Sensor/Switch C Circuit High Input"),
P0230("Throttle/Petal Position Sensor/Switch C Circuit Intermittent"),
P0231("Fuel Pump Primary Circuit Malfunction"),
P0232("Fuel Pump Secondary Circuit Low"),
P0233("Fuel Pump Secondary Circuit High"),
P0234("TC SYSTEM-B1"),
P0235("TURBO BOOST SENSOR"),
P0236("TC BOOST SEN/CIRC-B1"),
P0237("TC BOOST SEN/CIRC-B1"),
P0238("TC BOOST SEN/CIRC-B1"),
P0239("TC/SC boost sensor B"),
P023A("P023A"),
P023B("P023B"),
P023C("P023C"),
P0240("TC BOOST SEN/CIRC-B2"),
P0241("TC BOOST SEN/CIRC-B2"),
P0242("TC BOOST SEN/CIRC-B2"),
P0243("W/G CONT SOL/V-B1"),
P0244("Turbocharger Wastegate Solenoid A Malfunction"),
P0245("SCB/V CONT SOL/V"),
P0246("Turbocharger Wastegate Solenoid A Low"),
P0247("W/G CONT SOL/V-B2"),
P0248("Turbocharger Wastegate Solenoid B Malfunction"),
P0249("Turbocharger Wastegate Solenoid B Range/Performance"),
P0250("Turbocharger Wastegate Solenoid B Low"),
P0251("Turbocharger Wastegate Solenoid B High"),
P0252("Injection Pump Fuel Metering Control \"A\" Malfunction (Cam/Rotor/Injector)"),
P0253("Injection Pump Fuel Metering Control \"A\" Range/Performance (Cam/Rotor/Injector)"),
P0254("Injection Pump Fuel Metering Control \"A\" Low (Cam/Rotor/Injector)"),
P0255("Injection Pump Fuel Metering Control \"A\" High (Cam/Rotor/Injector)"),
P0256("Injection Pump Fuel Metering Control \"A\" Intermittent (Cam/Rotor/Injector)"),
P0257("Injection Pump Fuel Metering Control \"B\" Malfunction (Cam/Rotor/Injector)"),
P0258("Injection Pump Fuel Metering Control \"B\" Range/Performance (Cam/Rotor/Injector)"),
P0259("Injection Pump Fuel Metering Control \"B\" Low (Cam/Rotor/Injector)"),
P025A("FUEL PUMP MODULE A"),
P025B("FUEL PUMP MODULE A"),
P0260("Injection Pump Fuel Metering Control \"B\" High (Cam/Rotor/Injector)"),
P0261("CYL1 INJECTOR"),
P0262("CYL1 INJECTOR"),
P0263("Cylinder 1 Injector Circuit High"),
P0264("CYL2 INJECTOR"),
P0265("CYL2 INJECTOR"),
P0266("Cylinder 2 Injector Circuit High"),
P0267("CYL3 INJECTOR"),
P0268("CYL3 INJECTOR"),
P0269("Cylinder 3 Injector Circuit High"),
P0270("CYL4 INJECTOR"),
P0271("CYL4 INJECTOR"),
P0272("Cylinder 4 Injector Circuit High"),
P0273("Cylinder 4 Contribution/Balance Fault"),
P0274("Cylinder 5 Injector Circuit Low"),
P0275("Cylinder 5 Injector Circuit High"),
P0276("Cylinder 5 Contribution/Balance Fault"),
P0277("Cylinder 6 Injector Circuit Low"),
P0278("Cylinder 6 Injector Circuit High"),
P0279("Cylinder 6 Contribution/Balance Fault"),
P0280("Cylinder 7 Injector Circuit Low"),
P0281("Cylinder 7 Injector Circuit High"),
P0282("Cylinder 7 Contribution/Balance Fault"),
P0283("Cylinder 8 Injector Circuit Low"),
P0284("Cylinder 8 Injector Circuit High"),
P0285("Cylinder 8 Contribution/Balance Fault"),
P0286("Cylinder 9 Injector Circuit Low"),
P0287("Cylinder 9 Injector Circuit High"),
P0288("Cylinder 9 Contribution/Balance Fault"),
P0289("Cylinder 10 Injector Circuit Low"),
P0290("Cylinder 10 Injector Circuit High"),
P0291("Cylinder 10 Contribution/Balance Fault"),
P0292("Cylinder 11 Injector Circuit Low"),
P0293("Cylinder 11 Injector Circuit High"),
P0294("Cylinder 11 Contribution/Balance Fault"),
P0295("Cylinder 12 Injector Circuit Low"),
P0296("Cylinder 12 Injector Circuit High"),
P0299("SC FUNCTION"),
P0300("MULTI CYL MISFIRE"),
P0301("CYL 1 MISFIRE"),
P0302("CYL 2 MISFIRE"),
P0303("CYL 3 MISFIRE"),
P0304("CYL 4 MISFIRE"),
P0305("CYL 5 MISFIRE"),
P0306("CYL 6 MISFIRE"),
P0307("CYL 7 MISFIRE"),
P0308("CYL 8 MISFIRE"),
P0309("Cylinder 8 Misfire Detected"),
P0310("Cylinder 9 Misfire Detected"),
P0311("Cylinder 10 Misfire Detected"),
P0312("Cylinder 11 Misfire Detected"),
P0320("Cylinder 12 Misfire Detected"),
P0321("Ignition/Distributor Engine Speed Input Circuit Malfunction"),
P0322("Ignition/Distributor Engine Speed Input Circuit Range/Performance"),
P0323("Ignition/Distributor Engine Speed Input Circuit No Signal"),
P0325("KNOCK SEN/CIRC-B1"),
P0326("KNOCK SENSOR 1 B1"),
P0327("KNOCK SEN/CIRC-B1"),
P0328("KNOCK SEN/CIRC-B1"),
P0329("Knock Sensor 1 Circuit High Input (Bank 1 or Single Sensor)"),
P0330("KNOCK SEN/CIRC-B2"),
P0331("P0331"),
P0332("KNOCK SEN/CIRC-B2"),
P0333("KNOCK SEN/CIRC-B2"),
P0334("Knock Sensor 2 Circuit High Input (Bank 2)"),
P0335("CKP SEN/CIRCUIT"),
P0336("Crankshaft Position Sensor A Circuit Malfunction"),
P0337("Crankshaft Position Sensor A Circuit Range/Performance"),
P0338("Crankshaft Position Sensor A Circuit Low Input"),
P0339("Crankshaft Position Sensor A Circuit High Input"),
P0340("CMP SEN/CIRC-B1"),
P0341("Camshaft Position Sensor Circuit Malfunction"),
P0342("Camshaft Position Sensor Circuit Range/Performance"),
P0343("Camshaft Position Sensor Circuit Low Input"),
P0344("Camshaft Position Sensor Circuit High Input"),
P0345("CMP SEN/CIRC-B2"),
P0350("IGN SIGNAL-PRIMARY"),
P0351("IGNITION COIL A"),
P0352("IGNITION COIL B"),
P0353("IGNITION COIL C"),
P0354("IGNITION COIL D"),
P0355("Ignition Coil D Primary/Secondary Circuit Malfunction"),
P0356("Ignition Coil E Primary/Secondary Circuit Malfunction"),
P0357("Ignition Coil F Primary/Secondary Circuit Malfunction"),
P0358("Ignition Coil G Primary/Secondary Circuit Malfunction"),
P0359("Ignition Coil H Primary/Secondary Circuit Malfunction"),
P0360("Ignition Coil I Primary/Secondary Circuit Malfunction"),
P0361("Ignition Coil J Primary/Secondary Circuit Malfunction"),
P0362("Ignition Coil K Primary/Secondary Circuit Malfunction"),
P0365("CAMSHAFT POSITION SENSOR B B1"),
P0370("Ignition Coil L Primary/Secondary Circuit Malfunction"),
P0371("Timing Reference High Resolution Signal A Malfunction"),
P0372("Timing Reference High Resolution Signal A Too Many Pulses"),
P0373("Timing Reference High Resolution Signal A Too Few Pulses"),
P0374("Timing Reference High Resolution Signal A Intermittent/Erratic Pulses"),
P0375("Timing Reference High Resolution Signal A No Pulses"),
P0376("Timing Reference High Resolution Signal B Malfunction"),
P0377("Timing Reference High Resolution Signal B Too Many Pulses"),
P0378("Timing Reference High Resolution Signal B Too Few Pulses"),
P0379("Timing Reference High Resolution Signal B Intermittent/Erratic Pulses"),
P0380("Timing Reference High Resolution Signal B No Pulses"),
P0381("Glow Plug/Heater Circuit \"A\" Malfunction"),
P0382("Glow Plug/Heater Indicator Circuit Malfunction"),
P0385("CKP SENSOR B"),
P0386("CKP SENSOR B"),
P0387("Crankshaft Position Sensor B Circuit Range/Performance"),
P0388("Crankshaft Position Sensor B Circuit Low Input"),
P0389("Crankshaft Position Sensor B Circuit High Input"),
P0390("Camshaft Position Sensor "B" Circuit"),
P0400("EGR SYSTEM"),
P0401("EGR SYSTEM"),
P0402("EGRC-BPT VALVE"),
P0403("EGR VOL CON/V CIR"),
P0404("Exhaust Gas Recirculation Control Circuit Range/Performance"),
P0405("EGR TEMP SEN/CIRC"),
P0406("EGR TEMP SEN/CIRC"),
P0407("P0407"),
P0408("Exhaust Gas Recirculation Sensor B Circuit Low"),
P040B("EGR TEMPERATURE SENSOR A"),
P040C("EGR TEMPERATURE SENSOR A"),
P040D("EGR TEMPERATURE SENSOR A"),
P0410("AIR PUMP CONTROL"),
P0411("SCNDRY AIR SYSEM"),
P0412("PAIRC-S/V(PUMP)"),
P0413("Secondary Air Injection System Switching Valve A Circuit Malfunction"),
P0414("Secondary Air Injection System Switching Valve A Circuit Open"),
P0415("Secondary Air Injection System Switching Valve A Circuit Shorted"),
P0416("Secondary Air Injection System Switching Valve B Circuit Malfunction"),
P0417("Secondary Air Injection System Switching Valve B Circuit Open"),
P0418("Secondary Air Injection System Switching Valve B Circuit Shorted"),
P0419("Secondary Air Injection System Relay \"A\" Circuit Malfunction"),
P0420("TW CATALYST SYS-B1"),
P0421("Catalyst System Efficiency Below Threshold (Bank 1)"),
P0422("Warm Up Catalyst Efficiency Below Threshold (Bank 1)"),
P0423("Main Catalyst Efficiency Below Threshold (Bank 1)"),
P0424("Heated Catalyst Efficiency Below Threshold (Bank 1)"),
P0426("Heated Catalyst Temperature Below Threshold (Bank 1)"),
P0427("Catalyst Temperature Sensor Range/Performance (Bank 1)"),
P0428("Catalyst Temperature Sensor Low Input (Bank 1)"),
P0430("TW CATALYST SYS-B2"),
P0431("Catalyst System Efficiency Below Threshold (Bank 2)"),
P0432("Warm Up Catalyst Efficiency Below Threshold (Bank 2)"),
P0433("Main Catalyst Efficiency Below Threshold (Bank 2)"),
P0434("Heated Catalyst Efficiency Below Threshold (Bank 2)"),
P0436("Heated Catalyst Temperature Below Threshold (Bank 2)"),
P0437("Catalyst Temperature Sensor Range/Performance (Bank 2)"),
P0438("Catalyst Temperature Sensor Low Input (Bank 2)"),
P0440("EVAP SMALL LEAK"),
P0441("EVAP PURG FLOW/MON"),
P0442("EVAP SMALL LEAK"),
P0443("PURG VOLUME CONT/V"),
P0444("PURG VOLUME CONT/V"),
P0445("PURG VOLUME CONT/V"),
P0446("VENT CONTROL VALVE"),
P0447("VENT CONTROL VALVE"),
P0448("VENT CONTROL VALVE"),
P044A("Exhaust Gas Recirculation Sensor "C" Circuit"),
P044B("Exhaust Gas Recirculation Sensor "C" Circuit Range/Performance"),
P044C("Exhaust Gas Recirculation Sensor "C" Circuit Low"),
P044D("Exhaust Gas Recirculation Sensor "C" Circuit High"),
P044E("Exhaust Gas Recirculation Sensor "C" Circuit Intermittent/Erratic"),
P0450("EVAPO SYS PRES SEN"),
P0451("EVAP SYS PRES SEN"),
P0452("EVAP SYS PRES SEN"),
P0453("EVAP SYS PRES SEN"),
P0454("Evaporative Emission Control System Pressure Sensor High Input"),
P0455("EVAP GROSS LEAK"),
P0456("EVAP VERY SML LEAK"),
P0460("FUEL LEV SEN SLOSH"),
P0461("FUEL LEVEL SENSOR"),
P0462("FUEL LEVL SEN/CIRC"),
P0463("FUEL LEVL SEN/CIRC"),
P0464("FUEL LEVL SEN/CIRC"),
P0465("Fuel Level Sensor Circuit Intermittent"),
P0466("Purge Flow Sensor Circuit Malfunction"),
P0467("Purge Flow Sensor Circuit Range/Performance"),
P0468("Purge Flow Sensor Circuit Low Input"),
P0469("Purge Flow Sensor Circuit High Input"),
P046E("P046E"),
P046F("P046F"),
P0470("Purge Flow Sensor Circuit Intermittent"),
P0471("Exhaust Pressure Sensor Malfunction"),
P0472("Exhaust Pressure Sensor Range/Performance"),
P0473("Exhaust Pressure Sensor Low"),
P0474("Exhaust Pressure Sensor High"),
P0475("Exhaust Pressure Sensor Intermittent"),
P0476("Exhaust Pressure Control Valve Malfunction"),
P0477("Exhaust Pressure Control Valve Range/Performance"),
P0478("Exhaust Pressure Control Valve Low"),
P0479("Exhaust Pressure Control Valve High"),
P0480("Exhaust Pressure Control Valve Intermittent"),
P0481("Cooling Fan 1 Control Circuit Malfunction"),
P0482("Cooling Fan 2 Control Circuit Malfunction"),
P0483("Cooling Fan 3 Control Circuit Malfunction"),
P0484("Cooling Fan Rationality Check Malfunction"),
P0485("Cooling Fan Circuit Over Current"),
P0486("P0486"),
P0491("SCNDY AIR SYS-B1"),
P0492("SCNDY AIR SYS-B2"),
P0495("Fan speed"),
P0500("VEHICLE SPEED SEN A"),
P0501("VEHICLE SPEED SEN A"),
P0502("Vehicle Speed Sensor Range/Performance"),
P0503("Vehicle Speed Sensor Low Input"),
P0504("BRAKE SW/CIRCUIT"),
P0505("Vehicle Speed Sensor Intermittent/Erratic/High"),
P0506("ISC SYSTEM"),
P0507("ISC SYSTEM"),
P050A("COLD START CONTROL"),
P050B("COLD START CONTROL"),
P050E("COLD START CONTROL"),
P0510("CLOSED TP SW/CIRC"),
P0520("EOP SENSOR/SWITCH"),
P0521("Engine Oil Pressure Sensor/Switch Circuit Malfunction"),
P0522("Engine Oil Pressure Sensor/Switch Circuit Range/Performance"),
P0523("Engine Oil Pressure Sensor/Switch Circuit Low Voltage"),
P0524("ENGINE OIL PRESSURE"),
P0525("P0525"),
P0527("COOLING FAN SPD SEN"),
P052A("CAMSHAFT POSITION TIMING B1"),
P052B("CAMSHAFT POSITION TIMING B1"),
P052C("CAMSHAFT POSITION TIMING B2"),
P052D("CAMSHAFT POSITION TIMING B2"),
P0530("P0530"),
P0531("A/C Refrigerant Pressure Sensor Circuit Malfunction"),
P0532("P0532"),
P0533("P0533"),
P0534("A/C Refrigerant Pressure Sensor Circuit High Input"),
P0544("EXHAUST GAS TEMP SENSOR 1 B1"),
P0545("EXHAUST GAS TEMP SENSOR 1 B1"),
P0546("EXHAUST GAS TEMP SENSOR 1 B1"),
P0547("EXHAUST GAS TEMP SENSOR 1 B2"),
P0548("EXHAUST GAS TEMP SENSOR 1 B2"),
P0549("EXHAUST GAS TEMP SENSOR 1 B2"),
P0550("PW ST P SEN/CIRC"),
P0551("Power Steering Pressure Sensor Circuit Malfunction"),
P0552("Power Steering Pressure Sensor Circuit Range/Performance"),
P0553("Power Steering Pressure Sensor Circuit Low Input"),
P0554("Power Steering Pressure Sensor Circuit High Input"),
P0555("BRAKE BSTR PRES SEN/CIRC"),
P0560("Power Steering Pressure Sensor Circuit Intermittent"),
P0561("System Voltage Malfunction"),
P0562("System Voltage Unstable"),
P0563("SYSTEM VOLTAGE"),
P0564("P0564"),
P0565("System Voltage High"),
P0566("Cruise Control On Signal Malfunction"),
P0567("Cruise Control Off Signal Malfunction"),
P0568("Cruise Control Resume Signal Malfunction"),
P0569("Cruise Control Set Signal Malfunction"),
P0570("Cruise Control Coast Signal Malfunction"),
P0571("BRAKE SW"),
P0572("Cruise Control/Brake Switch A Circuit Malfunction"),
P0573("Cruise Control/Brake Switch A Circuit Low"),
P0574("Cruise Control/Brake Switch A Circuit High"),
P0575("Cruise Control Related Malfunction"),
P0576("Cruise Control Related Malfunction"),
P0578("Cruise Control Related Malfunction"),
P0579("Cruise Control Related Malfunction"),
P0580("Cruise Control Related Malfunction"),
P059F("ACTIVE GRILLE AIR SHUTTER A"),
P0600("A/T COMM LINE"),
P0601("Serial Communication Link Malfunction"),
P0602("Control Module Read Only Memory(ROM)"),
P0603("ECM BACK UP/CIRCUIT"),
P0604("ECM"),
P0605("ECM"),
P0606("CONTROL MODULE"),
P0607("ECM"),
P0608("PCM Processor Fault"),
P0609("Control Module VSS Output \"A\" Malfunction"),
P060A("CONTROL MODULE"),
P060B("CONTROL MODULE"),
P0611("FIC MODULE"),
P0620("GENERATOR"),
P0621("Generator Control Circuit Malfunction"),
P0622("Generator Lamp \"L\" Control Circuit Malfunction"),
P0627("SUB FUEL PUMP CIRC"),
P0629("SUB FUEL PUMP CIRC"),
P062A("SUB FUEL PUMP CIRC"),
P062B("ECM"),
P062F("CONTROL MODULE"),
P0643("SENSOR POWER/CIRC"),
P0650("MIL/CIRC"),
P0654("Malfunction Indicator Lamp (MIL) Control Circuit Malfunction"),
P0655("Engine RPM Output Circuit Malfunction"),
P0656("Engine Hot Lamp Output Control Circuit Malfucntion"),
P065B("GENERATOR"),
P06DA("P06DA"),
P06DB("P06DB"),
P0700("TRANSMISSION CONT"),
P0701("Transmission Control System Malfunction"),
P0702("Transmission Control System Range/Performance"),
P0703("Transmission Control System Electrical"),
P0704("Torque Converter/Brake Switch B Circuit Malfunction"),
P0705("T/M RANGE SENSOR A"),
P0706("Transmission Range Sensor Circuit malfunction (PRNDL Input)"),
P0707("Transmission Range Sensor Circuit Range/Performance"),
P0708("Transmission Range Sensor Circuit Low Input"),
P0709("Transmission Range Sensor Circuit High Input"),
P0710("FLUID TEMP SENSOR A"),
P0711("FLUID TEMP SENSOR A"),
P0712("Transmission Fluid Temperature Sensor Circuit Range/Performance"),
P0713("Transmission Fluid Temperature Sensor Circuit Low Input"),
P0714("Transmission Fluid Temperature Sensor Circuit High Input"),
P0715("INPUT SPEED SENSOR A"),
P0716("Input/Turbine Speed Sensor Circuit Malfunction"),
P0717("INPUT SPEED SENSOR A"),
P0718("Input/Turbine Speed Sensor Circuit No Signal"),
P0719("Input/Turbine Speed Sensor Circuit Intermittent"),
P0720("OUTPUT SPEED SENSOR"),
P0721("Output Speed Sensor Circuit Malfunction"),
P0722("OUTPUT SPEED SENSOR"),
P0723("Output Speed Sensor No Signal"),
P0724("Output Speed Sensor Intermittent"),
P0725("ENGINE SPEED"),
P0726("ENGINE SPEED"),
P0727("Engine Speed Input Circuit Range/Performance"),
P0728("Engine Speed Input Circuit No Signal"),
P0729("6GR INCORRECT RATIO"),
P0730("INCORRECT GR RATIO"),
P0731("1GR INCORRECT RATIO"),
P0732("2GR INCORRECT RATIO"),
P0733("3GR INCORRECT RATIO"),
P0734("4GR INCORRECT RATIO"),
P0735("5GR INCORRECT RATIO"),
P0736("A/T REV GR FNCTN"),
P0740("TORQUE CONVERTER"),
P0741("Torque Converter Clutch Circuit Malfuction"),
P0742("Torque Converter Clutch Circuit Performance or Stuck Off"),
P0743("Torque Converter Clutch Circuit Stuck On"),
P0744("TORQUE CONVERTER"),
P0745("PC SOLENOID A"),
P0746("PC SOLENOID A"),
P0747("Pressure Control Solenoid Performance or Stuck Off"),
P0748("Pressure Control Solenoid Stuck On"),
P0749("Pressure Control Solenoid Electrical"),
P0750("SHIFT SOLENOID A"),
P0751("Shift Solenoid A Malfunction"),
P0752("Shift Solenoid A Performance or Stuck Off/"),
P0753("1-2 Shift Solenoid Valve Performance"),
P0754("Shift Solenoid A Stuck On"),
P0755("SHIFT SOLENOID B"),
P0756("1-2 Shift Solenoid Circuit Electrical"),
P0757("Shift Solenoid A Intermittent"),
P0758("Shift Solenoid B Malfunction"),
P0759("Shift Solenoid B Performance or Stuck Off/"),
P0760("SHIFT SOLENOID C"),
P0761("Shift Solenoid B Stuck On"),
P0762("SHIFT SOLENOID C"),
P0763("Shift Solenoid B Intermittent"),
P0764("Shift Solenoid C Malfunction"),
P0765("SHIFT SOLENOID D"),
P0766("Shift Solenoid C Stuck On"),
P0767("Shift Solenoid C Electrical"),
P0768("Shift Solenoid C Intermittent"),
P0769("Shift Solenoid D Malfunction"),
P0770("SHIFT SOLENOID E"),
P0771("Shift Solenoid D Stuck On"),
P0772("Shift Solenoid D Electrical"),
P0773("Shift Solenoid D Intermittent"),
P0774("Shift Solenoid E Malfunction"),
P0775("PC SOLENOID B"),
P0776("PC SOLENOID B"),
P0777("Shift Solenoid E Electrical"),
P0778("PC SOLENOID B"),
P0779("Pressure Control Solenoid B Malfunction"),
P0780("SHIFT"),
P0781("Pressure Control Solenoid B Stuck On"),
P0782("Pressure Control Solenoid B Electrical"),
P0783("Pressure Control Solenoid B Intermittent"),
P0784("Shift Malfunction"),
P0785("1-2 Shift Malfunction"),
P0786("2-3 Shift Malfunction"),
P0787("3-4 Shift Malfunction"),
P0788("4-5 Shift Malfunction"),
P0789("Shift/Timing Solenoid Malfunction/ 3-2 Shift Solenoid Circuit Electrical"),
P0790("Shift/Timing Solenoid Range/Performance"),
P0795("PC SOLENOID C"),
P0797("PC SOLENOID C"),
P0801("Shift/Timing Solenoid Low"),
P0803("Shift/Timing Solenoid High"),
P0804("Shift/Timing Solenoid Intermittent"),
P0820("GR LVR X-Y POS SEN"),
P0830("CLUTCH INTLCK SW/CIRC"),
P0833("CLUTCH P/P SW/CIRC"),
P0840("FLUID PRESS SEN/SW A"),
P0841("FLUID PRESS SEN/SW A"),
P0845("FLUID PRESS SEN/SW B"),
P0850("P-N POS SW/CIRCUIT"),
P0882("TCM POWER INPUT SIG"),
P0A1E("STR/GEN C/M"),
P0A8F("14V PWR MDL SYS"),
P0AC4("HV ECU MIL REQUEST"),
P1005("FUEL SHUTOFF/V B"),
P1006("FUEL SHUTOFF/V C"),
P100A("VVEL SYSTEM-B1"),
P100B("VVEL SYSTEM-B2"),
P100C("V/T OFFSET DATA NOT WRITTEN"),
P1031("A/F SEN1 HTR (B1)"),
P1032("A/F SEN1 HTR (B1)"),
P1033("B/V POS SEN 1-2 CORRELATION"),
P1034("BYPASS VALVE POSITION SENSOR"),
P1035("BYPASS VALVE POSITION SENSOR"),
P1040("BRAKE PRESSURE SEN"),
P1044("BYPASS VALVE POSITION SENSOR 2"),
P1045("BYPASS VALVE POSITION SENSOR 2"),
P1048("P1048"),
P1049("P1049"),
P1051("A/F SEN1 HTR (B2)"),
P1052("A/F SEN1 HTR (B2)"),
P1065("ECM BACK UP/CIRCUIT"),
P1075("VVL S/V"),
P1078("EXH TIM SEN/CIR-B1"),
P1080("EXH/V TIM CONT-B1"),
P1084("EXH TIM SEN/CIR-B2"),
P1086("EXH/V TIM CONT-B2"),
P1087("VVEL SYSTEM-B1"),
P1088("VVEL SYSTEM-B2"),
P1089("VVEL POS SEN/CIRC-B1"),
P1090("VVEL ACTR MOT-B1"),
P1091("VVEL ACTR MOT PWR"),
P1092("VVEL POS SEN/CIRC-B2"),
P1093("VVEL ACTR MOT-B2"),
P10FF("SC MAGNETIC CLUTCH"),
P1100("Normal/Performance Switch Circuit Malfunction"),
P1101("Reverse Inhibit Control Circuit Malfunction"),
P1102("MAF SEN/CIRCUIT"),
P1103("MAP SENSOR"),
P1104("MAP SENSOR"),
P1105("MAP/BAR SW SOL/CIR"),
P1106("BARO PRES SEN/CIRC"),
P1107("MAF Sensor In Range But Lower Than Expected"),
P1108("MAP SENSOR"),
P1109("MAP/BAR SW SOL/CIR"),
P1110("INT/V TIM CONT-B1"),
P1111("INT/V TIM V/CIR-B1"),
P1112("Dual Alternator Lower Circuit Malfunction/ Manifold Absolute Pressure (MAP) Sensor Circuit Intermittent Low Voltage"),
P1113("Dual Alternator Battery Lamp Circuit Malfunction"),
P1114("IAT - B Sensor Intermittent"),
P1115("IAT Sensor (D/C) Open/Short"),
P1116("Intake Air Temperature (IAT) Sensor Circuit Intermittent High Voltage"),
P1117("Intake Air Temperature (IAT) Sensor Circuit Intermittent Low Voltage"),
P1118("IAT Sensor Open/Short"),
P1119("RADI TEMP SEN/CIRC"),
P1120("ETC FUNCTION/CIRC"),
P1121("ETC ACTR"),
P1122("ETC FUNCTION/CIRC"),
P1123("ETC MOT RLY/CIRC"),
P1124("ETC MOT PWR"),
P1125("MOT THRT SEN/CT"),
P1126("P1126"),
P1127("ETC MOT"),
P1128("ETC MOT"),
P1129("ETC MOT GND"),
P1130("SWIRL CONT SOL/V"),
P1131("SWIRL CONT SOL/V"),
P1132("VARI SWL CON/SV-B1"),
P1133("VARI SWL CON/SV-B2"),
P1134("HO2S1 (B1)"),
P1135("INT/V TIM CONT-B2"),
P1136("INT/V TIM V/CIR-B2"),
P1137("SWL CON/V POSI SEN"),
P1138("SWIRL CONT VALVE"),
P1139("HO2S Transition Time Ratio Sensor 1"),
P1140("INTK TIM S/CIRC-B1"),
P1141("Fan Control Circuit Malfunction"),
P1142("Lack Of HO2S Switch - Sensor Indicates Lean"),
P1143("HO2S1 (B1)"),
P1144("HO2S1 (B1)"),
P1145("INTK TIM S/CIRC-B2"),
P1146("HO2S2 (B1)"),
P1147("HO2S2 (B1)"),
P1148("CLOSED LOOP-B1"),
P1150("Water In Fuel Condition"),
P1151("Fuel Restriction Indicator Circuit Malfunction"),
P1152("Fuel Restriction Condition"),
P1153("Air Assist Control Valve Range/Performance"),
P1154("HO2S1 (B2)"),
P1155("Lack Of HO2S21 Switch - Adaptive Fuel At Limit"),
P1156("Lack Of HO2S21 Switch - Sensor Indicates Lean"),
P1157("Lack Of HO2S21 Switch - Sensor Indicates Rich"),
P1158("Bank 2 Fuel Control Shifted Lean"),
P1159("Bank 2 Fuel Control Shifted Rich"),
P1163("HO2S1 (B2)"),
P1164("HO2S1 (B2)"),
P1165("SWL CON VC SW/CIRC"),
P1166("HO2S2 (B2)"),
P1167("HO2S2 (B2)"),
P1168("CLOSED LOOP-B2"),
P1169("HO2S3 (B1)"),
P1170("HO2S3 (B1)"),
P1171("INTAKE ERROR"),
P1172("Invalid Test"),
P1173("Fuel Rail Sensor In-Range Low Failure"),
P1174("Fuel Rail Sensor In-Range High Failure"),
P1175("ESO - Engine Shut Off Solenoid Fault"),
P1176("Rotor Sensor Fault"),
P1177("Rotor Control Fault"),
P1178("Rotor Calibration Fault"),
P117A("AIR FUEL RATIO B1"),
P117B("AIR FUEL RATIO B2"),
P1180("Cam Sensor Fault"),
P1181("CYL TEMP SEN"),
P1182("Cam Calibration Fault"),
P1183("Synchronization Fault"),
P1184("GAS TEMP SEN/CYL"),
P1185("Fuel Delivery System Malfunction - Low"),
P1186("Fuel Delivery System Malfunction - High"),
P1187("Fuel Shut Off Solenoid Malfunction"),
P1188("Engine Oil Temperature Circuit Malfunction"),
P1189("GAS TEMP SEN/ENG"),
P1190("GAS PRES SEN/ENG"),
P1191("GAS LINE PRESS"),
P1192("FUEL PRES SEN B"),
P1193("FUEL PRES SEN B"),
P1194("GAS PRES SEN/CYL"),
P1195("ENGINE NOT START"),
P1196("POOR ENGINE POWER"),
P1197("FUEL_RUN_OUT"),
P1198("EGR Drive Overcurrent"),
P1199("ECU A/D Converter"),
P119A("P119A"),
P119B("P119B"),
P119C("P119C"),
P1200("FUEL PUMP"),
P1201("Key Off Voltage High"),
P1202("Key Off Voltage Low"),
P1203("Pump Rotor Control Underfueling"),
P1204("Fuel Level Input Circuit Low"),
P1205("Injector Control Circuit"),
P1206("Injector Circuit Open / Shorted - Cylinder #1"),
P1209("Injector Circuit Open / Shorted - Cylinder #2"),
P120A("FP RELAY 2"),
P120B("FP RELAY 3"),
P1210("TACM SW SIGNALS"),
P1211("TCS C/U FUNCTN"),
P1212("TCS/CIRC"),
P1213("INJECTOR D/U"),
P1214("INJECTOR D/U"),
P1215("FUEL CUT/V(ENG)"),
P1216("INJECTOR D/U"),
P1217("OVER HEAT"),
P1218("Start Injector Circuit Malfunction"),
P1219("Pedal Position Sensor B Circuit Intermittent"),
P1220("FPCM/CIRCUIT"),
P1221("FUEL CUT VALVE/CYL"),
P1222("FUEL CUT VALVE/CYL"),
P1223("TP SEN 2/CIRC"),
P1224("TP SEN 2/CIRC"),
P1225("CTP LEARNING-B1"),
P1226("CTP LEARNING-B1"),
P1227("APP SEN 2/CIRC"),
P1228("APP SEN 2/CIRC"),
P1229("SENSOR POWER/CIRC"),
P1230("PRESS REG/CONT S/V"),
P1231("Control Sleeve Sensor Malfunction"),
P1232("PRESS REGURATOR"),
P1233("P1233"),
P1234("CTP LEARNING-B2"),
P1235("CTP LEARNING-B2"),
P1236("ETC MOT-B2"),
P1237("ETC FNCTN/CIRC-B2"),
P1238("ETC ACTR-B2"),
P1239("TP SENSOR-B2"),
P1240("Fuel Pump Control Out Of Range"),
P1241("Fuel Pump Control Out Of Range"),
P1242("Fuel Pump Secondary Circuit Malfunction"),
P1243("Fuel Pump Secondary Circuit Malfunction"),
P1244("Speed Fuel Pump Positive Feed Fault"),
P1245("Sensor Power Supply Malfunction"),
P1246("Sensor Power Supply Low Input"),
P1247("Sensor Power Supply High Input"),
P1248("Second Fuel Pump Faulty or Ground Fault"),
P1249("Alternator Load Input Failed High"),
P1250("Alternator Load Input Failed Low"),
P1251("Alternator Load Input Failed"),
P1252("Turbo Boost Pressure Low"),
P1253("Turbo Boost Pressure Not Detected"),
P1254("Wastegate Control Valve Performance"),
P1255("PRC Solenoid Circuit Malfunction"),
P1256("Air Mixture Solenoid Circuit Malfunction"),
P1257("Pedal Correlation PDS1 and LPDS High"),
P1258("Pedal Correlation PDS1 and LPDS Low"),
P1259("Pedal Correlation PDS2 and LPDS High"),
P1260("Pedal Correlation PDS2 and LPDS Low"),
P1261("MAIN FUEL INJ"),
P1262("Pedal Correlation PDS2 and HPDS"),
P1263("TC SYSTEM-B2"),
P1264("Immobilizer to PCM Signal Error"),
P1265("THEFT Detected"),
P1266("Cylinder #1 High To Low Side Short"),
P1267("Cylinder #2 High To Low Side Short"),
P1268("Cylinder #3 High To Low Side Short"),
P1269("Cylinder #4 High To Low Side Short"),
P1270("Cylinder #5 High To Low Side Short"),
P1271("A/F SENSOR1 (B1)"),
P1272("A/F SENSOR1 (B1)"),
P1273("A/F SENSOR1 (B1)"),
P1274("A/F SENSOR1 (B1)"),
P1275("A/F SENSOR1 (B1)"),
P1276("A/F SENSOR1 (B1)"),
P1277("A/F SEN1 HTR (B1)"),
P1278("A/F SENSOR1 (B1)"),
P1279("A/F SENSOR1 (B1)"),
P1280("Cylinder #4 High To Low Side Open"),
P1281("A/F SENSOR1 (B2)"),
P1282("A/F SENSOR1 (B2)"),
P1283("A/F SENSOR1 (B2)"),
P1284("A/F SENSOR1 (B2)"),
P1285("A/F SENSOR1 (B2)"),
P1286("A/F SENSOR1 (B2)"),
P1287("A/F SEN1 HTR (B2)"),
P1288("A/F SENSOR1 (B2)"),
P1289("A/F SENSOR1 (B2)"),
P1290("ETC MOT PWR-B2"),
P1291("ETC MOT PWR-B2"),
P1292("Fuel Pulse In Range But Higher Than Expected"),
P1293("Cylinder Head Temp Sensor Out Of Self Test Range"),
P1294("Cylinder Head Temp Sensor High Input"),
P1295("Cylinder Head Temp Sensor Low Input"),
P1296("Injector High Side Short To GND Or VBATT - Bank 1"),
P1297("Injector High Side Short To GND Or VBATT - Bank 2"),
P1298("Injector High Side Open - Bank 1"),
P1299("CTP LEARNING"),
P1300("Multi-faults - Bank 1 - With Low Side Shorts"),
P1301("Multi-faults - Bank 2 - With Low Side Shorts"),
P1302("Injector High Sides Shorted Together"),
P1303("IDM Failure"),
P1304("Cylinder Head Overtemperature Protection Active"),
P1305("Boost Calibration Fault"),
P1306("Boost Calibration High"),
P1307("Boost Calibration Low"),
P1308("EGR Calibration Fault"),
P1309("EGR Calibration High"),
P1313("EGR Calibration Low"),
P1314("Kickdown Relay Pull - In Circuit Fault"),
P1315("Kickdown Relay Hold Circuit Fault"),
P1316("A/C Clutch Circuit Fault"),
P1317("Misfire Monitor AICE Chip Fault"),
P1320("IGN SIGNAL-PRIMARY"),
P1334("TC SYSTEM-B2"),
P1335("CKP SEN(REF)/CIRC"),
P1336("CKP SENSOR(COG)"),
P1340("Misfire Rate Catalyst Damage Fault - Bank 2"),
P1341("Persistent Misfire"),
P1345("Injector Circuit / IDM Codes Detected"),
P1346("Injector Circuit / IDM Codes Not Updated"),
P1347("Crank / Cam Sensor Range / Performance"),
P1348("Camshaft Position Sensor B Circuit Malfunction"),
P1349("Camshaft Position Sensor B Range / Performance"),
P1350("SGC (Cam Position) Sensor Circuit Malfunction/ Crankshaft Position - Camshaft Position Correlation"),
P1351("Fuel Level Sensor B Circuit Malfunction"),
P1352("Fuel Level Sensor B Range / Performance"),
P1353("Fuel Level Sensor B Circuit Low"),
P1354("Fuel Level Sensor B Circuit High"),
P1355("Fuel Level Sensor B Intermittent/Bypass Line Monitor"),
P1360("IDM Input Circuit Malfunction/ Ignition Coil Control Circuit High Voltage"),
P1361("Ignition Coil A Primary Circuit Malfunction"),
P1362("Ignition Coil B Primary Circuit Malfunction"),
P1363("Ignition Coil C Primary Circuit Malfunction"),
P1364("Ignition Coil D Primary Circuit Malfunction"),
P1365("Ignition Coil A Secondary Circuit Malfunction"),
P1366("Ignition Control (IC) Circuit Low Voltage"),
P1367("Ignition Coil C Secondary Circuit Malfunction"),
P1368("Ignition Coil D Secondary Circuit Malfunction"),
P1369("Ignition Coil Primary Circuit Failure"),
P1370("Ignition Coil Secondary Circuit Failure"),
P1371("Ignition Spare"),
P1372("Ignition Spare"),
P1373("Ignition Spare"),
P1374("Engine Temperature Light Monitor Failure"),
P1375("Insufficient RMP Increase During Spark Test"),
P1376("Ignition Coil - Cylinder 1 - Early Activation Fault"),
P1380("Ignition Coil - Cylinder 2 - Early Activation Fault"),
P1381("Ignition Coil - Cylinder 3 - Early Activation Fault"),
P1382("Crankshaft Position (CKP)/Ignition Coil - Cylinder 4 - Early Activation Fault"),
P1383("Ignition Coil - Cylinder 5 - Early Activation Fault"),
P1384("Ignition Coil - Cylinder 6 - Early Activation Fault"),
P1385("Misfire Detected - Rough Road Data Not Available"),
P1386("Variable Cam Timing Overadvanced (Bank #1)/ Misfire Detected - No Communication with BCM"),
P1387("Variable Cam Timing Solenoid #1 Circuit Malfunction"),
P1388("Variable Cam Timing Overretarded (Bank #1)"),
P1389("VVT Solenoid A Malfunction"),
P1390("Variable Cam Timing Solenoid B Malfunction"),
P1391("Variable Cam Timing Overadvanced (Bank #2)"),
P1392("Variable Cam Timing Solenoid #2 Circuit Malfunction"),
P1393("Variable Cam Timing Overretarded (Bank #2)"),
P1394("Glow Plug Circuit High Side Low Input"),
P1395("Octane Adjust Pin Out Of Self Test Range"),
P1396("Glow Plug Circuit Low Input (Bank #1)"),
P1397("Glow Plug Circuit High Input (Bank #1)"),
P1398("Glow Plug Circuit Low Input (Bank #2)"),
P1399("Glow Plug Circuit High Input (Bank #2)"),
P1400("EGRC SOLENOID/V"),
P1401("EGR TEMP SEN/CIRC"),
P1402("EGR SYSTEM"),
P1403("VVT Solenoid B Circuit High Input"),
P1404("Glow Plug Circuit High Side"),
P1405("DPFE Circuit Low Input"),
P1406("DPFE Circuit High Input"),
P1407("EGR Metering Orifice Restricted"),
P1408("DPFE Sensor Hoses Reversed"),
P1409("IAT - B Circuit Malfunction/ Exhaust Gas Recirculation Closed Position Performance"),
P1411("DPFE Sensor Upstream Hose Off Or Plugged"),
P1412("2ND AIR/V CIRC"),
P1413("Exhaust Gas Recirculation (EGR) Position Sensor Performance"),
P1414("EGR No Flow Detected"),
P1415("EGR Flow Out Of Self Test Range"),
P1416("EVR Control Circuit Malfunction"),
P1417("SAI System Incorrect Downstream Flow Detected"),
P1418("SAI System Monitor Circuit Low Input"),
P1419("SAI System Monitor Circuit High Input"),
P1420("Air Pump Circuit Malfunction/ (AIR) System Bank 1"),
P1421("COLD START CONTROL"),
P1422("COLD START CONTROL"),
P1423("COLD START CONTROL"),
P1424("COLD START CONTROL"),
P1425("COLD START CONTROL"),
P1426("Catalyst Damage"),
P1427("EGI Temperature Sensor Failure"),
P1428("EGI Functionality Test Failed"),
P1429("EGI Glow Plug Primary Failure"),
P1430("EGI Glow Plug Secondary Failure"),
P1433("EGI Mini - MAF Failed Out Of Range"),
P1434("EGI Mini - MAF Failed Short Circuit"),
P1435("EGI Mini - MAF Failed Open Circuit"),
P1436("Electric Air Pump Primary Failure"),
P1437("Electric Air Pump Secondary Failure"),
P1438("A/C Refrigerant Temperature Circuit Low"),
P1439("A/C Refrigerant Temperature Circuit High"),
P1440("EVAP SMALL LEAK"),
P1441("EVAP VERY SML LEAK"),
P1442("EVAP SMALL LEAK"),
P1443("CAN CONT VC CHK SW"),
P1444("PURG VOLUME CONT/V"),
P1445("Evaporative Emission (EVAP) System Flow During Non-Purge Chevrolet Only"),
P1446("VENT CONTROL VALVE"),
P1447("EVAP PURG FLOW/MON"),
P1448("VENT CONTROL VALVE"),
P1449("Purge Flow Sensor Circuit Low Input"),
P1450("Purge Flow Sensor Circuit High Input"),
P1451("TC/SC PR/S-EVAP PR/S"),
P1452("ELC System Closure Valve Flow Fault"),
P1453("ELC System 2 Fault"),
P1454("Evaporative Check Solenoid Circuit Malfunction"),
P1455("Unable To Bleed Up Fuel Tank Vacuum"),
P1456("EVAP VERY SML LEAK"),
P1457("Unable To Bleed - Up Vacuum in Tank"),
P1460("Fuel Tank Pressure Relief Valve Malfunction"),
P1461("Evaporative System Vacuum Test Malfunction"),
P1462("Evap Emission Control Sys Leak Detected (Gross Leak/No Flow)"),
P1463("Fuel Tank Temperature Sensor Circuit Malfunction"),
P1464("FUEL LEVL SEN/CIRC"),
P1465("Wide open throttle A/C cutoff relay circuit"),
P1466("A/C pressure sensor circuit voltage low"),
P1467("A/C pressure sensor circuit voltage high"),
P1468("A/C Pressure Sensor Insufficient Pressure Change"),
P1469("A/C Demand Out of Self Test Range"),
P1470("A/C Relay Circuit Malfunction"),
P1471("A/C Refrigerant Temperature Sensor/Circuit Malfunction"),
P1472("A/C Compressor Temperature Sensor Malfunction"),
P1473("SSPOD Open Circuit or Closed Circuit Fault"),
P1474("Low A/C Cycling Period"),
P1475("A/C Cycling Period Too Short"),
P1476("Electrodrive Fan 1 Operational Failure (Driver Side)"),
P1477("Electrodrive Fan 2 Operational Failure (Passenger Side)"),
P1478("Fan Secondary High With Fan(s) Off"),
P1479("Low Fan Control Primary Circuit Malfunction"),
P1480("FAN CONT S/V CIRC"),
P1481("Fan Relay (High) Circuit Malfunction"),
P1482("Additional Fan Relay Circuit Malfunction"),
P1483("Cooling Fan Driver Fault"),
P1484("High Fan Control Primary Circuit Malfunction"),
P1485("Fan Secondary Low with Low Fan On"),
P1486("Fan Secondary Low With High Fan On"),
P1487("SCP"),
P1490("VC/V BYPASS/V"),
P1491("VC CUT/V BYPASS/V"),
P1492("PURG CONT S/V"),
P1493("PURG CONT/V & S/V"),
P1494("EGRCHK Solenoid Circuit Malfunction"),
P1495("IDLE PURG S/V CIRC"),
P1497("GAUG ORIF S/V CIRC"),
P1500("Secondary Switch Solenoid Circuit Malfunction"),
P1501("APLSOL Solenoid Circuit Malfunction"),
P1502("RCNT Solenoid Circuit Malfunction"),
P1503("SPCUT Solenoid Circuit Malfunction"),
P1504("TCSPL Solenoid Circuit Malfunction"),
P1505("ISC SYSTEM/FNCTN"),
P1506("Vehicle Speed Sensor Out Of Self Test Range"),
P1507("INTAKE ERROR"),
P1508("Auxillary Speed Sensor Fault"),
P1509("Idle Air Control Circuit Malfunction"),
P1510("Idle Air Control System At Adaptive Clip"),
P1511("Idle Air Control Overspeed Error"),
P1512("STARTER"),
P1513("S/STR & GENERTR OPER COUNTR"),
P1514("Idle Control System Circuit Shorted"),
P1515("Idle Signal Circuit Malfunction"),
P1516("Idle Switch (Electric Control Throttle) Circuit Malfunction"),
P1517("Intake Manifold Runner Control (Bank 1) Stuck Closed"),
P1518("Intake Manifold Runner Control (Bank 2) Stuck Closed"),
P1519("High Load Neutral/Drive Fault"),
P1520("Electric Current Circuit Malfunction"),
P1521("IMRC Input Error (Bank 1)"),
P1522("IMRC Input Error (Bank 2)"),
P1523("Intake Manifold Runner Control (Stuck Open)"),
P1524("Intake Manifold Runner Control (Stuck Closed)"),
P1525("Intake Manifold Runner Control Circuit Malfunction"),
P1526("Variable Intake Solenoid #1 Circuit Malfunction"),
P1527("Variable Intake Solenoid #2 Circuit Malfunction"),
P1528("IVC Solenoid Circuit Malfunction"),
P1529("Variable Intake Solenoid System"),
P1530("Air Bypass Valve System"),
P1531("A/C COMPRESSOR"),
P1532("A/C COMP MAG CLTCH"),
P1533("Subsidiary Throttle Valve Solenoid Circuit Malfunction"),
P1534("SCAIR Solenoid Circuit Malfunction"),
P1535("A/C Clutch Circuit Malfunction"),
P1536("Invalid Test - Accelerator Pedal Movement"),
P1537("IMCC Circuit Malfunction"),
P1538("AAI Circuit Malfunction"),
P1539("Inertia Switch Activated"),
P1540("BATTERY CURRENT SENSOR B"),
P1541("BATTERY CURRENT SENSOR B"),
P1542("BATTERY CURRENT SENSOR B"),
P1543("BATTERY CURRENT SENSOR B"),
P1544("BATTERY CURRENT SENSOR B"),
P1546("BATTERY TEMPERATURE SENSOR B"),
P1547("BATTERY TEMPERATURE SENSOR B"),
P1549("Parking Brake Switch Circuit Failure"),
P1550("BAT CURRENT SENSOR"),
P1551("BAT CURRENT SENSOR"),
P1552("BAT CURRENT SENSOR"),
P1553("BAT CURRENT SENSOR"),
P1554("BAT CURRENT SENSOR"),
P1555("ALT CHRG CONT/SYS"),
P1556("BATTMPSEN/CIRC"),
P1557("BATTMPSEN/CIRC"),
P155D("GENERATOR"),
P155E("GENERATOR VOLTAGE"),
P155F("GENERATOR VOLTAGE"),
P1564("ASCD SW"),
P1565("Intake Manifold Runner Control (Bank 2) Stuck Open"),
P1566("Power To A/C Clutch Circuit Overcurrent"),
P1567("Air Bypass Valve Circuit Malfunction"),
P1568("ICC COMMAND VALUE"),
P1571("PSPS Out Of Self Test Range"),
P1572("ASCD BRAKE SW"),
P1573("Speed Control Command Switch Out of Range Low"),
P1574("ASCD VHL SPD SEN"),
P1575("BRAKE SW"),
P1576("ASCD BRAKE SW"),
P1577("ASCD BRAKE SW"),
P1578("Throttle Position Not Available"),
P1579("Throttle Position Sensor Disagreement btwn Sensors"),
P1580("Pedal Position Out of Self Test Range"),
P1581("Pedal Position Not Available"),
P1582("Pedal Position Sensor Disagreement btwn Sensors"),
P1583("ETC Power Less Than Demand"),
P1584("ETC In Power Limiting Mode"),
P1585("Electronic Throttle Monitor PCM Override"),
P1586("Electronic Throttle Monitor Malfunction"),
P1587("Electronic Throttle Monitor Data Available"),
P1588("Electronic Throttle Monitor Cruise Disable"),
P1589("TCU Detected IPE Circuit Malfunction"),
P158A("G SENSOR"),
P159A("G sensor"),
P159B("G sensor"),
P159C("G sensor"),
P159D("G sensor"),
P159F("P159F"),
P1600("Throttle Control Unit Malfunction"),
P1601("Throttle Control Unit Throttle Position Malfunction"),
P1602("Throttle Control Unit Modulated Command Malfunction"),
P1603("Throttle Control Unit Detected Loss of Return Spring"),
P1604("TCU Unable To Control Desired Throttle Angle"),
P1605("TP SENSOR"),
P1606("VVEL CONTROL MODULE"),
P1607("VVEL CONTROL MODULE"),
P1608("VVEL SENSOR POWER/CIRC"),
P1609("Code Word Unregestered"),
P1610("LOCK MODE"),
P1611("ID DISCORD,IMMU-ECM"),
P1612("CHAIN OF ECM-IMMU"),
P1613("ECM INT CIRC-IMMU"),
P1614("CHAIN OF IMMU-KEY"),
P1615("DIFFERENCE OF KEY"),
P1616("ECM"),
P1617("IMMU"),
P1618("LPG SYSTEM DIAGNOSIS"),
P1619("SBDS Interactive Codes"),
P161B("P161B"),
P161D("IMMOBILIZER"),
P161E("IMMOBILIZER"),
P161F("IMMOBILIZER"),
P1620("SBDS Interactive Codes"),
P1621("SBDS Interactive Codes"),
P1622("SBDS Interactive Codes"),
P1623("SBDS Interactive Codes"),
P1624("SBDS Interactive Codes"),
P1625("SBDS Interactive Codes"),
P1626("Control Module Long Term Memory Performance/ Immobilizer Code Words Do Not Match"),
P1627("Immobilizer ID Does Not Match"),
P1628("Immobilizer Code Word/ID Number Write Failure"),
P1629("Anti Theft System"),
P162B("P162B"),
P162C("P162C"),
P162D("P162D"),
P1630("B+ Supply To VCRM Fan Circuit Malfunction"),
P1631("Theft Deterrent Fuel Enable Signal Not Received/ B+ Supply To VCRM A/C Circuit Malfunction"),
P1632("Module Supply Voltage Out Of Range"),
P1633("Module Ignition Supply Input Malfunction"),
P1634("Internal Voltage Regulator Malfunction"),
P1635("Internal Vref Malfunction"),
P1636("Theft Deterrent Start Enable Signal Not Correct/ Main Relay Malfunction (Power Hold)"),
P1637("Smart Alternator Faults Sensor/Circuit Malfunction"),
P1638("KAM Voltage Too Low"),
P1639("Data Output Link Circuit Failure"),
P1640("Tire / Axle Ratio Out of Acceptable Range"),
P1641("Inductive Signature Chip Communication Error"),
P1642("Can Link ECM/ABSCM Circuit / Network Malfunction"),
P1643("Can Link ECM/INSTM Circuit / Network Malfunction"),
P1644("Vehicle ID Block Corrupted or Not Programmed"),
P1645("Powertrain DTCs Available in Another Module"),
P1650("STR MTR RELAY 2"),
P1651("STR MTR RELAY"),
P1652("STR MTR SYS COMM"),
P1653("Fuel Pump Speed Control Circuit Malfunction"),
P1654("Fuel Pump Resistor Switch Circuit Malfunction"),
P1655("ENGINE RESTART BYPASS RELAY"),
P1656("ENGINE RESTART BYPASS RELAY"),
P1660("PSP Switch Input Malfunction"),
P1661("IAC Monitor Disabled by PSP Switch Failed On"),
P1662("Power Steering Output Circuit Malfunction"),
P1663("Recirculation Override Circuit Malfunction"),
P1667("Starter Disable Circuit Malfunction"),
P1668("Output Circuit Check Signal High"),
P1670("Output Circuit Check Signal Low"),
P1680("IDM_EN Circuit Failure"),
P1681("Fuel Demand Command Signal Circuit Malfunction"),
P1682("CI Circuit Malfunction"),
P1683("PCM - IDM Communications Error"),
P1684("Electronic Feedback Signal Not Detected"),
P1685("Metering Oil Pump Malfunction"),
P1686("Metering Oil Pump Malfunction"),
P1687("Metering Oil Pump Malfunction"),
P1688("Metering Oil Pump Temperature Sensor Circuit Malfunction"),
P1689("Metering Oil Pump Position Sensor Circuit Malfunction"),
P1690("Metering Oil Pump Stepping Motor Circuit Malfunction"),
P1691("Metering Oil Pump Stepping Motor Circuit Malfunction"),
P1692("Metering Oil Pump Stepping Motor Circuit Malfunction"),
P1693("Metering Oil Pump Stepping Motor Circuit Malfunction"),
P1694("Oil Pressure Control Solenoid Circuit Malfunction"),
P1700("CVT C/U FUNCT"),
P1701("Turbo Pressure Control Solenoid Circuit Malfunction"),
P1702("Turbo Control Solenoid Circuit Malfunction"),
P1703("Turbo Charge Control Circuit Malfunction"),
P1704("Turbo Charge Relief Circuit Malfunction"),
P1705("TP SENSOR"),
P1706("P-N POS SW/CIRCUIT"),
P1707("TRS Circuit Intermittent Malfunction"),
P1708("Brake Switch Out Of Self Test Range"),
P1709("Digital TRS Failed to Transition States in KOEO / KOER"),
P1711("Not in P or N During KOEO / KOER"),
P1712("High Vehicle Speed Observed in Park"),
P1713("Transfer Case Neutral Indicator Hard Fault Present"),
P1714("Clutch Switch Circuit Malfunction"),
P1715("IN PULY SPEED"),
P1716("TURBINE REV S/CIRC"),
P1717("Trans Torque Reduction Request Signal Malfunction"),
P1718("TFT Sensor In Range Failure Low Value"),
P1720("V/SP SEN(A/T OUT)"),
P1721("SSB Inductive Signature Malfunction"),
P1722("SSC Inductive Signature Malfunction"),
P1723("SSD Inductive Signature Malfunction"),
P1724("TFT Sensor In Range Failure High"),
P1725("Vehicle Speed (Meter) Circuit Malfunction"),
P1726("Gear 1 Incorrect Ratio"),
P1727("Gear 2 Incorrect Ratio"),
P1728("Gear 3 incorrect Ratio"),
P1729("Gear 4 Incorrect Ratio"),
P1730("INTERLOCK"),
P1731("Insufficient Engine Speed Decrease During Self Test"),
P1732("Coast Clutch Solenoid Inductive Signature Malfunction"),
P1733("Transmission Slip Error"),
P1734("7GR INCORRECT RATIO"),
P1735("Gear Control Malfunction 2"),
P1736("1-2 Shift Malfunction"),
P1737("2-3 Shift Malfunction"),
P1738("3-4 Shift Malfunction"),
P1739("Gear Control Malfunction"),
P1740("SLCT SOLENOID"),
P1741("Second Gear Switch Circuit Malfunction"),
P1742("Lockup Solenoid System"),
P1743("Shift Time Error"),
P1744("Slip Solenoid System"),
P1745("Torque Converter Clutch Inductive Signature Malfunction"),
P1746("Torque Converter Clutch Control Error"),
P1747("Torque Converter Clutch Solenoid Failed On"),
P1748("Torque Converter Clutch Solenoid Failied On"),
P1749("Torque Converter Clutch System Performance"),
P1751("SHIFT CONT/FNCTN"),
P1752("INPUT CLUTCH SOL"),
P1753("SHIFT CONT SOL"),
P1754("INPUT CLUTCH SOL"),
P1755("Pressure Control Solenoid \"A\" Short Circuit"),
P1756("L/PRESS CONT/FNCTN"),
P1757("FR BRAKE SOLENOID"),
P1758("LINE PRES SOL"),
P1759("FR/B SOLENOID FNCT"),
P1760("OVER CLUTCH SOLENOID"),
P1761("Shift Solenoid A Performance"),
P1762("DRCT CLUTCH SOL"),
P1763("CLUTH PRES SOL"),
P1764("D/C SOLENOID FNCTN"),
P1765("Intermediate Speed Sensor (ISS) Malfunction"),
P1766("TCC CONT/FNCTN"),
P1767("HLR CLUTCH SOLENOID"),
P1768("CLUTH SW SOL"),
P1769("HLR/C SOL FNCTN"),
P1770("Overdrive Band Failed Off"),
P1772("L C BRAKE SOLENOID"),
P1774("L C BRAKE SOLENOID"),
P1775("TOR CONV CLTCH S/V"),
P1776("TOR CONV CLTCH S/V"),
P1777("STEP MOTOR"),
P1778("STEP MOTOR"),
P1779("Clutch Solenoid Circuit Malfunction"),
P1780("SHIFT SIG FNCTN"),
P1781("Ignition Retard Request Duration Fault"),
P1782("Ignition Retard Request Circuit Fault"),
P1783("Transmission Reverse I/P Circuit Malfunction"),
P1784("TCIL Circuit Malfunction"),
P1785("Trans Control Switch (O/D Cancel) Out of Self Test Range"),
P1786("4X4 Switch Out of Self Test Range"),
P1787("P/ES Circuit Out Of Self Test Range"),
P1788("Transmission Overtemperature Condition"),
P1789("Transmission Mechanical Failure - First And Reverse"),
P1790("Transmission Mechanical Failure - First And Second"),
P1791("LINE PRESSURE"),
P1792("2-1 Downshift Error"),
P1793("Pressure Control Solenoid \"B\" Open Circuit"),
P1794("Pressure Control Solenoid \"B\" Short Circuit"),
P1795("TP (Mechanical) Circuit Malfunction"),
P1796("TP (Electric) Circuit Malfunction"),
P1797("Barometer Pressure Circuit Malfunction"),
P1798("Intake Air Volume Circuit Malfunction"),
P1799("Battery Voltage Circuit Malfunction"),
P1800("VIAS S/V CIRC-B1"),
P1801("VIAS S/V CIRC-B2"),
P1802("Neutral Switch Circuit Malfunction"),
P1803("Coolant Temperature Circuit Malfunction"),
P1804("Hold Switch Circuit Malfunction"),
P1805("BRAKE SW/CIRCUIT"),
P1806("BRAKE VACUUM SEN"),
P1807("Transmission Clutch Interlock Safety Switch Short Circuit To Battery"),
P1808("Transmission Clutch Interlock Safety Switch Short Circuit To Ground"),
P1809("Transmission 4-Wheel Drive High Indicator Circuit Failure"),
P1810("Transmission 4-Wheel Drive High Indicator Open Circuit"),
P1811("Transmission 4-Wheel Drive High Indicator Short Circuit To Battery"),
P1812("Transmission 4-Wheel Drive High Indicator Short Circuit To Ground"),
P1813("Transmission 4-Wheel Drive Low Indicator Circuit Failure"),
P1814("Transmission 4-Wheel Drive Low Indicator Open Circuit"),
P1815("TFP Valve Position Switch Circuit/ Transmission 4-Wheel Drive Low Indicator Short Circuit To Battery"),
P1816("Transmission 4-Wheel Drive Low Indicator Short Circuit To Ground"),
P1817("Transmission 4-Wheel Drive Mode Select Circuit Failure"),
P1818("Transmission 4-Wheel Drive Mode Select Open Circuit"),
P1819("Transmission 4-Wheel Drive Mode Select Short Circuit To Battery"),
P1820("Transmission 4-Wheel Drive Mode Select Short Circuit To Ground"),
P1821("Transmission Neutral Safety Switch Circuit Failure"),
P1822("Transmission Neutral Safety Switch Open Circuit"),
P1823("Transmission Neutral Safety Switch Short Circuit To Battery"),
P1824("Transmission Neutral Safety Switch Short Circuit To Ground"),
P1825("Transmission Transfer Case Clockwise Shift Relay Coil Circuit Failure"),
P1826("Transmission Transfer Case Clockwise Shift Relay Coil Open Circuit"),
P1827("Transmission Transfer Case Clockwise Shift Relay Coil Short Circuit To Battery"),
P1828("Transmission Transfer Case Clockwise Shift Relay Coil Short Circuit To Ground"),
P1829("Transmission 4-Wheel Drive Clutch Relay Circuit Failure"),
P1830("Transmission 4-Wheel Drive Clutch Relay Open Circuit"),
P1831("Transmission 4-Wheel Drive Low Clutch Relay Circuit To Battery"),
P1832("Transmission 4-Wheel Drive Low Clutch Relay Circuit To Ground"),
P1833("Transmission Transfer Case Counter Clockwise Shift Relay Coil Circuit Failure"),
P1834("Transmission Transfer Case Counter Clockwise Shift Relay Coil Open Circuit"),
P1835("Transmission Transfer Case Counter Clockwise Shift Relay Coil Short Circuit To Battery"),
P1836("Transmission Transfer Case Counter Clockwise Shift Relay Coil Short Circuit To Ground"),
P1837("Transmission Transfer Case Differential Lock-Up Solenoid Circuit Failure"),
P1838("Transmission Transfer Case Differential Lock-Up Solenoid Open Circuit"),
P1839("Transmission Transfer Case Differential Lock-Up Solenoid Short Circuit To Battery"),
P1840("Transmission Transfer Case Differential Lock-Up Solenoid Short Circuit To Ground"),
P1841("Transmission Transfer Case Front Shaft Speed Sensor Circuit Failure"),
P1842("Transmission Transfer Case Rear Shaft Speed Sensor Circuit Failure"),
P1843("Transmission Transfer Case Shift Motor Circuit Failure"),
P1844("Transmission Transfer Case Shift Motor Open Circuit"),
P1845("Transmission Transfer Case Shift Motor Short Circuit To Battery"),
P1846("Transmission Transfer Case Shift Motor Short Circuit To Ground"),
P1847("Transmission Transfer Case Differential Lock-Up Feedback Switch Circuit Failure"),
P1848("Transmission Transfer Case Differential Lock-Up Feedback Switch Open Circuit"),
P1849("Transmission Transfer Case Differential Lock-Up Feedback Switch Short Circuit To Battery"),
P1850("SOL CURRENT"),
P1851("IND SIG"),
P1853("D-LOCK SIG"),
P1867("Transmission Transfer Case Contact Plate Power Circuit Failure"),
P1868("Transmission Transfer Case Contact Plate Power Open Circuit"),
P1869("Transmission Transfer Case Contact Plate Power Short To Battery"),
P1870("Transmission Transfer Case Contact Plate Power Short To Ground"),
P1871("Transmission Transfer Case System Concern - Servicing Required"),
P1872("Transmission Transfer Case Contact Plate General Circuit Failure"),
P1873("Transmission Automatic 4-Wheel Drive Indicator (Lamp) Circuit Failure"),
P1874("Transmission Automatic 4-Wheel Drive Indicator (Lamp) Circuit Short To Battery"),
P1875("Transmission Component Slipping/ Transmission Mechanical Transfer Case 4x4 Switch Circuit Failure"),
P1876("Transmission Mechanical Transfer Case 4x4 Switch Circuit Short To Battery"),
P1877("Transmission Mechanical 4-Wheel Drive Axle Lock Lamp Circuit Failure"),
P1878("Transmission Mechanical 4-Wheel Drive Axle Lock Lamp Circuit Short To Battery"),
P1879("Transmission Automatic Hall Effect Sensor Power Circuit Failure"),
P1880("Transmission Automatic Hall Effect Sensor Power Circuit Short To Battery / 4WD Low Switch Circuit Electrical"),
P1881("Transmission Transfer Case 2-Wheel Drive Solenoid Circuit Failure"),
P1882("Transmission Transfer Case 2-Wheel Drive Solenoid Circuit Short To Battery"),
P1883("Transmission Transfer Case Disengaged Solenoid Circuit Failure"),
P1884("Transmission Transfer Case Disengaged Solenoid Open Circuit"),
P1885("Transmission Transfer Case Disengaged Solenoid Short to Battery"),
P1886("Engine Coolant Level Switch Circuit Failure"),
P1890("Engine Coolant Level Switch Circuit Short to Ground"),
P1891("Engine Coolant Level Switch Circuit Failure"),
P1900("Engine Coolant Level Lamp Circuit Short to Ground"),
P1901("Transmission Transfer Case Disengaged Solenoid Short to Ground"),
P1902("4X4 Initialization Failure"),
P1903("Transmission 4WD Mode Select Return Input Circuit Failure"),
P1904("Transmission Transfer Case Contact Plate Ground Return Open Circuit"),
P1905("OSS Circuit Intermittent Malfunction"),
P1906("TSS Circuit Intermittent Malfunction"),
P1907("Pressure Control Solenoid \"B\" Intermittent Short"),
P1908("Pressure Control Solenoid \"C\" Short Circuit"),
P1909("Pressure Control Solenoid \"C\" Open Circuit"),
P1910("Pressure Control Solenoid \"C\" Intermittent Short"),
P1911("Kickdown Pull Relay Open or Short Circuit to Ground"),
P1912("Kickdown Hold Relay Open or Short Circuit to Ground"),
P1913("Transmission Pressure Circuit Solenoid Open or Short to Ground"),
P1914("Trans Temp Sensor Circuit Open or Shorted to Pwr or Gnd"),
P1915("VFS A Pressure Output Failed Low"),
P1916("VFS B Pressure Output Failed Low"),
P1917("VFS C Pressure Output Failed Low"),
P1918("Pressure Switch A Circuit Malfunction"),
P1FFF("ENGINE STALL"),
P2004("P2004"),
P2008("P2008"),
P2011("SWIRL CONT/V (B2)"),
P2014("P2014"),
P2016("IN/MANIFOLD RUNNER POS SEN B1"),
P2017("IN/MANIFOLD RUNNER POS SEN B1"),
P2018("IN/MANIFOLD RUNNER POS SEN B1"),
P2080("EXHAUST GAS TEMP SENSOR 1 B1"),
P2081("EXHAUST GAS TEMP SENSOR 1 B1"),
P2082("EXHAUST GAS TEMP SENSOR 1 B2"),
P2083("EXHAUST GAS TEMP SENSOR 1 B2"),
P2096("POST CATALYST FUEL TRIM SYS B1"),
P2097("POST CATALYST FUEL TRIM SYS B1"),
P2098("POST CATALYST FUEL TRIM SYS B2"),
P2099("POST CATALYST FUEL TRIM SYS B2"),
P2100("ETC MOT PWR-B1"),
P2101("ETC FNCTN/CIRC-B1"),
P2103("ETC MOT PWR-B1"),
P2109("CTP LEARNING"),
P2118("ETC MOT-B1"),
P2119("ETC ACTR-B1"),
P2122("APP SEN 1/CIRC"),
P2123("APP SEN 1/CIRC"),
P2127("APP SEN 2/CIRC"),
P2128("APP SEN 2/CIRC"),
P2132("TP SEN 1/CIRC-B2"),
P2133("TP SEN 1/CIRC-B2"),
P2135("TP SENSOR-B1"),
P2138("APP SENSOR"),
P2159("VEHICLE SPEED SEN B"),
P2162("VEHICLE SPEED SEN A-B"),
P2183("P2183"),
P2184("P2184"),
P2185("P2185"),
P219A("AIR FUEL RATIO IMBALANCE B1"),
P219B("AIR FUEL RATIO IMBALANCE B2"),
P2261("TC/SC BYPASS VALVE"),
P2263("TC SYSTEM-B1"),
P2299("P2299"),
P2413("P2413"),
P2423("HC ADS CATALYST-B1"),
P2424("HC ADS CATALYST-B2"),
P2432("SNDRY MAS A/F SE"),
P2433("SNDRY MAS A/F SE"),
P2440("AIR CUT S/V-B1"),
P2442("AIR CUT S/V-B2"),
P2444("AIR PUMP"),
P2445("AIR PUMP"),
P2448("SCNDRY AIR SYSEM"),
P2457("EGR COOLER EFFICIENCY"),
P2502("P2502"),
P2527("P2527"),
P2539("LOW FUEL PRES SEN"),
P2540("LOW FUEL PRES SEN"),
P2541("LOW FUEL PRES SEN"),
P2542("LOW FUEL PRES SEN"),
P2562("Turbocharger Boost Control Position Sensor Circuit"),
P2563("Turbocharger Boost Control Position Sensor Circuit Range/Performance"),
P2564("Turbocharger Boost Control Position Sensor Circuit Low"),
P2565("Turbocharger Boost Control Position Sensor Circuit High"),
P2566("Turbocharger Boost Control Position Sensor Circuit Intermittent"),
P2586("Turbocharger Boost Control Position Sensor Circuit"),
P2587("Turbocharger Boost Control Position Sensor Circuit Range/Performance"),
P2588("Turbocharger Boost Control Position Sensor Circuit Low"),
P2589("Turbocharger Boost Control Position Sensor Circuit High"),
P2590("Turbocharger Boost Control Position Sensor Circuit Intermittent/Erratic"),
P2610("ECM/PCM INTERNAL ENG OFF TIMER"),
P261B("P261B"),
P261C("P261C"),
P261D("P261D"),
P2635("LOW PRES FUEL PUMP"),
P2681("P2681"),
P26A3("P26A3"),
P26A5("P26A5"),
P26A6("P26A6"),
P26A7("P26A7"),
P26AB("P26AB"),
P2713("PC SOLENOID D"),
P2714("PC SOLENOID D"),
P2722("PC SOLENOID E"),
P2731("PC SOLENOID F"),
P2765("INPUT SPEED SENSOR B"),
P2807("PC SOLENOID G"),
P2A00("A/F SENSOR1 (B1)"),
P2A03("A/F SENSOR1 (B2)"),
P3021("SUB FUEL CONT SOL/V"),
P3022("SUB FUEL CONT SOL/V"),
P3023("SUB FUEL CONT SOL/V"),
P3075("SUB FUEL PUMP RELAY"),
P3077("SUB FUEL PUMP RELAY"),
P3078("SUB FUEL PUMP RELAY"),
P31A5("COMMUNICATION ERROR")
} | 0 | Kotlin | 3 | 8 | 133b16d11775f67845a06c3ede4eab71b21e5428 | 69,572 | AlpDroid | MIT License |
app/src/main/java/com/ytrewqwert/yetanotherjnovelreader/settings/PreferenceViewModel.kt | ytrewqwerT | 240,618,186 | false | null | package com.ytrewqwert.yetanotherjnovelreader.settings
import androidx.lifecycle.ViewModel
import androidx.lifecycle.asLiveData
import androidx.lifecycle.viewModelScope
import com.ytrewqwert.yetanotherjnovelreader.data.Repository
import kotlinx.coroutines.flow.map
class PreferenceViewModel(repository: Repository) : ViewModel() {
val marginsDp = repository.getReaderSettingsFlow().map {
it.marginsDp
}.asLiveData(viewModelScope.coroutineContext)
val pageTurnAreasPc = repository.getReaderSettingsFlow().map {
it.pageTurnAreasPc
}.asLiveData(viewModelScope.coroutineContext)
} | 6 | Kotlin | 0 | 0 | 63c12ceb1f34c60128475169fc6a727769e0dbd4 | 611 | YetAnotherJNovelReader | MIT License |
ffmpeg/src/main/java/com/coder/ffmpeg/jni/FFmpegConfig.kt | AnJoiner | 228,573,666 | false | null | package com.coder.ffmpeg.jni
import android.content.Context
import java.io.File
import java.io.FileOutputStream
import java.io.IOException
import java.util.Collections
import java.util.concurrent.atomic.AtomicReference
class FFmpegConfig {
companion object {
init {
System.loadLibrary("ffmpeg-org")
System.loadLibrary("ffmpeg-command")
}
/**
* Set the env of native
* @param name env name
* @param value env value
*/
private external fun setNativeEnv(name: String, value: String)
/**
* Whether to enable debugging mode
* @param debug true or false
*/
external fun setDebug(debug: Boolean)
/**
* Set font config dir for fontconfig
* Note:It's a config dir not font dir
* @param configPath the font config dir
*/
fun setFontConfigPath(configPath: String) {
setNativeEnv("FONTCONFIG_PATH", configPath)
}
/**
* Set font config file for fontconfig
* Note:It's a config file not font file
* @param configFile the font config file
*/
fun setFontConfigFile(configFile: String) {
setNativeEnv("FONTCONFIG_FILE", configFile)
}
/**
* Set font dir for fontconfig
* @param context context for application
* @param fontDir the font dir contain fonts (.ttf and .otf files)
* @param fontNameMapping
*/
fun setFontDir(context: Context, fontDir:String, fontNameMapping: Map<String, String>){
setFontDirList(context, Collections.singletonList(fontDir),fontNameMapping)
}
/**
* Set font dir for fontconfig
* @param context context for application
* @param fontDirList list of directories that contain fonts (.ttf and .otf files)
*/
fun setFontDirList(context: Context, fontDirList: List<String>, fontNameMapping: Map<String, String>) {
var validFontNameMappingCount = 0
val cacheDir = context.cacheDir
val fontConfigDir = File(cacheDir, "fontconfig")
if (!fontConfigDir.exists()) {
fontConfigDir.mkdirs()
}
// Create font config
val fontConfigFile = File(fontConfigDir, "fonts.conf")
if (fontConfigFile.exists() && fontConfigFile.isFile) {
fontConfigFile.delete()
}
fontConfigFile.createNewFile()
val fontNameMappingBlock = StringBuilder()
if (fontNameMapping.isNotEmpty()){
for (entry in fontNameMapping.entries) {
val fontName: String = entry.key
val mappedFontName: String = entry.value
if ((fontName.trim().isNotEmpty()) && (mappedFontName.trim().isNotEmpty())) {
fontNameMappingBlock.append(" <match target=\"pattern\">\n");
fontNameMappingBlock.append(" <test qual=\"any\" name=\"family\">\n");
fontNameMappingBlock.append(String.format(" <string>%s</string>\n", fontName));
fontNameMappingBlock.append(" </test>\n");
fontNameMappingBlock.append(" <edit name=\"family\" mode=\"assign\" binding=\"same\">\n");
fontNameMappingBlock.append(String.format(" <string>%s</string>\n", mappedFontName));
fontNameMappingBlock.append(" </edit>\n");
fontNameMappingBlock.append(" </match>\n");
validFontNameMappingCount++
}
}
}
val fontConfigBuilder = StringBuilder()
fontConfigBuilder.append("<?xml version=\"1.0\"?>\n")
fontConfigBuilder.append("<!DOCTYPE fontconfig SYSTEM \"fonts.dtd\">\n")
fontConfigBuilder.append("<fontconfig>\n")
fontConfigBuilder.append(" <dir prefix=\"cwd\">.</dir>\n")
for (fontDirectoryPath in fontDirList) {
fontConfigBuilder.append(" <dir>")
fontConfigBuilder.append(fontDirectoryPath)
fontConfigBuilder.append("</dir>\n")
}
fontConfigBuilder.append(fontNameMappingBlock)
fontConfigBuilder.append("</fontconfig>\n")
val reference = AtomicReference<FileOutputStream>()
try {
val outputStream = FileOutputStream(fontConfigFile)
reference.set(outputStream)
outputStream.write(fontConfigBuilder.toString().toByteArray())
outputStream.flush()
setFontConfigPath(fontConfigDir.absolutePath)
}catch (e:IOException){
e.printStackTrace()
}finally {
reference.get().close()
}
}
}
} | 28 | null | 154 | 820 | 2e48031c833e37156cd26e3d7c3491ba1c53bdd1 | 5,023 | FFmpegCommand | Apache License 2.0 |
modules/module-project/src/main/java/com/bbgo/module_project/bean/ProjectBean.kt | bbggo | 371,705,786 | false | null | package com.bytebitx.project.bean
import androidx.annotation.Keep
import androidx.room.*
import androidx.room.ForeignKey.Companion.CASCADE
@Keep
@Entity(tableName = "project_tree")
data class ProjectBean(
@PrimaryKey var id: Int = 0,
@Ignore var children: List<Any>? = null,
var courseId: Int = 0,
var name: String = "",
var order: Int = 0,
@ColumnInfo(name = "parent_chapter_id") var parentChapterId: Int = 0,
@ColumnInfo(name = "user_control_set_top") var userControlSetTop: Boolean = false,
var visible: Int = 0
)
@Keep
data class ArticleData(
var curPage: Int,
var datas: MutableList<ArticleDetail>,
var offset: Int,
var over: Boolean,
var pageCount: Int,
var size: Int,
var total: Int
)
@Keep
@Entity(tableName = "article_detail")
data class ArticleDetail(
@PrimaryKey var id: Int = 0,
@ColumnInfo(name = "apk_link") var apkLink: String = "",
var audit: Int = 0,
var author: String = "",
@ColumnInfo(name = "can_edit") var canEdit: Boolean = false,
@ColumnInfo(name = "chapter_id") var chapterId: Int = 0,
@ColumnInfo(name = "chapter_name") var chapterName: String = "",
var collect: Boolean = false,
@ColumnInfo(name = "course_id") var courseId: Int = 0,
var desc: String = "",
@ColumnInfo(name = "desc_md") var descMd: String = "",
@ColumnInfo(name = "envelope_pic") var envelopePic: String = "",
var fresh: Boolean = false,
var host: String = "",
var link: String = "",
@ColumnInfo(name = "nice_date") var niceDate: String = "",
@ColumnInfo(name = "nice_share_date") var niceShareDate: String = "",
var origin: String = "",
var prefix: String = "",
@ColumnInfo(name = "project_link") var projectLink: String = "",
@ColumnInfo(name = "publish_time") var publishTime: Long = 0,
@ColumnInfo(name = "real_super_chapter_id") var realSuperChapterId: Int = 0,
@ColumnInfo(name = "self_visible") var selfVisible: Int = 0,
@ColumnInfo(name = "share_date") var shareDate: Long = 0,
@ColumnInfo(name = "share_user") var shareUser: String = "",
@ColumnInfo(name = "super_chapter_id") var superChapterId: Int = 0,
@ColumnInfo(name = "super_chapter_name") var superChapterName: String = "",
@Ignore var tags: List<Tag>? = null,
var title: String = "",
var type: Int = 0,
@ColumnInfo(name = "user_id") var userId: Int = 0,
var visible: Int = 0,
var zan: Int = 0,
var top: String = "",
@ColumnInfo(name = "local_path") var localPath: String = ""
)
@Keep
@Entity(tableName = "tag",
foreignKeys = [
ForeignKey(
entity = ArticleDetail::class,
parentColumns = arrayOf("id"),
childColumns = arrayOf("article_id"),
onDelete = CASCADE,)],
indices = [Index(value = arrayOf("article_id"), unique = true)]
)
data class Tag(
@PrimaryKey(autoGenerate = true)var id: Long,
@ColumnInfo(name = "article_id") var artileId: Int,
var name: String,
var url: String
)
/**
* 连表查询,需要定义一个中间bean,具体用法详见
* https://developer.android.google.cn/training/data-storage/room/relationships?hl=zh-cn
*/
@Keep
data class ArticleDetailWithTag(
@Embedded var articleDetail: ArticleDetail,
@Relation(
parentColumn = "id",
entityColumn = "article_id"
)
var tags: List<Tag>?
) | 3 | Kotlin | 3 | 8 | 9c983af26f5bd9cd5e08b7a6080190305738b435 | 3,318 | WanAndroid | Apache License 2.0 |
simpleinstaller/src/main/kotlin/io/github/solrudev/simpleinstaller/activityresult/InstallPermissionContract.kt | solrudev | 433,213,881 | false | {"Kotlin": 97412} | package io.github.solrudev.simpleinstaller.activityresult
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.provider.Settings
import androidx.activity.result.contract.ActivityResultContract
import androidx.annotation.RequiresApi
import io.github.solrudev.simpleinstaller.SimpleInstaller.installerPackageName
import io.github.solrudev.simpleinstaller.SimpleInstaller.packageManager
/**
* An [ActivityResultContract] to request install permission.
*/
@RequiresApi(Build.VERSION_CODES.O)
public class InstallPermissionContract : ActivityResultContract<Unit, Boolean>() {
public override fun createIntent(context: Context, input: Unit): Intent = Intent(
Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES,
Uri.parse("package:$installerPackageName")
)
public override fun parseResult(resultCode: Int, intent: Intent?): Boolean =
packageManager.canRequestPackageInstalls()
} | 0 | Kotlin | 1 | 17 | e04ba526371086c42ff47497210a90d045fd74dc | 948 | SimpleInstaller | Apache License 2.0 |
privacy-config/privacy-config-impl/src/test/java/com/duckduckgo/privacy/config/impl/features/trackerallowlist/TrackerAllowlistPluginTest.kt | hojat72elect | 822,396,044 | false | {"Kotlin": 11627106, "HTML": 65873, "Ruby": 16984, "C++": 10312, "JavaScript": 5520, "CMake": 1992, "C": 1076, "Shell": 784} |
package com.duckduckgo.privacy.config.impl.features.trackerallowlist
import com.duckduckgo.common.test.FileUtilities
import com.duckduckgo.privacy.config.api.PrivacyFeatureName
import com.duckduckgo.privacy.config.store.PrivacyFeatureToggles
import com.duckduckgo.privacy.config.store.PrivacyFeatureTogglesRepository
import com.duckduckgo.privacy.config.store.TrackerAllowlistEntity
import com.duckduckgo.privacy.config.store.features.trackerallowlist.TrackerAllowlistRepository
import org.junit.Assert.*
import org.junit.Before
import org.junit.Test
import org.mockito.kotlin.argumentCaptor
import org.mockito.kotlin.mock
import org.mockito.kotlin.verify
class TrackerAllowlistPluginTest {
lateinit var testee: TrackerAllowlistPlugin
private val mockFeatureTogglesRepository: PrivacyFeatureTogglesRepository = mock()
private val mockAllowlistRepository: TrackerAllowlistRepository = mock()
@Before
fun before() {
testee = TrackerAllowlistPlugin(mockAllowlistRepository, mockFeatureTogglesRepository)
}
@Test
fun whenFeatureNameDoesNotMatchTrackerAllowlistThenReturnFalse() {
PrivacyFeatureName.values().filter { it != FEATURE_NAME }.forEach {
assertFalse(testee.store(it.value, EMPTY_JSON_STRING))
}
}
@Test
fun whenFeatureNameMatchesTrackerAllowlistThenReturnTrue() {
assertTrue(testee.store(FEATURE_NAME_VALUE, EMPTY_JSON_STRING))
}
@Test
fun whenFeatureNameMatchesTrackerAllowlistAndIsEnabledThenStoreFeatureEnabled() {
val jsonString = FileUtilities.loadText(javaClass.classLoader!!, "json/tracker_allowlist.json")
testee.store(FEATURE_NAME_VALUE, jsonString)
verify(mockFeatureTogglesRepository).insert(PrivacyFeatureToggles(FEATURE_NAME_VALUE, true, null))
}
@Test
fun whenFeatureNameMatchesTrackerAllowlistAndIsNotEnabledThenStoreFeatureDisabled() {
val jsonString = FileUtilities.loadText(javaClass.classLoader!!, "json/tracker_allowlist_disabled.json")
testee.store(FEATURE_NAME_VALUE, jsonString)
verify(mockFeatureTogglesRepository).insert(PrivacyFeatureToggles(FEATURE_NAME_VALUE, false, null))
}
@Test
fun whenFeatureNameMatchesTrackerAllowlistAndHasMinSupportedVersionThenStoreMinSupportedVersion() {
val jsonString = FileUtilities.loadText(javaClass.classLoader!!, "json/tracker_allowlist_min_supported_version.json")
testee.store(FEATURE_NAME_VALUE, jsonString)
verify(mockFeatureTogglesRepository).insert(PrivacyFeatureToggles(FEATURE_NAME_VALUE, true, 1234))
}
@Test
fun whenFeatureNameMatchesTrackerAllowlistThenUpdateAllExistingExceptions() {
val jsonString = FileUtilities.loadText(javaClass.classLoader!!, "json/tracker_allowlist.json")
testee.store(FEATURE_NAME_VALUE, jsonString)
argumentCaptor<List<TrackerAllowlistEntity>>().apply {
verify(mockAllowlistRepository).updateAll(capture())
val trackerAllowlistEntity = this.firstValue.first()
val rules = trackerAllowlistEntity.rules
assertEquals(1, this.allValues.size)
assertEquals("allowlist-tracker-1.com", trackerAllowlistEntity.domain)
assertEquals("allowlist-tracker-1.com/videos.js", rules.first().rule)
assertEquals("testsite.com", rules.first().domains.first())
assertEquals("match single resource on single site", rules.first().reason)
}
}
companion object {
private val FEATURE_NAME = PrivacyFeatureName.TrackerAllowlistFeatureName
private val FEATURE_NAME_VALUE = FEATURE_NAME.value
private const val EMPTY_JSON_STRING = "{}"
}
}
| 0 | Kotlin | 0 | 0 | 54351d039b85138a85cbfc7fc3bd5bc53637559f | 3,709 | DuckDuckGo | Apache License 2.0 |
app/src/main/java/com/rohitjakhar/hashpass/utils/Extension.kt | rohitjakhar | 469,813,668 | false | {"Kotlin": 112878} | package com.rohitjakhar.hashpass.utils
import android.app.Activity
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import android.graphics.LinearGradient
import android.graphics.Shader
import android.graphics.drawable.ShapeDrawable
import android.graphics.drawable.shapes.RectShape
import android.net.Uri
import android.util.Base64
import android.util.Base64.decode
import android.view.View
import android.widget.Toast
import androidx.annotation.ColorInt
import androidx.appcompat.app.AlertDialog
import androidx.biometric.BiometricManager
import androidx.biometric.BiometricPrompt
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import com.apollographql.apollo.api.Input
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.textfield.TextInputLayout
import com.rohitjakhar.hashpass.presention.MainActivity
import com.rohitjakhar.hashpass.data.local.PreferenceDataImpl
import com.rohitjakhar.hashpass.data.model.UserDetailsModel
import com.rohitjakhar.hashpass.databinding.DialogLoadingViewBinding
import kotlinx.coroutines.flow.first
import java.text.SimpleDateFormat
import java.util.*
import javax.crypto.Cipher
import javax.crypto.SecretKeyFactory
import javax.crypto.spec.IvParameterSpec
import javax.crypto.spec.PBEKeySpec
import javax.crypto.spec.SecretKeySpec
fun Fragment.toast(message: String) {
Toast.makeText(this.requireContext(), message, android.widget.Toast.LENGTH_SHORT)
.show()
}
fun Fragment.copyText(text: String) {
val clipboardManager =
this.requireContext().getSystemService(ClipboardManager::class.java) as ClipboardManager
val clipData = ClipData.newPlainText("text", text)
clipboardManager.setPrimaryClip(clipData)
}
fun Activity.loadingView(loadingText: String? = null, cancelable: Boolean = true): AlertDialog {
val binding = DialogLoadingViewBinding.inflate(this.layoutInflater)
return MaterialAlertDialogBuilder(this)
.setView(binding.root)
.setCancelable(cancelable)
.create()
}
fun View.show() {
this.isVisible = true
}
fun View.hide() {
this.isVisible = false
}
fun String.encrypt(password: String): String {
val pswdIterations = 65536
val keySize = 256
val saltBytes = byteArrayOf(0, 1, 2, 3, 4, 5, 6)
val factory: SecretKeyFactory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1")
val spec: PBEKeySpec = PBEKeySpec(
password.toCharArray(),
saltBytes,
pswdIterations,
keySize
)
val secretKey = factory.generateSecret(spec)
val secretKeySpec = SecretKeySpec(secretKey.encoded, "AES")
val iv = ByteArray(16)
val charArray = password.toCharArray()
for (i in charArray.indices) {
iv[i] = charArray[i].toByte()
}
val ivParameterSpec = IvParameterSpec(iv)
val cipher = Cipher.getInstance("AES/GCM/NoPadding")
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, ivParameterSpec)
val encryptedValue = cipher.doFinal(this.toByteArray())
return Base64.encodeToString(encryptedValue, Base64.DEFAULT)
}
fun String.decrypt(password: String): String {
val pswdIterations = 65536
val keySize = 256
val saltBytes = byteArrayOf(0, 1, 2, 3, 4, 5, 6)
val factory: SecretKeyFactory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1")
val spec: PBEKeySpec = PBEKeySpec(
password.toCharArray(),
saltBytes,
pswdIterations,
keySize
)
val secretKey = factory.generateSecret(spec)
val secretKeySpec = SecretKeySpec(secretKey.encoded, "AES")
val iv = ByteArray(16)
val charArray = password.toCharArray()
for (i in charArray.indices) {
iv[i] = charArray[i].toByte()
}
val ivParameterSpec = IvParameterSpec(iv)
val cipher = Cipher.getInstance("AES/GCM/NoPadding")
cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec)
val decryptedByteValue = cipher.doFinal(decode(this, Base64.DEFAULT))
return String(decryptedByteValue)
}
fun String?.toInputString(): Input<String> {
return Input.optional(this)
}
fun String?.toInputAny(): Input<Any> {
return Input.optional(this)
}
fun Long.toInputAny(): Input<Any> {
return Input.optional(this)
}
suspend fun PreferenceDataImpl.getUserId(): String {
return this.userId.first().toString()
}
suspend fun PreferenceDataImpl.getUserDetails(): UserDetailsModel {
this.apply {
return UserDetailsModel(
name = userName.first(),
email = userEmail.first(),
id = userId.first(),
userImage = userImage.first()
)
}
}
fun TextInputLayout.getText(): String {
return this.editText?.text.toString()
}
fun Context.messageDialog(message: String, okClick: (DialogInterface) -> Unit): AlertDialog {
return MaterialAlertDialogBuilder(this)
.setTitle(message)
.setPositiveButton("Ok") { dialogInterface, _ ->
okClick.invoke(dialogInterface)
}
.setCancelable(false)
.create()
}
fun Context.optionDialog(
message: String,
yesClick: (DialogInterface) -> Unit,
noClick: (DialogInterface) -> Unit
): AlertDialog {
return MaterialAlertDialogBuilder(this)
.setTitle(message)
.setPositiveButton("Yes") { dialogInterface, _ ->
yesClick.invoke(dialogInterface)
}
.setNegativeButton("No") { dialogInterface, _ ->
noClick.invoke(dialogInterface)
}
.setCancelable(true)
.create()
}
fun TextInputLayout.setText(text: String?) {
this.editText?.setText(text)
}
fun Activity.openInBrowser(link: String) {
startActivity(
Intent(Intent.ACTION_VIEW).also {
it.data = Uri.parse(link)
}
)
}
fun View.backgroundGradientDrawable(@ColorInt startColor: Int, @ColorInt endColor: Int) {
val h = this.height.toFloat()
val shapeDrawable = ShapeDrawable(RectShape())
shapeDrawable.paint.shader =
LinearGradient(0f, 0f, 0f, h, startColor, endColor, Shader.TileMode.REPEAT)
this.background = shapeDrawable
}
fun Activity.bioMetricsPrompts() {
val promptInfo = BiometricPrompt.PromptInfo.Builder()
.setTitle("Unlock")
.setSubtitle("Use Finger")
.setAllowedAuthenticators(BiometricManager.Authenticators.BIOMETRIC_STRONG or BiometricManager.Authenticators.DEVICE_CREDENTIAL)
.build()
val biometricPrompt = BiometricPrompt(
this as FragmentActivity,
object : BiometricPrompt.AuthenticationCallback() {
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
super.onAuthenticationError(errorCode, errString)
Toast.makeText(this@bioMetricsPrompts, "$errString", Toast.LENGTH_SHORT).show()
}
override fun onAuthenticationFailed() {
super.onAuthenticationFailed()
finish()
}
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
super.onAuthenticationSucceeded(result)
startActivity(Intent(this@bioMetricsPrompts, MainActivity::class.java))
finish()
}
}
)
biometricPrompt.authenticate(promptInfo)
}
fun String.toLink(): String {
var url: String = this
if (!url.startsWith("www.") && !url.startsWith("http://")) {
url = "www.$url"
}
if (!url.startsWith("http://")) {
url = "http://$url"
}
return url
}
fun Long.toDate(): String {
val sdf = SimpleDateFormat("dd/MM/yyyy", Locale.getDefault())
val netDate = Date(this)
return sdf.format(netDate)
}
| 3 | Kotlin | 3 | 24 | e7fe17c725546ed256694681ae262ebf928040b9 | 7,879 | hashpass | MIT License |
src/main/java/com/mrpowergamerbr/loritta/utils/misc/VaporwaveUtils.kt | Velctroo | 96,816,227 | true | {"Kotlin": 311628, "Java": 287766} | package com.mrpowergamerbr.loritta.utils.misc
object VaporwaveUtils {
/**
* Converte um texto para full width
*
* @return O texto em formato full width
*/
fun vaporwave(str: String): String {
var str = str
str = str.toLowerCase() // Como a gente abusa dos códigos unicode, é necessário dar lowercase antes de aplicar o efeito
val sb = StringBuilder()
for (c in str.toCharArray()) {
if (Character.isSpaceChar(c)) {
sb.append(" ")
continue
}
val vaporC = (c.toInt() + 0xFEE0).toChar()
if (Character.getType(vaporC) != 2) {
sb.append(c)
continue
}
sb.append(vaporC)
}
return sb.toString()
}
} | 0 | Kotlin | 0 | 1 | 252a7d8ff940f9a842592fc8e7381a38d0b26549 | 649 | Loritta | MIT License |
app/src/main/java/com/ctech/eaty/react/widget/tablayout/PageScrollStateChangedEvent.kt | dbof10 | 116,687,959 | false | null | package com.ctech.eaty.react.widget.tablayout
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.WritableMap
import com.facebook.react.uimanager.events.Event
import com.facebook.react.uimanager.events.RCTEventEmitter
internal class PageScrollStateChangedEvent constructor(viewTag: Int, private val mPageScrollState: String) : Event<PageScrollStateChangedEvent>(viewTag) {
companion object {
const val EVENT_NAME = "topPageScrollStateChanged"
}
override fun getEventName() = EVENT_NAME
override fun dispatch(rctEventEmitter: RCTEventEmitter) {
rctEventEmitter.receiveEvent(viewTag, eventName, serializeEventData())
}
private fun serializeEventData(): WritableMap {
val eventData = Arguments.createMap()
eventData.putString("pageScrollState", mPageScrollState)
return eventData
}
} | 2 | null | 11 | 49 | 2e3445debaedfea03f9b44ab62744046fe07f1cc | 881 | hunt-android | Apache License 2.0 |
app/src/main/java/es/upm/bienestaremocional/SistemaBienestarEmocionalApp.kt | Emotional-Wellbeing | 531,973,820 | false | null | package es.upm.bienestaremocional
import androidx.compose.runtime.Composable
import com.ramcosta.composedestinations.DestinationsNavHost
import es.upm.bienestaremocional.data.settings.ThemeMode
import es.upm.bienestaremocional.ui.screens.NavGraphs
import es.upm.bienestaremocional.ui.theme.BienestarEmocionalTheme
@Composable
fun BienestarEmocionalApp(darkTheme: ThemeMode,
dynamicColors : Boolean
)
{
BienestarEmocionalTheme(darkTheme = darkTheme.themeIsDark(), dynamicColors = dynamicColors)
{
DestinationsNavHost(navGraph = NavGraphs.root)
}
} | 0 | Kotlin | 0 | 1 | 1f579af1073a4a8ac99011b0a881a5dcfb424821 | 595 | App | Apache License 2.0 |
modules/console/src/main/kotlin/io/github/sculk_cli/console/Msvcrt.kt | sculk-cli | 789,376,205 | false | {"Kotlin": 192923, "JavaScript": 7023, "Python": 4725, "Nix": 2595, "Shell": 243} | package io.github.sculk_cli.console
import com.sun.jna.Library
import com.sun.jna.Native
internal interface Msvcrt: Library {
@Suppress("FunctionName")
fun _getwch(): Int
companion object {
val INSTANCE: Msvcrt = Native.load("msvcrt", Msvcrt::class.java)
}
}
| 7 | Kotlin | 0 | 3 | 3361a0764bdcb78d75a0eaa8f8184ab4c1285a93 | 268 | sculk | MIT License |
app/src/main/java/com/denysnovoa/nzbmanager/radarr/movie/detail/view/screen/MovieDetailActivity.kt | denysnovoa | 90,066,913 | false | null | package com.denysnovoa.nzbmanager.radarr.movie.detail.view.screen
import android.os.Bundle
import android.support.design.widget.Snackbar
import android.view.Menu
import android.view.MenuItem
import com.denysnovoa.nzbmanager.R
import com.denysnovoa.nzbmanager.common.framework.ui.BaseActivity
import com.denysnovoa.nzbmanager.di.ApplicationComponent
import com.denysnovoa.nzbmanager.di.subcomponent.movieDetail.MovieDetailActivityModule
import com.denysnovoa.nzbmanager.radarr.movie.detail.MovieDetailView
import com.denysnovoa.nzbmanager.radarr.movie.detail.view.presenter.MovieDetailPresenter
import com.denysnovoa.nzbmanager.radarr.movie.list.view.model.MovieViewModel
import com.denysnovoa.nzbmanager.radarr.movie.release.view.screen.MovieReleaseActivity
import com.squareup.picasso.Picasso
import kotlinx.android.synthetic.main.activity_movie_detail.*
import kotlinx.android.synthetic.main.content_movie_detail.*
import org.jetbrains.anko.*
import javax.inject.Inject
class MovieDetailActivity : BaseActivity(), MovieDetailView {
companion object {
val PARAMETER_MOVIE_ID: String = "PARAMETER_MOVIE_ID"
}
@Inject
lateinit var presenter: MovieDetailPresenter
@Inject
lateinit var picasso: Picasso
var movieId = 0
override fun injectDependencies(applicationComponent: ApplicationComponent) {
applicationComponent.plus(MovieDetailActivityModule(this))
.injectTo(this)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_movie_detail)
initializeToolbar()
movieId = intent.extras.getInt(PARAMETER_MOVIE_ID)
fab.setOnClickListener({ view ->
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show()
})
}
private fun initializeToolbar() {
setSupportActionBar(toolbar_movie_detail)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowHomeEnabled(true)
}
override fun onStop() {
super.onStop()
presenter.onStop()
}
override fun onResume() {
super.onResume()
presenter.onResume(movieId)
}
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.menu_movie_detail, menu)
return true
}
override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
R.id.action_movie_search_download -> {
startActivity<MovieReleaseActivity>(PARAMETER_MOVIE_ID to movieId)
true
}
R.id.action_delete_movie -> {
showAlertToConfirmDeleteMovie()
true
}
android.R.id.home -> {
onBackPressed()
true
}
else -> false
}
override fun showDetail(movie: MovieViewModel) {
with(movie) {
toolbar_layout_movie.title = title
movie_status.text = when (status) {
"inCinemas" -> "in Cinemas"
"released" -> "released"
"announced" -> " announced"
else -> "default status"
}
movie_overview.text = overview
movie_downloaded.text = when (downloaded) {
true -> getString(R.string.literal_download_movie).toUpperCase()
else -> getString(R.string.literal_no_download_movie).toUpperCase()
}
movie_monitored.text = when (monitored) {
true -> getString(R.string.literal_monitored_movie).toUpperCase()
else -> getString(R.string.literal_no_monitored_movie).toUpperCase()
}
picasso.load(imageBanner)
.centerCrop()
.fit()
.into(image_toolbar)
}
}
override fun showErrorLoadMovie() {
toast(getString(R.string.error_load_movie))
}
override fun returnToMoviesView() {
onBackPressed()
}
override fun showErrorDeleteMovie() {
toast(getString(R.string.error_delete_muvie))
}
fun showAlertToConfirmDeleteMovie() {
alert {
customView {
verticalLayout {
padding = dip(32)
val checkDeleteFiles = switch {
text = getString(R.string.chek_delete_all_files)
textSize = 16f
padding = dip(8)
}
val checkExcludeImports = switch {
text = getString(R.string.check_excludo_auto_import)
textSize = 16f
padding = dip(8)
}
positiveButton(getString(R.string.yes)) {
presenter.onDeleteMovie(movieId, checkDeleteFiles.isChecked, checkExcludeImports.isChecked)
}
negativeButton(getString(R.string.no))
}
}
}.show()
}
}
| 0 | Kotlin | 0 | 1 | 8944e3bae4c073856f9856bf2e5064a6dadde4f7 | 5,121 | radarrsonarr | Apache License 2.0 |
WeatherAppData/app/src/main/java/com/chizhikov/weatherapp/realmDB/Night.kt | B-O-O-P | 279,709,074 | false | null | package com.chizhikov.weatherapp.realmDB
import com.chizhikov.weatherapp.weatherApi.DayForecast
import io.realm.RealmObject
open class Night(var forecast: String = "") : RealmObject() {
constructor(night: DayForecast.Night) : this() {
forecast = night.forecast
}
} | 0 | Kotlin | 1 | 1 | 58bcbbe23ec1dec0cc66e6b346e9a7a299b58abb | 282 | itmo-android | MIT License |
cotbeacon/src/main/java/com/jon/cotbeacon/ui/BeaconEditPresetFragment.kt | b9389 | 547,559,544 | true | {"Kotlin": 310705, "Java": 3012} | package com.jon.cotbeacon.ui
import androidx.navigation.fragment.navArgs
import com.jon.common.presets.OutputPreset
import com.jon.common.ui.editpreset.EditPresetFragment
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class BeaconEditPresetFragment : EditPresetFragment() {
override val args: BeaconEditPresetFragmentArgs by navArgs()
override fun getFragmentArgumentPreset(): OutputPreset? {
return args.presetArgument
}
} | 0 | null | 0 | 0 | ae8809555a1e9e2a62f64ce90f2ff6fa5c6ef0fd | 463 | cotgenerator | Apache License 2.0 |
app/src/main/java/com/example/c323p6notes/NotesViewModel.kt | kuzeybektas | 703,330,136 | false | {"Kotlin": 14551} | package com.example.c323p6notes
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.launch
class NotesViewModel(val dao: NoteDao): ViewModel() {
//variables
var newNoteName = ""
val notes = dao.getAll()
private val _navigateToNote = MutableLiveData<Long?>()
val navigateToNote: LiveData<Long?>
get() = _navigateToNote
/*
adds new note to database and view
*/
fun addNote(){
viewModelScope.launch{
val note = Note()
note.noteName = newNoteName
dao.insert(note)
}
}
//deletes note from database and view
fun deleteById(noteId: Long){
viewModelScope.launch {
val note = Note()
note.noteId = noteId
dao.delete(note)
}
}
//navigate to selected note
fun onNoteClicked(noteId: Long){
_navigateToNote.value = noteId
}
//after navigation, reset variable
fun onNoteNavigated(){
_navigateToNote.value = null
}
} | 0 | Kotlin | 0 | 0 | b6216bfb9fb5adf1948d4b0d9bc2590d1baa4424 | 1,136 | NotesApp | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.