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/vectorinc/vectormoviesearch/data/local/MoviesDao.kt
|
somtorizm
| 513,634,919
| false
|
{"Kotlin": 221854}
|
package com.vectorinc.vectormoviesearch.data.local
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
@Dao
interface MoviesDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertMovieListings(
moviesEntity: MoviesEntity
)
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertTrendingListings(
moviesTrendingEntity: MoviesTrendingEntity
)
@Query("DELETE FROM moviesEntity")
suspend fun clearMovieListings()
@Query("DELETE FROM moviestrendingentity")
suspend fun clearMovieTrendingListings()
@Query(
"""
SELECT * FROM MoviesEntity
"""
)
suspend fun readMovieListings(): MoviesEntity
@Query(
"""
SELECT *FROM moviestrendingentity
"""
)
suspend fun readMovieTrendingListings(): MoviesEntity
}
| 0
|
Kotlin
|
0
| 3
|
f8ee62191309cdaefc3297010133e3800a2bf30a
| 934
|
MovieAblum
|
Apache License 2.0
|
app/src/main/java/com/vectorinc/vectormoviesearch/data/local/MoviesDao.kt
|
somtorizm
| 513,634,919
| false
|
{"Kotlin": 221854}
|
package com.vectorinc.vectormoviesearch.data.local
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
@Dao
interface MoviesDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertMovieListings(
moviesEntity: MoviesEntity
)
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertTrendingListings(
moviesTrendingEntity: MoviesTrendingEntity
)
@Query("DELETE FROM moviesEntity")
suspend fun clearMovieListings()
@Query("DELETE FROM moviestrendingentity")
suspend fun clearMovieTrendingListings()
@Query(
"""
SELECT * FROM MoviesEntity
"""
)
suspend fun readMovieListings(): MoviesEntity
@Query(
"""
SELECT *FROM moviestrendingentity
"""
)
suspend fun readMovieTrendingListings(): MoviesEntity
}
| 0
|
Kotlin
|
0
| 3
|
f8ee62191309cdaefc3297010133e3800a2bf30a
| 934
|
MovieAblum
|
Apache License 2.0
|
plugins/uast-kotlin/tests/AbstractKotlinRenderLogTest.kt
|
gigliovale
| 89,726,097
| false
|
{"Java": 23302590, "Kotlin": 21941511, "JavaScript": 137521, "Protocol Buffer": 56992, "HTML": 49980, "Lex": 18051, "Groovy": 14093, "ANTLR": 9797, "IDL": 7706, "Shell": 5152, "CSS": 4679, "Batchfile": 3721}
|
package org.jetbrains.uast.test.kotlin
import org.jetbrains.uast.test.common.RenderLogTestBase
import java.io.File
abstract class AbstractKotlinRenderLogTest : AbstractKotlinUastTest(), RenderLogTestBase {
override fun getTestFile(testName: String, ext: String) =
File(File(TEST_KOTLIN_MODEL_DIR, testName).canonicalPath + '.' + ext)
}
| 0
|
Java
|
4
| 6
|
ce145c015d6461c840050934f2200dbc11cb3d92
| 353
|
kotlin
|
Apache License 2.0
|
app/src/test/java/com/kevalpatel2106/yip/edit/colorPicker/ColorStatesTest.kt
|
kevalpatel2106
| 166,789,807
| false
| null |
package com.kevalpatel2106.yip.edit.colorPicker
import android.graphics.Color
import com.kevalpatel2106.yip.core.ext.emptyString
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
@RunWith(JUnit4::class)
class ColorStatesTest {
private val colorState = ColorStates(Color.WHITE, false)
@Test
fun checkConstructor() {
assertEquals(Color.WHITE, colorState.color)
assertEquals(false, colorState.isSelected)
}
@Test
fun checkEquals() {
val otherColorInt = ColorStates(Color.TRANSPARENT, false)
val selectedColor = ColorStates(Color.WHITE, true)
val sameColor = ColorStates(Color.WHITE, false)
assertEquals(sameColor, colorState)
assertNotEquals(otherColorInt, colorState)
assertNotEquals(selectedColor, colorState)
assertNotEquals(null, colorState)
assertNotEquals(emptyString(), colorState)
}
@Test
fun checkHashcode() {
val otherColorInt = ColorStates(Color.TRANSPARENT, false)
val selectedColor = ColorStates(Color.WHITE, true)
val sameColor = ColorStates(Color.WHITE, false)
assertEquals(sameColor.hashCode(), colorState.hashCode())
assertNotEquals(otherColorInt.hashCode(), colorState.hashCode())
assertNotEquals(selectedColor.hashCode(), colorState.hashCode())
}
}
| 0
|
Kotlin
|
1
| 16
|
61311ba7d40802ba7fed87b2f16b72089c6f7746
| 1,454
|
year-in-progress
|
Apache License 2.0
|
app/src/main/java/shvyn22/flexingtranslations/di/RepositoryModule.kt
|
shvyn22
| 379,557,417
| false
|
{"Kotlin": 28483}
|
package shvyn22.flexingtranslations.di
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import shvyn22.flexingtranslations.data.local.dao.TranslationDao
import shvyn22.flexingtranslations.data.remote.api.ApiService
import shvyn22.flexingtranslations.repository.Repository
import shvyn22.flexingtranslations.repository.RepositoryImpl
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
object RepositoryModule {
@Singleton
@Provides
fun provideRepository(
api: ApiService,
translationDao: TranslationDao
): Repository = RepositoryImpl(api, translationDao)
}
| 0
|
Kotlin
|
0
| 0
|
ac41ad1faa4db697d028d275f7aa9c3edf68bf16
| 688
|
FlexingTranslations
|
MIT License
|
app/src/main/java/com/armutyus/ninova/constants/Constants.kt
|
armutyus
| 494,403,387
| false
|
{"Kotlin": 257381}
|
package com.armutyus.ninova.constants
import com.armutyus.ninova.BuildConfig
import com.armutyus.ninova.R
import com.armutyus.ninova.constants.Util.Companion.toLocalizedString
object Constants {
const val VERSION_NAME = BuildConfig.VERSION_NAME
//Firebase
const val DELETED_FIRESTORE = "Deleted from firestore"
const val DELETING_FIRESTORE = "Deleting from firestore"
const val UPLOADING_FIRESTORE = "Uploading to firestore"
const val UPLOADED_FIRESTORE = "Uploaded to firestore"
//Messages
val ERROR_MESSAGE = R.string.unexpected_error.toLocalizedString()
//Intents
const val ABOUT_INTENT = "aboutIntent"
const val BOOK_DETAILS_INTENT = "bookDetailsIntent"
const val LOGIN_INTENT = "loginIntent"
const val MAIN_INTENT = "mainIntent"
const val REGISTER_INTENT = "registerIntent"
//Preferences
const val CHANGE_EMAIL = "change_email"
const val CHANGE_PASSWORD = "change_password"
const val NINOVA_DARK_THEME = "ninova_dark"
const val NINOVA_LIGHT_THEME = "ninova_light"
const val BERGAMA_LIGHT_THEME = "bergama_light"
const val BERGAMA_DARK_THEME = "bergama_dark"
const val ALEXANDRIA_LIGHT_THEME = "alexandria_light"
const val ALEXANDRIA_DARK_THEME = "alexandria_dark"
const val MAIN_SHARED_PREF = "main_shared_preferences"
const val FORGOT_PASSWORD = "forgot_password"
const val REGISTER = "register"
const val SETTINGS_ACTION_KEY = "action"
//References
const val GOOGLE_BOOKS_BASE_URL = "https://www.googleapis.com/books/v1/"
const val OPEN_LIBRARY_BASE_URL = "https://openlibrary.org/"
const val BOOKS_REF = "Books"
const val BOOKSHELF_CROSS_REF = "BookShelfCrossRef"
const val FIREBASE_URL = "https://firebase.google.com/"
const val GLIDE_URL = "https://github.com/bumptech/glide"
const val GOOGLE_BOOKS_API_URL = "https://developers.google.com/books"
const val LINK_BUILDER_URL = "https://github.com/klinker24/Android-TextView-LinkBuilder"
const val LOTTIE_FILES_URL = "https://lottiefiles.com/"
const val NINOVA_LOGO_URL =
"https://play-lh.googleusercontent.com/ZeOfg2rgd6wCdWDlBjepSHK4dLenmvSd0wQz0mNIZmRXie95GIhNLWZhKm3iU81xww=w480-h960-rw"
const val PRIVACY_POLICY_URL = "https://sites.google.com/view/ninova-bookshelf-app"
const val RETROFIT_URL = "https://square.github.io/retrofit/"
const val SHELVES_REF = "Shelves"
const val USERS_REF = "Users"
//UserFields
const val CREATED_AT = "createdAt"
const val EMAIL = "email"
const val NAME = "name"
const val PHOTO_URL = "photoUrl"
//BookViewType
const val BOOK_TYPE_FOR_DETAILS = "bookTypeForDetails"
const val GOOGLE_BOOK_TYPE = 0
const val LOCAL_BOOK_TYPE = 1
const val OPEN_LIB_BOOK_TYPE = 2
//DiscoverScreenCategories
val discoverScreenCategories = listOf(
"Drama",
"Fantasy",
"Historical Fiction",
"Horror",
"Humor",
"Literature",
"Magic",
"Mystery and Detective Stories",
"Plays",
"Poetry",
"Romance",
"Science Fiction",
"Short Stories",
"Thriller",
"Young Adult Fiction",
"Science",
"Business",
"Cooking",
"Cookbooks",
"Mental Health",
"Exercise",
"Nutrition",
"Self-help",
"History",
"Anthropology",
"Religion",
"Political Science",
"Psychology",
"Biography",
"Architecture",
"Art & Art Instruction",
"Art History",
"Dance",
"Design",
"Fashion",
"Film",
"Graphic Design",
"Music",
"Music Theory",
"Painting",
"Photography",
"Bedtime",
"Children"
)
//RandomWordsList
val randomWordList = listOf(
"William",
"Shakespeare",
"Christie",
"Agatha",
"Cartland",
"Barbara",
"Danielle",
"Steel",
"Harold",
"Robbins",
"Georges",
"Simenon",
"Enid",
"Blyton",
"Sidney",
"Sheldon",
"Eiichiro",
"Rowling",
"Gilbert",
"Patten",
"Seuss",
"Akira",
"Tolstoy",
"Dostoyevski",
"Corin",
"Tellado",
"Pushkin",
"Fyodor",
"Aleksandr",
"Dean",
"Koontz",
"Chuck",
"Jackie",
"Collins",
"Hegel",
"Darwin",
"Yalom",
"Harari",
"Gogol",
"Stephen",
"King",
"Paulo",
"Coelho",
"Edgar",
"Allan",
"Wallace",
"Jiro",
"Akagawa",
"Tolkien",
"Robert",
"Ludlum",
"Dan",
"Brown",
"Yuval",
"Palahniuk",
"Kant",
"Heidegger",
"James",
"Patterson",
"Rene",
"Goscinny",
"Frederik",
"Osamu",
"Roald",
"Dahl",
"Irving",
"Wallace",
"Karl",
"Carter",
"Masashi",
"Kishimoto",
"Fleming",
"Robin",
"Cook",
"Charles",
"Dickens",
"Antoine",
"Saint-Exupery",
"Lewis",
"Haggard",
"Salinger",
"Nabokov",
"Gabriel",
"Garcia",
"Marquez",
"Ursula",
"Atwood",
"George",
"Orwell",
"Lucy",
"Maud",
"Montgomery",
"Machiavelli",
"Umberto",
"Eco",
"Richard",
"Adams",
"Higgins",
"Harper",
"Lee",
"Carl",
"Sagan",
"Anne",
"Frank",
"Scott",
"Fitzgerald",
"Stieg",
"Larsson",
"Margaret",
"Mitchell",
"Hawking",
"Suzanne",
"Collins",
"Mark",
"Twain",
"Jane",
"Austen",
"Albert",
"Camus",
"Dante",
"Alighieri",
"Carlo",
"Collodi"
)
}
| 3
|
Kotlin
|
4
| 9
|
d1482f60dc309b1aff82bb725e901ecb4ef58122
| 6,110
|
ninova
|
MIT License
|
app/src/main/java/me/tandeneck/tanutils/MainActivity.kt
|
ahaliulang
| 323,002,178
| false
| null |
package me.tandeneck.tanutils
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import dagger.hilt.android.AndroidEntryPoint
import me.tandeneck.tanutils.bean.TruckBean
import timber.log.Timber
import javax.inject.Inject
private const val TAG = "MainActivity"
@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
@Inject
lateinit var truck: TruckBean
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
truck.deliver()
}
}
| 0
|
Kotlin
|
0
| 0
|
ed39c975e03860caed711cf17f42377c754c58b3
| 599
|
TanUtils
|
Apache License 2.0
|
common/presentation/overview/src/commonMain/kotlin/com/gmvalentino/overview/contract/OverviewEvent.kt
|
wasabi-muffin
| 378,753,431
| false
|
{"Objective-C": 1112998, "Kotlin": 144204, "Swift": 6514, "Ruby": 2369, "JavaScript": 503, "HTML": 175, "Dockerfile": 121}
|
package com.gmvalentino.overview.contract
import com.gmvalentino.contract.Event
import com.gmvalentino.entities.Task
sealed class OverviewEvent : Event {
object NavigateToCreate : OverviewEvent()
data class NavigateToEdit(val task: Task) : OverviewEvent()
}
| 0
|
Objective-C
|
0
| 1
|
088077dc5db7245e1e116e32b8c65b74c510326f
| 267
|
mvi-multiplatform
|
Apache License 2.0
|
scanformatbeam/src/main/kotlin/com/seanshubin/code/structure/scanformatbeam/BeamFileWriter.kt
|
SeanShubin
| 614,471,624
| false
| null |
package com.seanshubin.code.structure.scanformatbeam
import com.seanshubin.code.structure.scanformatbeam.IntUtil.paddingFor
import java.io.OutputStream
import java.nio.ByteBuffer
import java.nio.charset.StandardCharsets
object BeamFileWriter {
fun OutputStream.writeAtoms(atoms: List<String>) {
writeBytes("AtU8")
val unpaddedSize = atoms.sumOf { it.length } + atoms.size
val padding = unpaddedSize.paddingFor(4)
writeInt(unpaddedSize + 4)
writeInt(atoms.size)
atoms.forEach {
writeAtom(it)
}
writePadding(padding)
}
fun OutputStream.writePadding(padding: Int) {
if (padding == 0) return
write(0)
writePadding(padding - 1)
}
fun OutputStream.writeAtom(atom: String) {
val size = atom.length
write(size)
writeBytes(atom)
}
fun OutputStream.writeImports(imports: List<Import>) {
writeBytes("ImpT")
val size = imports.size * 12 + 4
writeInt(size)
writeInt(imports.size)
imports.forEach { import ->
writeInt(import.moduleIndex)
writeInt(import.functionIndex)
writeInt(import.arity)
}
}
fun OutputStream.writeInt(x: Int) {
this.write(ByteBuffer.allocate(4).putInt(x).array())
}
fun OutputStream.writeBytes(s: String) {
write(s.toByteArray(StandardCharsets.UTF_8))
}
fun OutputStream.writeBeamFile(beamFile: BeamFile) {
writeBytes("FOR1")
writeInt(beamFile.computeSize())
writeBytes("BEAM")
beamFile.sections.forEach { section ->
when (section.name) {
"AtU8" -> {
writeAtoms(beamFile.atoms)
}
"ImpT" -> {
writeImports(beamFile.imports)
}
else -> {
writeSection(section)
}
}
}
}
fun OutputStream.writeSection(section: Section) {
writeBytes(section.name)
writeInt(section.size)
val padding = section.bytes.size.paddingFor(4)
write(section.bytes.toByteArray())
writePadding(padding)
}
}
| 0
|
Kotlin
|
0
| 0
|
8a23cd7c1fe574063351caaaadcb11786d9781c9
| 2,234
|
code-structure
|
The Unlicense
|
common/compose-ui/src/commonMain/kotlin/ru/tetraquark/ton/explorer/app/ui/view/Spacer.kt
|
Tetraquark
| 608,328,051
| false
| null |
package ru.tetraquark.ton.explorer.app.ui.view
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
@Composable
fun ColumnScope.ColumnSpacer(
size: Dp
) {
Spacer(modifier = Modifier.height(size))
}
@Composable
fun RowScope.RowSpacer(
size: Dp
) {
Spacer(modifier = Modifier.width(size))
}
| 0
|
Kotlin
|
0
| 3
|
c4ff09ac5e3919f9025af1fba9db54002bc4083a
| 620
|
TONSkanner
|
MIT License
|
wallet-core/src/main/java/io/zerion/wallet/core/models/WalletAccount.kt
|
zeriontech
| 484,262,866
| false
|
{"Kotlin": 85014}
|
package io.zerion.wallet.core.models
/**
* Created by rolea on 23.11.2021.
*/
class WalletAccount(
val address: String,
val index: Int?,
val derivationPath: String?,
)
| 0
|
Kotlin
|
0
| 3
|
644f50534bfa5fa8a133a260b3fca42546bdcd2b
| 182
|
wallet-core-android
|
Apache License 2.0
|
features/articles/src/main/java/com/aliumujib/artic/articles/presentation/ArticleListActionProcessor.kt
|
aliumujib
| 210,103,091
| false
|
{"Kotlin": 448725}
|
/*
* Copyright 2020 <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 com.aliumujib.artic.articles.presentation
import com.aliumujib.artic.domain.models.Article
import com.aliumujib.artic.domain.usecases.articles.GetAllArticles
import com.aliumujib.artic.domain.usecases.articles.SetArticleBookmarkStatus
import com.aliumujib.artic.domain.usecases.settings.FetchViewModeSettings
import com.aliumujib.artic.domain.usecases.settings.UpdateViewModeSettings
import com.aliumujib.artic.views.ext.ofType
import kotlinx.coroutines.flow.*
import timber.log.Timber
import javax.inject.Inject
class ArticleListActionProcessor @Inject constructor(
private val getAllArticles: GetAllArticles,
private val setArticleBookmarkStatus: SetArticleBookmarkStatus,
private val updateViewModeSettings: UpdateViewModeSettings,
private val fetchViewModeSettings: FetchViewModeSettings
) {
fun actionToResultTransformer(action: ArticleListAction): Flow<ArticleListResult> {
return when (action) {
is ArticleListAction.LoadArticleListAction -> {
loadArticleListResult(flowOf(action))
}
is ArticleListAction.RefreshArticleListAction -> {
pullToRefreshResult(flowOf(action))
}
is ArticleListAction.FetchMoreArticleListAction -> {
loadAnotherArticleListResult(flowOf(action))
}
is ArticleListAction.SetArticleBookmarkStatusAction -> {
bookmarkArticleResult(flowOf(action))
}
is ArticleListAction.SwitchArticleListViewModeAction -> {
changeArticleListViewModeResult(flowOf(action))
}
}
}
/**
* For some reason, passing in a flow here produces more than one emission
* So flowOf(A) emmits A, A or sometimes A,A,A which in turn executes more than one action.
* This is very weird behaviour considering the fact that I'm only trying to flatMap my flow.
* TODO find out why it behaves like that and see if the behaviour can be remedied.
*
* I tried writing a holdOn operator which holds all the sudden emissions for a time period and emmits only
* the latest one, didn't make a lot of progress with that ... TODO finish writing it for the science
* */
fun actionToResultTransformer(actionsFlow: Flow<ArticleListAction>): Flow<ArticleListResult> {
return actionsFlow.flatMapMerge {
merge(
loadArticleListResult(actionsFlow.ofType(ArticleListAction.LoadArticleListAction::class.java)),
pullToRefreshResult(actionsFlow.ofType(ArticleListAction.RefreshArticleListAction::class.java)),
loadAnotherArticleListResult(actionsFlow.ofType(ArticleListAction.FetchMoreArticleListAction::class.java))
)
}
}
private fun loadArticleListResult(actionsFlow: Flow<ArticleListAction.LoadArticleListAction>): Flow<ArticleListResult> {
return actionsFlow.flatMapMerge { action ->
getAllArticles.build(GetAllArticles.Params.make(true, action.page, 5)).combine(flow { emit(fetchViewModeSettings.invoke()) })
{ list: List<Article>, isGrid: Boolean ->
ArticleListResult.LoadArticleListResults.Success(list, isGrid)
}.map { result ->
result as ArticleListResult
}
.onStart { emit(ArticleListResult.LoadArticleListResults.Loading) }
.catch {
Timber.e(it)
emit(ArticleListResult.LoadArticleListResults.Error(it))
}
}
}
private fun loadAnotherArticleListResult(actionsFlow: Flow<ArticleListAction.FetchMoreArticleListAction>): Flow<ArticleListResult> {
return actionsFlow.flatMapMerge { action ->
getAllArticles.build(GetAllArticles.Params.make(false, action.page, 5))
.map { articles ->
ArticleListResult.FetchMoreArticleListResults.Success(data = articles) as ArticleListResult
}
.onStart { emit(ArticleListResult.FetchMoreArticleListResults.Loading) }
.catch {
Timber.e(it)
emit(ArticleListResult.FetchMoreArticleListResults.Error(it))
}
}
}
private fun pullToRefreshResult(actionsFlow: Flow<ArticleListAction.RefreshArticleListAction>): Flow<ArticleListResult> =
actionsFlow.flatMapMerge {
getAllArticles.build(GetAllArticles.Params.make(true, 1, 5))
.map { articles ->
ArticleListResult.RefreshArticleListResults.Success(data = articles) as ArticleListResult
}
.onStart { emit(ArticleListResult.RefreshArticleListResults.Refreshing) }
.catch {
Timber.e(it)
emit(ArticleListResult.RefreshArticleListResults.Error(it))
}
}
private fun changeArticleListViewModeResult(actionsFlow: Flow<ArticleListAction.SwitchArticleListViewModeAction>): Flow<ArticleListResult> {
return actionsFlow.flatMapMerge { action ->
flow {
emit(updateViewModeSettings.invoke(UpdateViewModeSettings.Params.make(action.isGrid)))
}.map {
ArticleListResult.SetArticleListViewModeResults.Success(it) as ArticleListResult
}.catch {
Timber.e(it)
emit(ArticleListResult.SetBookmarkStatusResults.Error(it))
}
}
}
private fun bookmarkArticleResult(actionsFlow: Flow<ArticleListAction.SetArticleBookmarkStatusAction>): Flow<ArticleListResult> {
return actionsFlow.flatMapMerge { action ->
flow {
emit(
setArticleBookmarkStatus.invoke(
SetArticleBookmarkStatus.Params.make(
action.article,
action.isBookmarked
)
)
)
}.map {
ArticleListResult.SetBookmarkStatusResults.Success(it!!) as ArticleListResult
}.catch {
Timber.e(it)
emit(ArticleListResult.SetBookmarkStatusResults.Error(it))
}
}
}
}
| 0
|
Kotlin
|
6
| 47
|
ad986536632f532d0d24aa3847bdef33ab7a5d16
| 6,887
|
Artic
|
Apache License 2.0
|
app/src/main/java/com/martinszuc/phishing_emails_detection/data/data_repository/local/component/emails/EmailMboxLocalRepository.kt
|
martinszuc
| 698,968,668
| false
|
{"Kotlin": 383778, "Python": 48298}
|
package com.martinszuc.phishing_emails_detection.data.data_repository.local.component.emails
import android.util.Log
import com.martinszuc.phishing_emails_detection.data.data_repository.local.db.AppDatabase
import com.martinszuc.phishing_emails_detection.data.data_repository.local.entity.EmailMboxMetadata
import com.martinszuc.phishing_emails_detection.data.data_repository.local.entity.email_full.EmailFull
import com.martinszuc.phishing_emails_detection.data.data_repository.local.component.file.FileRepository
import com.martinszuc.phishing_emails_detection.utils.Constants
import com.martinszuc.phishing_emails_detection.utils.emails.MboxFactory
import javax.inject.Inject
/**
* Facilitates storage and management of mbox files and their metadata locally. This repository is responsible
* for saving and retrieving mbox file content and metadata, deleting mbox files, and converting EmailFull
* objects to mbox format for storage. It interacts with both the file system and the local database to ensure
* consistency between stored files and their recorded metadata.
*
* @author <EMAIL>
*/
private const val logTag = "EmailMboxRepository"
class EmailMboxLocalRepository @Inject constructor(
private val database: AppDatabase,
private val fileRepository: FileRepository
) {
private val emailMboxMetadataDao = database.emailMboxDao()
suspend fun saveEmailMbox(emailId: String, mboxContent: String, timestamp: Long) {
val filename = "$emailId.mbox"
try {
fileRepository.saveMboxContent(mboxContent, Constants.MBOX_FILES_DIR, filename)
val metadata = EmailMboxMetadata(id = filename, timestamp = timestamp)
emailMboxMetadataDao.insert(metadata)
Log.d(logTag, "Saved mbox file and metadata successfully: $filename")
} catch (e: Exception) {
Log.e(logTag, "Failed to save mbox file or metadata: $filename", e)
}
}
suspend fun buildAndSaveMbox(emailFull: EmailFull) {
try {
val mboxContent = MboxFactory.formatEmailFullToMbox(emailFull)
saveEmailMbox(emailFull.id, mboxContent, emailFull.internalDate)
Log.d(logTag, "Built and saved mbox for email ID: ${emailFull.id}")
} catch (e: Exception) {
Log.e(logTag, "Failed to build and save mbox for email ID: ${emailFull.id}", e)
}
}
suspend fun fetchMboxContentById(id: String): String? {
try {
// Attempt to fetch metadata for the mbox file
val metadata = emailMboxMetadataDao.getEmailMbox(id)
metadata?.let {
// Try to load content from the main directory if metadata is found
fileRepository.loadFileContent(Constants.MBOX_FILES_DIR, it.id)?.let { content ->
Log.d(logTag, "Fetched mbox content for id: $id from ${Constants.MBOX_FILES_DIR}")
return content // If content is found, return it
} ?: Log.w(logTag, "No file found in main directory for id: $id, trying fallback")
}
// If the main directory attempt fails or metadata is null, try the fallback directory
return fileRepository.loadFileContent(Constants.SAVED_EMAILS_DIR, id)?.also {
Log.d(logTag, "Fetched fallback mbox content for id: $id from ${Constants.SAVED_EMAILS_DIR}")
} ?: run {
Log.w(logTag, "No file found in fallback directory for id: $id")
null // Return null if no file is found in the fallback directory
}
} catch (e: Exception) {
Log.e(logTag, "Failed to fetch mbox content for id: $id", e)
return null // Return null if an exception occurs
}
}
suspend fun deleteEmailMboxById(emailId: String) {
val filename = "$emailId.mbox" // Construct the filename from the email ID
try {
// Attempt to delete the file from the directory
fileRepository.deleteFile(Constants.MBOX_FILES_DIR, filename)
// Attempt to delete the corresponding metadata from the database
emailMboxMetadataDao.deleteEmailMbox(filename) // Ensure this method accepts the filename as the identifier
Log.d(logTag, "Deleted mbox file and metadata: $filename")
} catch (e: Exception) {
Log.e(logTag, "Failed to delete mbox file or metadata: $filename", e)
}
}
}
| 0
|
Kotlin
|
0
| 0
|
2e5e043695000fd0401347179b17743e511a0f2a
| 4,449
|
phishing-emails-detection
|
MIT License
|
url-gen/src/main/kotlin/com/cloudinary/transformation/Background.kt
|
baraka-gini
| 266,517,520
| true
|
{"Kotlin": 589400, "Java": 7089}
|
package com.cloudinary.transformation
class Background(private val action: Action) : Action by action {
companion object {
fun color(color: Color) = background(color.cldAsBackground())
fun color(color: String) = background(Color.parseString(color).cldAsBackground())
}
}
fun background(param: Param) = Background(ParamsAction(param))
| 0
|
Kotlin
|
0
| 0
|
4eedf1de1b7d784dff7232aa108f6a363364f205
| 360
|
cloudinary_kotlin
|
MIT License
|
app/src/main/java/com/fridaytech/zrxkit/sample/TransactionsFragment.kt
|
5daytech
| 197,700,358
| false
| null |
package com.fridaytech.zrxkit.sample
import android.graphics.Color
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.fridaytech.zrxkit.sample.core.TransactionRecord
import kotlinx.android.synthetic.main.fragment_transactions.*
import java.text.SimpleDateFormat
import java.util.*
class TransactionsFragment : Fragment() {
private lateinit var viewModel: MainViewModel
private val transactionsAdapter = TransactionsAdapter()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
activity?.let {
viewModel = ViewModelProviders.of(it).get(MainViewModel::class.java)
viewModel.transactions.observe(this, Observer { txs ->
txs?.let { transactions ->
transactionsAdapter.items = transactions
transactionsAdapter.notifyDataSetChanged()
}
})
viewModel.lastBlockHeight.observe(this, Observer { height ->
height?.let {
transactionsAdapter.lastBlockHeight = height
}
})
}
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? =
inflater.inflate(R.layout.fragment_transactions, null)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
transactions.adapter = transactionsAdapter
transactions.layoutManager = LinearLayoutManager(context)
ethFilter.setOnClickListener { viewModel.filterTransactions(0) }
wethFilter.setOnClickListener { viewModel.filterTransactions(1) }
tokenFilter.setOnClickListener { viewModel.filterTransactions(2) }
}
}
class TransactionsAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
var items = listOf<TransactionRecord>()
var lastBlockHeight: Long = 0
override fun getItemCount() = items.size
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder =
TransactionViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.item_transaction, parent, false))
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
when (holder) {
is TransactionViewHolder -> holder.bind(items[position], itemCount - position, lastBlockHeight)
}
}
}
class TransactionViewHolder(view: View) : RecyclerView.ViewHolder(view) {
private val summary = itemView.findViewById<TextView>(R.id.summary)!!
fun bind(tx: TransactionRecord, index: Int, lastBlockHeight: Long) {
itemView.setBackgroundColor(if (index % 2 == 0)
Color.parseColor("#dddddd")
else
Color.TRANSPARENT
)
val format = SimpleDateFormat("dd-MM-yyyy HH:mm:ss")
var value = """
- #$index
- Tx Hash: ${tx.transactionHash}
- Tx Index: ${tx.transactionIndex}
- Inter Tx Index: ${tx.interTransactionIndex}
- Time: ${format.format(Date(tx.timestamp * 1000))}
- From: ${tx.from.address}
- To: ${tx.to.address}
- Amount: ${Utils.df.format(tx.amount)}
"""
if (lastBlockHeight > 0)
value += "\n- Confirmations: ${tx.blockHeight?.let { lastBlockHeight - it } ?: 0}"
summary.text = value.trimIndent()
}
}
| 0
|
Kotlin
|
2
| 4
|
3bcce510a88d5d2d27144380a5578f9a720ec76d
| 3,791
|
zrx-kit-android
|
MIT License
|
app/src/main/java/com/mw/beam/beamwallet/screens/owner_key/OwnerKeyPresenter.kt
|
BeamMW
| 156,687,787
| false
|
{"Kotlin": 1454975, "Java": 16801, "Shell": 4651, "IDL": 1}
|
/*
* // Copyright 2018 Beam Development
* //
* // Licensed under the Apache License, Version 2.0 (the "License");
* // you may not use this file except in compliance with the License.
* // You may obtain a copy of the License at
* //
* // http://www.apache.org/licenses/LICENSE-2.0
* //
* // Unless required by applicable law or agreed to in writing, software
* // distributed under the License is distributed on an "AS IS" BASIS,
* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* // See the License for the specific language governing permissions and
* // limitations under the License.
*/
package com.mw.beam.beamwallet.screens.owner_key
import com.mw.beam.beamwallet.base_screen.BasePresenter
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import io.reactivex.subjects.PublishSubject
class OwnerKeyPresenter(view: OwnerKeyContract.View?, repository: OwnerKeyContract.Repository, val state: OwnerKeyState)
: BasePresenter<OwnerKeyContract.View, OwnerKeyContract.Repository>(view, repository), OwnerKeyContract.Presenter {
private lateinit var keyDisposable: Disposable
private val copyTag = "OwnerKey"
override fun initSubscriptions() {
super.initSubscriptions()
keyDisposable = PublishSubject.fromArray(arrayOf(true))
.map { repository.getOwnerKey() }
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
state.key = it
view?.init(it)
}
}
override fun getSubscriptions(): Array<Disposable>? = arrayOf(keyDisposable)
override fun onCopyPressed() {
view?.copyToClipboard(state.key, copyTag)
view?.showCopiedSnackBar()
}
}
| 4
|
Kotlin
|
21
| 36
|
7e9d9c0df49f3cb35bb58152c285cc7b618a28ba
| 1,894
|
android-wallet
|
Apache License 2.0
|
src/main/kotlin/me/techchrism/enchantmentjsonexporter/RemappedClassLoader.kt
|
techchrism
| 512,617,449
| false
| null |
package me.techchrism.enchantmentjsonexporter
import net.md_5.specialsource.JarMapping
import net.md_5.specialsource.JarRemapper
import net.md_5.specialsource.repo.ClassRepo
import java.io.ByteArrayInputStream
import java.io.InputStream
import java.util.jar.JarEntry
import java.util.jar.JarInputStream
class RemappedClassLoader(
parentLoader: ClassLoader,
mapping: JarMapping,
bundledJarStream: JarInputStream
) : ClassLoader(parentLoader) {
private val inverseMappedClasses = HashMap<String, String>()
private val jarContents = HashMap<String, ByteArray>()
private var remapper: JarRemapper
private var repo: ClassRepo
private val manuallyRemapPackages = HashSet<String>()
init {
registerAsParallelCapable()
// Inverse mapping for quick class calculation
for((key, value) in mapping.classes) {
if(inverseMappedClasses.containsKey(value)) {
println("Warning: Duplicate for $value -> $key")
}
inverseMappedClasses[value] = key
}
// Load library and server jars from bundle
lateinit var entry: JarEntry
while(bundledJarStream.nextJarEntry?.also { entry = it } != null) {
if (entry.isDirectory || !entry.name.endsWith(".jar")) continue
if (entry.name.startsWith("META-INF/versions/") || entry.name.startsWith("META-INF/libraries/")) {
val jis = JarInputStream(ByteArrayInputStream(bundledJarStream.readAllBytes()))
lateinit var subJarEntry: JarEntry
while(jis.nextJarEntry?.also { subJarEntry = it } != null) {
jarContents[subJarEntry.name] = jis.readAllBytes()
}
}
}
mapping.setFallbackInheritanceProvider(ProcessedInheritanceProvider(jarContents))
repo = ExtractedClassRepo(jarContents)
remapper = JarRemapper(mapping)
}
fun reloadClass(clazz: Class<*>): Class<*> {
val name = clazz.name
val classPath = name.replace('.', '/') + ".class"
val classStream = this.javaClass.classLoader.getResourceAsStream(classPath)
val bytes = classStream!!.readAllBytes()
val newClass = defineClass(name, bytes, 0, bytes.size)
resolveClass(newClass)
manuallyRemapPackages.removeIf { it.startsWith(name) }
manuallyRemapPackages.add(name)
return newClass
}
override fun getResourceAsStream(name: String?): InputStream? {
val contents = jarContents[name] ?: return super.getResourceAsStream(name)
return ByteArrayInputStream(contents)
}
override fun loadClass(name: String): Class<*> {
val classPath = name.replace('.', '/')
val obfuscatedName = inverseMappedClasses[classPath]
if(obfuscatedName != null) {
val fileName = "$obfuscatedName.class"
val bytes = jarContents[fileName]
if(bytes != null) {
val remappedBytes = remapper.remapClassFile(bytes, repo)
//println("Dynamically remapped ${obfuscatedName} to ${name}")
val newClass = defineClass(name, remappedBytes, 0, remappedBytes!!.size)
resolveClass(newClass)
return newClass
}
return super.loadClass(name)
} else {
// Search for class in other jars
val fileName = "$classPath.class"
val bytes = jarContents[fileName]
if(bytes != null) {
val newClass = defineClass(name, bytes, 0, bytes.size)
resolveClass(newClass)
return newClass
}
if(manuallyRemapPackages.any { name.startsWith(it) }) {
val classByteStream = super.getResourceAsStream(fileName) ?: throw ClassNotFoundException("Custom could not find $name")
val classBytes = classByteStream.readAllBytes()
classByteStream.close()
val newClass = defineClass(name, classBytes, 0, classBytes!!.size)
resolveClass(newClass)
return newClass
}
return super.loadClass(name)
}
}
}
| 0
|
Kotlin
|
0
| 0
|
7f3b41873c49b48c3f4d5ba35c1f74f18961632d
| 4,320
|
enchantment-json-exporter
|
MIT License
|
imagepicker/src/main/java/com/wilinz/imagepicker/ImagePicker.kt
|
wilinz
| 489,705,420
| false
|
{"Kotlin": 36733}
|
package com.wilinz.imagepicker
object ImagePicker {
var pickerOption = PickerOption()
}
| 0
|
Kotlin
|
0
| 0
|
bf55835557fcc045040363c64ddabfea0db8c487
| 92
|
ImagePicker
|
Apache License 2.0
|
rounded/src/commonMain/kotlin/me/localx/icons/rounded/bold/QuizAlt.kt
|
localhostov
| 808,861,591
| false
|
{"Kotlin": 79430321, "HTML": 331, "CSS": 102}
|
package me.localx.icons.rounded.bold
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.PathFillType.Companion.NonZero
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.StrokeCap.Companion.Butt
import androidx.compose.ui.graphics.StrokeJoin.Companion.Miter
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.ImageVector.Builder
import androidx.compose.ui.graphics.vector.path
import androidx.compose.ui.unit.dp
import me.localx.icons.rounded.Icons
public val Icons.Bold.QuizAlt: ImageVector
get() {
if (_quizAlt != null) {
return _quizAlt!!
}
_quizAlt = Builder(name = "QuizAlt", defaultWidth = 24.0.dp, defaultHeight = 24.0.dp,
viewportWidth = 24.0f, viewportHeight = 24.0f).apply {
path(fill = SolidColor(Color(0xFF000000)), stroke = null, strokeLineWidth = 0.0f,
strokeLineCap = Butt, strokeLineJoin = Miter, strokeLineMiter = 4.0f,
pathFillType = NonZero) {
moveToRelative(15.114f, 11.959f)
curveToRelative(2.191f, -0.297f, 3.886f, -2.18f, 3.886f, -4.451f)
verticalLineToRelative(-3.016f)
curveToRelative(0.0f, -2.477f, -2.015f, -4.492f, -4.492f, -4.492f)
horizontalLineToRelative(-5.017f)
curveToRelative(-2.477f, 0.0f, -4.492f, 2.016f, -4.492f, 4.492f)
verticalLineToRelative(3.016f)
curveToRelative(0.0f, 2.272f, 1.696f, 4.156f, 3.92f, 4.452f)
lineToRelative(1.738f, 1.532f)
curveToRelative(0.384f, 0.339f, 0.866f, 0.509f, 1.346f, 0.509f)
curveToRelative(0.476f, 0.0f, 0.95f, -0.167f, 1.325f, -0.498f)
lineToRelative(1.784f, -1.544f)
close()
moveTo(10.524f, 9.375f)
curveToRelative(-0.274f, -0.242f, -0.667f, -0.375f, -1.032f, -0.375f)
curveToRelative(-0.823f, 0.0f, -1.492f, -0.669f, -1.492f, -1.492f)
verticalLineToRelative(-3.016f)
curveToRelative(0.0f, -0.823f, 0.669f, -1.492f, 1.492f, -1.492f)
horizontalLineToRelative(5.017f)
curveToRelative(0.823f, 0.0f, 1.492f, 0.669f, 1.492f, 1.492f)
verticalLineToRelative(3.016f)
curveToRelative(0.0f, 0.823f, -0.669f, 1.492f, -1.492f, 1.492f)
curveToRelative(-0.36f, 0.0f, -0.708f, 0.13f, -0.981f, 0.365f)
lineToRelative(-1.521f, 1.315f)
lineToRelative(-1.482f, -1.306f)
close()
moveTo(6.16f, 17.416f)
lineToRelative(0.732f, 2.139f)
horizontalLineToRelative(-1.784f)
lineToRelative(0.725f, -2.121f)
curveToRelative(0.023f, -0.047f, 0.112f, -0.102f, 0.167f, -0.102f)
curveToRelative(0.057f, 0.0f, 0.142f, 0.047f, 0.16f, 0.083f)
close()
moveTo(6.0f, 14.0f)
curveToRelative(-2.761f, 0.0f, -5.0f, 2.239f, -5.0f, 5.0f)
reflectiveCurveToRelative(2.239f, 5.0f, 5.0f, 5.0f)
reflectiveCurveToRelative(5.0f, -2.239f, 5.0f, -5.0f)
reflectiveCurveToRelative(-2.239f, -5.0f, -5.0f, -5.0f)
close()
moveTo(8.041f, 21.778f)
horizontalLineToRelative(0.0f)
curveToRelative(-0.232f, 0.0f, -0.439f, -0.148f, -0.514f, -0.368f)
lineToRelative(-0.254f, -0.743f)
horizontalLineToRelative(-2.544f)
lineToRelative(-0.254f, 0.743f)
curveToRelative(-0.075f, 0.22f, -0.282f, 0.368f, -0.515f, 0.368f)
curveToRelative(-0.372f, 0.0f, -0.634f, -0.365f, -0.515f, -0.717f)
lineToRelative(1.354f, -4.034f)
curveToRelative(0.293f, -0.667f, 0.693f, -0.804f, 1.202f, -0.804f)
curveToRelative(0.509f, 0.0f, 0.909f, 0.137f, 1.194f, 0.784f)
lineToRelative(1.362f, 4.055f)
curveToRelative(0.118f, 0.352f, -0.144f, 0.717f, -0.515f, 0.717f)
close()
moveTo(18.556f, 18.445f)
horizontalLineToRelative(-1.667f)
verticalLineToRelative(-0.556f)
curveToRelative(0.0f, -0.307f, 0.249f, -0.556f, 0.556f, -0.556f)
horizontalLineToRelative(1.086f)
curveToRelative(0.29f, 0.0f, 0.549f, 0.211f, 0.578f, 0.499f)
curveToRelative(0.033f, 0.331f, -0.228f, 0.612f, -0.553f, 0.612f)
close()
moveTo(18.0f, 14.001f)
curveToRelative(-2.761f, 0.0f, -5.0f, 2.239f, -5.0f, 5.0f)
reflectiveCurveToRelative(2.239f, 5.0f, 5.0f, 5.0f)
reflectiveCurveToRelative(5.0f, -2.239f, 5.0f, -5.0f)
reflectiveCurveToRelative(-2.239f, -5.0f, -5.0f, -5.0f)
close()
moveTo(19.067f, 21.779f)
horizontalLineToRelative(-1.512f)
curveToRelative(-0.982f, 0.0f, -1.778f, -0.796f, -1.778f, -1.778f)
verticalLineToRelative(-2.0f)
curveToRelative(0.0f, -0.982f, 0.796f, -1.778f, 1.883f, -1.778f)
horizontalLineToRelative(0.848f)
curveToRelative(0.911f, 0.0f, 1.689f, 0.711f, 1.713f, 1.622f)
curveToRelative(0.008f, 0.314f, -0.071f, 0.609f, -0.214f, 0.863f)
curveToRelative(0.498f, 0.319f, 0.817f, 0.896f, 0.765f, 1.541f)
curveToRelative(-0.07f, 0.873f, -0.83f, 1.53f, -1.705f, 1.53f)
close()
moveTo(19.664f, 20.169f)
curveToRelative(-0.029f, 0.288f, -0.287f, 0.499f, -0.577f, 0.499f)
horizontalLineToRelative(-1.643f)
curveToRelative(-0.307f, 0.0f, -0.555f, -0.249f, -0.555f, -0.556f)
verticalLineToRelative(-0.556f)
horizontalLineToRelative(2.222f)
curveToRelative(0.325f, 0.0f, 0.586f, 0.281f, 0.553f, 0.612f)
close()
moveTo(14.671f, 5.743f)
lineToRelative(-1.939f, 1.755f)
curveToRelative(-0.366f, 0.331f, -0.825f, 0.497f, -1.284f, 0.497f)
reflectiveCurveToRelative(-0.917f, -0.166f, -1.283f, -0.496f)
lineToRelative(-0.835f, -0.755f)
curveToRelative(-0.41f, -0.37f, -0.442f, -1.003f, -0.072f, -1.413f)
curveToRelative(0.371f, -0.408f, 1.002f, -0.441f, 1.413f, -0.071f)
lineToRelative(0.778f, 0.703f)
lineToRelative(1.881f, -1.702f)
curveToRelative(0.41f, -0.372f, 1.042f, -0.339f, 1.412f, 0.07f)
curveToRelative(0.371f, 0.409f, 0.339f, 1.042f, -0.07f, 1.412f)
close()
}
}
.build()
return _quizAlt!!
}
private var _quizAlt: ImageVector? = null
| 1
|
Kotlin
|
0
| 5
|
cbd8b510fca0e5e40e95498834f23ec73cc8f245
| 7,032
|
icons
|
MIT License
|
rounded/src/commonMain/kotlin/me/localx/icons/rounded/bold/QuizAlt.kt
|
localhostov
| 808,861,591
| false
|
{"Kotlin": 79430321, "HTML": 331, "CSS": 102}
|
package me.localx.icons.rounded.bold
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.PathFillType.Companion.NonZero
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.StrokeCap.Companion.Butt
import androidx.compose.ui.graphics.StrokeJoin.Companion.Miter
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.ImageVector.Builder
import androidx.compose.ui.graphics.vector.path
import androidx.compose.ui.unit.dp
import me.localx.icons.rounded.Icons
public val Icons.Bold.QuizAlt: ImageVector
get() {
if (_quizAlt != null) {
return _quizAlt!!
}
_quizAlt = Builder(name = "QuizAlt", defaultWidth = 24.0.dp, defaultHeight = 24.0.dp,
viewportWidth = 24.0f, viewportHeight = 24.0f).apply {
path(fill = SolidColor(Color(0xFF000000)), stroke = null, strokeLineWidth = 0.0f,
strokeLineCap = Butt, strokeLineJoin = Miter, strokeLineMiter = 4.0f,
pathFillType = NonZero) {
moveToRelative(15.114f, 11.959f)
curveToRelative(2.191f, -0.297f, 3.886f, -2.18f, 3.886f, -4.451f)
verticalLineToRelative(-3.016f)
curveToRelative(0.0f, -2.477f, -2.015f, -4.492f, -4.492f, -4.492f)
horizontalLineToRelative(-5.017f)
curveToRelative(-2.477f, 0.0f, -4.492f, 2.016f, -4.492f, 4.492f)
verticalLineToRelative(3.016f)
curveToRelative(0.0f, 2.272f, 1.696f, 4.156f, 3.92f, 4.452f)
lineToRelative(1.738f, 1.532f)
curveToRelative(0.384f, 0.339f, 0.866f, 0.509f, 1.346f, 0.509f)
curveToRelative(0.476f, 0.0f, 0.95f, -0.167f, 1.325f, -0.498f)
lineToRelative(1.784f, -1.544f)
close()
moveTo(10.524f, 9.375f)
curveToRelative(-0.274f, -0.242f, -0.667f, -0.375f, -1.032f, -0.375f)
curveToRelative(-0.823f, 0.0f, -1.492f, -0.669f, -1.492f, -1.492f)
verticalLineToRelative(-3.016f)
curveToRelative(0.0f, -0.823f, 0.669f, -1.492f, 1.492f, -1.492f)
horizontalLineToRelative(5.017f)
curveToRelative(0.823f, 0.0f, 1.492f, 0.669f, 1.492f, 1.492f)
verticalLineToRelative(3.016f)
curveToRelative(0.0f, 0.823f, -0.669f, 1.492f, -1.492f, 1.492f)
curveToRelative(-0.36f, 0.0f, -0.708f, 0.13f, -0.981f, 0.365f)
lineToRelative(-1.521f, 1.315f)
lineToRelative(-1.482f, -1.306f)
close()
moveTo(6.16f, 17.416f)
lineToRelative(0.732f, 2.139f)
horizontalLineToRelative(-1.784f)
lineToRelative(0.725f, -2.121f)
curveToRelative(0.023f, -0.047f, 0.112f, -0.102f, 0.167f, -0.102f)
curveToRelative(0.057f, 0.0f, 0.142f, 0.047f, 0.16f, 0.083f)
close()
moveTo(6.0f, 14.0f)
curveToRelative(-2.761f, 0.0f, -5.0f, 2.239f, -5.0f, 5.0f)
reflectiveCurveToRelative(2.239f, 5.0f, 5.0f, 5.0f)
reflectiveCurveToRelative(5.0f, -2.239f, 5.0f, -5.0f)
reflectiveCurveToRelative(-2.239f, -5.0f, -5.0f, -5.0f)
close()
moveTo(8.041f, 21.778f)
horizontalLineToRelative(0.0f)
curveToRelative(-0.232f, 0.0f, -0.439f, -0.148f, -0.514f, -0.368f)
lineToRelative(-0.254f, -0.743f)
horizontalLineToRelative(-2.544f)
lineToRelative(-0.254f, 0.743f)
curveToRelative(-0.075f, 0.22f, -0.282f, 0.368f, -0.515f, 0.368f)
curveToRelative(-0.372f, 0.0f, -0.634f, -0.365f, -0.515f, -0.717f)
lineToRelative(1.354f, -4.034f)
curveToRelative(0.293f, -0.667f, 0.693f, -0.804f, 1.202f, -0.804f)
curveToRelative(0.509f, 0.0f, 0.909f, 0.137f, 1.194f, 0.784f)
lineToRelative(1.362f, 4.055f)
curveToRelative(0.118f, 0.352f, -0.144f, 0.717f, -0.515f, 0.717f)
close()
moveTo(18.556f, 18.445f)
horizontalLineToRelative(-1.667f)
verticalLineToRelative(-0.556f)
curveToRelative(0.0f, -0.307f, 0.249f, -0.556f, 0.556f, -0.556f)
horizontalLineToRelative(1.086f)
curveToRelative(0.29f, 0.0f, 0.549f, 0.211f, 0.578f, 0.499f)
curveToRelative(0.033f, 0.331f, -0.228f, 0.612f, -0.553f, 0.612f)
close()
moveTo(18.0f, 14.001f)
curveToRelative(-2.761f, 0.0f, -5.0f, 2.239f, -5.0f, 5.0f)
reflectiveCurveToRelative(2.239f, 5.0f, 5.0f, 5.0f)
reflectiveCurveToRelative(5.0f, -2.239f, 5.0f, -5.0f)
reflectiveCurveToRelative(-2.239f, -5.0f, -5.0f, -5.0f)
close()
moveTo(19.067f, 21.779f)
horizontalLineToRelative(-1.512f)
curveToRelative(-0.982f, 0.0f, -1.778f, -0.796f, -1.778f, -1.778f)
verticalLineToRelative(-2.0f)
curveToRelative(0.0f, -0.982f, 0.796f, -1.778f, 1.883f, -1.778f)
horizontalLineToRelative(0.848f)
curveToRelative(0.911f, 0.0f, 1.689f, 0.711f, 1.713f, 1.622f)
curveToRelative(0.008f, 0.314f, -0.071f, 0.609f, -0.214f, 0.863f)
curveToRelative(0.498f, 0.319f, 0.817f, 0.896f, 0.765f, 1.541f)
curveToRelative(-0.07f, 0.873f, -0.83f, 1.53f, -1.705f, 1.53f)
close()
moveTo(19.664f, 20.169f)
curveToRelative(-0.029f, 0.288f, -0.287f, 0.499f, -0.577f, 0.499f)
horizontalLineToRelative(-1.643f)
curveToRelative(-0.307f, 0.0f, -0.555f, -0.249f, -0.555f, -0.556f)
verticalLineToRelative(-0.556f)
horizontalLineToRelative(2.222f)
curveToRelative(0.325f, 0.0f, 0.586f, 0.281f, 0.553f, 0.612f)
close()
moveTo(14.671f, 5.743f)
lineToRelative(-1.939f, 1.755f)
curveToRelative(-0.366f, 0.331f, -0.825f, 0.497f, -1.284f, 0.497f)
reflectiveCurveToRelative(-0.917f, -0.166f, -1.283f, -0.496f)
lineToRelative(-0.835f, -0.755f)
curveToRelative(-0.41f, -0.37f, -0.442f, -1.003f, -0.072f, -1.413f)
curveToRelative(0.371f, -0.408f, 1.002f, -0.441f, 1.413f, -0.071f)
lineToRelative(0.778f, 0.703f)
lineToRelative(1.881f, -1.702f)
curveToRelative(0.41f, -0.372f, 1.042f, -0.339f, 1.412f, 0.07f)
curveToRelative(0.371f, 0.409f, 0.339f, 1.042f, -0.07f, 1.412f)
close()
}
}
.build()
return _quizAlt!!
}
private var _quizAlt: ImageVector? = null
| 1
|
Kotlin
|
0
| 5
|
cbd8b510fca0e5e40e95498834f23ec73cc8f245
| 7,032
|
icons
|
MIT License
|
src/main/kotlin/no/nav/helse/nl/Application.kt
|
navikt
| 209,468,274
| false
| null |
package no.nav.helse.nl
import io.ktor.application.Application
import io.ktor.application.install
import io.ktor.metrics.micrometer.MicrometerMetrics
import io.ktor.routing.routing
import io.ktor.server.engine.embeddedServer
import io.ktor.server.netty.Netty
import io.micrometer.core.instrument.Clock
import io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics
import io.micrometer.core.instrument.binder.jvm.JvmGcMetrics
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics
import io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics
import io.micrometer.core.instrument.binder.logging.LogbackMetrics
import io.micrometer.core.instrument.binder.system.ProcessorMetrics
import io.micrometer.prometheus.PrometheusConfig
import io.micrometer.prometheus.PrometheusMeterRegistry
import io.prometheus.client.CollectorRegistry
import kotlinx.coroutines.asCoroutineDispatcher
import kotlinx.coroutines.cancelChildren
import kotlinx.coroutines.runBlocking
import no.nav.helse.nl.api.registerNaisApi
import org.slf4j.LoggerFactory
import java.util.concurrent.Executors
data class ApplicationState(var running: Boolean = true, var initialized: Boolean = false)
private val log: org.slf4j.Logger = LoggerFactory.getLogger("ApplicationKt")
fun main() = runBlocking(Executors.newFixedThreadPool(2).asCoroutineDispatcher()) {
val env = getEnvironment()
val applicationState = ApplicationState()
embeddedServer(Netty, env.applicationPort) {
install(MicrometerMetrics) {
registry =
PrometheusMeterRegistry(PrometheusConfig.DEFAULT, CollectorRegistry.defaultRegistry, Clock.SYSTEM)
meterBinders = listOf(
ClassLoaderMetrics(),
JvmMemoryMetrics(),
JvmGcMetrics(),
ProcessorMetrics(),
JvmThreadMetrics(),
LogbackMetrics()
)
}
initRouting(applicationState)
}.start(wait = false)
Runtime.getRuntime().addShutdownHook(Thread {
coroutineContext.cancelChildren()
})
applicationState.initialized = true
}
fun Application.initRouting(applicationState: ApplicationState) {
routing {
registerNaisApi(
readynessCheck = {
applicationState.initialized
},
livenessCheck = {
applicationState.running
}
)
}
}
| 0
|
Kotlin
|
0
| 0
|
a4f31d464a6b4d6d0bc77ad298ae09f41d330e49
| 2,419
|
helse-nl-altinn
|
MIT License
|
src/server/src/Client.kt
|
andersonarc
| 218,299,357
| false
|
{"Kotlin": 57869, "GLSL": 3320}
|
import java.net.Socket
class Client(socket: Socket) {
private val reader = socket.getInputStream().bufferedReader()
private val writer = socket.getOutputStream().bufferedWriter()
fun write(string: String) {
writer.write(string)
writer.newLine()
writer.flush()
}
fun read(): String {
return reader.readLine()
}
}
| 0
|
Kotlin
|
0
| 1
|
95307498e5d19fe2b9b831776b95f32d426e931e
| 370
|
graphics
|
The Unlicense
|
hideout-worker/src/main/kotlin/dev/usbharu/hideout/worker/DeliverAcceptTaskRunner.kt
|
usbharu
| 627,026,893
| false
|
{"Kotlin": 1472831, "Mustache": 111614, "Gherkin": 21440, "JavaScript": 1112, "HTML": 936}
|
/*
* Copyright (C) 2024 usbharu
*
* 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 dev.usbharu.hideout.worker
import dev.usbharu.hideout.activitypub.service.common.APRequestService
import dev.usbharu.hideout.application.external.Transaction
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
import dev.usbharu.hideout.core.external.job.DeliverAcceptTask
import dev.usbharu.hideout.core.external.job.DeliverAcceptTaskDef
import dev.usbharu.owl.consumer.AbstractTaskRunner
import dev.usbharu.owl.consumer.TaskRequest
import dev.usbharu.owl.consumer.TaskResult
import org.springframework.stereotype.Component
@Component
class DeliverAcceptTaskRunner(
private val apRequestService: APRequestService,
private val actorRepository: ActorRepository,
private val transaction: Transaction,
) : AbstractTaskRunner<DeliverAcceptTask, DeliverAcceptTaskDef>(DeliverAcceptTaskDef) {
override suspend fun typedRun(typedParam: DeliverAcceptTask, taskRequest: TaskRequest): TaskResult {
transaction.transaction {
apRequestService.apPost(
typedParam.inbox,
typedParam.accept,
actorRepository.findById(typedParam.signer)
)
}
return TaskResult.ok()
}
}
| 37
|
Kotlin
|
0
| 11
|
99a846bdfbd6ab8923a98adfb8eeec1a3f239dc1
| 1,789
|
Hideout
|
Apache License 2.0
|
app/src/main/java/com/erkindilekci/instagramclone/presentation/components/BottomNavigationMenu.kt
|
erkindilekci
| 660,885,899
| false
| null |
package com.erkindilekci.instagramclone.presentation.components
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import com.erkindilekci.instagramclone.R
import com.erkindilekci.instagramclone.util.Screen
@Composable
fun BottomNavigationMenu(
selectedItem: BottomNavigationItem,
navController: NavController
) {
Row(
modifier = Modifier
.fillMaxWidth()
.height(55.dp)
.background(MaterialTheme.colorScheme.surface),
verticalAlignment = Alignment.CenterVertically
) {
for (item in BottomNavigationItem.values()) {
Image(
painter = painterResource(id = item.icon),
contentDescription = null,
modifier = Modifier
.size(40.dp)
.padding(5.dp)
.weight(1f)
.clickable { navigateTo(navController, item.navDestination) },
colorFilter = if (item == selectedItem) ColorFilter.tint(MaterialTheme.colorScheme.onSurface)
else ColorFilter.tint(Color.LightGray)
)
}
}
}
enum class BottomNavigationItem(val icon: Int, val navDestination: Screen) {
FEED(R.drawable.ic_home, Screen.Feed),
ADD(R.drawable.ic_addpost, Screen.Add),
POSTS(R.drawable.ic_posts, Screen.MyPosts)
}
| 0
|
Kotlin
|
0
| 0
|
2af2dda8f4f205882a6ed9bb75104ff775d7efae
| 2,049
|
InstragramClone
|
Apache License 2.0
|
app/src/main/java/com/example/superheroes/HeroesScreen.kt
|
Hitendra27
| 781,150,687
| false
|
{"Kotlin": 22806}
|
package com.example.superheroes
import android.content.res.Configuration
import androidx.annotation.DrawableRes
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.core.MutableTransitionState
import androidx.compose.animation.core.Spring.DampingRatioLowBouncy
import androidx.compose.animation.core.Spring.StiffnessVeryLow
import androidx.compose.animation.core.spring
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInVertically
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.sizeIn
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import com.example.superheroes.model.Hero
import com.example.superheroes.model.HeroesRepository.heroes
import com.example.superheroes.ui.theme.SuperheroesTheme
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Scaffold
import androidx.compose.ui.Alignment
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.unit.dp
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.remember
import androidx.compose.ui.draw.clip
import com.example.superheroes.model.HeroesRepository
/**
* Composable that displays an an bar and a list of superheroes.
*/
//@OptIn(ExperimentalAnimationApi::class)
//@Composable
//fun HeroesList(
// heroes: List<Hero>,
// modifier: Modifier = Modifier,
// contentPadding: PaddingValues = PaddingValues(0.dp),
//) {
// val visibleState = remember {
// MutableTransitionState(false).apply {
// // Start the animation immediately.
// targetState = true
// }
// }
//
// // Fade in entry animation for the entire list
// AnimatedVisibility(
// visibleState = visibleState,
// enter = fadeIn(
// animationSpec = spring(dampingRatio = DampingRatioLowBouncy)
// ),
// exit = fadeOut(),
// modifier = modifier
// ) {
// LazyColumn(contentPadding = contentPadding) {
// itemsIndexed(heroes) { index, hero ->
// HeroesItem(
// hero = hero,
// modifier = Modifier
// .padding(horizontal = 16.dp, vertical = 8.dp)
// // Animate each list item to slide in vertically
// .animateEnterExit(
// enter = slideInVertically(
// animationSpec = spring(
// stiffness = StiffnessVeryLow,
// dampingRatio = DampingRatioLowBouncy
// ),
// initialOffsetY = { it * (index + 1) } // staggered entrance
// )
// )
// )
// }
// }
// }
//}
//
//@Composable
//fun HeroesItem(
// hero: Hero,
// modifier: Modifier = Modifier
//) {
// Card (
// elevation = CardDefaults.cardElevation(defaultElevation = 2.dp),
// modifier = modifier
// ){
// Row(
// modifier = modifier
// .fillMaxWidth()
// .padding(16.dp)
// .sizeIn(minHeight = 72.dp)
//
// ) {
// HeroesInformation(
// heroName = hero.nameRes,
// heroInfo = hero.descriptionRes
// )
// Spacer(modifier = Modifier.width(16.dp))
// Box(
// modifier = Modifier
// .size(72.dp)
// .clip(RoundedCornerShape(8.dp))
// ) {
// //HeroIcon(heroIcon = hero.imageRes)
// Image(
// painter = painterResource(hero.imageRes),
// contentDescription = null,
// alignment = Alignment.TopCenter,
// contentScale = ContentScale.FillWidth
// )
// }
// }
// }
//
//}
//
///**
// * Composable that displays a photo of a Superhero
// *
// *@param heroIcon is the resource ID for the image of the superher
// * @param modifier modifiers to set to this composable
// */
//@Composable
//fun HeroIcon(
// @DrawableRes heroIcon: Int,
// modifier: Modifier = Modifier
//) {
// Image(
// painter = painterResource(heroIcon) ,
// contentDescription = null,
// alignment = Alignment.TopCenter,
// contentScale = ContentScale.FillWidth,
// modifier = modifier
// .size(72.dp)
// .padding(start = 16.dp)
// )
//}
//
///**
// * Composable that displays a SuperHero's name and info
// *
// * @param heroName is the resource ID for the string of the superhero name
// * @param heroInfo is the Int that represents the superhero's infomation
// * @param modifier modifiers to set to this composable
// */
//@Composable
//fun HeroesInformation(
// heroName: Int,
// heroInfo: Int,
// modifier: Modifier = Modifier
//) {
// Column(modifier = modifier) {
// Text(
// text = stringResource(heroName),
// style = MaterialTheme.typography.displaySmall
// )
// Text(
// text = stringResource(heroInfo),
// style = MaterialTheme.typography.bodyLarge
// )
// }
//}
//
//@Preview(showBackground = true)
//@Composable
//fun HeroAppPreview() {
// SuperheroesTheme {
// HeroesList(heroes = heroes)
// }
//}
@OptIn(ExperimentalAnimationApi::class)
@Composable
fun HeroesList(
heroes: List<Hero>,
modifier: Modifier = Modifier,
contentPadding: PaddingValues = PaddingValues(0.dp),
) {
val visibleState = remember {
MutableTransitionState(false).apply {
// Start the animation immediately.
targetState = true
}
}
// Fade in entry animation for the entire list
AnimatedVisibility(
visibleState = visibleState,
enter = fadeIn(
animationSpec = spring(dampingRatio = DampingRatioLowBouncy)
),
exit = fadeOut(),
modifier = modifier
) {
LazyColumn(contentPadding = contentPadding) {
itemsIndexed(heroes) { index, hero ->
HeroListItem(
hero = hero,
modifier = Modifier
.padding(horizontal = 16.dp, vertical = 8.dp)
// Animate each list item to slide in vertically
.animateEnterExit(
enter = slideInVertically(
animationSpec = spring(
stiffness = StiffnessVeryLow,
dampingRatio = DampingRatioLowBouncy
),
initialOffsetY = { it * (index + 1) } // staggered entrance
)
)
)
}
}
}
}
@Composable
fun HeroListItem(
hero: Hero,
modifier: Modifier = Modifier
) {
Card(
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp),
modifier = modifier,
) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp)
.sizeIn(minHeight = 72.dp)
) {
Column(modifier = Modifier.weight(1f)) {
Text(
text = stringResource(hero.nameRes),
style = MaterialTheme.typography.displaySmall
)
Text(
text = stringResource(hero.descriptionRes),
style = MaterialTheme.typography.bodyLarge
)
}
Spacer(Modifier.width(16.dp))
Box(
modifier = Modifier
.size(72.dp)
.clip(RoundedCornerShape(8.dp))
) {
Image(
painter = painterResource(hero.imageRes),
contentDescription = null,
alignment = Alignment.TopCenter,
contentScale = ContentScale.FillWidth
)
}
}
}
}
@Preview("Light Theme")
@Preview("Dark Theme", uiMode = Configuration.UI_MODE_NIGHT_YES)
@Composable
fun HeroPreview() {
val hero = Hero(
R.string.hero1,
R.string.description1,
R.drawable.android_superhero1
)
SuperheroesTheme {
HeroListItem(hero = hero)
}
}
@Preview("Heroes List")
@Composable
fun HeroesPreview() {
SuperheroesTheme(darkTheme = false) {
Surface (
color = MaterialTheme.colorScheme.background
) {
/* Important: It is not a good practice to access data source directly from the UI.
In later units you will learn how to use ViewModel in such scenarios that takes the
data source as a dependency and exposes heroes.
*/
HeroesList(heroes = HeroesRepository.heroes)
}
}
}
| 0
|
Kotlin
|
0
| 0
|
e3e7883bf3ef256006a607aaaa211c7809ff8bc2
| 10,187
|
Superheroes
|
MIT License
|
app/src/main/java/com/jrk/mood4food/waterbalance/model/WaterBalanceObserver.kt
|
JanPfenning
| 299,564,277
| false
| null |
package com.jrk.mood4food.waterbalance.model
import com.jrk.mood4food.model.DomainObservers
interface WaterBalanceObserver: DomainObservers {
fun waterStoredIn()
fun goalsChanged()
}
| 0
|
Kotlin
|
1
| 0
|
08864088d22b321defd659a2aed3511feff361e2
| 193
|
Mood4Food
|
MIT License
|
app/src/main/java/com/siedg/desafio_android/data/api/ApiService.kt
|
Siedg
| 393,771,537
| true
|
{"Kotlin": 32482}
|
package com.siedg.desafio_android.data.api
import com.siedg.desafio_android.data.model.*
import retrofit2.Response
import retrofit2.http.GET
import retrofit2.http.Query
interface ApiService {
@GET("people")
suspend fun getPersonList(@Query("page") index: Int): Response<PersonList>
@GET("planets")
suspend fun getPlanetsList(@Query("page") index: Int): Response<PlanetList>
@GET("species")
suspend fun getSpeciesList(@Query("page") index: Int): Response<SpecieList>
}
| 0
|
Kotlin
|
0
| 0
|
e212df9769b03de9b9053fa0d347fc777d5aa736
| 495
|
desafio-android
|
The Unlicense
|
src/main/kotlin/com/hkmod/soluna/Soluna.kt
|
HKMOD
| 525,047,786
| false
|
{"Kotlin": 27261}
|
package com.hkmod.soluna
import com.hkmod.soluna.client.keybind.KeyBindings
import com.hkmod.soluna.client.renderer.registerRenderers
import com.hkmod.soluna.common.blocks.SolunaBlocks
import com.hkmod.soluna.common.blocks.entity.SolunaBlockEntities
import com.hkmod.soluna.common.items.SolunaItems
import com.hkmod.soluna.datagen.datagen
import net.minecraftforge.fml.common.Mod
import org.apache.logging.log4j.Level
import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.Logger
import thedarkcolour.kotlinforforge.forge.DIST
import thedarkcolour.kotlinforforge.forge.MOD_BUS
const val MODID = "soluna"
@Mod(MODID)
object Soluna {
val LOGGER: Logger = LogManager.getLogger()
init {
LOGGER.log(Level.INFO, "$MODID has started!")
SolunaItems.registerItems(MOD_BUS)
SolunaBlocks.registerBlocks(MOD_BUS)
SolunaBlockEntities.registerBEs(MOD_BUS)
MOD_BUS.addListener(::datagen)
if (DIST.isClient) {
MOD_BUS.addListener(KeyBindings::registerKeybindings)
MOD_BUS.addListener(::registerRenderers)
}
}
}
| 0
|
Kotlin
|
0
| 1
|
596423f0cbf7eaca09f3eb340458b9f7face640e
| 1,112
|
Soluna
|
MIT License
|
app/src/main/java/com/example/appName/presentation/features/main/MainIntent.kt
|
maanoo1409
| 283,405,874
| false
| null |
package com.example.appName.presentation.features.main
sealed class MainIntent {
object Login : MainIntent()
object Logout : MainIntent()
}
| 0
|
Kotlin
|
0
| 1
|
d2f40c652bd9a51e2d6756cc983babcb90fad676
| 149
|
sabb
|
MIT License
|
src/main/kotlin/com/unqueam/gamingplatform/application/http/AuthController.kt
|
UNQueam
| 681,903,849
| false
|
{"Kotlin": 149452, "HTML": 3393}
|
package com.unqueam.gamingplatform.application.http
import com.unqueam.gamingplatform.infrastructure.configuration.jwt.JwtTokenBlacklistService
import com.unqueam.gamingplatform.application.dtos.AuthenticationOutput
import com.unqueam.gamingplatform.application.dtos.SignInRequest
import com.unqueam.gamingplatform.application.dtos.SignUpRequest
import com.unqueam.gamingplatform.core.services.IAuthenticationService
import jakarta.servlet.http.HttpServletRequest
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
@RestController
@RequestMapping(API.ENDPOINT_AUTH)
class AuthController {
private final val authService: IAuthenticationService
private final val tokenBlacklistService: JwtTokenBlacklistService
@Autowired
constructor(authService: IAuthenticationService, tokenBlacklistService: JwtTokenBlacklistService) {
this.authService = authService
this.tokenBlacklistService = tokenBlacklistService
}
@PostMapping ("/signIn")
fun userSignIn(@RequestBody signInRequest: SignInRequest, httpServletRequest: HttpServletRequest) : ResponseEntity<AuthenticationOutput> {
val output = authService.signIn(signInRequest, httpServletRequest)
return ResponseEntity.status(HttpStatus.OK).body(output)
}
@PostMapping ("/signUp")
fun userSignUp(@RequestBody signUpRequest: SignUpRequest) : ResponseEntity<AuthenticationOutput> {
val output = authService.signUp(signUpRequest)
return ResponseEntity.status(HttpStatus.CREATED).body(output)
}
@GetMapping ("/logout")
fun userLogout(request: HttpServletRequest): ResponseEntity<Any> {
tokenBlacklistService.addTokenToBlacklistFromRequest(request)
return ResponseEntity.status(HttpStatus.OK).build()
}
}
| 0
|
Kotlin
|
0
| 0
|
f8e80a146d23cd061f4934ecefbe6005e903e525
| 2,165
|
unqueam-backend
|
MIT License
|
app/src/main/java/xyz/sentrionic/harmony/ui/main/story/state/StoryStateEvent.kt
|
sentrionic
| 220,498,638
| false
|
{"Kotlin": 325826}
|
package xyz.sentrionic.harmony.ui.main.story.state
sealed class StoryStateEvent {
class StorySearchEvent : StoryStateEvent()
class ProfileSearchEvent : StoryStateEvent()
class GetProfilePropertiesEvent : StoryStateEvent()
class GetProfileStoriesEvent: StoryStateEvent()
class CheckAuthorOfStoryPost : StoryStateEvent()
class DeleteStoryPostEvent : StoryStateEvent()
class LikeStoryPostEvent : StoryStateEvent()
class FollowProfileEvent : StoryStateEvent()
class GetStoryPostComments : StoryStateEvent()
class PostCommentEvent : StoryStateEvent()
class None : StoryStateEvent()
}
| 0
|
Kotlin
|
0
| 1
|
0751148a2566ad11098ddd7f122cade7c1792dc3
| 635
|
HarmonyApp
|
MIT License
|
src/main/kotlin/com/github/imeszaros/vb2buxfer/gui/GUI.kt
|
imeszaros
| 144,510,968
| false
| null |
package com.github.imeszaros.vb2buxfer.gui
import com.github.imeszaros.buxfer.Buxfer.Companion.login
import com.github.imeszaros.buxfer.BuxferException
import com.github.imeszaros.vb2buxfer.Configuration
import com.github.imeszaros.vb2buxfer.Configuration.Buxfer.password
import com.github.imeszaros.vb2buxfer.Configuration.Buxfer.username
import org.eclipse.swt.dnd.Clipboard
import org.eclipse.swt.dnd.HTMLTransfer
import org.eclipse.swt.graphics.Color
import org.eclipse.swt.graphics.Image
import org.eclipse.swt.graphics.ImageData
import org.eclipse.swt.graphics.RGB
import org.eclipse.swt.widgets.Display
import org.eclipse.swt.widgets.Shell
import kotlin.concurrent.thread
class GUI(private val config: Configuration) {
val display = Display.getDefault()!!
private val clipboard = Clipboard(display)
private val images = mutableMapOf<String, Image>()
private val colors = mutableMapOf<RGB, Color>()
fun loop() {
val hiddenShell = Shell(display)
try {
ProgressDialog.whileReturns(this, hiddenShell, "Logging in…") {
login(config[username], config[password])
}
} catch (e: BuxferException) {
hiddenShell.showError("Unable to log-in to Buxfer. Please check the configuration.")
null
} finally {
hiddenShell.dispose()
}?.let {
val appWindow = AppWindow(it, config, this)
appWindow.shell.open()
while (!appWindow.shell.isDisposed) {
if (!display.readAndDispatch()) {
display.sleep()
}
}
}
images.values.forEach(Image::dispose)
colors.values.forEach(Color::dispose)
clipboard.dispose()
display.dispose()
}
fun image(path: String): Image = images.computeIfAbsent(path) {
p -> Image(display, ImageData(GUI::class.java.getResourceAsStream(p)))
}
fun color(rgb: RGB): Color = colors.computeIfAbsent(rgb) { o -> Color(display, o.red, o.green, o.blue )}
fun getClipboardText() = clipboard.getContents(HTMLTransfer.getInstance()) as String? ?: ""
companion object {
fun init(config: Configuration) = thread(name = "User Interface Thread") {
Display.setAppName("Volksbank -> Buxfer")
Display.setAppVersion("1.0")
GUI(config).loop()
}
}
}
| 0
|
Kotlin
|
0
| 0
|
ede4202a604cc43a90613c0cdab3167d069053f8
| 2,408
|
vb2buxfer
|
Apache License 2.0
|
kotlin-code-generation/src/main/kotlin/spec/KotlinAnnotationClassSpec.kt
|
toolisticon
| 804,098,315
| false
|
{"Kotlin": 324780}
|
package io.toolisticon.kotlin.generation.spec
import com.squareup.kotlinpoet.ClassName
import com.squareup.kotlinpoet.ExperimentalKotlinPoetApi
import com.squareup.kotlinpoet.TypeSpec
import io.toolisticon.kotlin.generation.poet.KDoc
import kotlin.reflect.KClass
/**
* Represents an annotation class.
*/
@ExperimentalKotlinPoetApi
data class KotlinAnnotationClassSpec(
override val className: ClassName,
private val spec: TypeSpec
) : KotlinGeneratorTypeSpec<KotlinAnnotationClassSpec>, KotlinAnnotationClassSpecSupplier, KotlinDocumentableSpec {
override fun <T : Any> tag(type: KClass<T>): T? = get().tag(type)
override fun spec(): KotlinAnnotationClassSpec = this
override fun get(): TypeSpec = spec
override val kdoc: KDoc get() = KDoc(spec.kdoc)
}
/**
* Marks the builder and the spec so they are interchangeable.
*/
@ExperimentalKotlinPoetApi
interface KotlinAnnotationClassSpecSupplier : KotlinGeneratorSpecSupplier<KotlinAnnotationClassSpec>, ToFileTypeSpecSupplier {
override fun get(): TypeSpec = spec().get()
}
| 5
|
Kotlin
|
0
| 2
|
e16f4f5ab3fc01ca585e833caa67e85f9152caa6
| 1,044
|
kotlin-code-generation
|
Apache License 2.0
|
transferwise/src/main/java/com/transferwise/banks/recipients/create/CreateRecipientFragment.kt
|
Ryggs
| 237,440,757
| true
|
{"Kotlin": 446684}
|
/*
* Copyright 2019 TransferWise Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.transferwise.banks.recipients.create
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.lifecycle.Observer
import androidx.navigation.fragment.navArgs
import com.transferwise.banks.R
import com.transferwise.banks.databinding.FragmentCreateRecipientBinding
import com.transferwise.banks.recipients.create.CreateRecipientUiState.Error
import com.transferwise.banks.recipients.create.CreateRecipientUiState.Idle
import com.transferwise.banks.recipients.create.CreateRecipientUiState.Saving
import com.transferwise.banks.util.sharedViewModel
import com.transferwise.banks.util.toast
/**
* Please refer to the design guide for more information about each screen:
* https://www.notion.so/Bank-Integrations-Design-Guide-8c375c5c5f1e4c64953b4b601ff6abc6
*/
internal class CreateRecipientFragment : Fragment() {
private lateinit var binding: FragmentCreateRecipientBinding
private val viewModel by viewModels<CreateRecipientViewModel> { getFactory() }
val args: CreateRecipientFragmentArgs by navArgs()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
binding = FragmentCreateRecipientBinding.inflate(inflater)
binding.save.setOnClickListener {
binding.dynamicForm.clearFocus()
viewModel.saveRecipient()
}
viewModel.uiState.observe(viewLifecycleOwner, Observer(::refreshUi))
return binding.root
}
override fun onStart() {
super.onStart()
viewModel.doOnStart()
}
private fun refreshUi(state: CreateRecipientUiState) = when (state) {
is Error -> {
binding.dynamicForm.animate().alpha(1f)
binding.save.alpha = 1f
binding.progressBarSave.isVisible = false
showError()
}
is Saving -> {
binding.dynamicForm.animate().alpha(0.5f)
binding.save.alpha = 0f
binding.progressBarSave.isVisible = true
Unit
}
Idle -> {
binding.dynamicForm.animate().alpha(1f)
binding.save.alpha = 1f
binding.progressBarSave.isVisible = false
}
}
private fun showError() = toast(R.string.create_recipient_failed)
private fun getFactory(): CreateRecipientViewModelFactory = CreateRecipientViewModelFactory(
sharedViewModel, binding.dynamicForm.controller, resources, args.customerId, args.quoteId, args.targetCurrency
)
}
| 0
| null |
0
| 1
|
54688a6bd7054c2ed7d5db325591bf26a97286bd
| 3,283
|
banks-reference-android
|
Apache License 2.0
|
compiler/testData/diagnostics/tests/imports/ExplicitPackageImportsAmbiguity.kt
|
staltz
| 38,581,975
| true
|
{"Java": 15450397, "Kotlin": 8578737, "JavaScript": 176060, "HTML": 22810, "Lex": 17327, "Protocol Buffer": 13024, "ANTLR": 9689, "CSS": 9431, "Shell": 3931, "IDL": 3257, "Groovy": 3010, "Batchfile": 2831}
|
// FILE: a.kt
package a.x
class X
// FILE: b.kt
package b.x
class X
// FILE: c.kt
package c
import <!CONFLICTING_IMPORT!>a.x<!>
import <!CONFLICTING_IMPORT!>b.x<!>
class Y : <!UNRESOLVED_REFERENCE!>x<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>X<!>
| 0
|
Java
|
0
| 1
|
80074c71fa925a1c7173e3fffeea4cdc5872460f
| 246
|
kotlin
|
Apache License 2.0
|
attendance/app/src/main/java/com/capstone/attendance/ui/update/UpdateUsernameFragment.kt
|
gunadermawan
| 428,836,954
| false
|
{"Kotlin": 79686}
|
package com.capstone.attendance.ui.update
import android.app.Activity
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.res.ResourcesCompat
import androidx.fragment.app.Fragment
import androidx.navigation.Navigation
import com.capstone.attendance.R
import com.capstone.attendance.databinding.FragmentUpdateUsernameBinding
import com.capstone.attendance.utils.*
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.UserProfileChangeRequest
import www.sanju.motiontoast.MotionToast
import www.sanju.motiontoast.MotionToastStyle
class UpdateUsernameFragment : Fragment() {
private lateinit var auth: FirebaseAuth
private lateinit var updateUsernameBinding: FragmentUpdateUsernameBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?,
): View {
updateUsernameBinding =
FragmentUpdateUsernameBinding.inflate(layoutInflater, container, false)
// Inflate the layout for this fragment
return updateUsernameBinding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
auth = FirebaseAuth.getInstance()
updateUsernameBinding.etUsername.requestFocus()
val user = auth.currentUser
updateUsernameBinding.etUsername.setText(user?.displayName)
updateUsernameBinding.btnUpdate.setOnClickListener {
val name = updateUsernameBinding.etUsername.text.toString()
if (name.isEmpty()) {
updateUsernameBinding.txtInputUsername.error = NAME_EMPTY
updateUsernameBinding.txtInputUsername.requestFocus()
return@setOnClickListener
}
UserProfileChangeRequest.Builder()
.setDisplayName(name)
.build().also {
user?.updateProfile(it)?.addOnCompleteListener { Task ->
if (Task.isSuccessful) {
val actionUpdateUsername =
UpdateUsernameFragmentDirections.actionUpdatedUsername()
Navigation.findNavController(view).navigate(actionUpdateUsername)
FunctionLibrary.toast(
context as Activity,
TOAST_SUCCESS,
USERNAME_UPDATED,
MotionToastStyle.SUCCESS,
MotionToast.GRAVITY_BOTTOM,
MotionToast.LONG_DURATION,
ResourcesCompat.getFont(context as Activity,
R.font.helveticabold)
)
} else {
FunctionLibrary.toast(
context as Activity,
TOAST_WARNING,
"${Task.exception?.message}",
MotionToastStyle.ERROR,
MotionToast.GRAVITY_BOTTOM,
MotionToast.LONG_DURATION,
ResourcesCompat.getFont(context as Activity,
R.font.helveticabold)
)
}
}
}
}
}
}
| 1
|
Kotlin
|
0
| 4
|
f33091dabbc54b7abe14d34505a9886a46576ce2
| 3,555
|
android-PeduliPresensi-kotlin
|
MIT License
|
speech_demo/android/app/src/main/kotlin/ecu/cs4730/speech_demo/MainActivity.kt
|
JimSeker
| 349,205,191
| false
|
{"Dart": 149553, "C++": 37398, "HTML": 33284, "CMake": 20024, "Java": 2726, "C": 1468, "Swift": 1212, "Kotlin": 127, "Objective-C": 114}
|
package ecu.cs4730.speech_demo
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
}
| 0
|
Dart
|
0
| 3
|
6f1e2a4f4e222274af0dea72a2b9d315b53a4629
| 127
|
flutter
|
Apache License 2.0
|
app/src/main/java/com/apx8/mongoose/presentation/view/display/ForecastTodayDisplay.kt
|
volt772
| 770,166,792
| false
|
{"Kotlin": 115465, "Shell": 8753}
|
package com.apx8.mongoose.presentation.view.display
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.apx8.mongoose.R
import com.apx8.mongoose.domain.dto.ForecastListInfo
import com.apx8.mongoose.presentation.ext.getWeatherConditionCodes
import com.apx8.mongoose.presentation.ui.theme.MgSubDarkBlue
import com.apx8.mongoose.presentation.ui.theme.MgWhite
import com.apx8.mongoose.presentation.ui.theme.MgYellowTransparent
@Composable
fun ForecastTodayDisplay(
infoList: List<ForecastListInfo>,
modifier: Modifier = Modifier
) {
if (infoList.isNotEmpty()) {
/**
* @box Root
*/
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.Start
) {
/**
* @view 섹션 레이블 (오늘날씨)
*/
Text(
text = stringResource(id = R.string.today_forecast),
fontSize = 20.sp,
color = MgYellowTransparent,
fontWeight = FontWeight.Bold
)
Spacer(modifier = Modifier.height(5.dp))
/**
* @list 오늘날씨 아이템
*/
LazyRow {
items(infoList.size) {
TodayWeatherItem(index = it, infoList = infoList)
}
}
}
}
}
@Composable
fun TodayWeatherItem(index: Int, infoList: List<ForecastListInfo>) {
val paddingStart = if (index == 0) 0.dp else 8.dp
val info = infoList[index]
/**
* @box Root
*/
Box(
modifier = Modifier
.padding(start = paddingStart)
) {
/**
* @box Root
*/
Column(
modifier = Modifier
.clip(RoundedCornerShape(10.dp))
.background(MgSubDarkBlue)
.size(130.dp)
.clickable {}
.padding(13.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
val weatherType = info.weatherId.getWeatherConditionCodes()
val temperature = info.temp
val description = info.weatherDescription
val time = info.dtTxtTime
/**
* @view 아이콘
*/
Image(
painterResource(id = weatherType.mainRes),
contentDescription = null,
modifier = Modifier.size(50.dp)
)
Spacer(modifier = Modifier.height(5.dp))
/**
* @view 시간 : 기온
* @example 12시 : 22°C
*/
Text(
text = stringResource(
id = R.string.time_label,
time.substring(0, time.length - 6),
temperature
),
fontWeight = FontWeight.W400,
fontSize = 16.sp,
color = MgWhite,
)
Spacer(modifier = Modifier.height(3.dp))
/**
* @view 설명
* @example 실 비
*/
Text(
text = description,
fontWeight = FontWeight.W400,
fontSize = 14.sp,
color = MgWhite,
)
}
}
}
@Preview
@Composable
fun PreviewTodayWeatherItem() {
TodayWeatherItem(
index = 0,
infoList = previewInfoList,
)
}
@Preview
@Composable
fun PreviewTodayDisplay() {
ForecastTodayDisplay(
infoList = previewInfoList
)
}
val previewInfoList = mutableListOf<ForecastListInfo>().also { list ->
list.add(ForecastListInfo(dt=1717210800000, temp=22, dtTxtDate="2024-06-01", dtTxtTime = "12:00:00", weatherId=500, weatherDescription = "실 비", weatherMain="Rain", weatherIcon="https://openweathermap.org/img/wn/10d.png"))
list.add(ForecastListInfo(dt=1717221600000, temp=24, dtTxtDate="2024-06-01", dtTxtTime = "15:00:00", weatherId=802, weatherDescription = "실 비", weatherMain="Clouds", weatherIcon="https://openweathermap.org/img/wn/03d.png)"))
list.add(ForecastListInfo(dt=1717232400000, temp=24, dtTxtDate="2024-06-01", dtTxtTime = "18:00:00", weatherId=800, weatherDescription = "실 비", weatherMain="Clear", weatherIcon="https://openweathermap.org/img/wn/01d.png)"))
list.add(ForecastListInfo(dt=1717243200000, temp=21, dtTxtDate="2024-06-01", dtTxtTime = "21:00:00", weatherId=800, weatherDescription = "실 비", weatherMain="Clear", weatherIcon="https://openweathermap.org/img/wn/01n.png)"))
}
| 0
|
Kotlin
|
0
| 1
|
dc651d3d7dd9903295229379b64acbe59e720915
| 5,486
|
mongoose
|
Apache License 2.0
|
src/test/kotlin/nl/fifthpostulate/specifikation/algebra/AllTest.kt
|
fifth-postulate
| 283,838,936
| false
| null |
package nl.fifthpostulate.specifikation.algebra
import nl.fifthpostulate.specifikation.*
import nl.fifthpostulate.specifikation.assertions.ReportAssert.Companion.assertThat
import org.junit.jupiter.api.*
class AllTest {
lateinit var subject: Person
@BeforeEach
fun `create subject under test`() {
subject = Person("test")
}
@Test
fun `when all sub specifications succeed then all succeeds`() {
val specification: Specification<Person, String> = All(Succeed(), Succeed(), Succeed())
val report = specification.isMetBy(subject)
assertThat(report).isSuccess()
}
@Test
fun `when one sub specifications fails then all fail`() {
val specification: Specification<Person, String> = All(Succeed(), Succeed(), Succeed(), Fail("first"))
val report = specification.isMetBy(subject)
assertThat(report).isFailure()
}
@Test
fun `when failing violations are collected`() {
val specification: Specification<Person, String> = All(Succeed(), Fail("first"), Succeed(), Succeed(), Fail("second"))
val report = specification.isMetBy(subject)
assertThat(report).isFailureWithViolations("first", "second")
}
}
| 0
|
Kotlin
|
0
| 0
|
25fc5c99cd1d426c67dfd05d5648a9b2a59779e2
| 1,231
|
specifikation
|
MIT License
|
MoviesApp/app/src/main/java/com/larrykapija/moviesapp/ui/navigation/Destinations.kt
|
LarryKapija
| 776,903,563
| false
|
{"Kotlin": 55363}
|
package com.larrykapija.moviesapp.ui.navigation
object Destinations {
const val SplashScreen = "splashScreen"
const val MainScreen = "mainScreen"
const val SearchScreen = "searchScreen"
const val WatchListScreen = "watchListScreen"
const val DetailsScreen = "detailsScreen"
}
| 0
|
Kotlin
|
0
| 0
|
5a61c292014583f984ceef2c0cae41c4d23f8b05
| 297
|
Android-Movies-App
|
MIT License
|
app/src/main/java/com/tensesapp/navigation/NavGraph.kt
|
RanggaNf
| 802,828,457
| false
|
{"Kotlin": 238849}
|
package com.tensesapp.navigation
import androidx.navigation.NavHostController
object Destination {
// Tambahkan konstanta untuk home screen
const val Home = "Home"
const val Splash = "Splash"
const val Login = "Login"
const val DetailScreen = "DetailScreen"
const val Materi = "Materi"
const val QuizList = "QuizList"
const val SimplePresentQuiz = "SimplePresentQuiz"
const val SimplePastQuiz = "SimplePastQuiz"
const val PresentContinuousQuiz = "PresentContinuousQuiz"
const val PresentPerfectQuiz = "PresentPerfectQuiz"
const val SimpleFutureQuiz = "SimpleFutureQuiz"
const val AboutScreen = "AboutScreen"
const val ProductScreen = "Product Screen"
const val OriginScreen = "OriginScreen"
const val AnswerSimplePresent = "AnswerSimplePresent"
const val AnswerSimplePast = "AnswerSimplePast"
const val AnswerSimpleFuture = "AnswerSimpleFuture"
const val AnswerPresentPerfect = "AnswerPresentPerfect"
const val AnswerPersentContinuos = "AnswerPersentContinuos"
const val favoriteScreen ="favoriteScreen"
const val onDevelop = "onDevelop"
}
class Actions(navController: NavHostController) {
// Fungsi untuk membuka layar detail materi
val openDetailMateri: (Int) -> Unit = { materiId ->
navController.navigate("${Destination.DetailScreen}/$materiId")
}
// Fungsi untuk kembali ke layar sebelumnya
val upPress: () -> Unit = {
navController.popBackStack()
}
}
| 0
|
Kotlin
|
1
| 1
|
84cc6594c945178544fa14c2be95a7dee8a1425d
| 1,493
|
TensesApp
|
MIT License
|
domain/src/main/java/com/pomodorotime/domain/login/ILoginRepository.kt
|
RoberMiranda92
| 283,567,928
| false
| null |
package com.pomodorotime.domain.login
import com.pomodorotime.domain.models.User
interface ILoginRepository {
suspend fun signIn(email: String, password: String): User
suspend fun signUp(email: String, password: String): User
}
| 1
|
Kotlin
|
0
| 0
|
07e77f018db930b50b1695d0d79debdc373f39e7
| 240
|
PomodoroTime
|
Apache License 2.0
|
app/src/main/java/codingblocks/com/networkokhttp/Tvshows/TvDetails.kt
|
Karandeep98
| 195,439,969
| false
| null |
package codingblocks.com.networkokhttp.Tvshows
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.room.Room
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import codingblocks.com.networkokhttp.*
import codingblocks.com.networkokhttp.ProductionCompanies
import com.google.android.material.snackbar.Snackbar
import com.squareup.picasso.Picasso
import kotlinx.android.synthetic.main.activity_tv_details.*
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
class TvDetails : AppCompatActivity() {
val db2 by lazy {
Room.databaseBuilder(this,AppDatabase2::class.java,"todo2.db")
.allowMainThreadQueries()
.fallbackToDestructiveMigration()
.build()
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_tv_details)
setSupportActionBar(toolbar)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
val pos = intent.getIntExtra("ID", 55)
Log.i("pos",pos.toString())
val check = db2.tododao().checkrepeat(pos)
// favbt.isChecked = check.isNotEmpty()
if(check.isNotEmpty()) {
favfill.visibility = View.VISIBLE
favborder.visibility=View.GONE
}
else if (check.isEmpty()){
favborder.visibility = View.VISIBLE
favfill.visibility=View.GONE
}
val retrofitClient = Retrofit.Builder()
.baseUrl("https://api.themoviedb.org/3/tv/")
.addConverterFactory(GsonConverterFactory.create())
.build()
val service = retrofitClient.create(TVLinks::class.java)
service.overview(pos).enqueue(object : Callback<Basicdetails> {
override fun onFailure(call: Call<Basicdetails>, t: Throwable) {
// tv.text="Loading failed!"
// tv.text=tv.text.toString()+t.cause.toString()
Snackbar.make(root,"No Internet Connection", Snackbar.LENGTH_INDEFINITE).show()
prg.visibility= View.GONE
}
override fun onResponse(
call: Call<Basicdetails>,
response: Response<Basicdetails>
) {
runOnUiThread {
favborder.setOnClickListener {
db2.tododao().insert(Todo(id = pos))
Toast.makeText(this@TvDetails, "TV Show is added in favourites!", Toast.LENGTH_LONG).show()
favfill.visibility=View.VISIBLE
favborder.visibility=View.GONE
}
favfill.setOnClickListener {
db2.tododao().deletetask(Todo(id = pos))
Toast.makeText(this@TvDetails, "TV Show is removed from favourites!", Toast.LENGTH_LONG).show()
favborder.visibility=View.VISIBLE
favfill.visibility=View.GONE
}
// if(response.body()?.production_companies!!.isEmpty()){
// tvproduction.visibility=View.GONE
// }
// rviewproduction.layoutManager = LinearLayoutManager(this@TvDetails, LinearLayoutManager.HORIZONTAL,false)
// rviewproduction.adapter = ProductionAdapter(this@TvDetails, response.body()!!.production_companies.filter {
// it.logo_path!=null
// } as ArrayList<ProductionCompanies>)
// prg.setProgress(false)
toolbar.title=response.body()!!.name
tvtitle.text=response.body()!!.name
Picasso.get().load("https://image.tmdb.org/t/p/original"+response.body()?.backdrop_path).fit().centerCrop().into(img)
// if(response.body()?.backdrop_path==null){
// Picasso.get().load("https://image.tmdb.org/t/p/w500"+response.body()?.poster_path).fit().centerCrop().into(img)
//
// }
if(response.body()?.vote_average?.toInt()!=0) {
tv.text = "\n\n⭐ " + response.body()!!.vote_average + "/10"
}
tv.text=tv.text.toString()+"\n\nPlot: "+ response.body()!!.overview+"\n" +
"\nFirst Air Date: "+response.body()!!.first_air_date
// if(response.body()?.runtime!=0){
//// Log.i("movieruntime",response.body()?.runtime)
// if(response.body()!!.runtime/60!=0){
// tv.text=tv.text.toString()+"\n\nRuntime: "+response.body()!!.runtime/60 +" hrs " +response.body()!!.runtime%60+" mins"
// }
// else
// tv.text=tv.text.toString()+"\n\nRuntime: "+response.body()!!.runtime%60+" mins"
// }
}
tv.text=tv.text.toString() +"\n\nGenres: "
prg.visibility = View.GONE
scrollview.visibility=View.VISIBLE
// prg.setProgress(100,false)
for(i in 0 until response.body()!!.genres.size ){
tv.text= tv.text.toString() +response.body()!!.genres[i].name+", "
}
tv.text=tv.text.substring(0,tv.text.length-2) //to remove the extra comma
//list of production companies
share.setOnClickListener {
// val j=Intent(Intent.ACTION_VIEW, Uri.parse("http://www.imdb.com/title/${response.body()?.imdb_id}"))
// startActivity(j)
val intent = Intent(Intent.ACTION_SEND)
intent.type = "text/plain"
intent.putExtra(Intent.EXTRA_TEXT, response.body()?.homepage)
startActivity(Intent.createChooser(intent, "Share with"))
}
// favbt.setOnClickListener {
// adapter.updateTasks(favlist)
// val l=Intent(this@Details,Room::class.java)
// l.putExtra("favlist",response.body()!!.id)
// startActivity(l)
// if(favbt.isChecked){
// favborder.setOnClickListener {
// db.tododao().insert(Todo(id = pos))
// Toast.makeText(this@Details, "Movie is added in favourites!", Toast.LENGTH_LONG).show()
// favfill.visibility=View.VISIBLE
// favborder.visibility=View.GONE
// }
// favfill.setOnClickListener {
// db.tododao().deletetask(Todo(id = pos))
// Toast.makeText(this@Details, "Movie is removed from favourites!", Toast.LENGTH_LONG).show()
// favborder.visibility=View.VISIBLE
// favfill.visibility=View.GONE
// }
// tv.text=tv.text.toString()+favbt.isChecked.toString()
// }
}
}
)
service.videos(pos).enqueue(object : Callback<Trailerarray> {
override fun onFailure(call: Call<Trailerarray>, t: Throwable) {
tv.text="Loading failed!"
tv.text=tv.text.toString()+t.cause.toString()
}
override fun onResponse(
call: Call<Trailerarray>,
response: Response<Trailerarray>
) {
runOnUiThread {
// tv.text=response.body().toString()
rview3.layoutManager = LinearLayoutManager(this@TvDetails, LinearLayoutManager.HORIZONTAL,false)
rview3.adapter = MovieAdapter2(this@TvDetails, response.body()!!.results)
// Picasso.get().load(response.body()?.Poster.toString()).into(image)
if(response.body()!!.results.isEmpty())
tvtrailer.text=""
}
}
})
service.cast(pos).enqueue(object : Callback<Cast> {
override fun onFailure(call: Call<Cast>, t: Throwable) {
tv.text="Loading failed!"
tv.text=tv.text.toString()+t.cause.toString()
}
override fun onResponse(
call: Call<Cast>,
response: Response<Cast>
) {
runOnUiThread {
// tv.text=response.body().toString()
rview.layoutManager = LinearLayoutManager(this@TvDetails, LinearLayoutManager.HORIZONTAL,false)
rview.adapter = MovieAdapter(this@TvDetails, response.body()!!.cast)
// Picasso.get().load(response.body()?.Poster.toString()).into(image)
}
}
})
service.similartvshows(pos).enqueue(object : Callback<SimilarArray> {
override fun onFailure(call: Call<SimilarArray>, t: Throwable) {
tv.text="Loading failed!"
tv.text=tv.text.toString()+t.cause.toString()
}
override fun onResponse(
call: Call<SimilarArray>,
response: Response<SimilarArray>
) {
runOnUiThread {
// toolbarimage
// tv.text=response.body().toString()
rview2.layoutManager = LinearLayoutManager(this@TvDetails,LinearLayoutManager.HORIZONTAL,false)
rview2.adapter = SimilarTvshowsAdapter(this@TvDetails, response.body()!!.results)
// Picasso.get().load(response.body()?.Poster.toString()).into(image)
if(response.body()!!.results.isEmpty())
tvsimilar.text=""
}
}
})
swipeRefresh.setOnRefreshListener(SwipeRefreshLayout.OnRefreshListener {
// refreshData() // your code
val i =Intent(this,TvDetails::class.java)
i.putExtra("ID",pos)
finish()
startActivity(i)
swipeRefresh.isRefreshing = false
})
reviews.setOnClickListener {
val k=Intent(this,Reviews::class.java)
k.putExtra("ID",pos)
k.putExtra("type","tv")
startActivity(k)
}
}
}
| 0
|
Kotlin
|
0
| 1
|
63050fad03bc84a8eaf012a7061da72e1cd90df8
| 10,789
|
Movie-Time
|
FSF All Permissive License
|
kotlin/perfect-numbers/src/main/kotlin/NaturalNumber.kt
|
aymannadeem
| 128,678,010
| true
|
{"JavaScript": 1037867, "C#": 482229, "F#": 359821, "Java": 351020, "Haskell": 258405, "Scala": 230869, "Kotlin": 111391, "Elm": 92127, "Shell": 7468, "Batchfile": 5992, "GLSL": 5077, "Smalltalk": 2949, "RenderScript": 1248}
|
enum class Classification {
DEFICIENT, PERFECT, ABUNDANT
}
fun sumOfFactors(naturalNumber: Int): Int {
var sumOfFactors = 0
for (i in 1..naturalNumber - 1)
if (naturalNumber % i === 0)
sumOfFactors += i
return sumOfFactors
}
fun classify(naturalNumber: Int): Classification {
require(naturalNumber >= 0)
var sumOfFactorsForInput = sumOfFactors(naturalNumber)
if (sumOfFactorsForInput < naturalNumber)
return Classification.DEFICIENT
else if (sumOfFactorsForInput == naturalNumber)
return Classification.PERFECT
else
return Classification.ABUNDANT
}
| 0
|
JavaScript
|
0
| 0
|
5f9371845afca71f5fe0a50ddaf07a6796a174ce
| 635
|
exercism
|
Apache License 2.0
|
app/src/test/java/net/msalt/doublecheck/BunchDetailViewModelUnitTest.kt
|
msaltnet
| 519,156,245
| false
|
{"Kotlin": 49240}
|
package net.msalt.doublecheck
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.delay
import kotlinx.coroutines.test.StandardTestDispatcher
import kotlinx.coroutines.test.runTest
import net.msalt.doublecheck.bunchdetail.BunchDetailViewModel
import net.msalt.doublecheck.data.Bunch
import net.msalt.doublecheck.data.CheckItem
import org.junit.Assert.assertEquals
import org.junit.Rule
import org.junit.Test
import timber.log.Timber
@ExperimentalCoroutinesApi
class BunchDetailViewModelUnitTest {
@get:Rule
val timberRule = TimberRule()
@get:Rule
val mainCoroutineRule = MainCoroutineRule()
@get:Rule
val rule = InstantTaskExecutorRule()
@Test
fun start_should_call_update_bunch_when_called_with_bunch() = runTest {
val repo = FakeCheckListRepository()
val viewModel = BunchDetailViewModel(repo)
val bunch = Bunch()
viewModel.start(bunch)
val retrieved = repo.getBunch(bunch.id)
assertEquals(bunch, retrieved)
}
@Test
fun start_should_update_title_and_items_when_called_with_bunchId() = runTest {
val repo = FakeCheckListRepository()
val viewModel = BunchDetailViewModel(repo)
val bunch = Bunch(title = "mango_title")
val checkItem = CheckItem(bunchId = bunch.id, contents = "mango")
repo.updateBunch(bunch)
repo.updateCheckItem(checkItem)
viewModel.start(bunch.id)
assertEquals(viewModel.title.value, "mango_title")
assertEquals(viewModel.items.value?.size, 1)
assertEquals(viewModel.items.value?.get(0)?.id, checkItem.id)
assertEquals(viewModel.items.value?.get(0)?.contents, checkItem.contents)
}
@Test
fun toggleCheck_update_toggle_state_when_called_with_item() = runTest {
val repo = FakeCheckListRepository()
val viewModel = BunchDetailViewModel(repo)
val bunch = Bunch(title = "mango_title")
val checkItem = CheckItem(bunchId = bunch.id, contents = "mango")
repo.updateBunch(bunch)
repo.updateCheckItem(checkItem)
viewModel.start(bunch.id)
assertEquals(viewModel.items.value?.get(0)?.checked, false)
viewModel.toggleCheck(viewModel.items.value?.get(0)!!)
assertEquals(viewModel.items.value?.get(0)?.checked, true)
var targetCheckItem = repo.getCheckItems(bunchId = bunch.id)[0]
assertEquals(targetCheckItem.checked, true)
assertEquals(targetCheckItem.id, checkItem.id)
assertEquals(viewModel.items.value?.get(0)?.checked, true)
viewModel.toggleCheck(viewModel.items.value?.get(0)!!)
assertEquals(viewModel.items.value?.get(0)?.checked, false)
targetCheckItem = repo.getCheckItems(bunchId = bunch.id)[0]
assertEquals(targetCheckItem.checked, false)
assertEquals(targetCheckItem.id, checkItem.id)
}
@Test
fun resetCheckState_update_check_state_when_called() = runTest {
val repo = FakeCheckListRepository()
val viewModel = BunchDetailViewModel(repo)
val bunch = Bunch(title = "mango_title")
val checkItem = CheckItem(bunchId = bunch.id, checked = true, order = 1)
val checkItem2 = CheckItem(bunchId = bunch.id, checked = false, order = 0)
val checkItem3 = CheckItem(bunchId = bunch.id, checked = true, order = 2)
repo.updateBunch(bunch)
repo.updateCheckItem(checkItem)
repo.updateCheckItem(checkItem2)
repo.updateCheckItem(checkItem3)
viewModel.start(bunch.id)
assertEquals(viewModel.items.value?.get(0)?.checked, false)
assertEquals(viewModel.items.value?.get(1)?.checked, true)
assertEquals(viewModel.items.value?.get(2)?.checked, true)
viewModel.resetCheckState()
assertEquals(viewModel.items.value?.get(0)?.checked, false)
assertEquals(viewModel.items.value?.get(1)?.checked, false)
assertEquals(viewModel.items.value?.get(2)?.checked, false)
delay(0)
val targetCheckItems = repo.getCheckItems(bunchId = bunch.id)
Timber.d("targetCheckItems $targetCheckItems")
assertEquals(targetCheckItems[0].checked, false)
assertEquals(targetCheckItems[1].checked, false)
assertEquals(targetCheckItems[2].checked, false)
}
}
| 5
|
Kotlin
|
0
| 1
|
e2e8c0f91e2466be1c59584032f88e7fe4cda630
| 4,386
|
double-check
|
MIT License
|
nuimo/src/main/kotlin/com/senic/nuimo/NuimoGestureEvent.kt
|
getsenic
| 46,062,491
| false
| null |
/*
* Copyright (c) 2015 Senic. All rights reserved.
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
package com.senic.nuimo
class NuimoGestureEvent(gesture: NuimoGesture, value: Int? = null) {
val gesture: NuimoGesture = gesture
val value: Int? = value
}
enum class NuimoGesture {
BUTTON_PRESS,
BUTTON_RELEASE,
ROTATE,
TOUCH_LEFT,
TOUCH_RIGHT,
TOUCH_TOP,
TOUCH_BOTTOM,
LONG_TOUCH_LEFT,
LONG_TOUCH_RIGHT,
LONG_TOUCH_TOP,
LONG_TOUCH_BOTTOM,
SWIPE_LEFT,
SWIPE_RIGHT,
SWIPE_UP,
SWIPE_DOWN,
FLY_LEFT,
FLY_RIGHT,
FLY_BACKWARDS,
FLY_TOWARDS,
FLY_UP_DOWN
}
| 4
|
Kotlin
|
4
| 12
|
34f4ff7184bdfad46ea87b1db9da7b33b7742d74
| 723
|
nuimo-android
|
MIT License
|
kmm_otus_news/shared/src/commonMain/kotlin/com/azharkova/kmm_news/network/NetworkClient.kt
|
anioutkazharkova
| 525,440,114
| false
| null |
package com.azharkova.kmm_news.network
import io.ktor.client.*
import io.ktor.client.call.*
import io.ktor.client.request.*
expect fun createHttpClient() : HttpClient
class NetworkClient {
var httpClient = createHttpClient()
suspend inline fun<reified T> getData(path: String): Result<T> {
try {
val result = httpClient.get(path).body<T>()
return Result.success(result)
}catch (e: Exception) {
return Result.failure(e)
}
}
}
| 0
|
Kotlin
|
0
| 0
|
86bda10514bfa80c6f77cd1f016bae9df3a300c5
| 502
|
kmm_otus_news_16_08
|
Apache License 2.0
|
locationsyncservice/src/main/java/com/shuttl/location_pings/data/model/request/SendLocationRequestBody.kt
|
betaCode95
| 228,328,623
| false
|
{"Kotlin": 40171}
|
package com.shuttl.location_pings.data.model.request
import com.shuttl.location_pings.data.model.entity.GPSLocation
data class SendLocationRequestBody(val data: List<GPSLocation>? = listOf(), val userId: String? = "", val bookingId: String? = "") {
companion object {
fun create(gps: List<GPSLocation>?) = SendLocationRequestBody(data = gps)
}
}
| 1
|
Kotlin
|
2
| 4
|
16c639d4477c869c4abe4a5ab00b346199f8f545
| 364
|
Wherro
|
Apache License 2.0
|
app/src/main/java/com/zhuzichu/orange/ui/picture/viewmodel/PictureViewModel.kt
|
qq524787275
| 191,562,693
| false
| null |
package com.zhuzichu.orange.ui.picture.viewmodel
import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.zhuzichu.mvvm.base.BaseViewModel
import com.zhuzichu.mvvm.databinding.command.BindingCommand
import com.zhuzichu.mvvm.utils.itemBindingOf
import com.zhuzichu.mvvm.utils.itemDiffOf
import com.zhuzichu.orange.BR
import com.zhuzichu.orange.R
import com.zhuzichu.orange.ui.camerax.viewmodel.ItemAlbumViewModel
import me.tatarka.bindingcollectionadapter2.collections.AsyncDiffObservableList
/**
* Created by Android Studio.
* Blog: zhuzichu.com
* User: zhuzichu
* Date: 2019-08-12
* Time: 17:01
*/
class PictureViewModel(
application: Application
) : BaseViewModel(application) {
val list = AsyncDiffObservableList(itemDiffOf<ItemPictureViewModel> { oldItem, newItem ->
oldItem.path == newItem.path
})
val itemBind = itemBindingOf<Any>(BR.item, R.layout.item_picture)
val numInfo = MutableLiveData<String>()
val onPageSelectedCommand = BindingCommand<Int>(consumer = {
numInfo.value = it.inc().toString().plus("/").plus(list.size)
})
val onClickBack = BindingCommand<Any>({
back()
})
}
| 0
|
Kotlin
|
2
| 2
|
79b0cd43c4f33b492cbb7e219be4547a6900d866
| 1,186
|
orange
|
Apache License 2.0
|
app/src/main/java/com/example/todolist/domain/base/BaseResult.kt
|
yoempanha
| 730,547,101
| false
|
{"Kotlin": 38263}
|
package com.example.todolist.domain.base
sealed class BaseResult<out T> {
data class Success<T>(val data: T): BaseResult<T>()
data class Failure(val error: Throwable): BaseResult<Nothing>()
}
| 0
|
Kotlin
|
0
| 0
|
fb0dcd9f83ce886641f9966eb3ea112baa4bd246
| 201
|
todo-list
|
Apache License 2.0
|
src/main/kotlin/org.domaintbn.sommd.core/synth/Oversampler.kt
|
user00e00
| 163,682,297
| false
| null |
package org.domaintbn.sommd.core.synth
import kotlin.math.pow
class Oversampler(private val osc: OscilatorInterface, overSamplingFactor: Int) {
private var lastphase: Double = 0.toDouble()
private val oversampling: Int
init {
this.lastphase = 0.0
this.oversampling = (2.0).pow(overSamplingFactor.toDouble()).toInt()
}
fun getval(phase: Double): Double {
var output = 0.0
for (i in 1..oversampling) {
val weight = (i + 0.0) / (0.0 + oversampling)
output += this.osc.getval(phase * weight + lastphase * (1 - weight))
}
output = output / oversampling //filter
this.lastphase = phase
return output
}
}
| 0
|
Kotlin
|
2
| 0
|
60c6784e53eb38894272f74616c9484019cc3ab4
| 722
|
sommd
|
MIT License
|
app/src/main/java/com/thicapps/artbook/Constants.kt
|
cemaltuysuz
| 398,304,728
| false
| null |
package com.thicapps.artbook
object Constants {
object Api{
const val API_KEY = "<KEY>"
const val BASE_URL = "https://pixabay.com/"
}
}
| 0
|
Kotlin
|
0
| 0
|
9d854b731cfe9973f3082a1e803f5f55e750283e
| 162
|
ArtBook-Lesson-Example
|
MIT License
|
codec/src/commonTest/kotlin/com/inkapplications/ack/codec/extension/SignalInfoCodecTest.kt
|
InkApplications
| 277,934,100
| false
| null |
package com.inkapplications.ack.codec.extension
import com.inkapplications.ack.structures.SignalInfo
import com.inkapplications.ack.structures.unit.Strength
import inkapplications.spondee.measure.Bels
import inkapplications.spondee.measure.Feet
import inkapplications.spondee.spatial.Cardinal
import inkapplications.spondee.spatial.toAngle
import inkapplications.spondee.structure.Deci
import inkapplications.spondee.structure.of
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFails
import kotlin.test.assertNull
class SignalInfoCodecTest {
@Test
fun decode() {
val given = "DFS2364"
val result = SignalInfoCodec.decode(given)
assertEquals(Strength(2), result.strength)
assertEquals(Cardinal.South.toAngle(), result.direction)
assertEquals(Bels.of(Deci, 6), result.gain)
assertEquals(Feet.of(80), result.height)
}
@Test
fun decodeOmniDirection() {
val given = "DFS2360"
val result = SignalInfoCodec.decode(given)
assertEquals(Strength(2), result.strength)
assertNull(result.direction)
assertEquals(Bels.of(Deci, 6), result.gain)
assertEquals(Feet.of(80), result.height)
}
@Test
fun illegalDecode() {
val given = "DFSABCD"
assertFails("Should not parse illegal characters") { SignalInfoCodec.decode(given) }
}
@Test
fun illegalPrefix() {
val given = "PHG0050"
assertFails("Should not parse with wrong control.") { SignalInfoCodec.decode(given) }
}
@Test
fun decodeLengthIllegal() {
val given = "DFS2360asdf"
assertFails("Should not parse excess data.") { SignalInfoCodec.decode(given) }
}
@Test
fun encode() {
val given = SignalInfo(
strength = Strength(2),
direction = Cardinal.South.toAngle(),
height = Feet.of(80),
gain = Bels.of(Deci, 6),
)
val result = SignalInfoCodec.encode(given)
assertEquals("DFS2364", result)
}
@Test
fun encodeNull() {
val given = SignalInfo(
strength = null,
direction = null,
height = null,
gain = null,
)
val result = SignalInfoCodec.encode(given)
assertEquals("DFS0000", result)
}
}
| 4
|
Kotlin
|
1
| 0
|
665be5fd074f047ff018ab428b69e680cc101a9b
| 2,355
|
Karps
|
MIT License
|
app/src/main/java/com/teknolojipiri/contactsgenerator/generate/GenerateContactsUseCase.kt
|
mehmet6parmak
| 543,553,308
| false
| null |
package com.teknolojipiri.contactsgenerator.generate
import android.content.Context
import contacts.async.commitWithContext
import contacts.core.Contacts
import contacts.core.entities.NewRawContact
import contacts.core.entities.PhoneEntity
import contacts.core.log.AndroidLogger
import contacts.core.util.addPhone
import contacts.core.util.setName
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class GenerateContactsUseCase @Inject constructor(private val context: Context) {
suspend fun generateContacts(prefix: String, rangeStart: String, rangeEnd: String) {
val result = Contacts(context, logger = AndroidLogger()).insert()
.allowBlanks(true)
.rawContacts(buildContacts(prefix, rangeStart, rangeEnd))
.forAccount(null)
.commitWithContext()
println(result)
}
private fun buildContacts(prefix: String, rangeStart: String, rangeEnd: String): List<NewRawContact> {
try {
val start = rangeStart.toDouble().toLong()
val end = rangeEnd.toDouble().toLong()
val result = mutableListOf<NewRawContact>()
for (suffix in start..end) {
val number = "$prefix${suffix}"
val name = "${getRandomString(5)} ${getRandomString(5)}"
result.add(buildNewContact(name, number))
}
return result
} catch (numberFormatException: NumberFormatException) {
throw ContactGenerationError.InvalidInputs
}
}
private fun getRandomString(length: Int): String {
val allowedChars = ('A'..'Z') + ('a'..'z') + ('0'..'9')
return (1..length)
.map { allowedChars.random() }
.joinToString("")
}
private fun buildNewContact(name: String, phone: String): NewRawContact {
return NewRawContact().apply {
setName { givenName = name }
addPhone {
type = PhoneEntity.Type.MOBILE
number = phone
}
}
}
sealed class ContactGenerationError : RuntimeException() {
object InvalidInputs : ContactGenerationError()
object InsertionFailed : ContactGenerationError()
}
}
| 0
|
Kotlin
|
0
| 0
|
c2518701aa90a6b9350605d39e9dad4ea7a659d4
| 2,241
|
contacts-generator-android
|
Apache License 2.0
|
app/src/main/java/app/books/tanga/feature/listen/PlaySummaryAudioScreen.kt
|
rygelouv
| 605,776,570
| false
| null |
package app.books.tanga.feature.listen
import androidx.compose.foundation.background
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.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Scaffold
import androidx.compose.material.Surface
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Slider
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import app.books.tanga.core_ui.components.SummaryImage
import app.books.tanga.core_ui.icons.TangaIcons
import app.books.tanga.core_ui.theme.LocalSpacing
import app.books.tanga.data.FakeData
import app.books.tanga.feature.summary.list.SummaryUi
@Composable
fun PlaySummaryAudioScreen(onBackClicked: () -> Unit) {
val summary = remember {
FakeData.allSummaries().shuffled().last()
}
Scaffold(
modifier = Modifier.fillMaxSize(),
topBar = {
PlaySummaryAudioTopBar(onBackClicked)
},
) {
Surface(
color = MaterialTheme.colorScheme.background,
modifier = Modifier
.fillMaxSize()
.padding(it)
) {
PlaySummaryAudioContent(summary)
}
}
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun PlaySummaryAudioTopBar(onBackClicked: () -> Unit) {
TopAppBar(
title = {},
navigationIcon = {
IconButton(onClick = { onBackClicked() }) {
Icon(
modifier = Modifier.size(26.dp),
painter = painterResource(id = TangaIcons.LeftArrow),
tint = MaterialTheme.colorScheme.onTertiaryContainer,
contentDescription = "back navigation"
)
}
}
)
}
@Composable
fun PlaySummaryAudioContent(summary: SummaryUi) {
Box(modifier = Modifier.fillMaxSize()) {
Surface(
color = Color.White,
modifier = Modifier
.fillMaxSize()
.offset(y = 148.dp),
shape = RoundedCornerShape(topStart = 40.dp, topEnd = 40.dp),
) {
Column(
modifier = Modifier
.fillMaxSize()
.padding(start = 10.dp, end = 10.dp, top = 30.dp, bottom = 10.dp)
.verticalScroll(rememberScrollState()),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Top,
) {
Spacer(modifier = Modifier.height(LocalSpacing.current.extraExtraLarge))
Spacer(modifier = Modifier.height(LocalSpacing.current.large))
Box(
modifier = Modifier
.width(34.dp)
.height(4.dp)
.background(MaterialTheme.colorScheme.onTertiaryContainer)
)
Spacer(modifier = Modifier.height(LocalSpacing.current.large))
Text(
text = "Ego is the Enemy",
maxLines = 1,
overflow = TextOverflow.Ellipsis,
style = MaterialTheme.typography.titleLarge,
)
Spacer(modifier = Modifier.height(LocalSpacing.current.small))
Text(
color = MaterialTheme.colorScheme.outline,
text = "<NAME>",
maxLines = 1,
overflow = TextOverflow.Ellipsis,
style = MaterialTheme.typography.bodyMedium,
)
Spacer(modifier = Modifier.height(LocalSpacing.current.extraExtraLarge))
PlaybackControls()
Spacer(modifier = Modifier.height(LocalSpacing.current.extraExtraLarge))
AudioBar()
}
}
SummaryImage(
modifier = Modifier
.width(154.dp)
.align(alignment = Alignment.TopCenter)
.offset(y = 4.dp),
painter = painterResource(id = summary.cover),
onSummaryClicked = { }
)
}
}
@Composable
private fun PlaybackControls() {
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceEvenly,
verticalAlignment = Alignment.CenterVertically
) {
IconButton(onClick = { /*TODO*/ }) {
Icon(
modifier = Modifier.size(18.dp),
painter = painterResource(id = TangaIcons.Backward),
tint = MaterialTheme.colorScheme.primary,
contentDescription = "previous"
)
}
Text(
color = MaterialTheme.colorScheme.outline,
text = "-15s",
maxLines = 1,
overflow = TextOverflow.Ellipsis,
style = MaterialTheme.typography.bodySmall,
)
IconButton(onClick = { /*TODO*/ }, modifier = Modifier.size(64.dp)) {
Surface(
modifier = Modifier.fillMaxSize(),
shape = CircleShape,
color = MaterialTheme.colorScheme.primary
) {
Icon(
modifier = Modifier
.size(24.dp)
.padding(14.dp),
painter = painterResource(id = TangaIcons.Pause),
tint = MaterialTheme.colorScheme.onPrimary,
contentDescription = "play"
)
}
}
Text(
color = MaterialTheme.colorScheme.outline,
text = "+15s",
maxLines = 1,
overflow = TextOverflow.Ellipsis,
style = MaterialTheme.typography.bodySmall,
)
IconButton(onClick = { /*TODO*/ }) {
Icon(
modifier = Modifier.size(18.dp),
painter = painterResource(id = TangaIcons.Forward),
tint = MaterialTheme.colorScheme.primary,
contentDescription = "next"
)
}
}
}
@Composable
private fun AudioBar() {
var sliderPosition by remember { mutableFloatStateOf(0.5f) }
Column(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 20.dp)
) {
Slider(
modifier = Modifier.fillMaxWidth(),
value = sliderPosition, onValueChange = { sliderPosition = it }
)
Row(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 10.dp)
) {
Text(
color = MaterialTheme.colorScheme.outline,
text = "00:00",
maxLines = 1,
overflow = TextOverflow.Ellipsis,
style = MaterialTheme.typography.bodySmall,
)
Spacer(modifier = Modifier.weight(1f))
Text(
color = MaterialTheme.colorScheme.outline,
text = "10:35",
maxLines = 1,
overflow = TextOverflow.Ellipsis,
style = MaterialTheme.typography.bodySmall,
)
}
}
}
| 0
|
Kotlin
|
0
| 4
|
d06dfe7c57225bd6d07817d5011d7d123da00826
| 8,521
|
Tanga
|
Apache License 2.0
|
server/src/test/kotlin/io/liquidsoftware/base/web/integration/user/UserRegistrationTest.kt
|
edreyer
| 445,325,795
| false
|
{"Kotlin": 204259, "Procfile": 119}
|
package io.liquidsoftware.base.web.integration.user
import assertk.assertThat
import assertk.assertions.isEqualTo
import io.liquidsoftware.base.test.BaseWebTest
import io.liquidsoftware.base.user.adapter.`in`.web.RegisterUserInputDto
import io.liquidsoftware.base.user.adapter.`in`.web.RegisteredUserDto
import io.liquidsoftware.base.user.application.port.`in`.RoleDto
import io.liquidsoftware.base.user.application.port.`in`.UserDto
import io.liquidsoftware.common.validation.MsisdnParser
import io.restassured.path.json.JsonPath
import io.restassured.response.Response
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.Order
import org.junit.jupiter.api.Test
class UserRegistrationTest : BaseWebTest() {
private lateinit var inputDto: RegisterUserInputDto
@BeforeAll
fun initUser() {
inputDto = RegisterUserInputDto(
msisdn = "5125550002",
email = "<EMAIL>",
password = "<PASSWORD>",
role = RoleDto.ROLE_USER
)
}
@Test
@Order(1)
fun `register new user`() {
val regReq = inputDto
val actual = registerUser(regReq)
val expected = RegisteredUserDto(UserDto(
id = actual.user.id,
email = inputDto.email,
msisdn = MsisdnParser.toInternational(inputDto.msisdn),
active = true,
roles = listOf(RoleDto.ROLE_USER)
))
assertThat(actual).isEqualTo(expected)
}
@Test
@Order(2)
fun `register existing user`() {
val regReq = inputDto
val response: Response = post("/user/register", regReq)
val json = response.asString()
val jsonPath = JsonPath(json)
assertThat(jsonPath.getString("errors")).isEqualTo("User 5125550002 exists")
assertThat(response.statusCode()).isEqualTo(400)
}
@Test
fun `register blank user`() {
val regReq = inputDto.copy(msisdn = "", email = "")
val response: Response = post("/user/register", regReq)
assertThat(response.statusCode()).isEqualTo(403)
}
}
| 7
|
Kotlin
|
12
| 49
|
8e006542b23bb90823c66dfe59a70476370a912c
| 1,938
|
modulith
|
MIT License
|
app/src/main/java/com/kryptkode/carz/ui/summary/SummaryFragment.kt
|
KryptKode
| 342,202,429
| false
| null |
package com.kryptkode.carz.ui.summary
import android.os.Bundle
import android.view.View
import androidx.core.os.bundleOf
import androidx.fragment.app.Fragment
import com.kryptkode.carz.R
import com.kryptkode.carz.data.model.CarBuildDate
import com.kryptkode.carz.data.model.CarManufacturer
import com.kryptkode.carz.data.model.CarType
import com.kryptkode.carz.databinding.FragmentSummaryBinding
import com.kryptkode.carz.navigator.Navigator
import com.kryptkode.carz.utils.viewbinding.viewBinding
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
@AndroidEntryPoint
class SummaryFragment : Fragment(R.layout.fragment_summary) {
@Inject
lateinit var navigator: Navigator
private val binding by viewBinding(FragmentSummaryBinding::bind)
private val manufacturer by lazy { arguments?.getParcelable<CarManufacturer>(MANUFACTURER_KEY)!! }
private val carType by lazy { arguments?.getParcelable<CarType>(CAR_TYPE_KEY)!! }
private val buildDate by lazy { arguments?.getParcelable<CarBuildDate>(CAR_BUILD_DATE_KEY)!! }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setUpToolbar()
setupViews()
}
private fun setUpToolbar() {
binding.appBarLayout.toolbar.title = getString(R.string.title_summary)
binding.appBarLayout.toolbar.setNavigationIcon(R.drawable.ic_arrow_back)
binding.appBarLayout.toolbar.setNavigationOnClickListener {
navigator.navigateUp()
}
}
private fun setupViews() {
binding.manufacturer.text = manufacturer.name
binding.carType.text = carType.name
binding.carBuildDate.text = buildDate.year
}
companion object {
private const val MANUFACTURER_KEY = "manufacturer"
private const val CAR_TYPE_KEY = "car_type"
private const val CAR_BUILD_DATE_KEY = "build_date"
fun buildArguments(manufacturer: CarManufacturer, carType: CarType, buildDate: CarBuildDate): Bundle {
return bundleOf(
MANUFACTURER_KEY to manufacturer,
CAR_TYPE_KEY to carType,
CAR_BUILD_DATE_KEY to buildDate,
)
}
}
}
| 0
|
Kotlin
|
0
| 0
|
a121312a983dcbb44226d6a2b23f00e3af396a3f
| 2,250
|
Carz
|
MIT License
|
app/src/main/java/com/example/sescgmf/adapter/TrainingAdapter.kt
|
andrecomegno
| 677,199,399
| false
|
{"Kotlin": 26757}
|
package com.example.sescgmf.adapter
import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.example.sescgmf.databinding.TrainingItemBinding
import com.example.sescgmf.training.TrainingClasses
class TrainingAdapter(private val context: Context, private val trainingList: MutableList<TrainingClasses>) : RecyclerView.Adapter<TrainingAdapter.TrainingViewHolder>()
{
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TrainingViewHolder
{
val listItem :TrainingItemBinding = TrainingItemBinding.inflate(LayoutInflater.from(context), parent, false)
return TrainingViewHolder(listItem)
}
override fun getItemCount() = trainingList.size
override fun onBindViewHolder(holder: TrainingViewHolder, position: Int)
{
holder.imTraining.setBackgroundResource(trainingList[position].imgTraining!!)
holder.lbDescription.text = trainingList[position].description
holder.lbRepetitions.text = trainingList[position].repetitions
}
inner class TrainingViewHolder(binding: TrainingItemBinding): RecyclerView.ViewHolder(binding.root)
{
val imTraining = binding.imTraining
val lbDescription = binding.lbDescription
val lbRepetitions = binding.lbRepetitions
}
}
| 0
|
Kotlin
|
0
| 1
|
2e1979f68d906e5a1315ed3c7431ad4c4a9a352f
| 1,362
|
SescGMF
|
MIT License
|
router/src/main/java/com/speakerboxlite/router/result/RouterResultProviderImpl.kt
|
AlexExiv
| 688,805,446
| false
|
{"Kotlin": 441742}
|
package com.speakerboxlite.router.result
import com.speakerboxlite.router.ViewResult
import java.lang.ref.WeakReference
class RouterResultProviderImpl(private val from: String,
private val resultManager: ResultManager): RouterResultProvider
{
override val key: String get() = from
override val viewResult: ViewResult? get() = weakVR.get()
override var resultType: ViewResultType? = null
private var weakVR = WeakReference<ViewResult>(null)
override fun <R : Any> send(result: R)
{
resultManager.send(from, result)
}
override fun start(vke: ViewResult)
{
val rt = ViewResultType.fromViewResult(vke)
check(resultType == null || (resultType != null && resultType == rt)) { "" }
resultType = rt
weakVR = WeakReference(vke)
resultManager.register(from, this)
}
override fun pause()
{
resultManager.unregister(from, resultType!!)
}
}
| 11
|
Kotlin
|
2
| 3
|
2732f15dcd89d3afde46176a82cd6f927c04f468
| 973
|
Router-Android
|
MIT License
|
core/src/commonMain/kotlin/maryk/core/query/responses/AddResponse.kt
|
marykdb
| 290,454,412
| false
| null |
package maryk.core.query.responses
import maryk.core.models.IsRootDataModel
import maryk.core.models.SimpleQueryDataModel
import maryk.core.properties.IsPropertyDefinitions
import maryk.core.properties.ObjectPropertyDefinitions
import maryk.core.properties.definitions.list
import maryk.core.properties.enum.TypeEnum
import maryk.core.properties.types.TypedValue
import maryk.core.query.responses.statuses.IsAddResponseStatus
import maryk.core.values.SimpleObjectValues
/** Response with [statuses] to an Add request to [dataModel] */
data class AddResponse<DM : IsRootDataModel<*>> constructor(
override val dataModel: DM,
val statuses: List<IsAddResponseStatus<DM>>
) : IsDataModelResponse<DM> {
@Suppress("unused")
companion object : SimpleQueryDataModel<AddResponse<*>>(
properties = object : ObjectPropertyDefinitions<AddResponse<*>>() {
val dataModel by addDataModel(AddResponse<*>::dataModel)
val statuses by list(
index = 2u,
getter = { response ->
response.statuses.map { TypedValue(it.statusType, it) }
},
valueDefinition = statusesMultiType
)
}
) {
override fun invoke(values: SimpleObjectValues<AddResponse<*>>) = AddResponse(
dataModel = values(1u),
statuses = values<List<TypedValue<TypeEnum<IsAddResponseStatus<IsRootDataModel<IsPropertyDefinitions>>>, IsAddResponseStatus<IsRootDataModel<IsPropertyDefinitions>>>>?>(2u)?.map { it.value } ?: emptyList()
)
}
}
| 0
|
Kotlin
|
0
| 6
|
2db4430b9d05f6f25ffc8d7d79a637a50bd73390
| 1,577
|
maryk
|
Apache License 2.0
|
src/test/kotlin/no/nav/medlemskap/sykepenger/lytter/service/BrukerinputMappingLogikkTest.kt
|
navikt
| 392,288,955
| false
|
{"Kotlin": 311975, "Dockerfile": 44}
|
package no.nav.medlemskap.sykepenger.lytter.service
import no.nav.medlemskap.sykepenger.lytter.persistence.*
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import java.time.LocalDate
class BrukerinputMappingLogikkTest {
@Test
fun testmappingAvOppholdstilatelseMedNullVerdi(){
val oppholdstilatelse = mapOppholdstilatelse(null)
Assertions.assertNull(oppholdstilatelse)
}
@Test
fun testmappingAvOppholdstilatelsePermanent(){
val medlemskap_oppholdstilatelse_brukersporsmaal = Medlemskap_oppholdstilatelse_brukersporsmaal(
id="1",
sporsmalstekst = "abc",
svar = true,
vedtaksdato = LocalDate.now(),
vedtaksTypePermanent = true,
perioder = emptyList()
)
val oppholdstilatelse = mapOppholdstilatelse(medlemskap_oppholdstilatelse_brukersporsmaal)
Assertions.assertEquals("1",oppholdstilatelse!!.id)
Assertions.assertEquals("abc",oppholdstilatelse.sporsmalstekst)
Assertions.assertEquals(true,oppholdstilatelse.svar)
Assertions.assertEquals(true,oppholdstilatelse.vedtaksTypePermanent)
Assertions.assertTrue(oppholdstilatelse.perioder.isEmpty())
}
@Test
fun testmappingAvOppholdstilatelseMidlertidig(){
val medlemskap_oppholdstilatelse_brukersporsmaal = Medlemskap_oppholdstilatelse_brukersporsmaal(
id="1",
sporsmalstekst = "abc",
svar = true,
vedtaksdato = LocalDate.now(),
vedtaksTypePermanent = false,
perioder = listOf(Periode(LocalDate.now(), LocalDate.now()))
)
val oppholdstilatelse = mapOppholdstilatelse(medlemskap_oppholdstilatelse_brukersporsmaal)
Assertions.assertEquals("1",oppholdstilatelse!!.id)
Assertions.assertEquals("abc",oppholdstilatelse.sporsmalstekst)
Assertions.assertEquals(true,oppholdstilatelse.svar)
Assertions.assertEquals(false,oppholdstilatelse.vedtaksTypePermanent)
Assertions.assertEquals(LocalDate.now().toString(),oppholdstilatelse.perioder[0].fom)
Assertions.assertEquals(LocalDate.now().toString(),oppholdstilatelse.perioder[0].tom)
}
@Test
fun testmappingAvArbeidUtlandTrue(){
val medlemskap_utfort_arbeid_utenfor_norge =
Medlemskap_utfort_arbeid_utenfor_norge(
id="1",
sporsmalstekst = "abc",
svar = true,
arbeidUtenforNorge = listOf(
ArbeidUtenforNorge(
id = "2",
arbeidsgiver = "test",
land = "Sverige",
perioder = listOf(Periode(LocalDate.now(), LocalDate.now())))
,
ArbeidUtenforNorge(
id = "3",
arbeidsgiver = "test2",
land = "Danmark",
perioder = listOf(Periode(LocalDate.now(), LocalDate.now())))
)
)
val utfortAarbeidUtenforNorge = maputfortAarbeidUtenforNorge(medlemskap_utfort_arbeid_utenfor_norge)
Assertions.assertNotNull(utfortAarbeidUtenforNorge,"dersom det finnes et innslag på arbeid utland så skal ser mappes")
Assertions.assertEquals("1",utfortAarbeidUtenforNorge!!.id)
Assertions.assertEquals("abc",utfortAarbeidUtenforNorge.sporsmalstekst)
Assertions.assertEquals(true,utfortAarbeidUtenforNorge.svar)
Assertions.assertTrue(utfortAarbeidUtenforNorge.arbeidUtenforNorge.isNotEmpty())
Assertions.assertTrue(utfortAarbeidUtenforNorge.arbeidUtenforNorge.size == 2)
Assertions.assertEquals("2",utfortAarbeidUtenforNorge.arbeidUtenforNorge[0].id)
Assertions.assertEquals("Sverige",utfortAarbeidUtenforNorge.arbeidUtenforNorge[0].land)
Assertions.assertEquals("test",utfortAarbeidUtenforNorge.arbeidUtenforNorge[0].arbeidsgiver)
Assertions.assertEquals(LocalDate.now().toString(),utfortAarbeidUtenforNorge.arbeidUtenforNorge[0].perioder[0].fom)
Assertions.assertEquals(LocalDate.now().toString(),utfortAarbeidUtenforNorge.arbeidUtenforNorge[0].perioder[0].tom)
}
@Test
fun testmappingAvArbeidUtlandFalse(){
val medlemskap_utfort_arbeid_utenfor_norge =
Medlemskap_utfort_arbeid_utenfor_norge(
id="1",
sporsmalstekst = "abc",
svar = false,
arbeidUtenforNorge = listOf()
)
val utfortAarbeidUtenforNorge = maputfortAarbeidUtenforNorge(medlemskap_utfort_arbeid_utenfor_norge)
Assertions.assertNotNull(utfortAarbeidUtenforNorge,"dersom det finnes et innslag på arbeid utland så skal ser mappes")
Assertions.assertEquals("1",utfortAarbeidUtenforNorge!!.id)
Assertions.assertEquals("abc",utfortAarbeidUtenforNorge.sporsmalstekst)
Assertions.assertEquals(false,utfortAarbeidUtenforNorge.svar)
Assertions.assertTrue(utfortAarbeidUtenforNorge.arbeidUtenforNorge.isEmpty())
}
@Test
fun testmappingAvArbeidUtlandNullVerdi(){
val medlemskap_utfort_arbeid_utenfor_norge = null
val utfortAarbeidUtenforNorge = maputfortAarbeidUtenforNorge(medlemskap_utfort_arbeid_utenfor_norge)
Assertions.assertNull(utfortAarbeidUtenforNorge)
}
@Test
fun testmappingAvOppholdUtenforNorgeNullVerdi(){
val medlemskapOppholdUtenforNorge = null
val utfortAarbeidUtenforNorge = mapOppholdUtenforNorge(medlemskapOppholdUtenforNorge)
Assertions.assertNull(utfortAarbeidUtenforNorge)
}
@Test
fun testmappingAvOppholdUtenforNorgeFalse(){
val medlemskapOppholdUtenforNorge = Medlemskap_opphold_utenfor_norge(
id="1",
sporsmalstekst = "abc",
svar = false,
oppholdUtenforNorge = emptyList()
)
val oppholdUtenforNorge = mapOppholdUtenforNorge(medlemskapOppholdUtenforNorge)
Assertions.assertNotNull(oppholdUtenforNorge)
Assertions.assertEquals("1",oppholdUtenforNorge!!.id)
Assertions.assertEquals("abc",oppholdUtenforNorge.sporsmalstekst)
Assertions.assertEquals(false,oppholdUtenforNorge.svar)
Assertions.assertTrue(oppholdUtenforNorge.oppholdUtenforNorge.isEmpty())
}
@Test
fun testmappingAvOppholdUtenforNorgeTrue(){
val medlemskapOppholdUtenforNorge = Medlemskap_opphold_utenfor_norge(
id="1",
sporsmalstekst = "abc",
svar = true,
oppholdUtenforNorge = listOf(
OppholdUtenforNorge(
id="2",
land = "Sverige",
grunn = "ingen",
perioder = listOf(Periode(LocalDate.now(), LocalDate.now()))
),
OppholdUtenforNorge(
id="3",
land = "Danmark",
grunn = "ingen",
perioder = listOf(Periode(LocalDate.now(), LocalDate.now())))
)
)
val oppholdUtenforNorge = mapOppholdUtenforNorge(medlemskapOppholdUtenforNorge)
Assertions.assertNotNull(oppholdUtenforNorge)
Assertions.assertEquals("1",oppholdUtenforNorge!!.id)
Assertions.assertEquals("abc",oppholdUtenforNorge.sporsmalstekst)
Assertions.assertEquals(true,oppholdUtenforNorge.svar)
Assertions.assertTrue(oppholdUtenforNorge.oppholdUtenforNorge.isNotEmpty())
Assertions.assertTrue(oppholdUtenforNorge.oppholdUtenforNorge.size == 2)
Assertions.assertEquals("2",oppholdUtenforNorge.oppholdUtenforNorge[0].id)
Assertions.assertEquals("ingen",oppholdUtenforNorge.oppholdUtenforNorge[0].grunn)
Assertions.assertEquals("Sverige",oppholdUtenforNorge.oppholdUtenforNorge[0].land)
Assertions.assertEquals(LocalDate.now().toString(),oppholdUtenforNorge.oppholdUtenforNorge[0].perioder[0].fom)
Assertions.assertEquals(LocalDate.now().toString(),oppholdUtenforNorge.oppholdUtenforNorge[0].perioder[0].tom)
}
@Test
fun testmappingAvOppholdUtenforEOSFalse(){
val medlemskapOppholdUtenforEOS = Medlemskap_opphold_utenfor_eos(
id="1",
sporsmalstekst = "abc",
svar = false,
oppholdUtenforEOS = emptyList()
)
val oppholdUtenforeos = mapOppholdUtenforEOS(medlemskapOppholdUtenforEOS)
Assertions.assertNotNull(oppholdUtenforeos)
Assertions.assertEquals("1",oppholdUtenforeos!!.id)
Assertions.assertEquals("abc",oppholdUtenforeos.sporsmalstekst)
Assertions.assertEquals(false,oppholdUtenforeos.svar)
Assertions.assertTrue(oppholdUtenforeos.oppholdUtenforEOS.isEmpty())
}
@Test
fun testmappingAvOppholdUtenforEOSTrue(){
val medlemskapOppholdUtenforeos = Medlemskap_opphold_utenfor_eos(
id="1",
sporsmalstekst = "abc",
svar = true,
oppholdUtenforEOS = listOf(
OppholdUtenforEOS(
id="2",
land = "Sverige",
grunn = "ingen",
perioder = listOf(Periode(LocalDate.now(), LocalDate.now()))
),
OppholdUtenforEOS(
id="3",
land = "Danmark",
grunn = "ingen",
perioder = listOf(Periode(LocalDate.now(), LocalDate.now())))
)
)
val oppholdUtenforeos = mapOppholdUtenforEOS(medlemskapOppholdUtenforeos)
Assertions.assertNotNull(oppholdUtenforeos)
Assertions.assertEquals("1",oppholdUtenforeos!!.id)
Assertions.assertEquals("abc",oppholdUtenforeos.sporsmalstekst)
Assertions.assertEquals(true,oppholdUtenforeos.svar)
Assertions.assertTrue(oppholdUtenforeos.oppholdUtenforEOS.isNotEmpty())
Assertions.assertTrue(oppholdUtenforeos.oppholdUtenforEOS.size == 2)
Assertions.assertEquals("2",oppholdUtenforeos.oppholdUtenforEOS[0].id)
Assertions.assertEquals("ingen",oppholdUtenforeos.oppholdUtenforEOS[0].grunn)
Assertions.assertEquals("Sverige",oppholdUtenforeos.oppholdUtenforEOS[0].land)
Assertions.assertEquals(LocalDate.now().toString(),oppholdUtenforeos.oppholdUtenforEOS[0].perioder[0].fom)
Assertions.assertEquals(LocalDate.now().toString(),oppholdUtenforeos.oppholdUtenforEOS[0].perioder[0].tom)
}
}
| 0
|
Kotlin
|
1
| 0
|
9b0ba0b0089c177a9b7f7f85a21ad0feeeac3d00
| 10,523
|
medlemskap-sykepengerlytter
|
MIT License
|
app/src/main/java/br/com/meiadois/decole/presentation/user/education/InteractiveModeListener.kt
|
meiadois
| 256,744,460
| false
| null |
package br.com.meiadois.decole.presentation.user.education
import java.lang.Exception
interface InteractiveModeListener {
fun onStarted()
fun onSuccess()
fun onFailure(ex: Exception)
}
| 0
|
Kotlin
|
1
| 2
|
f9c861124d3a1031bf0b802465eaa166c16f1693
| 198
|
decole-android
|
MIT License
|
app/src/main/java/com/awxkee/jxlcoder/app/glide/MainActivity.kt
|
awxkee
| 693,219,289
| false
|
{"Kotlin": 15911}
|
package com.awxkee.jxlcoder.app.glide
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.awxkee.jxlcoder.app.glide.ui.theme.JxlCoderGlideTheme
import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi
import com.bumptech.glide.integration.compose.GlideImage
class MainActivity : ComponentActivity() {
@OptIn(ExperimentalGlideComposeApi::class)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
JxlCoderGlideTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
Greeting("Android")
GlideImage(
model = "https://wh.aimuse.online/preset/jxl_icc_12.bit.jxl",
contentDescription = ""
)
}
}
}
}
}
@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
Text(
text = "Hello $name!",
modifier = modifier
)
}
@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
JxlCoderGlideTheme {
Greeting("Android")
}
}
| 0
|
Kotlin
|
0
| 6
|
22b8d47f45dd4cdfb9f30b4d26921180e0151780
| 1,711
|
jxl-coder-glide
|
Creative Commons Zero v1.0 Universal
|
src/main/kotlin/exceptions/ParserException.kt
|
OwnMind-ai
| 831,952,738
| false
|
{"Kotlin": 115274}
|
package org.cindustry.exceptions
import org.cindustry.parser.Token
class ParserException(message: String, token: Token? = null) : TokenException(SYNTAX, message, token)
| 0
|
Kotlin
|
0
| 0
|
6d13218019afea572f9ae60acf0402b681d2fb02
| 170
|
Cindustry
|
MIT License
|
core/src/main/kotlin/finance/tegro/core/contract/op/SuccessfulSwapPayloadOp.kt
|
TegroTON
| 586,902,794
| false
|
{"Kotlin": 227007}
|
package finance.tegro.core.contract.op
import org.ton.block.Maybe
import org.ton.cell.Cell
import org.ton.cell.CellBuilder
import org.ton.cell.CellSlice
import org.ton.tlb.TlbCodec
import org.ton.tlb.TlbConstructor
import org.ton.tlb.constructor.AnyTlbConstructor
import org.ton.tlb.loadTlb
import org.ton.tlb.storeTlb
data class SuccessfulSwapPayloadOp(
val payload: Maybe<Cell>
) : PayloadOp {
companion object : TlbCodec<SuccessfulSwapPayloadOp> by SuccessfulSwapPayloadOpConstructor {
@JvmStatic
fun tlbCodec(): TlbConstructor<SuccessfulSwapPayloadOp> = SuccessfulSwapPayloadOpConstructor
}
}
private object SuccessfulSwapPayloadOpConstructor : TlbConstructor<SuccessfulSwapPayloadOp>(
schema = "successful_swap_payload#de6e0675 payload:(Maybe ^Cell) = Payload;"
) {
override fun storeTlb(cellBuilder: CellBuilder, value: SuccessfulSwapPayloadOp) {
cellBuilder.apply {
storeTlb(Maybe.tlbCodec(AnyTlbConstructor), value.payload)
}
}
override fun loadTlb(cellSlice: CellSlice): SuccessfulSwapPayloadOp = cellSlice.run {
SuccessfulSwapPayloadOp(
payload = loadTlb(Maybe.tlbCodec(AnyTlbConstructor)),
)
}
}
| 17
|
Kotlin
|
4
| 0
|
f15616ec84716f9ecab118b855a8d5aaf5c2a9be
| 1,215
|
API-DEX-TON-Blockchain
|
MIT License
|
app/src/main/java/ui/all_characters/AllItemsFragment.kt
|
omertzroya
| 809,783,374
| false
|
{"Kotlin": 31122}
|
package ui.all_characters
import android.os.Bundle
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.couponchest.R
import com.example.couponchest.databinding.FragmentAllItemsBinding
import data.viewModel.ItemsViewModel
class AllItemsFragment :Fragment(){
private var _binding : FragmentAllItemsBinding? = null
private val binding get() = _binding!!
private val viewModel : ItemsViewModel by activityViewModels()
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
setHasOptionsMenu(true)
_binding = FragmentAllItemsBinding.inflate(inflater,container,false)
binding.fab.setOnClickListener{
findNavController().navigate(R.id.action_allItemsFragment_to_addItemFragment)
}
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.navigateButton.setOnClickListener{
findNavController().navigate(R.id.action_allItemsFragment_to_mapFragment)
}
arguments?.getString(getString(R.string.title))?.let{
Toast.makeText(requireActivity(),it,Toast.LENGTH_SHORT).show()
}
viewModel.items?.observe(viewLifecycleOwner){
binding.recycler.adapter = ItemAdapter(it,object : ItemAdapter.ItemListener {
override fun onItemClicked(index: Int) {
val item = (binding.recycler.adapter as ItemAdapter).itemAt(index)
viewModel.setItem(item)
findNavController().navigate(R.id.action_allItemsFragment_to_detailItemFragment)
}
override fun onItemLongClicked(index: Int) {
val item = (binding.recycler.adapter as ItemAdapter).itemAt(index)
viewModel.setItem(item)
findNavController().navigate(R.id.action_allItemsFragment_to_editItemFragment)
}
})
binding.recycler.layoutManager = LinearLayoutManager(requireContext())
}
ItemTouchHelper(object : ItemTouchHelper.Callback(){
override fun getMovementFlags(
recyclerView: RecyclerView,
viewHolder: RecyclerView.ViewHolder
) = makeFlag(ItemTouchHelper.ACTION_STATE_SWIPE,ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT)
override fun onMove(
recyclerView: RecyclerView,
viewHolder: RecyclerView.ViewHolder,
target: RecyclerView.ViewHolder
): Boolean {
TODO("Not yet implemented")
}
override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {
val item = (binding.recycler.adapter as ItemAdapter).itemAt(viewHolder.adapterPosition)
val builder = AlertDialog.Builder(viewHolder.itemView.context)
builder.setTitle(viewHolder.itemView.context.getString(R.string.confirm_delete))
.setMessage(viewHolder.itemView.context.getString(R.string.are_you_sure_you_want_to_delete_this_item))
.setPositiveButton(viewHolder.itemView.context.getString(R.string.yes)) { dialog, id ->
viewModel.deleteItem(item)
}
.setNegativeButton(viewHolder.itemView.context.getString(R.string.no)) { dialog, id ->
binding.recycler.adapter!!.notifyItemChanged(viewHolder.adapterPosition)
}
val dialog = builder.create()
dialog.setOnCancelListener {
binding.recycler.adapter!!.notifyItemChanged(viewHolder.adapterPosition)
}
dialog.show()
}
}).attachToRecyclerView(binding.recycler)
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
inflater.inflate(R.menu.main_menu,menu)
super.onCreateOptionsMenu(menu, inflater)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.action_delete) {
val builder = AlertDialog.Builder(requireContext())
builder.setTitle(getString(R.string.confirm_delete))
.setMessage(getString(R.string.are_you_sure_you_want_to_delete_all_items))
.setPositiveButton(getString(R.string.yes)) { _, _ ->
viewModel.deleteAll()
Toast.makeText(requireContext(),
getString(R.string.items_deleted), Toast.LENGTH_SHORT).show()
}
.setNegativeButton(getString(R.string.no)) { dialog, _ ->
dialog.dismiss()
}
.show()
}
return super.onOptionsItemSelected(item)
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
| 0
|
Kotlin
|
0
| 0
|
1648a953c794a0441a31c9b1e21f1748851414e3
| 5,548
|
CouponChest-Kotlin-App
|
MIT License
|
src/test/kotlin/g1501_1600/s1534_count_good_triplets/SolutionTest.kt
|
javadev
| 190,711,550
| false
|
{"Kotlin": 4870729, "TypeScript": 50437, "Python": 3646, "Shell": 994}
|
package g1501_1600.s1534_count_good_triplets
import org.hamcrest.CoreMatchers.equalTo
import org.hamcrest.MatcherAssert.assertThat
import org.junit.jupiter.api.Test
internal class SolutionTest {
@Test
fun countGoodTriplets() {
assertThat(
Solution().countGoodTriplets(intArrayOf(3, 0, 1, 1, 9, 7), 7, 2, 3),
equalTo(4)
)
}
@Test
fun countGoodTriplets2() {
assertThat(
Solution().countGoodTriplets(intArrayOf(1, 1, 2, 2, 3), 0, 0, 1), equalTo(0)
)
}
}
| 0
|
Kotlin
|
20
| 43
|
e8b08d4a512f037e40e358b078c0a091e691d88f
| 546
|
LeetCode-in-Kotlin
|
MIT License
|
src/main/kotlin/com/dongfg/project/api/web/graphql/resolver/ResourceResolver.kt
|
fossabot
| 170,657,046
| false
| null |
package com.dongfg.project.api.web.graphql.resolver
import com.coxautodev.graphql.tools.GraphQLQueryResolver
import com.dongfg.project.api.component.ZiMuZu
import com.dongfg.project.api.model.ResourceDetail
import com.dongfg.project.api.model.ResourceEpisode
import com.dongfg.project.api.model.ResourceInfo
import com.dongfg.project.api.service.ResourceService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component
@Component
class ResourceResolver : GraphQLQueryResolver {
@Autowired
private lateinit var ziMuZu: ZiMuZu
@Autowired
private lateinit var resourceService: ResourceService
fun resources(keyword: String): List<ResourceInfo> {
return ziMuZu.search(keyword)
}
fun resourceDetail(resourceId: String): ResourceDetail {
return ziMuZu.detail(resourceId)
}
fun episodes(resourceId: String): List<ResourceEpisode> {
return resourceService.episodes(resourceId)
}
}
| 0
|
Kotlin
|
0
| 1
|
e0538f524b92931e70cf5badfac5e23b53214fc7
| 996
|
api-10
|
MIT License
|
domain/src/main/java/tachiyomi/domain/manga/interactor/SetFetchInterval.kt
|
tachiyomiorg
| 43,807,251
| false
| null |
package tachiyomi.domain.manga.interactor
import tachiyomi.domain.chapter.interactor.GetChapterByMangaId
import tachiyomi.domain.chapter.model.Chapter
import tachiyomi.domain.manga.model.Manga
import tachiyomi.domain.manga.model.MangaUpdate
import java.time.Instant
import java.time.ZonedDateTime
import java.time.temporal.ChronoUnit
import kotlin.math.absoluteValue
const val MAX_FETCH_INTERVAL = 28
private const val FETCH_INTERVAL_GRACE_PERIOD = 1
class SetFetchInterval(
private val getChapterByMangaId: GetChapterByMangaId,
) {
suspend fun toMangaUpdateOrNull(
manga: Manga,
dateTime: ZonedDateTime,
window: Pair<Long, Long>,
): MangaUpdate? {
val currentWindow = if (window.first == 0L && window.second == 0L) {
getWindow(ZonedDateTime.now())
} else {
window
}
val chapters = getChapterByMangaId.await(manga.id)
val interval = manga.fetchInterval.takeIf { it < 0 } ?: calculateInterval(chapters, dateTime)
val nextUpdate = calculateNextUpdate(manga, interval, dateTime, currentWindow)
return if (manga.nextUpdate == nextUpdate && manga.fetchInterval == interval) {
null
} else {
MangaUpdate(id = manga.id, nextUpdate = nextUpdate, fetchInterval = interval)
}
}
fun getWindow(dateTime: ZonedDateTime): Pair<Long, Long> {
val today = dateTime.toLocalDate().atStartOfDay(dateTime.zone)
val lowerBound = today.minusDays(FETCH_INTERVAL_GRACE_PERIOD.toLong())
val upperBound = today.plusDays(FETCH_INTERVAL_GRACE_PERIOD.toLong())
return Pair(lowerBound.toEpochSecond() * 1000, upperBound.toEpochSecond() * 1000 - 1)
}
internal fun calculateInterval(chapters: List<Chapter>, zonedDateTime: ZonedDateTime): Int {
val sortedChapters = chapters
.sortedWith(compareByDescending<Chapter> { it.dateUpload }.thenByDescending { it.dateFetch })
.take(50)
val uploadDates = sortedChapters
.filter { it.dateUpload > 0L }
.map {
ZonedDateTime.ofInstant(Instant.ofEpochMilli(it.dateUpload), zonedDateTime.zone)
.toLocalDate()
.atStartOfDay()
}
.distinct()
val fetchDates = sortedChapters
.map {
ZonedDateTime.ofInstant(Instant.ofEpochMilli(it.dateFetch), zonedDateTime.zone)
.toLocalDate()
.atStartOfDay()
}
.distinct()
val interval = when {
// Enough upload date from source
uploadDates.size >= 3 -> {
val uploadDelta = uploadDates.last().until(uploadDates.first(), ChronoUnit.DAYS)
val uploadPeriod = uploadDates.indexOf(uploadDates.last())
uploadDelta.floorDiv(uploadPeriod).toInt()
}
// Enough fetch date from client
fetchDates.size >= 3 -> {
val fetchDelta = fetchDates.last().until(fetchDates.first(), ChronoUnit.DAYS)
val uploadPeriod = fetchDates.indexOf(fetchDates.last())
fetchDelta.floorDiv(uploadPeriod).toInt()
}
// Default to 7 days
else -> 7
}
return interval.coerceIn(1, MAX_FETCH_INTERVAL)
}
private fun calculateNextUpdate(
manga: Manga,
interval: Int,
dateTime: ZonedDateTime,
window: Pair<Long, Long>,
): Long {
return if (
manga.nextUpdate !in window.first.rangeTo(window.second + 1) ||
manga.fetchInterval == 0
) {
val latestDate = ZonedDateTime.ofInstant(Instant.ofEpochMilli(manga.lastUpdate), dateTime.zone)
.toLocalDate()
.atStartOfDay()
val timeSinceLatest = ChronoUnit.DAYS.between(latestDate, dateTime).toInt()
val cycle = timeSinceLatest.floorDiv(
interval.absoluteValue.takeIf { interval < 0 }
?: doubleInterval(interval, timeSinceLatest, doubleWhenOver = 10),
)
latestDate.plusDays((cycle + 1) * interval.toLong()).toEpochSecond(dateTime.offset) * 1000
} else {
manga.nextUpdate
}
}
private fun doubleInterval(delta: Int, timeSinceLatest: Int, doubleWhenOver: Int): Int {
if (delta >= MAX_FETCH_INTERVAL) return MAX_FETCH_INTERVAL
// double delta again if missed more than 9 check in new delta
val cycle = timeSinceLatest.floorDiv(delta) + 1
return if (cycle > doubleWhenOver) {
doubleInterval(delta * 2, timeSinceLatest, doubleWhenOver)
} else {
delta
}
}
}
| 462
|
Kotlin
|
2586
| 23,920
|
96f6a5abc2a879cf4ff79c0c4e61153292f61357
| 4,778
|
tachiyomi
|
Apache License 2.0
|
src/test/kotlin/io/github/simplydemo/ConfigurationVerticleTest.kt
|
simplydemo
| 710,141,733
| false
|
{"Kotlin": 11690, "Dockerfile": 188}
|
package io.github.simplydemo
import io.vertx.config.ConfigRetriever
import io.vertx.config.ConfigRetrieverOptions
import io.vertx.config.ConfigStoreOptions
import io.vertx.core.Vertx
import io.vertx.junit5.VertxExtension
import io.vertx.junit5.VertxTestContext
import io.vertx.kotlin.core.json.json
import io.vertx.kotlin.core.json.obj
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
@ExtendWith(VertxExtension::class)
class ConfigurationVerticleTest {
@BeforeEach
fun deploy_verticle(vertx: Vertx, testContext: VertxTestContext) {/*
vertx.deployVerticle(ConfigurationVerticle())
.onSuccess { testContext.completeNow() }
.onFailure { testContext.failNow(it) }
vertx.deployVerticle(ConfigurationVerticle(), testContext.succeedingThenComplete())
vertx.deployVerticle(ConfigurationVerticle(), testContext.succeeding<String> { _ -> testContext.completeNow() })
*/
vertx.deployVerticle(ConfigurationVerticle()).onSuccess { testContext.completeNow() }
.onFailure { testContext.failNow(it) }
}
@Test
@DisplayName("Test vertx handler")
@Throws(Throwable::class)
fun testConfigurationVerticle(testContext: VertxTestContext) {
testContext.completeNow()
}
@Test
@DisplayName("Test get operation from CommonHandler")
@Throws(Throwable::class)
fun test_json(vertx: Vertx) {
println("test_json")
val options = ConfigStoreOptions().setType("file").setFormat("yaml").setConfig(json {
obj(
"path" to "application.yaml"
)
})
val retrieverOptions = ConfigRetrieverOptions().addStore(options).setScanPeriod(10000)
val configRetriever = ConfigRetriever.create(vertx, retrieverOptions)
configRetriever.getConfig { ar ->
if (ar.failed()) {
println("Failed to retrieve the configuration")
} else {
println("AsyncResult")
val config = ar.result()
for (key in config.fieldNames()) {
println(key)
}
}
}
configRetriever.close()
}
// @Test
// @DisplayName("Test get operation from CommonHandler")
// @Throws(Throwable::class)
// fun testConfigurationVerticle(vertx: Vertx, context: VertxTestContext) {
// vertx.deployVerticle(ConfigurationVerticle(), DeploymentOptions().setMaxWorkerExecuteTime(1000).setWorker(true))
// .onSuccess { context.completeNow() }
// .onFailure { context.failNow(it) }
// //.onComplete { vertx.close(context.succeeding { response -> context.completeNow() }) }
// vertx.exceptionHandler().run {
// println("")
// }
// }
}
| 0
|
Kotlin
|
0
| 0
|
c2e51629e830acd134117d2fb55566d23c5f452d
| 2,901
|
vertx-lotto-api
|
Apache License 2.0
|
src/test/kotlin/com/tylerthrailkill/helpers/prettyprint/EnumTest.kt
|
youvere
| 220,963,506
| true
|
{"Kotlin": 120549}
|
package com.tylerthrailkill.helpers.prettyprint
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
object EnumTest : Spek({
setup()
describe("pretty printing enums should") {
it("render all values of the enum") {
prettyPrint(TestEnum.BOOLEAN) mapsTo """TestEnum.BOOLEAN"""
}
it("render enum in a list") {
prettyPrint(listOf(TestEnum.BOOLEAN)) mapsTo """
[
TestEnum.BOOLEAN
]
""".trimIndent()
}
it("render enum as key in a map") {
prettyPrint(mapOf(TestEnum.BOOLEAN to "")) mapsTo """
{
TestEnum.BOOLEAN -> ""
}
"""
}
it("render enum as value in a map") {
prettyPrint(mapOf("" to TestEnum.BOOLEAN)) mapsTo """
{
"" -> TestEnum.BOOLEAN
}
"""
}
it("render enum in an object") {
prettyPrint(ObjectWithEnum(TestEnum.BOOLEAN)) mapsTo """
ObjectWithEnum(
enum = TestEnum.BOOLEAN
)
"""
}
}
})
| 0
| null |
0
| 0
|
93db14fcf85f5ad73ca929b6a776455b992c3e0d
| 1,253
|
pretty-print
|
MIT License
|
app/src/main/java/des/c5inco/pokedexer/di/MovesDatabaseModule.kt
|
c5inco
| 461,368,002
| false
|
{"Kotlin": 241702}
|
package des.c5inco.pokedexer.di
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import des.c5inco.pokedexer.data.PokemonDatabase
import des.c5inco.pokedexer.data.moves.MovesDao
@InstallIn(SingletonComponent::class)
@Module
object MovesDatabaseModule {
@Provides
fun provideMovesDao(database: PokemonDatabase): MovesDao {
return database.movesDao()
}
}
| 0
|
Kotlin
|
11
| 98
|
864891236d09bbcbfaca75cb4cdba4c2fdb112db
| 448
|
compose-pokedexer
|
MIT License
|
app/src/main/java/at/opnote/notifications/NotificationsProvider.kt
|
fly8899
| 456,671,546
| false
| null |
package at.opnote.notifications
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import android.content.SharedPreferences
import android.os.Bundle
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.navigation.NavDeepLinkBuilder
import at.opnote.R
import at.opnote.constants.FRAGMENT_NOTE_EDIT_ID
import at.opnote.ui.settings.OpSettings
import at.opnote.util.extensions.getColorFromAttr
class NotificationsProvider(
private val _applicationContext: Context,
private val _sharedPreferences: SharedPreferences,
private val _opSettings: OpSettings
) {
private val _notificationManagerCompat = createNotificationChannel()
fun send(
implementation: NotificationCapability,
sendFrom: String
) {
val model = implementation.getNotificationModel()
if (!areNotificationsEnabled()) return
val args = Bundle()
args.putLong("id", model.id)
val destinationId =
if (sendFrom == FRAGMENT_NOTE_EDIT_ID) R.id.op_note_edit_navigation
else R.id.op_todo_edit_navigation
val pendingIntent = NavDeepLinkBuilder(_applicationContext)
.setGraph(R.navigation.main_navigation)
.setDestination(destinationId)
.setArguments(args)
.createPendingIntent()
val builder = NotificationCompat.Builder(
_applicationContext,
_applicationContext.getString(R.string.channel_id)
).apply {
setSmallIcon(R.drawable.ic_op_note_icon)
color = _applicationContext.getColorFromAttr(R.attr.colorPrimary)
val style = NotificationCompat.BigTextStyle()
if (model.title.spanned.isNotEmpty()) {
setContentTitle(model.title.spanned)
style.setBigContentTitle(model.title.spanned)
}
if (model.text.spanned.isNotEmpty()) {
style.bigText(model.text.spanned)
}
setStyle(style)
setOngoing(_opSettings.useOngoingNotifications())
setSilent(true)
setShowWhen(false)
setContentIntent(pendingIntent)
priority = NotificationCompat.PRIORITY_DEFAULT
}
//areNotificationsDisabledByOS() above
@Suppress("MissingPermission")
_notificationManagerCompat.notify(
model.notificationId,
builder.build()
)
}
fun cancel(notificationId: Int) {
if (!areNotificationsEnabled()) return
_notificationManagerCompat.cancel(notificationId)
}
fun getNotificationId(): Int {
var id = _sharedPreferences.getInt("notificationId", 0)
when (id) {
Int.MAX_VALUE -> {
_sharedPreferences.edit().putInt("notificationId", 0).apply()
id = 1
}
else -> {
_sharedPreferences.edit().putInt("notificationId", ++id).apply()
}
}
return id
}
fun areNotificationsEnabled(): Boolean {
return _notificationManagerCompat.areNotificationsEnabled()
}
private fun createNotificationChannel(): NotificationManagerCompat {
val channelName = _applicationContext.getString(R.string.channel_name)
val channelDescription = _applicationContext.getString(R.string.channel_description)
val importance = NotificationManager.IMPORTANCE_DEFAULT
val channel =
NotificationChannel(
_applicationContext.getString(R.string.channel_id),
channelName,
importance
)
channel.description = channelDescription
val notificationChannel = NotificationManagerCompat.from(_applicationContext)
notificationChannel.createNotificationChannel(channel)
return notificationChannel
}
}
| 0
|
Kotlin
|
0
| 0
|
a5997cb2031ea57f6a16c4ab8cd203e51838c0ce
| 3,963
|
OpNote
|
Apache License 2.0
|
rx-runtime-reaktive/src/commonTest/kotlin/com/suparnatural/runtime/rx/reaktive/ReaktiveTests.kt
|
suparngp
| 191,891,618
| false
| null |
package com.suparnatural.runtime.rx.reaktive
import kotlin.test.Test
class ReaktiveTests {
@Test
fun testRxRuntime() {
}
}
| 15
|
HTML
|
7
| 97
|
82b217e1fcfdc7a62fdfb3821a556409a2b34ad3
| 136
|
kotlin-multiplatform-projects
|
MIT License
|
src/main/kotlin/io/matrixfy/commands.kt
|
VaiTon
| 588,932,217
| false
| null |
package io.matrixfy
import com.adamratzman.spotify.SpotifyScope
import com.adamratzman.spotify.SpotifyUserAuthorization
import com.adamratzman.spotify.endpoints.pub.SearchApi
import com.adamratzman.spotify.getSpotifyAuthorizationUrl
import com.adamratzman.spotify.models.SpotifyTrackUri
import com.adamratzman.spotify.spotifyClientApi
import kotlinx.coroutines.flow.first
import kotlinx.html.*
import net.folivo.trixnity.client.MatrixClient
import net.folivo.trixnity.client.room
import net.folivo.trixnity.client.room.message.reply
import net.folivo.trixnity.client.room.message.text
import net.folivo.trixnity.client.store.TimelineEvent
internal fun BotDispatcher.registerPlayingCmd() {
registerCommand("playing") { _, _ ->
sendNowPlaying(this, client)
}
}
internal fun BotDispatcher.registerSearchCmd() {
registerCommand("search") { content, _ ->
searchSong(this, client, content.body)
}
}
internal fun BotDispatcher.registerLoginCmd() {
registerCommand("login") command@{ content, args ->
val senderId = event.sender
val clientId = AppData.settings.spotifyClientId
val clientSecret = AppData.settings.spotifyClientSecret
val redirectUrl = AppData.settings.spotifyRedirectUrl
if (args.isEmpty()) {
val authorizationUrl = getSpotifyAuthorizationUrl(
clientId = clientId,
redirectUri = redirectUrl,
scopes = SpotifyScope.values(),
)
client.room.sendMessage(event.roomId) {
reply(this@command)
text(authorizationUrl)
}
return@command
} else {
val authCode = content.body.substringAfter("code=").substringBefore("&").trim()
val spotifyClientApi = spotifyClientApi(
clientId,
clientSecret,
redirectUrl,
SpotifyUserAuthorization(authCode)
).build()
if (spotifyClientApi.isTokenValid().isValid) {
AppData.addUser(User(senderId, spotifyClientApi.token))
client.room.sendMessage(event.roomId) {
reply(this@command)
text("Logged in as ${spotifyClientApi.users.getClientProfile().displayName}")
}
} else {
client.room.sendMessage(event.roomId) {
reply(this@command)
text("Login failed")
}
}
}
}
}
internal fun BotDispatcher.registerSearch() {
registerTextListener { roomMessageEventContent ->
val isDirectChat = client.room.getById(roomId).first()?.isDirect
if (isDirectChat != true) {
return@registerTextListener false
}
searchSong(this, client, roomMessageEventContent.body)
return@registerTextListener true
}
}
internal fun BotDispatcher.registerTrackPlay() {
registerTextListener { content ->
val spotifyClient = getSpotifyClient(client, this)
?: return@registerTextListener false
val input = content.body
if (!input.startsWith("spotify:track")) {
return@registerTextListener false
}
val uri = SpotifyTrackUri(input)
val track = spotifyClient.tracks.getTrack(uri.id)!!
spotifyClient.player.startPlayback(trackIdsToPlay = listOf(track.id))
sendNowPlaying(this, client)
return@registerTextListener true
}
}
internal suspend fun sendNowPlaying(event: TimelineEvent, client: MatrixClient) {
val spotifyClient = getSpotifyClient(client, event) ?: return
val track =
spotifyClient.player.getCurrentlyPlaying()?.item?.asTrack ?: return
client.room.sendMessage(roomId = event.roomId) {
reply(event)
html {
+"Now playing "
strong { +track.name }
+" by "
em { +track.artists.joinToString { it.name } }
}
}
}
/**
* @param query the search query
* @param client the matrix client
* @param event the event that prompted the search
*/
internal suspend fun searchSong(
event: TimelineEvent,
client: MatrixClient,
query: String,
) {
val spotifyClient = getSpotifyClient(client, event) ?: return
val searchResult = spotifyClient.search.search(query, SearchApi.SearchType.Track)
val trackList = searchResult.tracks?.take(5) ?: return
client.room.sendMessage(event.roomId) {
reply(event)
html {
ul {
trackList.forEach { track ->
li {
+"${track.name} by ${track.artists.joinToString { it.name }} - "
pre { code { +track.uri.uri } }
}
}
}
}
}
}
internal fun BotDispatcher.registerSkipCmd() {
registerCommand("skip") { _, _ ->
val spotify = getSpotifyClient(client) ?: return@registerCommand
spotify.player.skipForward()
client.room.sendMessage(event.roomId) {
html { +"Skipped" }
}
}
}
| 3
|
Kotlin
|
0
| 5
|
9a60797a2bcb69274a07adbbbdbbee27faeb6350
| 5,132
|
matrixfy
|
Apache License 2.0
|
app/src/main/java/ke/co/svs/mykrypto/MainActivity.kt
|
Wamae
| 428,778,929
| false
|
{"Kotlin": 25476}
|
package ke.co.svs.mykrypto
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.example.basicmvvm.ui.screens.settings.ChartsScreen
import com.example.basicmvvm.ui.screens.splash.SplashScreen
import ke.co.svs.mykrypto.ui.screens.alerts.AlertsScreen
import ke.co.svs.mykrypto.ui.screens.home.HomeScreen
import ke.co.svs.mykrypto.ui.screens.settings.SettingsScreen
import ke.co.svs.mykrypto.ui.theme.MyKryptoTheme
import ke.co.svs.mykrypto.utils.Routes
import kotlinx.coroutines.CoroutineScope
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
val navHostController = rememberNavController()
val coroutineHostScope = rememberCoroutineScope()
MyKryptoTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
) {
Navigation(
navHostController = navHostController,
coroutineHostScope = coroutineHostScope,
)
}
}
}
}
}
@Composable
fun Navigation(
navHostController: NavHostController,
coroutineHostScope: CoroutineScope,
) {
NavHost(
navController = navHostController,
startDestination = Routes.ROUTE_SPLASH
) {
composable(Routes.ROUTE_SPLASH) {
SplashScreen(navController = navHostController)
}
composable(Routes.ROUTE_HOME) {
HomeScreen(navController = navHostController)
}
composable(route = Routes.ROUTE_CHARTS) {
ChartsScreen(navController = navHostController)
}
composable(Routes.ROUTE_ALERTS) {
AlertsScreen(navController = navHostController)
}
composable(Routes.ROUTE_SETTINGS) {
SettingsScreen(navController = navHostController)
}
}
}
| 5
|
Kotlin
|
0
| 0
|
edb383788eaf2c9ccfeebbdd97b3cf58129899db
| 2,572
|
krypto
|
MIT License
|
src/main/kotlin/ru/coding4fun/intellij/database/action/security/NewCryptographicProviderAction.kt
|
scrappyCoco
| 201,919,288
| false
| null |
package ru.coding4fun.intellij.database.action.security
//import ru.coding4fun.intellij.database.action.common.updateVisibility
//import ru.coding4fun.intellij.database.data.property.security.SecurityDataProviders
//import ru.coding4fun.intellij.database.ui.displayDialog
import ru.coding4fun.intellij.database.action.KindPaths
import ru.coding4fun.intellij.database.action.common.NewModelAction
import ru.coding4fun.intellij.database.data.property.security.SecurityDataProviders
import ru.coding4fun.intellij.database.model.property.security.MsCryptographicProviderModel
import ru.coding4fun.intellij.database.ui.form.security.CryptographicProviderDialog
class NewCryptographicProviderAction : NewModelAction<MsCryptographicProviderModel, CryptographicProviderDialog>(
KindPaths.cryptographicProvider,
CryptographicProviderDialog(),
SecurityDataProviders::getCryptographicProvider
)
| 0
|
Kotlin
|
2
| 1
|
1408f2a9229dbdf9ad99966faa5e7a5b74786270
| 888
|
SQL-Server-Administration-Tool
|
Apache License 2.0
|
src/main/kotlin/views/screens/GeneratedPathPickerScreen.kt
|
legora-io
| 473,590,009
| false
| null |
package views.screens
import androidx.compose.foundation.layout.*
import androidx.compose.material.Button
import androidx.compose.material.OutlinedTextField
import androidx.compose.material.Text
import androidx.compose.material.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.rotate
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.ExperimentalUnitApi
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.TextUnitType
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.AwtWindow
import utils.ApplicationColors
import utils.ApplicationIcons
import utils.ApplicationProjectsManager
import utils.ApplicationStrings
import views.common.HeaderComponent
import views.components.CircleIconComponent
import views.components.ProjectCardComponent
import java.awt.FileDialog
import java.awt.Frame
import java.io.File
@OptIn(ExperimentalUnitApi::class)
@Composable
fun GeneratedPathPickerScreen(
projectKey: String,
nextRoute: Int,
prevRoute: Int,
onRouteChangeDestination: (Int, String) -> Unit,
) {
val selectedProjectInformation = ApplicationProjectsManager.getProjectsList().filter { it.key.equals(projectKey) }
val generatedPath = remember { mutableStateOf("") }
val isFileChooserOpen = remember { mutableStateOf(false) }
Column(modifier = Modifier.fillMaxWidth().fillMaxHeight()) {
HeaderComponent()
Row(modifier = Modifier.padding(20.dp)) {
Column(modifier = Modifier.fillMaxWidth(0.7f)) {
Text(ApplicationStrings.GENERATED_PATH_TITLE, fontSize = TextUnit(15f, TextUnitType.Sp), fontWeight = FontWeight.Bold)
Text(ApplicationStrings.GENERATED_PATH_DESCRIPTION, fontSize = TextUnit(12f, TextUnitType.Sp))
Spacer(Modifier.height(30.dp))
Column {
OutlinedTextField(
colors = TextFieldDefaults.outlinedTextFieldColors(
focusedBorderColor = ApplicationColors.PRIMARY_COLOR,
cursorColor = ApplicationColors.PRIMARY_COLOR,
focusedLabelColor = ApplicationColors.PRIMARY_COLOR
),
value = generatedPath.value,
label = { Text(text = "Please Enter Source Code Path") },
placeholder = { Text(text = "Please Enter Source Code Path") },
onValueChange = { newText ->
generatedPath.value = newText
},
singleLine = true
)
Spacer(Modifier.height(20.dp))
Button(onClick = {
isFileChooserOpen.value = true
}) {
Text("Pick Application Source Path")
}
}
}
Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.End) {
Box(Modifier.fillMaxWidth(0.4f)) {
ProjectCardComponent(selectedProjectInformation[0], projectKey) {}
}
if (generatedPath.value.isNotEmpty()) {
Column(
modifier = Modifier.fillMaxWidth().fillMaxHeight().padding(10.dp)
) {
Column(
verticalArrangement = Arrangement.Bottom,
horizontalAlignment = Alignment.End,
modifier = Modifier.fillMaxWidth().fillMaxHeight()
) {
Row {
Box(modifier = Modifier.rotate(180f)) {
CircleIconComponent(ApplicationIcons.NEXT_ARROW, "Prev Page") {
onRouteChangeDestination(prevRoute, generatedPath.value)
}
}
Spacer(modifier = Modifier.width(20.dp))
CircleIconComponent(ApplicationIcons.NEXT_ARROW, "Next Page") {
onRouteChangeDestination(nextRoute, generatedPath.value)
}
}
}
}
}
}
}
}
if (isFileChooserOpen.value) {
FileDialog(
onCloseRequest = {
isFileChooserOpen.value = false
generatedPath.value = it ?: ""
}
)
}
}
@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun FileDialog(
parent: Frame? = null,
onCloseRequest: (result: String?) -> Unit,
) = AwtWindow(
create = {
object : FileDialog(parent, "Choose The Source Code Path", LOAD) {
override fun setVisible(value: Boolean) {
super.setVisible(value)
if (value) {
val path = File(directory + file).absolutePath
if (!path.contains("null")) {
onCloseRequest(path)
}
}
}
}
},
dispose = FileDialog::dispose
)
| 0
|
Kotlin
|
1
| 1
|
d71d1277101350569eabd21c26b92d352b23bce7
| 5,547
|
Legora
|
MIT License
|
src/main/kotlin/net/averkhoglyad/chess/manager/core/service/ProfileServiceImpl.kt
|
averkhoglyad
| 113,734,963
| false
| null |
//package net.averkhoglyad.chess.manager.core.service
//
//import net.averkhoglyad.chess.manager.core.sdk.data.User
//
//import java.nio.file.Files
//import java.nio.file.Path
//import java.util.ArrayList
//import java.util.stream.Collectors
//import java.util.stream.Stream
//
//import net.averkhoglyad.chess.manager.core.helper.ExceptionHelper.doStrict
//
//class ProfileServiceImpl(private val profilesFile: Path) : ProfileService {
//
// override fun load(): List<User> {
// val users = ArrayList<E>()
// if (Files.exists(profilesFile)) {
// doStrict { Files.lines(profilesFile) }.use({ lines -> lines.map(Function<String, R> { User() }).forEachOrdered(Consumer<R> { users.add() }) })
// }
// return users
// }
//
// override fun save(profiles: List<User>) {
// val usernames = profiles.stream()
// .map(Function<User, R> { User.getUsername() })
// .collect(Collectors.toList<Any>())
// doStrict { Files.write(profilesFile, usernames) }
// }
//
//}
| 3
|
Kotlin
|
0
| 0
|
3a3c5ebd00cd716713da584409d8f1eabcb4ef3b
| 1,048
|
chess-manager
|
Apache License 2.0
|
app/src/main/java/com/example/ceritaku/data/remote/response/story/NewStoryResponse.kt
|
Alstonargodi
| 479,324,167
| false
|
{"Kotlin": 121568}
|
package com.example.ceritaku.data.remote.response.story
import com.google.gson.annotations.SerializedName
data class NewStoryResponse(
@SerializedName("error")
val error: Boolean,
@SerializedName("message")
val message: String
)
| 0
|
Kotlin
|
0
| 3
|
0fe9437bfbb0e5ec5b532b72b73934033f9f697f
| 247
|
Cerita
|
Apache License 2.0
|
xenoglot-atlas-extended/src/commonMain/kotlin/dev/teogor/xenoglot/atlas/extended/LanguageToCountryMappings_to.kt
|
teogor
| 718,087,802
| false
|
{"Kotlin": 1614676}
|
/*
* Copyright 2024 teogor (<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 dev.teogor.xenoglot.atlas.extended
import dev.teogor.xenoglot.atlas.CountryLocalization
import kotlin.collections.List
/**
* Holds the internal list of country-language mappings used for lookups within the package for
* language code to.
*
* This property contains a hardcoded list of [CountryLocalization] objects, each representing
* a country and its associated official languages. This list is used by [CountryLanguageRegistry]
* to provide access to country-language data and should not be modified directly.
*
* @see CountryLocalization
* @see CountryLanguageRegistry
*/
internal val _countryLanguageMappings_to: List<CountryLocalization> = listOf(
CountryLocalization("af", "lea fakapēsia", "ʻAfikānisitani"),
CountryLocalization("al", "lea fakaʻalapēnia", "ʻAlipania"),
CountryLocalization("dz", "lea fakafalanisē", "ʻAlisilia"),
CountryLocalization("as", "lea fakapālangi", "Haʻamoa ʻAmelika"),
CountryLocalization("ad", "lea fakakatalani", "ʻAnitola"),
CountryLocalization("ao", "lea lingikala", "ʻAngikola"),
CountryLocalization("ai", "lea fakapālangi", "Anikuila"),
CountryLocalization("ag", "lea fakapālangi", "Anitikua mo Palaputa"),
CountryLocalization("ar", "lea fakasipēnisi", "ʻAsenitina"),
CountryLocalization("am", "lea fakaʻāmenia", "ʻĀmenia"),
CountryLocalization("aw", "lea fakahōlani", "ʻAlupa"),
CountryLocalization("au", "lea fakapālangi", "ʻAositelēlia"),
CountryLocalization("at", "lea fakapālangi", "ʻAositulia"),
CountryLocalization("az", "lea fakaʻasapaisani", "ʻAsapaisani"),
CountryLocalization("bs", "lea fakapālangi", "Pahama"),
CountryLocalization("bh", "lea fakaʻalepea", "Paleini"),
CountryLocalization("bd", "lea fakapāngilā", "Pengilātesi"),
CountryLocalization("bb", "lea fakapālangi", "Pāpeitosi"),
CountryLocalization("by", "lea fakapelalusi", "Pelalusi"),
CountryLocalization("be", "lea fakafalanisē", "Pelesiume"),
CountryLocalization("bz", "lea fakapālangi", "Pelise"),
CountryLocalization("bj", "lea fakafalanisē", "Penini"),
CountryLocalization("bm", "lea fakapālangi", "Pēmuta"),
CountryLocalization("bt", "lea fakatisōngika", "Pūtani"),
CountryLocalization("bo", "lea fakasipēnisi", "Polīvia"),
CountryLocalization("ba", "lea fakaposinia", "Posinia mo Hesikōvina"),
CountryLocalization("bw", "lea fakapālangi", "Potisiuana"),
CountryLocalization("br", "lea fakapotukali", "Palāsili"),
CountryLocalization("io", "lea fakapālangi", "Potu fonua moana ʻInitia fakapilitānia"),
CountryLocalization("vg", "lea fakapālangi", "ʻOtumotu Vilikini fakapilitānia"),
CountryLocalization("bn", "lea fakamalei", "Pulunei"),
CountryLocalization("bg", "lea fakapulukalia", "Pulukalia"),
CountryLocalization("bf", "lea fakafalanisē", "Pekano Faso"),
CountryLocalization("bi", "lea fakafalanisē", "Puluniti"),
CountryLocalization("kh", "lea fakakamipōtia", "Kamipōtia"),
CountryLocalization("cm", "lea fakapasaʻa", "Kameluni"),
CountryLocalization("ca", "lea fakafalanisē", "Kānata"),
CountryLocalization("ic", "lea fakasipēnisi", "ʻOtumotu Kaneli"),
CountryLocalization("cv", "lea fakakapuvelitianu", "Muiʻi Vēte"),
CountryLocalization("bq", "lea fakahōlani", "Kalipiane fakahōlani"),
CountryLocalization("ky", "lea fakapālangi", "ʻOtumotu Keimeni"),
CountryLocalization("cf", "lea lingikala", "Lepupelika ʻAfilika Lotoloto"),
CountryLocalization("ea", "lea fakasipēnisi", "Siuta mo Melila"),
CountryLocalization("td", "lea fakaʻalepea", "Sāti"),
CountryLocalization("cl", "lea fakasipēnisi", "Sili"),
CountryLocalization("cn", "lea fakatipeti", "Siaina"),
CountryLocalization("cx", "lea fakapālangi", "Motu Kilisimasi"),
CountryLocalization("cc", "lea fakapālangi", "ʻOtumotu Koko"),
CountryLocalization("co", "lea fakasipēnisi", "Kolomipia"),
CountryLocalization("km", "lea fakaʻalepea", "Komolosi"),
CountryLocalization("cg", "lea lingikala", "Kongo - Palasavila"),
CountryLocalization("cd", "lea fakasuahili", "Kongo - Kinisasa"),
CountryLocalization("ck", "lea fakapālangi", "ʻOtumotu Kuki"),
CountryLocalization("cr", "lea fakasipēnisi", "Kosita Lika"),
CountryLocalization("hr", "lea fakakuloisia", "Kuloisia"),
CountryLocalization("cu", "lea fakasipēnisi", "Kiupa"),
CountryLocalization("cw", "lea fakahōlani", "Kulasao"),
CountryLocalization("cy", "lea fakapālangi", "Saipalesi"),
CountryLocalization("cz", "lea fakaseki", "Sēkia"),
CountryLocalization("ci", "lea fakafalanisē", "Matafonua ʻAivolī"),
CountryLocalization("dk", "lea fakapālangi", "Tenimaʻake"),
CountryLocalization("dg", "lea fakapālangi", "Tieko Kāsia"),
CountryLocalization("dj", "lea fakafalanisē", "Siputi"),
CountryLocalization("dm", "lea fakapālangi", "Tominika"),
CountryLocalization("do", "lea fakasipēnisi", "Lepupelika Tominika"),
CountryLocalization("ec", "lea fakakuetisa", "ʻEkuetoa"),
CountryLocalization("eg", "lea fakaʻalepea", "ʻIsipite"),
CountryLocalization("sv", "lea fakasipēnisi", "ʻEle Salavatoa"),
CountryLocalization("gq", "lea fakasipēnisi", "ʻEkueta Kini"),
CountryLocalization("er", "lea fakatikilinia", "ʻElitulia"),
CountryLocalization("ee", "lea fakaʻesitōnia", "ʻEsitōnia"),
CountryLocalization("et", "lea fakaʻameliki", "ʻĪtiōpia"),
CountryLocalization("fk", "lea fakapālangi", "ʻOtumotu Fokulani"),
CountryLocalization("fo", "lea fakafaloe", "ʻOtumotu Faloe"),
CountryLocalization("fj", "lea fakapālangi", "Fisi"),
CountryLocalization("fi", "lea fakasuēteni", "Finilani"),
CountryLocalization("fr", "lea fakasiamane-suisilani", "Falanisē"),
CountryLocalization("gf", "lea fakafalanisē", "Kuiana fakafalanisē"),
CountryLocalization("pf", "lea fakafalanisē", "Polinisia fakafalanisē"),
CountryLocalization("ga", "lea fakafalanisē", "Kaponi"),
CountryLocalization("gm", "lea fakapālangi", "Kamipia"),
CountryLocalization("ge", "lea fakaʻosetiki", "Seōsia"),
CountryLocalization("de", "lea fakasōpia-hifo", "Siamane"),
CountryLocalization("gh", "lea fakapālangi", "Kana"),
CountryLocalization("gi", "lea fakapālangi", "Sipalālitā"),
CountryLocalization("gr", "lea fakakalisi", "Kalisi"),
CountryLocalization("gl", "lea fakakalaʻalisuti", "Kulinilani"),
CountryLocalization("gd", "lea fakapālangi", "Kelenatā"),
CountryLocalization("gp", "lea fakafalanisē", "Kuatalupe"),
CountryLocalization("gu", "lea fakapālangi", "Kuamu"),
CountryLocalization("gt", "lea fakasipēnisi", "Kuatamala"),
CountryLocalization("gg", "lea fakapālangi", "Kuenisī"),
CountryLocalization("gn", "lea fakafalanisē", "Kini"),
CountryLocalization("gw", "lea fakapotukali", "Kini-Pisau"),
CountryLocalization("gy", "lea fakapālangi", "Kuiana"),
CountryLocalization("ht", "lea fakafalanisē", "Haiti"),
CountryLocalization("hn", "lea fakasipēnisi", "Honitulasi"),
CountryLocalization("hk", "lea fakasiaina", "Hongi Kongi SAR Siaina"),
CountryLocalization("hu", "lea fakahungakalia", "Hungakalia"),
CountryLocalization("is", "lea fakaʻaisilani", "ʻAisilani"),
CountryLocalization("in", "lea fakanepali", "ʻInitia"),
CountryLocalization("id", "Indonesian", "ʻInitonēsia"),
CountryLocalization("ir", "lea fakapēsia", "ʻIlaani"),
CountryLocalization("iq", "lea fakaluli-tokelau", "ʻIlaaki"),
CountryLocalization("ie", "lea fakapālangi", "ʻAealani"),
CountryLocalization("im", "lea fakamangikī", "Motu Mani"),
CountryLocalization("il", "lea fakapālangi", "ʻIsileli"),
CountryLocalization("it", "lea fakasiamane", "ʻĪtali"),
CountryLocalization("jm", "lea fakapālangi", "Samaika"),
CountryLocalization("jp", "lea fakasiapani", "Siapani"),
CountryLocalization("je", "lea fakapālangi", "Selusī"),
CountryLocalization("jo", "lea fakaʻalepea", "Soatane"),
CountryLocalization("kz", "lea fakakasaki", "Kasakitani"),
CountryLocalization("ke", "lea fakasomali", "Keniā"),
CountryLocalization("ki", "lea fakapālangi", "Kilipasi"),
CountryLocalization("xk", "lea fakasēpia", "Kōsovo"),
CountryLocalization("kw", "lea fakaʻalepea", "Kueiti"),
CountryLocalization("kg", "lea fakalūsia", "Kīkisitani"),
CountryLocalization("la", "lea fakalau", "Lau"),
CountryLocalization("lv", "lea fakalativia", "Lativia"),
CountryLocalization("lb", "lea fakaʻalepea", "Lepanoni"),
CountryLocalization("ls", "lea fakapālangi", "Lesoto"),
CountryLocalization("lr", "lea fakapālangi", "Laipelia"),
CountryLocalization("ly", "lea fakaʻalepea", "Līpia"),
CountryLocalization("li", "lea fakasiamane-suisilani", "Likitenisiteini"),
CountryLocalization("lt", "lea fakalituania", "Lituania"),
CountryLocalization("lu", "lea fakalakisimipeki", "Lakisimipeki"),
CountryLocalization("mo", "lea fakapotukali", "Makau SAR Siaina"),
CountryLocalization("mk", "lea fakaʻalapēnia", "Masetōnia"),
CountryLocalization("mg", "lea fakafalanisē", "Matakasika"),
CountryLocalization("mw", "lea fakapālangi", "Malaui"),
CountryLocalization("my", "lea fakatamili", "Malēsia"),
CountryLocalization("ml", "lea fakafalanisē", "Māli"),
CountryLocalization("mt", "lea fakapālangi", "Malita"),
CountryLocalization("mh", "lea fakapālangi", "ʻOtumotu Māsolo"),
CountryLocalization("mq", "lea fakafalanisē", "Mātiniki"),
CountryLocalization("mr", "lea fakaʻalepea", "Maulitenia"),
CountryLocalization("mu", "lea fakamolisieni", "Maulitiusi"),
CountryLocalization("yt", "lea fakafalanisē", "Maiote"),
CountryLocalization("mx", "lea fakasipēnisi", "Mekisikou"),
CountryLocalization("fm", "lea fakapālangi", "Mikolonīsia"),
CountryLocalization("md", "lea fakalūsia", "Molotova"),
CountryLocalization("mc", "lea fakafalanisē", "Monako"),
CountryLocalization("mn", "lea fakamongokōlia", "Mongokōlia"),
CountryLocalization("me", "lea fakasēpia", "Monitenikalo"),
CountryLocalization("ms", "lea fakapālangi", "Moʻungaselati"),
CountryLocalization("ma", "lea fakatamasaiti-ʻatilasi-loloto", "Moloko"),
CountryLocalization("mz", "lea fakamakūa-meʻeto", "Mosēmipiki"),
CountryLocalization("mm", "lea fakapema", "Pema"),
CountryLocalization("na", "lea fakapālangi", "Namipia"),
CountryLocalization("nr", "lea fakapālangi", "Naulu"),
CountryLocalization("np", "lea fakanepali", "Nepali"),
CountryLocalization("nl", "lea fakapālangi", "Hōlani"),
CountryLocalization("nc", "lea fakafalanisē", "Niu Kaletōnia"),
CountryLocalization("nz", "lea fakapālangi", "Nuʻusila"),
CountryLocalization("ni", "lea fakasipēnisi", "Nikalakua"),
CountryLocalization("ne", "lea fakahausa", "Nisia"),
CountryLocalization("ng", "lea fakahausa", "Naisilia"),
CountryLocalization("nu", "lea fakapālangi", "Niuē"),
CountryLocalization("nf", "lea fakapālangi", "Motu Nōfoliki"),
CountryLocalization("kp", "lea fakakōlea", "Kōlea tokelau"),
CountryLocalization("mp", "lea fakapālangi", "ʻOtumotu Maliana tokelau"),
CountryLocalization("no", "lea fakasami-tokelau", "Noauē"),
CountryLocalization("om", "lea fakaʻalepea", "ʻOmani"),
CountryLocalization("pk", "lea fakapālangi", "Pākisitani"),
CountryLocalization("pw", "lea fakapālangi", "Palau"),
CountryLocalization("ps", "lea fakaʻalepea", "Potu Palesitaine"),
CountryLocalization("pa", "lea fakasipēnisi", "Panamā"),
CountryLocalization("pg", "lea fakapālangi", "Papuaniukini"),
CountryLocalization("py", "lea fakasipēnisi", "Palakuai"),
CountryLocalization("pe", "lea fakasipēnisi", "Pelū"),
CountryLocalization("ph", "lea fakafilipaini", "Filipaini"),
CountryLocalization("pn", "lea fakapālangi", "ʻOtumotu Pitikeni"),
CountryLocalization("pl", "lea fakapolani", "Polani"),
CountryLocalization("pt", "lea fakapotukali", "Potukali"),
CountryLocalization("pr", "lea fakapālangi", "Puēto Liko"),
CountryLocalization("qa", "lea fakaʻalepea", "Katā"),
CountryLocalization("ro", "lea fakalōmenia", "Lomēnia"),
CountryLocalization("ru", "lea fakatatale", "Lūsia"),
CountryLocalization("rw", "lea fakapālangi", "Luanitā"),
CountryLocalization("re", "lea fakafalanisē", "Lēunioni"),
CountryLocalization("ws", "lea fakapālangi", "Haʻamoa"),
CountryLocalization("sm", "lea fakaʻītali", "Sā Malino"),
CountryLocalization("sa", "lea fakaʻalepea", "Saute ʻAlepea"),
CountryLocalization("sn", "lea fakafalanisē", "Senekalo"),
CountryLocalization("rs", "lea fakasēpia", "Sēpia"),
CountryLocalization("cs", "lea fakasēpia", "Serbia and Montenegro"),
CountryLocalization("sc", "lea fakafalanisē", "ʻOtumotu Seiseli"),
CountryLocalization("sl", "lea fakapālangi", "Siela Leone"),
CountryLocalization("sg", "lea fakatamili", "Singapoa"),
CountryLocalization("sx", "lea fakapālangi", "Sā Mātini (fakahōlani)"),
CountryLocalization("sk", "lea fakasolāvaki", "Silōvakia"),
CountryLocalization("si", "lea fakasolovenia", "Silōvenia"),
CountryLocalization("sb", "lea fakapālangi", "ʻOtumotu Solomone"),
CountryLocalization("so", "lea fakaʻalepea", "Sōmalia"),
CountryLocalization("za", "lea fakapālangi", "ʻAfilika tonga"),
CountryLocalization("kr", "lea fakakōlea", "Kōlea tonga"),
CountryLocalization("ss", "lea fakanueli", "Sūtani fakatonga"),
CountryLocalization("es", "lea fakasipēnisi", "Sipeini"),
CountryLocalization("lk", "lea fakatamili", "Sīlangikā"),
CountryLocalization("bl", "lea fakafalanisē", "Sā Patēlemi"),
CountryLocalization("sh", "lea fakapālangi", "Sā Helena"),
CountryLocalization("kn", "lea fakapālangi", "Sā Kitisi mo Nevisi"),
CountryLocalization("lc", "lea fakapālangi", "Sā Lūsia"),
CountryLocalization("mf", "lea fakafalanisē", "Sā Mātini (fakafalanisē)"),
CountryLocalization("pm", "lea fakafalanisē", "Sā Piea mo Mikeloni"),
CountryLocalization("vc", "lea fakapālangi", "Sā Viniseni mo Kulenatini"),
CountryLocalization("sd", "lea fakaʻalepea", "Sūteni"),
CountryLocalization("sr", "lea fakahōlani", "Suliname"),
CountryLocalization("sj", "lea fakanouaē-pokimali", "Sivolopāti mo Sani Maieni"),
CountryLocalization("sz", "lea fakapālangi", "Suasilani"),
CountryLocalization("se", "lea fakasuēteni", "Suēteni"),
CountryLocalization("ch", "lea fakasiamane-suisilani", "Suisilani"),
CountryLocalization("sy", "lea fakaʻalepea", "Sīlia"),
CountryLocalization("st", "lea fakapotukali", "Sao Tomē mo Pilinisipe"),
CountryLocalization("tw", "lea fakasiaina", "Taiuani"),
CountryLocalization("tj", "lea fakatāsiki", "Tasikitani"),
CountryLocalization("tz", "lea fakamakōnite", "Tenisānia"),
CountryLocalization("th", "lea fakatailani", "Tailani"),
CountryLocalization("tl", "lea fakapotukali", "Timoa hahake"),
CountryLocalization("tg", "lea fakafalanisē", "Toko"),
CountryLocalization("tk", "lea fakapālangi", "Tokelau"),
CountryLocalization("to", "lea fakatonga", "Tonga"),
CountryLocalization("tt", "lea fakapālangi", "Tilinitati mo Topako"),
CountryLocalization("tn", "lea fakafalanisē", "Tunīsia"),
CountryLocalization("tr", "lea fakatoake", "Toake"),
CountryLocalization("tm", "lea fakatēkimeni", "Tūkimenisitani"),
CountryLocalization("tc", "lea fakapālangi", "ʻOtumotu Tuki mo Kaikosi"),
CountryLocalization("tv", "lea fakapālangi", "Tūvalu"),
CountryLocalization("um", "lea fakapālangi", "ʻOtumotu siʻi ʻo ʻAmelika"),
CountryLocalization("vi", "lea fakapālangi", "ʻOtumotu Vilikini fakaʻamelika"),
CountryLocalization("ug", "lea fakasuahili", "ʻIukanitā"),
CountryLocalization("ua", "lea fakaʻūkalaʻine", "ʻŪkalaʻine"),
CountryLocalization("ae", "lea fakaʻalepea", "ʻAlepea Fakatahataha"),
CountryLocalization("gb", "lea fakapālangi", "Pilitānia"),
CountryLocalization("us", "lea fakalakota", "Puleʻanga fakatahataha ʻAmelika"),
CountryLocalization("uy", "lea fakasipēnisi", "ʻUlukuai"),
CountryLocalization("uz", "lea fakaʻusipeki", "ʻUsipekitani"),
CountryLocalization("vu", "lea fakafalanisē", "Vanuatu"),
CountryLocalization("va", "lea fakaʻītali", "Kolo Vatikani"),
CountryLocalization("ve", "lea fakasipēnisi", "Venesuela"),
CountryLocalization("vn", "lea fakavietinami", "Vietinami"),
CountryLocalization("wf", "lea fakafalanisē", "ʻUvea mo Futuna"),
CountryLocalization("eh", "lea fakaʻalepea", "Sahala fakahihifo"),
CountryLocalization("ye", "lea fakaʻalepea", "Iemeni"),
CountryLocalization("zm", "lea fakapālangi", "Semipia"),
CountryLocalization("zw", "lea fakanetepele-tokelau", "Simipapuei"),
CountryLocalization("ax", "lea fakasuēteni", "ʻOtumotu ʻAlani"),
)
| 0
|
Kotlin
|
0
| 6
|
48dddb213920f7cc1d19d2ea34a61948a633dc38
| 16,852
|
xenoglot
|
Apache License 2.0
|
korma-triangulator/src/commonMain/kotlin/korlibs.math/geom/vector/VectorBuilderTriangleExt.kt
|
korlibs
| 666,376,560
| false
| null |
package korlibs.math.geom.vector
import korlibs.math.geom.Triangle
fun VectorBuilder.triangle(triangle: Triangle) {
polygon(triangle.points.map { it }, close = true)
}
fun VectorBuilder.triangles(triangles: List<Triangle>) {
for (triangle in triangles) triangle(triangle)
}
| 0
|
Kotlin
|
0
| 2
|
1569421f0412127bdd9fe01d7285177dcdf94f3d
| 284
|
korma-triangulator
|
MIT License
|
src/main/kotlin/com/mytrove/items/ItemFamilyCategory.kt
|
stackstorage
| 171,768,478
| false
| null |
package com.mytrove.items
/**
* Top-level category for {@link ItemFamily}.
*/
enum class ItemFamilyCategory {
/**
* Category for a family where all the member item types have a similar use.
*/
USE,
/**
* Category for a family where all the member item types are often in the same room.
*/
ROOM,
;
}
| 0
|
Kotlin
|
0
| 0
|
bc347c815802c861deddd9411b60123da0f2b2d5
| 325
|
items
|
Apache License 2.0
|
app/src/main/java/dev/eastar/recyclerview/DiffBindingDataArrayAdapterDemo.kt
|
eastar-dev
| 293,751,844
| false
| null |
package dev.eastar.recyclerview
import android.log.Log
import android.os.Bundle
import android.recycler.DiffBindingDataArrayAdapter
import android.recycler.DiffBindingDataArrayAdapter.DiffInfo
import android.recycler.NullItem
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.BindingAdapter
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
import dev.eastar.recyclerview.databinding.DiffbindingdataarrayadapterDemoBinding
import dev.eastar.recyclerview.model.Data
class DiffBindingDataArrayAdapterDemo : AppCompatActivity() {
private lateinit var mAdapter: DiffBindingDataArrayAdapter
private lateinit var bb: DiffbindingdataarrayadapterDemoBinding
private val vm by viewModels<DiffBindingDataArrayAdapterDemoViewModel>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
bb = DataBindingUtil.setContentView(this, R.layout.diffbindingdataarrayadapter_demo)
bb.vm = vm
bb.lifecycleOwner = this
//mAdapter = DiffBindingDataArrayAdapter(
// DiffInfo(R.layout.diffbindingdataarrayadapter_demo_item, BR.data, Data::class.java),
// DiffInfo(R.layout.recycler_activity_item_devider, DiffInfo.NoBr, NullItem::class.java),
// items = vm.items.value!!
//)
//bb.list.adapter = mAdapter
//mAdapter.setOnItemClickListener { parent, view, position, data ->
// Log.e(parent, view, position, data)
//}
}
}
@BindingAdapter("adapterData")
fun setAdapterData(
view: RecyclerView,
data: List<Any>?,
) {
Log.e(view, data)
if (view.adapter !is DiffBindingDataArrayAdapter)
view.adapter = DiffBindingDataArrayAdapter(
DiffInfo(R.layout.diffbindingdataarrayadapter_demo_item, BR.data, Data::class.java),
DiffInfo(R.layout.recycler_activity_item_devider, DiffInfo.NoBr, NullItem::class.java)
)
(view.adapter as DiffBindingDataArrayAdapter).run {
set(data)
}
}
| 0
|
Kotlin
|
0
| 0
|
ab4ed110351a73fc53ef6f349ecdd2fe76c87432
| 2,091
|
EastarRecyclerview
|
Apache License 2.0
|
TeamCode/src/main/java/org/firstinspires/ftc/teamcode/components/IMU.kt
|
RoshanAH
| 554,962,519
| false
|
{"Kotlin": 65941, "Java": 44938}
|
package org.firstinspires.ftc.teamcode.components
import com.qualcomm.hardware.rev.RevHubOrientationOnRobot
import com.qualcomm.robotcore.hardware.HardwareMap
import com.qualcomm.robotcore.hardware.IMU as RevIMU
import com.roshanah.jerky.math.Angle
import com.roshanah.jerky.math.rad
import org.firstinspires.ftc.teamcode.core.Component
import org.firstinspires.ftc.robotcore.external.navigation.AngleUnit
import kotlinx.coroutines.CoroutineScope
import kotlin.math.abs
import kotlin.math.PI
import kotlin.math.sign
import kotlin.math.floor
class IMU (
map: HardwareMap,
name: String,
private val orientation: RevHubOrientationOnRobot
) : Component{
val imu = map.get(RevIMU::class.java, name)
var heading: Angle = 0.0.rad
private set
private var lastMeasuredVel = 0.0
private var rotations = 0
var velocity: Double = 0.0
private set
override fun init(scope: CoroutineScope){
val params = RevIMU.Parameters(orientation)
imu.initialize(params)
imu.resetYaw()
}
override fun start(scope: CoroutineScope){}
override fun update(scope: CoroutineScope){
heading = imu.robotYawPitchRollAngles.getYaw(AngleUnit.RADIANS).rad
val rawVel = imu.getRobotAngularVelocity(AngleUnit.RADIANS).zRotationRate.toDouble()
var difference = rawVel - lastMeasuredVel
if(abs(difference) > PI){
rotations -= sign(difference).toInt()
}
lastMeasuredVel = rawVel
velocity = rotations * 2 * PI + rawVel
}
}
| 0
|
Kotlin
|
1
| 1
|
4435be448884baa316d2c011e6bfaadb7e59bfe3
| 1,484
|
power-play
|
BSD 3-Clause Clear License
|
archivarius/src/test/java/com/sherepenko/android/archivarius/entries/RawLogEntryTest.kt
|
asherepenko
| 237,088,692
| false
| null |
package com.sherepenko.android.archivarius.entries
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.common.truth.Truth.assertThat
import com.sherepenko.android.archivarius.utils.ArchivariusTestUtils
import com.sherepenko.android.archivarius.utils.DateTimeUtils
import java.io.ByteArrayOutputStream
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class RawLogEntryTest {
private lateinit var outputStream: ByteArrayOutputStream
@Before
fun setUp() {
outputStream = ByteArrayOutputStream()
ArchivariusTestUtils.setDefaultTimeZone()
}
@Test
@Throws(Exception::class)
fun testFormat() {
val date = DateTimeUtils.parse("2014-05-01T14:15:16.000+00:00")!!
val entry = TestRawLogEntry(date.time, 3)
ArchivariusTestUtils.writeTo(outputStream, entry)
assertThat(String(outputStream.toByteArray()))
.isEqualTo("TestRawLogEntry\n2014-05-01T14:15:16.000+00:00 3\n")
}
private class TestRawLogEntry(
eventTime: Long,
eventUpTime: Long
) : RawLogEntry(eventTime, eventUpTime)
}
| 0
|
Kotlin
|
0
| 2
|
2829053317fbf042ac0f67d39a412487d2ebaec5
| 1,170
|
android-archivarius
|
MIT License
|
app/src/main/java/com/example/ecommerce/ui/main_screen/MyTabs.kt
|
stymsaw
| 737,599,268
| false
|
{"Kotlin": 110066}
|
package com.example.ecommerce.ui.main_screen
import androidx.compose.foundation.background
import androidx.compose.material3.Icon
import androidx.compose.material3.Tab
import androidx.compose.material3.TabRow
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.example.ecommerce.data.mockdata.TabItem
import com.example.ecommerce.data.mockdata.TabItems
import com.example.ecommerce.ui.theme.app_blue
import com.example.ecommerce.ui.theme.app_blue_light
import com.example.ecommerce.ui.theme.app_orange
import com.example.ecommerce.ui.theme.app_white
@Composable
fun MyBottomTab(
modifier: Modifier = Modifier,
selectedTabIndex: Int,
tabItems: List<TabItem>,
onTabSelected: (Int) -> Unit,
) {
TabRow(
selectedTabIndex = selectedTabIndex,
containerColor = app_blue,
contentColor = app_blue_light,
modifier = modifier
.background(app_blue)
) {
tabItems.forEachIndexed { index, tabItem ->
Tab(
selected = selectedTabIndex == index,
onClick = {
onTabSelected(index)
},
text = {
Text(
text = tabItem.title,
color = app_white
)
},
icon = {
Icon(
imageVector =
if (index == selectedTabIndex) tabItem.selectedIcon
else tabItem.unSelectedIcon,
contentDescription = tabItem.title,
tint = app_orange,
)
}
)
}
}
}
@Preview
@Composable
private fun MyTabPreview() {
MyBottomTab(
modifier = Modifier,
selectedTabIndex = 1,
tabItems = TabItems.tabs,
onTabSelected = {
}
)
}
| 0
|
Kotlin
|
0
| 1
|
d117965449c37f9530ebe4ed406ff0ed0ffa6bb1
| 2,040
|
Ecommerce
|
The Unlicense
|
common/src/main/java/com/hh/common/base/BaseActivity.kt
|
yellowhai
| 469,705,102
| false
|
{"Kotlin": 326860}
|
/*
* 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
*
* 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.hh.common.base
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.WindowCompat
abstract class BaseActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
WindowCompat.setDecorFitsSystemWindows(window, false)
}
}
| 0
|
Kotlin
|
1
| 8
|
1463c4d222cd0bf36fd8deeccf295b4f68d479a5
| 982
|
PlayAndroid
|
Apache License 2.0
|
src/main/kotlin/dev/lunarcoffee/risako/bot/Extensions.kt
|
lunarcoffee
| 191,968,430
| false
|
{"Kotlin": 283896}
|
package dev.lunarcoffee.risako.bot
import dev.lunarcoffee.risako.bot.consts.TIME_FORMATTER
import java.time.LocalDateTime
fun Boolean.toYesNo() = if (this) "yes" else "no"
fun String.constToEng() = replace("_", " ").toLowerCase()
fun <T : Enum<T>> Enum<T>.constToEng() = name.replace("_", " ").toLowerCase()
fun LocalDateTime.localWithoutWeekday() = format(TIME_FORMATTER).drop(4)
| 0
|
Kotlin
|
0
| 0
|
8ae6c0fa0f85c90725667055493276116a0c0870
| 386
|
Risako
|
MIT License
|
server/src/main/kotlin/net/eplusx/mimosa/server/Routing.kt
|
eplusx
| 707,934,134
| false
|
{"Kotlin": 29820}
|
package net.eplusx.mimosa.server
import io.ktor.server.application.*
import io.ktor.server.request.receive
import io.ktor.server.response.*
import io.ktor.server.routing.*
import kotlinx.serialization.Serializable
@Serializable
data class Request(
val name: String,
)
fun Application.configureRouting() {
routing {
post("/") {
val request = call.receive<Request>()
call.respondText("Hello World, ${request.name}!")
}
}
}
| 0
|
Kotlin
|
0
| 0
|
3e3c5a326ad55b081ac9876f5eb9bcf2177b333c
| 475
|
mimosa
|
MIT License
|
app/src/main/java/com/rektapps/assaulttimer/dagger/module/ServiceModule.kt
|
N3-M3-S1S
| 199,498,741
| false
| null |
package com.rektapps.assaulttimer.dagger.module
import com.rektapps.assaulttimer.service.AssaultService
import com.rektapps.assaulttimer.service.AssaultsUpdater
import com.rektapps.assaulttimer.service.IncomingAssaultService
import com.rektapps.assaulttimer.service.ManualNotificationsService
import com.rektapps.assaulttimer.service.impl.AssaultServiceImpl
import com.rektapps.assaulttimer.service.impl.AssaultsUpdaterImpl
import com.rektapps.assaulttimer.service.impl.IncomingAssaultServiceImpl
import com.rektapps.assaulttimer.service.impl.ManualNotificationsServiceImpl
import dagger.Binds
import dagger.Module
import dagger.Reusable
import javax.inject.Singleton
@Module(includes = [DatabaseModule::class, FactoryModule::class])
interface ServiceModule{
@Binds
@Singleton
fun providesAssaultService(assaultRepositoryImpl: AssaultServiceImpl) : AssaultService
@Binds
@Reusable
fun providesManualNotificationService(notificationRepositoryImpl: ManualNotificationsServiceImpl): ManualNotificationsService
@Binds
@Reusable
fun providesAssaultsUpdater(assaultsUpdaterImpl: AssaultsUpdaterImpl): AssaultsUpdater
@Binds
fun providesIncomingAssaultService(incomingAssaultServiceImpl: IncomingAssaultServiceImpl): IncomingAssaultService
}
| 0
|
Kotlin
|
0
| 0
|
0a01605890842182d00963cad4e3165e2da81b45
| 1,285
|
assault_timer
|
MIT License
|
domain/src/main/java/com/aconno/sensorics/domain/ifttt/NotificationDisplay.kt
|
recreational-snacker
| 163,322,239
| false
| null |
package com.aconno.sensorics.domain.ifttt
/**
* @author aconno
*/
interface NotificationDisplay {
fun displayAlertNotification(message: String)
}
| 0
|
Kotlin
|
0
| 0
|
18530c7272e685744f1b25f223124e9f67bfdd0b
| 152
|
Sensorics
|
Apache License 2.0
|
domain/src/main/java/com/aconno/sensorics/domain/ifttt/NotificationDisplay.kt
|
recreational-snacker
| 163,322,239
| false
| null |
package com.aconno.sensorics.domain.ifttt
/**
* @author aconno
*/
interface NotificationDisplay {
fun displayAlertNotification(message: String)
}
| 0
|
Kotlin
|
0
| 0
|
18530c7272e685744f1b25f223124e9f67bfdd0b
| 152
|
Sensorics
|
Apache License 2.0
|
app/src/main/kotlin/me/xizzhu/android/joshua/search/SearchViewModel.kt
|
TrendingTechnology
| 336,463,037
| true
|
{"Kotlin": 1016945}
|
/*
* Copyright (C) 2020 <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 me.xizzhu.android.joshua.search
import kotlinx.coroutines.flow.*
import me.xizzhu.android.joshua.core.*
import me.xizzhu.android.joshua.infra.activity.BaseSettingsViewModel
import me.xizzhu.android.joshua.utils.firstNotEmpty
data class SearchRequest(
val query: String, val instantSearch: Boolean,
val includeBookmarks: Boolean, val includeHighlights: Boolean, val includeNotes: Boolean
)
data class SearchResult(
val query: String, val verses: List<Verse>,
val bookmarks: List<Pair<Bookmark, Verse>>,
val highlights: List<Pair<Highlight, Verse>>,
val notes: List<Pair<Note, Verse>>,
val bookNames: List<String>, val bookShortNames: List<String>
)
class SearchViewModel(private val bibleReadingManager: BibleReadingManager,
private val bookmarkManager: VerseAnnotationManager<Bookmark>,
private val highlightManager: VerseAnnotationManager<Highlight>,
private val noteManager: VerseAnnotationManager<Note>,
settingsManager: SettingsManager) : BaseSettingsViewModel(settingsManager) {
private val _searchRequest = MutableStateFlow<SearchRequest?>(null)
val searchRequest: Flow<SearchRequest> = _searchRequest.filterNotNull()
fun requestSearch(request: SearchRequest) {
_searchRequest.value = request
}
fun search(query: String, includeBookmarks: Boolean, includeHighlights: Boolean, includeNotes: Boolean): Flow<SearchResult> = flow {
val currentTranslation = bibleReadingManager.currentTranslation().firstNotEmpty()
val verses = bibleReadingManager.search(currentTranslation, query)
val bookmarks: List<Pair<Bookmark, Verse>>
val highlights: List<Pair<Highlight, Verse>>
if (includeBookmarks || includeHighlights) {
val versesWithIndexes = verses.associateBy { it.verseIndex }
bookmarks = if (includeBookmarks) {
bookmarkManager.read(Constants.SORT_BY_BOOK).mapNotNull { bookmark ->
versesWithIndexes[bookmark.verseIndex]?.let { verse -> Pair(bookmark, verse) }
}
} else {
emptyList()
}
highlights = if (includeHighlights) {
highlightManager.read(Constants.SORT_BY_BOOK).mapNotNull { highlight ->
versesWithIndexes[highlight.verseIndex]?.let { verse -> Pair(highlight, verse) }
}
} else {
emptyList()
}
} else {
bookmarks = emptyList()
highlights = emptyList()
}
val notes = if (includeNotes) {
noteManager.search(query).let { notes ->
val versesWithNotes = bibleReadingManager.readVerses(currentTranslation, notes.map { it.verseIndex })
arrayListOf<Pair<Note, Verse>>().apply {
ensureCapacity(notes.size)
notes.forEach { note ->
add(Pair(note, versesWithNotes.getValue(note.verseIndex)))
}
}
}
} else {
emptyList()
}
emit(SearchResult(
query, verses, bookmarks, highlights, notes,
bibleReadingManager.readBookNames(currentTranslation),
bibleReadingManager.readBookShortNames(currentTranslation)
))
}
suspend fun saveCurrentVerseIndex(verseIndex: VerseIndex) {
bibleReadingManager.saveCurrentVerseIndex(verseIndex)
}
}
| 0
| null |
0
| 0
|
db9b681ca744bb9dc4a415cf1dec0de7e3f8fa1a
| 4,181
|
Joshua
|
Apache License 2.0
|
app/src/main/java/me/lazy_assedninja/demo/ui/retrofit/RetrofitListAdapter.kt
|
henryhuang1219
| 357,838,778
| false
| null |
package me.lazy_assedninja.demo.ui.retrofit
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.DiffUtil
import me.lazy_assedninja.demo.R
import me.lazy_assedninja.demo.databinding.RetrofitItemBinding
import me.lazy_assedninja.demo.library.ui.BaseListAdapter
import me.lazy_assedninja.demo.library.util.AppExecutors
import me.lazy_assedninja.demo.vo.YouBike
class RetrofitListAdapter(
appExecutors: AppExecutors,
private val viewModel: RetrofitViewModel
) : BaseListAdapter<YouBike, RetrofitItemBinding>(
appExecutors = appExecutors,
diffCallback = object : DiffUtil.ItemCallback<YouBike>() {
override fun areItemsTheSame(oldItem: YouBike, newItem: YouBike): Boolean {
return oldItem == newItem
}
override fun areContentsTheSame(oldItem: YouBike, newItem: YouBike): Boolean {
return oldItem.stationNo == newItem.stationNo
}
}
) {
override fun createBinding(parent: ViewGroup): RetrofitItemBinding {
return DataBindingUtil.inflate(
LayoutInflater.from(parent.context),
R.layout.retrofit_item,
parent,
false
)
}
override fun bind(binding: RetrofitItemBinding, item: YouBike) {
binding.youBike = item
binding.viewModel = viewModel
}
}
| 0
|
Kotlin
|
1
| 2
|
2f5a79974f8d6b6af516a8959824558324bab8ce
| 1,401
|
Android-Demo
|
Apache License 2.0
|
src/main/kotlin/io/github/clechasseur/adventofcode/y2022/Day2.kt
|
clechasseur
| 567,968,171
| false
| null |
package io.github.clechasseur.adventofcode.y2022
import io.github.clechasseur.adventofcode.y2022.data.Day2Data
object Day2 {
private val input = Day2Data.input
fun part1(): Int = input.lines().sumOf { score(it) }
fun part2(): Int = input.lines().sumOf { score2(it) }
private enum class Choice(val opponent: Char, val you: Char, val score: Int) {
ROCK('A', 'X', 1),
PAPER('B', 'Y', 2),
SCISSORS('C', 'Z', 3);
companion object {
fun forOpponent(c: Char): Choice = values().first { it.opponent == c }
fun forYou(c: Char): Choice = values().first { it.you == c }
fun forOutcome(opponent: Choice, outcome: Char): Choice = if (outcome == 'Y') {
opponent
} else when (opponent) {
ROCK -> if (outcome == 'X') SCISSORS else PAPER
PAPER -> if (outcome == 'X') ROCK else SCISSORS
SCISSORS -> if (outcome == 'X') PAPER else ROCK
}
}
}
private fun Choice.beats(other: Choice): Boolean? = if (other == this) null else when (this) {
Choice.ROCK -> other == Choice.SCISSORS
Choice.PAPER -> other == Choice.ROCK
Choice.SCISSORS -> other == Choice.PAPER
}
private fun score(match: String): Int {
val opponent = Choice.forOpponent(match[0])
val you = Choice.forYou(match[2])
return you.score + when (you.beats(opponent)) {
false -> 0
null -> 3
true -> 6
}
}
private fun score2(match: String): Int {
val opponent = Choice.forOpponent(match[0])
val you = Choice.forOutcome(opponent, match[2])
return you.score + when (you.beats(opponent)) {
false -> 0
null -> 3
true -> 6
}
}
}
| 0
|
Kotlin
|
0
| 0
|
7ead7db6491d6fba2479cd604f684f0f8c1e450f
| 1,835
|
adventofcode2022
|
MIT License
|
src/jvmTest/kotlin/main.kt
|
apereira435
| 336,340,523
| false
| null |
class jvmTest {
}
| 0
|
Kotlin
|
0
| 0
|
9a9340f245ca578fd53bfab7fc6dd7af178e57ad
| 18
|
take5
|
MIT License
|
mewwalletbl/src/main/java/com/myetherwallet/mewwalletbl/data/PurchasePrices.kt
|
MyEtherWallet
| 225,456,139
| false
| null |
package com.myetherwallet.mewwalletbl.data
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.android.parcel.Parcelize
import java.math.BigDecimal
@Parcelize
data class PurchasePrices(
@SerializedName("fiat_currency")
val fiatCurrency: String,
@SerializedName("crypto_currency")
val cryptoCurrency: String,
@SerializedName("price")
val price: BigDecimal
) : Parcelable
| 1
|
Kotlin
|
6
| 7
|
62f56849b4a7c0909cf00c20076bf036aa39192e
| 462
|
mew-wallet-android-biz-logic
|
MIT License
|
app/src/main/java/com/lttrung/notepro/domain/usecases/ResetPasswordUseCase.kt
|
lttrung2001
| 587,661,881
| false
| null |
package com.lttrung.notepro.domain.usecases
import io.reactivex.rxjava3.core.Single
import javax.inject.Singleton
@Singleton
interface ResetPasswordUseCase {
fun execute(code: String, newPassword: String): Single<Unit>
}
| 0
|
Kotlin
|
0
| 0
|
c4d5b4d167b092fc003f5a61849b043b6ea47367
| 226
|
note-pro
|
MIT License
|
auth/ui/src/main/java/com/niqr/auth/ui/screens/authentication/components/SignInWithGoogleButton.kt
|
Niqrs
| 619,145,854
| false
| null |
package com.niqr.auth.ui.screens.authentication.components
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.layout.*
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.niqr.auth.ui.R
import com.niqr.core.ui.theme.MonoTheme
@Composable
internal fun SignInWithGoogleButton(
onClick: () -> Unit
) {
OutlinedButton(
modifier = Modifier
.fillMaxWidth(),
onClick = onClick,
border = BorderStroke(1.5.dp, MaterialTheme.colorScheme.primary),
contentPadding = PaddingValues(
horizontal = 12.dp,
vertical = 10.dp
)
) {
Row(
verticalAlignment = Alignment.CenterVertically
) {
Icon(
modifier = Modifier.size(28.dp),
painter = painterResource(R.drawable.ic_google_logo_24dp),
contentDescription = null
)
Box(
modifier = Modifier.fillMaxWidth(),
contentAlignment = Alignment.Center
) {
Text(
text = stringResource(R.string.sign_in_with_google),
fontSize = 17.sp,
fontWeight = FontWeight(490)
)
}
}
}
}
@Preview
@Composable
private fun SignInWithGoogleButtonPreview() {
MonoTheme {
Box(
modifier = Modifier
.width(280.dp)
.height(100.dp),
contentAlignment = Alignment.Center
) {
SignInWithGoogleButton(
onClick = {}
)
}
}
}
| 1
|
Kotlin
|
0
| 1
|
2609d528b85685ab01343ef2bf066782409343cb
| 2,146
|
Mono
|
MIT License
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.