Questions tagged [kotlin]

Kotlin is a statically typed programming language that compiles to JVM bytecode, JavaScript, or native binaries.

62 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6 votes
0 answers
198 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 ...
Jeroen Vannevel's user avatar
4 votes
0 answers
2k 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 ...
ansh sachdeva's user avatar
4 votes
0 answers
220 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 ...
Vitaliy-T's user avatar
  • 183
4 votes
0 answers
905 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 ...
leonardkraemer's user avatar
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). ...
Sean Dawson's user avatar
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,...
Sai's user avatar
  • 171
3 votes
0 answers
146 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 ...
durron597's user avatar
  • 918
3 votes
0 answers
1k 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 ...
Destroyer's user avatar
  • 477
3 votes
0 answers
288 views

Android BMI calculator using LiveData

I have made a Body mass index-calculator using ViewModel and LiveData. Source-code of the MainActivity: ...
michael.zech's user avatar
  • 4,294
3 votes
0 answers
151 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 ...
Zymus's user avatar
  • 187
3 votes
0 answers
947 views

Generic RecyclerView Adapter in Kotlin

I've just finished implementing a Generic RecyclerView adapter in my Android app, written in Kotlin. BaseAdapter.kt: ...
milancodes's user avatar
3 votes
0 answers
291 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 ...
Christian Hujer's user avatar
3 votes
0 answers
94 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. ...
LppEdd's user avatar
  • 161
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 ...
Dani Nuñez's user avatar
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 ...
Zymus's user avatar
  • 187
3 votes
0 answers
910 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. ...
Satyendra Kumar's user avatar
3 votes
0 answers
71 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. ...
Adam's user avatar
  • 321
3 votes
0 answers
446 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 ...
ostojan's user avatar
  • 151
3 votes
0 answers
816 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? ...
KarolDevz's user avatar
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. ...
Roland Illig's user avatar
  • 21.3k
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 ...
Ankur_009's user avatar
  • 131
3 votes
0 answers
153 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 : ...
Gorcyn's user avatar
  • 131
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 ...
CAD97's user avatar
  • 1,944
3 votes
0 answers
304 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 ...
MrPlow's user avatar
  • 489
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 ...
Sebastian Kramer's user avatar
2 votes
0 answers
160 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 ...
CJR's user avatar
  • 151
2 votes
0 answers
271 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 ...
Caleb Moore's user avatar
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 ...
PerfLearnling's user avatar
2 votes
0 answers
194 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 * ...
AdamHurwitz's user avatar
2 votes
0 answers
223 views

How to implement a single-value cache in RxJava 3?

Kotlin 1.3.+ RxJava 3.0.+ Kotest 4.1.+ ...
Andrey's user avatar
  • 121
2 votes
0 answers
55 views

Linked tree built from (n) leaves

Firstly, here is the relevant code. It is written in kotlin. ...
Emery Tanghanwaye's user avatar
2 votes
0 answers
352 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 ...
Ramanathan Ganesan's user avatar
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 ...
Ramanathan Ganesan's user avatar
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). ...
triplem's user avatar
  • 121
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 ...
user125756's user avatar
2 votes
0 answers
137 views

Knuth Morris Pratt substring search algorithm

Below you can find a Kotlin based implementation of the Knuth-Morris-Pratt substring search algorithm. ...
gil.fernandes's user avatar
2 votes
0 answers
322 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 ...
IAE's user avatar
  • 765
1 vote
0 answers
53 views

Dialog manager for Compose dialogs

I needed something that would help me keep dialogs in my Jetpack Compose desktop application under control and without dozens of *Visible variables etc, so I ...
t3chb0t's user avatar
  • 44.3k
1 vote
0 answers
84 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 ...
t3chb0t's user avatar
  • 44.3k
1 vote
0 answers
57 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. ...
Android Developer's user avatar
1 vote
0 answers
61 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 ...
Travis Griggs's user avatar
1 vote
0 answers
217 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 ...
michael.zech's user avatar
  • 4,294
1 vote
0 answers
36 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 ...
Christian Bongiorno's user avatar
1 vote
0 answers
308 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, ...
TBatist's user avatar
  • 11
1 vote
0 answers
178 views

Matrix implementation in Kotlin

I put this together for a task and thought some feedback would be useful. ...
OldCurmudgeon's user avatar
1 vote
0 answers
150 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 ...
Weeedooo's user avatar
1 vote
0 answers
61 views

Basic REST API in Ktor

I have written a basic REST endpoint in Ktor and would like some pointers. Application.kt ...
F.P's user avatar
  • 111
1 vote
0 answers
35 views

String tuple serializer

Please review my class which is responsible of serialization and deserialization of the StringTuple data class. ...
Piotr Aleksander Chmielowski's user avatar
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 ...
Klaas van Aarsen's user avatar
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 ...
Roland Illig's user avatar
  • 21.3k