Skip to main content
The 2024 Developer Survey results are live! See the results
10 votes
Accepted

Find index of double number delimiter

The problems with the first approach ...
Tunaki's user avatar
  • 9,233
10 votes
Accepted

SlotMachine game as first Android app

Clear state rather than restart You use this function to restart the game: public void recreateGame(View v) { finish(); startActivity(getIntent()); } ...
janos's user avatar
  • 111k
10 votes
Accepted

Recyclerview Adapter for weather app - Makes API calls for each item

First issue You're calling the weather API on every OnBindViewHolder(), which means it will get called for each visible row, and on new rows entering, or re-...
Benito Bertoli's user avatar
8 votes

Android Activity with a RecyclerView inflated by a big ArrayList

I don't know much about Android so I will comment on a more general concern with the code. There is something I find makes your code difficult to read for me: I don't speak Italian. In fact, most ...
Phrancis's user avatar
  • 20.4k
6 votes
Accepted

Sudoku with Android

Singletons You have made your GameEngine and SudokuChecker as singletons, meaning that you are preventing multiple instances ...
Simon Forsberg's user avatar
6 votes
Accepted

Android splash screen

Using a thread for a SplashScreen is fine, however a much cleaner solution would to use a Handler as below... ...
Mekon's user avatar
  • 156
6 votes

Does this method contain multiple implementations?

Seemed fine at first, then I took another look... The validation function displays the error message? I'm sorry, but that's indeed a violation of SRP. You'd be better off returning a ...
Pimgd's user avatar
  • 22.3k
6 votes
Accepted

Validating an IP address and returning the reason it's invalid

Your code has three major errors that all the previous reviewers failed to spot. If I were a lecturer, I'd show your code to the students as an example why they should always use libraries, even doing ...
Rok Kralj's user avatar
  • 184
6 votes

Updating positions of enemies every frame

Some things you could try: Unless the waypoints change position, the objects will continue in the same direction each frame. This means you don't have to recalculate ...
Trent Bartlem's user avatar
6 votes

SlotMachine game as first Android app

// Do the math ... Doesn't provide much explanation. I would instead say: ...
Dair's user avatar
  • 5,906
6 votes
Accepted

Code for sorting items in recyclerView

You're right that the duplicate code in the sorters looks bad. To solve this, each sorter should only define the compare function, and all the rest should be done by the enum class. Or not even this. ...
Roland Illig's user avatar
  • 21.3k
5 votes

Android splash screen

The best way to do splash screens is creating a style and adding a drawable (the layout of the page) to this style; afterwards setting the activity theme the style you just created. drawable/...
Punpuf's user avatar
  • 151
5 votes
Accepted

Simple Background Thread Worker Class (follow-up)

Escape of this on the constructor When you call start the thread may receive the current object (this) and start execution ...
Bruno Costa's user avatar
  • 5,566
5 votes
Accepted

Reading complete contact information in Android

Use AsyncQueryHandler, a helper class to help make handling asynchronous ContentResolver queries easier. It basically wraps the ...
Amandeep Rohila's user avatar
5 votes
Accepted

Setting icons when a tab is selected

You check whether the index of the tab equals the position. If this is the case, use the selected icon, otherwise use the unselected one: ...
mtj's user avatar
  • 4,822
5 votes

Tic Tac Toe in Android

Favor enum values over magic values int c[][]; This holds the board and the numbers represent state. Consider ...
mdfst13's user avatar
  • 21.6k
5 votes
Accepted

Getting location using LiveData and FusedLocationProviderClient

Let me explain how to work with LiveData - ViewModel and Activity. Right now your ...
Akshay Chordiya's user avatar
5 votes
Accepted

Kotlin text validation

First of all, make attention - your code twice convert and check value. Suppose it's not efficient. Another tiny problem - 1280 and 1500 values is not change prefs.mtuSize… My code: ...
Victor Dmitrienko's user avatar
5 votes
Accepted

My Android app is really slow when getting simple data from PHP

When approaching optimization problems (and it kinda is one as you want to make a call faster) its generally best to first make sure that you understand exactly what is happening so when in doubt - ...
Azahe's user avatar
  • 265
5 votes

Calculator App with Kotlin and Android Studio

Crash Dividing by 0 crashes the app ungracefully. Detect this and show an error message. Warnings Check your "Problems" tab in Android studio. It tells you to use ...
ggorlen's user avatar
  • 3,813
5 votes

Android - A way to show/hide loader without writting false/true in every viewmodelScope.launch

If I interpret it correctly, you can basically wrap everything in a single method, and pass it a lambda: ...
Simon Forsberg's user avatar
5 votes
Accepted

Compose Grid With Lists

Looks quite good already, I haven't found any serious issues. The are some minor improvements that I would suggest, though. Small bugs I'm not sure how your data source looks like, but you import <...
Leviathan's user avatar
  • 428
4 votes
Accepted

Using generics to find a View by Class

This works but feels clunky This seems fine. It does the job well. I don't see how this can be done simpler, and I'm not aware of other existing method in the SDK that can help simplify this. any ...
janos's user avatar
  • 111k
4 votes
Accepted

Populating a Fragment/Activity dynamically on Android gets ugly

Layouts. Your biggest savings (in terms of line count) is going to be had by inflating XML layouts. By hardcoding dimensions in Java, all your sizes are going to un-scaled (so you're saying margin ...
mdd-sbo's user avatar
  • 457
4 votes

Validating an IP address and returning the reason it's invalid

A few additional comments to complement the other review: Avoid spelling errors, especially in user-visible strings The first error message has "octect" but what was meant was undoubtedly "octet". ...
Edward's user avatar
  • 66.5k
4 votes
Accepted

How do I reduce the use of if else in this display function?

I am sure there is a better way to do things instead of using the if-else statements. There certainly is. Not only is your current code quite difficult to read, it is also difficult to maintain. What ...
tim's user avatar
  • 25.1k
4 votes

Android recycler view adapter filter

Consider using iterator instead of for-looping. That will get rid of your index manipulation (decrement if element is removed). ...
Keith Lee's user avatar
4 votes
Accepted

Android recyclerview filter

Your main questions Can I optimize HashMap memory by using ArrayMap? Should I use comma separated positions in ...
janos's user avatar
  • 111k
4 votes

Text messaging app that allows you to interact with AI

In terms of staying organized, one thing you could keep in your mind is something called the Single Responsibility Principle. You may have heard about this before, but if not, it basically says that ...
Langecrew's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible