https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
stackoverflow
  • u

    user

    06/30/2022, 11:11 AM
    Spring Kafka Streams : Custom Deserialization Error Handler implementation with Functional Programming I have set the ErrorHandlingDeserializer for both key & value, and a delegate as StringDeserializer & IntegerDeserializer for the key & value respectively.So far, this works well. When the IntegerDeserializer fails to deserialize a string input, how can I set the CommonErrorHandler? I am using @Bean + Consumer as the consumer. The control always goes to the DefaultErrorHandler in KafkaMessageListenerContainer as below: at...
  • u

    user

    06/30/2022, 11:11 AM
    Executing a callback only when reaching a certain state without user interactions Our app receives a notification with a PendingIntent that when clicked, opens the following screen: @Composable fun IntermediateMonthlyBillings( onDataAcquired: (AllStatementsByYear) -> Unit, myEwayLoggedInViewModel: MyEwayLoggedInViewModel = get() ) { val statementsByYear by myEwayLoggedInViewModel.statementsByYear.observeAsState(null) if (statementsByYear == null) { GenericLoader(type = MyLoaderType.LIGHT_BACKGROUND) } else { Button(onClick = {...
  • u

    user

    06/30/2022, 11:51 AM
    hiltViewModel method unresolved in composable function I am new to Android dev and need to build my first project for university. The university was using the old XML version with Java, but I wanted to learn Compose so I learnt Kotlin. Now after getting everything setup, I am trying to use hiltViewModel() method to inject the view model inside the composable function and I am getting an error. I watched this tutorial: <a href="

    https://www.youtube.com/watch?v=A7CGcFjQQtQ&amp;t=10sâ–¾

    " rel="nofollow...
  • u

    user

    06/30/2022, 12:11 PM
    How can i change back image like there? I open beghaviar and add call back to hide it. It work well. So I'd like to change back image also.

    https://i.stack.imgur.com/HAWtc.pngâ–¾

    https://i.stack.imgur.com/yCZui.pngâ–¾

  • u

    user

    06/30/2022, 12:31 PM
    JPA: check if one array overlaps another/do arrays have common items My tech stack is Kotlin/Spring Data JPA/Hibernate/Postgres. I implement PagingAndSortingRepository interface to initialize all logic I need to manage entities. Let's consider I have an entity class: @Entity @Table(name = "team") @TypeDefs( TypeDef(name = "jsonb", typeClass = JsonBinaryType::class), TypeDef(name = "list-array", typeClass = ListArrayType::class) ) data class TeamEntity( @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long? = null,...
  • u

    user

    06/30/2022, 1:11 PM
    How to do implement immutable spring properties without @ConstructorBinding In general, developers can implement immutable Spring properties through @ConstructorBinding Both java record type and kotlin data class can be used to declare immutable types, here use the kotlin data class to be the example. @ConfigurationProperites(prefix = "myframework") @ConstructorBinding data class MyFrameworkProperties( ...omit immutable properties here... ) However, I want this class to support all frameworks, like quarkus, not spring only. So I do not want to use any spring...
  • u

    user

    06/30/2022, 1:31 PM
    Grouping list by object except one field I have to group list items if the items fields are the same. Above in my code, it works what I want if every id is the same. But product ids are unique. For that reason, I cant make the right grouping. I want to make grouping by item except for id. data class Product( val id: Int, val name: String, val price: Int, val quantity: Int ) data class GroupedProduct( val product: Product, val count: Int, val totalQuantity: Int, val isGroup: Boolean ) var products =...
  • u

    user

    06/30/2022, 1:31 PM
    How to know which condition has failed in a if statement? How can we know which condition in the if statement has failed in java, kotlin or javascript? I did find this post, which does it with many if statements, but that is not what I wanted! This is what I have: In java boolean a = true; boolean b = false; boolean c = true; boolean d = false; if(a && b && c && d){ } else { // which condition has failed } In kotlin val a = true;...
  • u

    user

    06/30/2022, 2:11 PM
    How to scale the camera preview to any given dimensions or shapes in a translucent background using Jetpack Compose I have a dialog fragment with a translucent background. I want to place a camera preview on this dialog fragment either in the shape of a circle or a square. On setting the scale type as PreviewView.ScaleType.FIT_CENTER, the preview is as follows:

    camera preview with black bordersâ–¾

    Whereas, if I were to set the scale type as PreviewView.ScaleType.FILL_CENTER, the preview is as follows: <a...
  • u

    user

    06/30/2022, 2:11 PM
    Header in a XWPFDocument is only on the last page when adding section breaks I am trying to create a word document using Apache POI. This document includes images, and I need to flip the page with the image to be landscape oriented, while keeping the rest of the document portrait oriented. However, I also need to use a header (and a footer, but I assume it is gonna work the same way as headers do). The code I am using: val document = XWPFDocument() // the header I need to be on every page...
  • u

    user

    06/30/2022, 2:31 PM
    How Can I Add App Open Ads with Jetpack Compose? I Have a project in android using Koltin and jetpack compose, How Can I add App Open Ads? Any Help Guys!
  • u

    user

    06/30/2022, 2:51 PM
    Not able to activate a product id for in-app billing in my google play console I have an application where i added in-app billing library and setup of code is done , i have uploaded my aab file to closed testing and the app has been reviewed and approved , when i create a product id and try to activate , i keep getting errors , if anyone could help with this , Thank you When i click on 'Activate' , this is the error i'm getting An unexpected error has occurred. Please try again. (5DB42EFE -> this number keeps changing everytime) This is a screenshot of the error...
  • u

    user

    06/30/2022, 2:51 PM
    Implement ad banner in Fragment android I have managed to implement the anchored adaptive banner as explained in this tutorial (anchored adaptive banner). First within an Activity and then within a Fragment. override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { _binding = FragmentTestBinding.inflate(inflater, container, false)...
  • u

    user

    06/30/2022, 2:51 PM
    The 'kotlin-android-extensions' Gradle plugin is deprecated. Error [duplicate] I add ViewBinding to my project, but when I replace 'kotlin-android-extensions' in build-gradle with 'kotlin-parcelize' I get an error in MainActivity place.

    https://i.stack.imgur.com/FFYZj.pngâ–¾

  • u

    user

    06/30/2022, 2:51 PM
    How can I create a simple count down timer in HH:MM:SS and show them in a Lazy Column I was learning jetpack compose and I can't seem to get my head around how to create a simple countDownTimer. What I want to do is create a countDownTimer that accepts three inputs from the user (hours, minutes, and seconds), and then when I click on the start button I want to show the timer in a LazyColomun . Any link that you think might help me understand this is acceptable for me.
  • u

    user

    06/30/2022, 3:11 PM
    I am adding an ImageView in android app in android studio. The image size is 1.93MB. When I am running the AVD, app is getting closed due to an error This is the error I am getting : java.lang.RuntimeException: Canvas: trying to draw too large(115781908bytes) bitmap. Is there any way by which I can fix this without reducing the image quality?
  • u

    user

    06/30/2022, 3:11 PM
    @NotNull not working on nested object properties in a Kotlin class even though @Valid is added I have a spring-boot app in Kotlin. I have a model called MyModel with just two field : a, b NotNull validation works fine on a but it doesn't work on b although I've added @valid on top of b. So when I don't pass b in my api request, it doesn't invalidate the model, although it's invalid (since b is missing). I really don't know why it doesn't work. if I remove ? to enforce not nullness, then Jackson would throw exception when trying to deserializing the model. So I cannot make it...
  • u

    user

    06/30/2022, 3:11 PM
    How to solve android retrofit post image error 500 So I tried to upload image with multipart but i received 500 error code. I've tried it on postman and it worked well and it worked too with this code but without image. Am I wrong at multipart thing?

    ApiServiceâ–¾

    Filepathâ–¾

    MediaTypeâ–¾

    <a...
  • u

    user

    06/30/2022, 3:31 PM
    Class cast exception between parent and child classes I waas develop an app in kotlin, when I get to the following error:

    https://i.stack.imgur.com/b9GA4.pngâ–¾

    rise by the following check in the first line: (it.responseBase as ValidateOtpResponse).let {resp -> // error rise here if (resp.code == "200") { val sucessDialog = GenericDialog( context = requireContext(), icon =...
  • u

    user

    06/30/2022, 5:51 PM
    How to use BeanUtils.copyProperties on data classes? I recently discovered the method copyProperties from BeanUBeanUtilstils class and I was wondering how can I copy the properties of a class into a new empty class? for example: data class User(val name: String, age: Int) data class ConvertedUser(val name: String, age: Int, address: String) I already have a class User with the properties filled and I want to create a new class ConvertedUser using the copyProperties but I can't instantiate a new ConvertedUser without passing the parameters to...
  • u

    user

    06/30/2022, 5:51 PM
    Room database not working-2 Errors See Description When the app is ran, the following errors occur: Errors: C:\Users\John\AndroidStudioProjects\Todoit 2\app\build\tmp\kapt3\stubs\debug\com\example\todoit\data\TodoDao.java:11: error: Not sure how to handle insert method's return type. public abstract java.lang.Object addTodo(@org.jetbrains.annotations.NotNull() C:\Users\John\AndroidStudioProjects\Todoit 2\app\build\tmp\kapt3\stubs\debug\com\example\todoit\data\TodoDao.java:13: error: Type of the parameter must be a class annotated with @Entity...
  • u

    user

    06/30/2022, 6:11 PM
    suspend function testing with spock I have a simple function in kotlin like that : suspend fun createTicket(@Valid request: CreateTicketRequest, authentication: Authentication): HttpResponse { request.customerId = "customerId" logger().info("Receive by the client $request") return HttpResponse.created(service.create(request)) } I've already Mock the request and the authentication. So, I call it on Spock: def 'It should create a ticket with success'() { given: def request = createRequest(...
  • u

    user

    06/30/2022, 6:51 PM
    How to get separators position in a recycler view I have this recycler view that uses a PagingDataAdapter that has separators added by insertSeparators. These separators contain a string with a date such as "13 June". I need to get these separators positions but how can I do that since they are not exactly part of the recycler view? I need to be able to scroll to a separator when a word I have matches the separator's string. To do the scrolling I'm using the scrollToPosition method but the tricky part is getting the position of the...
  • u

    user

    06/30/2022, 6:51 PM
    How to use SpannableString in Kotlin MVVM I'm kinda stack with this scenario actually, Since I need to span some characters in my string, but still gives me a plain text. Do you guys have any suggestion here how to use SpannableString not directly using in TextView but instead assigning this to the String object and will be use later on the TextView? It is obvious it will work inside the activity and fragment. but I'm working on the outside of the context since I'm using a shared component. example: I have here a ui factory. fun...
  • u

    user

    06/30/2022, 6:51 PM
    ViewBind Imports in Build.gradle Not Working [Kotlin] "Compile_Incremental_With_Artigact_Transform Thanks for reading my question. I had a perfectly running android app before I updated the sdk or gradle. I was using id 'kotlin-android' id 'kotlin-android-extensions' In my plugins section in build.gradle(:app) and it was working fine up until yesterday. I got an error message that told me it was deprecated, so I updated to the appropriate imports to no avail id 'kotlin-parcelize' Did not work, I got this message Plugin [id: 'kotlin-parcelize'] was not found in any of the following...
  • u

    user

    06/30/2022, 7:11 PM
    How to encode bitmaps into animated webp file? I am retrieving bitmaps and delays from animated webp file and resizing it then I want to encode them into animated Webp file again. How can I achieve that? try{ val source_file:File = File(src) val drawable = GlideApp.with(context).load(source_file).skipMemoryCache(true) .diskCacheStrategy(DiskCacheStrategy.NONE) .submit().get() as WebpDrawable drawable.constantState val state =...
  • u

    user

    06/30/2022, 7:11 PM
    How to replace fragment outside of bottom sheet by clicking button inside of bottom sheet? So I've decided to make my app with single Activity. In one of my fragments (fragment(A)) I open bottom sheet by clicking Button open BS. Now the tricky park, inside bottom sheet there is a FragmentContainerView that has two fragments inside and I want to click Button B inside this FragmentContainerView (in fragment(B)) that would change fragment(A) to fragment(C) and close bottom sheet. I'm aware that by using code below it's possible to swap fragment and close bottom sheet (here I'm...
  • u

    user

    06/30/2022, 7:51 PM
    How to refresh a RecylcerView? I need to develop an app from university. When I start the app, the RecyclerView is displayed correctly. However, when I refresh the RecyclerView or switch to another TAP, the card layouts are no longer displayed. I get all the events from Firebase using an Event data class and pass them to the RecyclerAdapter. Can you help me so that the refresh works? Thanks a lot Augustin RecyclerAdapter: class RecyclerAdapter(val events: List) : RecyclerView.Adapter() { private lateinit var...
  • u

    user

    06/30/2022, 7:51 PM
    Android Studio Button not visible on Emulator I just created in Android Studio some new Project. I chose the "Basic Acitivity" Template. Just to play around i changed the Text and run the app and everything works so far. When I add some more text, it also gets displayed in the Emulator. Also some CalendarView is displayed. But a normal Button is not visible in the Emulator. What am I doing wrong here?

    https://i.stack.imgur.com/a81AH.pngâ–¾

    <a href="

    https://i.stack.imgur.com/b9pNE.pngâ–¾

    " rel="nofollow...
  • u

    user

    06/30/2022, 8:11 PM
    How to handle switch button in navigation drawer- Android Kotlin I have a navigation Drawer menu in my app and in one item i added a switch button. However, i couldn't reach the switch button to handle it. Here is my Switch layout; (This switch button will be open or close notifications. In the image below, "Bildirimler" means notifications in Turkish.) My Menu xml, And my Main Activity, class MainActivity : AppCompatActivity() { private lateinit var...
Powered by Linen
Title
u

user

06/30/2022, 8:11 PM
How to handle switch button in navigation drawer- Android Kotlin I have a navigation Drawer menu in my app and in one item i added a switch button. However, i couldn't reach the switch button to handle it. Here is my Switch layout; (This switch button will be open or close notifications. In the image below, "Bildirimler" means notifications in Turkish.) My Menu xml, And my Main Activity, class MainActivity : AppCompatActivity() { private lateinit var...
View count: 4