Questions tagged [kotlin]
Kotlin is a statically typed programming language that compiles to JVM bytecode, JavaScript, or native binaries.
66
questions with no upvoted or accepted answers
6
votes
0
answers
189
views
Converting between cooking measurements
I've made an Android app that converts between cooking measurements, taking into account the type of product you use (that way it can convert between mass and volume by using the density). What are ...
4
votes
0
answers
1k
views
View Binding with Base Classes
UPDATE: After getting "a kind of" affirmation from various platforms( my discussions on twitter, reddit, other stack overflow posts,etc) I have written an article on this style of view ...
4
votes
0
answers
216
views
A better understanding for separation of concerns. Android; Kotlin
I am an Android developer with only 5 months of experience. I am still learning and trying to do my best.
Right now I am interested in concept of ...
4
votes
0
answers
902
views
Wrap location API in coroutines
In my app I need to query location and scan wifi periodically. To conserve power I need to change the rate dynamically, depending on the distance to the target. Also I want to wait for both ...
4
votes
0
answers
64
views
Time travelling through state history with persistent consequences
I am working on a game written in Kotlin that has a state management system similar to Redux. The state of the game is kept in a single place and is represented as immutable data classes (no logic). ...
4
votes
0
answers
287
views
Trying to avoid null types using lazy and lateinit Kotlin
I am using Kotlin from quite some time now, but I could not able to achieve not-null types for all the properties in Kotlin.
After what I learned by watching Kotlin in Google IO and a bit of research,...
3
votes
0
answers
141
views
Advent of Code 2021 Day 19
I am taking advantage of the recent layoffs to teach myself Kotlin. I am a career Java programmer, I've touched Kotlin before but not actively, and not for a few years. I wrote it all in one file ...
3
votes
0
answers
260
views
Android BMI calculator using LiveData
I have made a Body mass index-calculator using ViewModel and LiveData.
Source-code of the MainActivity:
...
3
votes
0
answers
149
views
Replacing type-check with Visitor in Immutable Event-Sourced Aggregate
In my previous question, one of the answers mentioned that I shouldn't be changing behavior based on the Event class
The whole point of classing is that you can get result without having to decide ...
3
votes
0
answers
933
views
Generic RecyclerView Adapter in Kotlin
I've just finished implementing a Generic RecyclerView adapter in my Android app, written in Kotlin.
BaseAdapter.kt:
...
3
votes
0
answers
284
views
Game of Life in Kotlin
I've implemented a Game of Life in Kotlin.
There are some major requirements on this solution:
Purely object-functional production code.
As close to an infinite universe as possible.
File ...
3
votes
0
answers
86
views
N-elements byte array to integer conversion (little/big endian and signed/unsigned)
I'm trying to come up with a function to convert byte arrays to their integer representation, using both
endianness, and with a signed/unsigned option.
...
3
votes
0
answers
98
views
ANDROID - Receive and manage markers in Google Maps
Recently, I've received negative feedback of interview's test. They say that they need somebody with higher technical level, the quality of the task was not good enough.
I upload it here, to request ...
3
votes
0
answers
63
views
Node Based Code Flow Builder
Background
In my development of a game engine, I realized the need to be able to construct processing units in a serializable way (code below does not show serialization, just the wiring).
I broke ...
3
votes
0
answers
900
views
Object Oriented Chess Design In Kotlin
I know there's a similar question to this: See here.
And I have taken the points mentioned there into consideration. However, I wanted to learn Kotlin and thought of writing OOP based Chess myself.
...
3
votes
0
answers
70
views
Listing YouTube videos using API with RxJava
I am new to RxJava and have the following code which I use to search YouTube videos via the API and ultimately display them in a list.
...
3
votes
0
answers
443
views
Timer application in MVP
I create simple Android timer application and I try to use MVP design pattern. I read some tutorials and after that I started writing code. My code is working correctly and as intended. There is ...
3
votes
0
answers
767
views
Endless scroll in kotlin (android)
This is the code of my function to endless scrolling. It's a good practice to bind new disposable in onscroll listener? What do you think about my code?
...
3
votes
0
answers
570
views
Reverse string in Kotlin
In the question of how to reverse a string in Java, a comment mentioned that combining Unicode code points need to be taken into account.
The below code works as intended for all test cases I tried. ...
3
votes
0
answers
266
views
Search GitHub users when text field changes in Kotlin Android app
Problem: Search for users by their name using the GitHub API (sorted by the number of followers) and display the results in a RecyclerView.
Implementation: Hitting the GitHub API every time when user ...
3
votes
0
answers
151
views
BDD on Android with Kotlin
I am considering an approach fo BDD tests on Android.
The sample app — a simple messenger — has been made in Kotlin, so will be the tests.
I ended up with something like this :
...
3
votes
0
answers
1k
views
Kotlin fuzzy matching
This is a pseudo-follow up to Kotlin Data Class Wildcard: taking in advice from that question I came upon a better but quite different solution to the same problem.
The problem: fuzzy matching AST ...
3
votes
0
answers
302
views
Console command parser for my custom Libgdx console (gamedev)
For a game I'm writing using LibGDX framework and Kotlin language, I've decided to make a dev console. This is a WIP line parser. Since there's already a decent amount of code written I've decided to ...
3
votes
0
answers
1k
views
Roman number converter in Kotlin
I'm learning kotlin and java. As a code-kata I wrote the roman to decimal converter. I'd be very grateful for code review.
I was trying to keep things simple and funcional. I'd especially appreciate ...
2
votes
1
answer
279
views
Android: Navigation with Hilt + Jetpack Compose
The project is simple:
Login screen and a forgot password screen. You can navigate from Login to ForgotPassword.
I feel like I overcomplicated things, but I don't know if (and how) it can be ...
2
votes
0
answers
908
views
Jetpack compose login screen + ViewModel
Im working on the login screen for my application. It has fields for users email and password. Also users can click on forgot password button to send an email with new passsword. It can validate these ...
2
votes
0
answers
122
views
Android architecture and dependency injection of domain layer usecases
I am implementing some of the architectural designs from Google I/O's app to my own app, but I have come across something in their app that has created some confusion for me.
They have a domain layer ...
2
votes
0
answers
230
views
Kotlin AsyncPriorityQueue
Unbounded threadsafe suspending priority queue
Items are ordered by an integer priority value passed into the enqueue() method
dequeue() retrieves and removes the head of the queue or suspends until ...
2
votes
0
answers
42
views
Which of my string indexing functions in Kotlin is semantically closer to my Java one?
I have a working string indexing method in Java and did convert in Kotlin.
All methods shown below produce the same result but as I am really new to the Kotlin language I wanted to ask which of my two ...
2
votes
0
answers
180
views
2D Array Word Search: Complexity and Optimization
🧩 Objective
Determine whether a given word is contained in a 2D Array word search.
🔎 Question
1. What are the time and space complexities of the current algorithm?
Time complexity
Linear: \$O(2(r * ...
2
votes
0
answers
208
views
How to implement a single-value cache in RxJava 3?
Kotlin 1.3.+
RxJava 3.0.+
Kotest 4.1.+
...
2
votes
0
answers
55
views
Linked tree built from (n) leaves
Firstly, here is the relevant code. It is written in kotlin.
...
2
votes
0
answers
334
views
Canvas Drawing / Bucket Filing Kotlin
I have completed a solution for the below problem and uploaded it in Git Repo. I would be grateful if somebody can review in term of code quality, design and Kotlin language usage.
Repo
You're ...
2
votes
0
answers
2k
views
Program to draw ASCII art based on commands
I want to know how to improve the design of Canvas drawing implementation.
Canvas Drawing
This solution is to implement a console-based canvas drawing application.
Problem Statement
Description
...
2
votes
0
answers
47
views
Convert flat object hierarchy to json
I do work for a project currently, where the data is send to the server as application/x-www-form-urlencoded (which is bad, and it should be JSON, but unfortunately I am not able to change this one).
...
2
votes
0
answers
1k
views
Kotlin DAO with Exposed: How to reduce redundancy in classes?
I'm writing a Kotlin app that uses Exposed (https://github.com/JetBrains/Exposed) as a SQL wrapper to write and read objects from databases. The problem I'm facing is that I end up with 3 classes ...
2
votes
0
answers
133
views
Knuth Morris Pratt substring search algorithm
Below you can find a Kotlin based implementation of the Knuth-Morris-Pratt substring search algorithm.
...
2
votes
0
answers
320
views
Converting SpriteSheet Metadata .txt to .yaml
For practice I decided that I wanted to write an animation class for SpriteSheets. The problem is that a single Sprite can have different widths depending on the action they are drawn to act. A tool ...
1
vote
0
answers
58
views
Import large Excel files directly from XML streams into an SQLite database
I've got some pretty large Excel files with nearly 1M rows that are almost impossible to open and work with in Excel anymore that I'm migrating into a database. Desipte this these files will stick ...
1
vote
0
answers
47
views
Architecting my Compose UI
I have designed a layout that includes recipe details and three CTAs in the app bar to share, delete, and edit recipes. I need feedback regarding the architecture of my Compose UI.
...
1
vote
0
answers
51
views
Learning Jetpack Compose: TabBar with Paging Screens
I'm piecewise reimplementing an existing iOS app. My initial go at it visually looks like this:
I'm looking for any feedback on more idiomatic ways to implement what I've done. There's a couple of ...
1
vote
0
answers
148
views
Jetpack Compose: Items-list with Item-Details-view
The app is based upon an exercise from a Udemy-course. The purpose is to become familiar with LazyColumns. I've enhanced the exercise with a Details-view and a navigation between LazyColumn and ...
1
vote
0
answers
32
views
Kotlin JSR 310 validation annotation
So, I am trying to implement an annotation in Kotlin, and it works, but I definitely feel like I could do a lot better. Below is the code and some areas I think could be improved. The purpose of this ...
1
vote
0
answers
264
views
An automated jOOQ-query-builder based on input using JSON in Kotlin
In my current project, I have to build a criteria builder which users can use to find "contacts" (the definition of which is not relevant). For this, I have created the front-end in Elm, ...
1
vote
0
answers
169
views
Matrix implementation in Kotlin
I put this together for a task and thought some feedback would be useful.
...
1
vote
0
answers
134
views
Signing in with "Remember me" option implemented with Spring and Kotlin
I'm trying to implement authentication with "Remember me" option using Spring and Kotlin. I would really appriciate if someone could help me find potential issues with that implementation as ...
1
vote
0
answers
60
views
Basic REST API in Ktor
I have written a basic REST endpoint in Ktor and would like some pointers.
Application.kt
...
1
vote
0
answers
31
views
String tuple serializer
Please review my class which is responsible of serialization and deserialization of the StringTuple data class.
...
1
vote
0
answers
61
views
Design to separate client API from internal API in Kotlin for a chess engine
This is a follow-up from my previous review on this site. To be clear, the code is stand-alone, and does not depend on the previous review.
As before my goal is to come up with a design for a chess ...
1
vote
0
answers
87
views
Generate random letters containing a word
There is a popular game called 4 Pics 1 Word that presents to the user 4 pictures representing a common word. The word has to be typed by selecting some of the 9 random letters appearing below the ...