16
votes
Accepted
Selecting an enum for a payment transaction
You're using the wrong tool for the job.
If there's ever going to be a loan that I will pay an amount to every week for 2 years, you're gonna have to write a script to generate the code for you, ...
10
votes
Accepted
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());
}
...
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-...
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 ...
7
votes
Accepted
Android utils class
I'm looking at this class and I'm confused.
The reason why is that I'm doing web programming so a dialog can be asked on different sessions.
In that case this class is useless.
In stead of holding ...
7
votes
Accepted
Recycler view with cursor adapter
First of all CursorAdapter is not designed for use with a RecyclerView. You are trying to hack something in there that would ...
7
votes
Accepted
Login UI for an Android app
Using an AsyncTask instead would be much better. You've got many callbacks to the UI thread, all of this you could do in the post execute method instead:
...
6
votes
Reuse a base class [Activity] handler in all sub classes for background work
You make some assumptions about your window in this line:
mHandler = getWindow().getDecorView().getHandler();
As mentioned by the Activity docs for getWindow()
...
6
votes
Accepted
Calculate sum of all the items in array list?
Naming
s is a bad parameter name. If there's nothing better, use editable.
Avoid abbreviations. ...
6
votes
Android unit converter
What you need is to use a common base unit that all your other units converts to.
For example, let's take a look at this:
...
6
votes
Selecting an enum for a payment transaction
There is a better way indeed, which is to have the installments value as an attribute of each enumeration value.
An as example, we can simply consider 2 of those ...
6
votes
Accepted
Sudoku with Android
Singletons
You have made your GameEngine and SudokuChecker as singletons, meaning that you are preventing multiple instances ...
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...
...
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 ...
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 ...
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 ...
6
votes
SlotMachine game as first Android app
// Do the math ...
Doesn't provide much explanation. I would instead say:
...
5
votes
Accepted
5
votes
Android app with config and customization classes
Public class, private Interface?
I'm pretty confused by this setup.
The meaning is always trying working towards the most highest object( this case interface) possible.
I'm thinking that you created ...
5
votes
Iterate faster through the Android file system and find specific files using java multithreading
Have you read the docs of CopyOnWriteArrayList?
As the name suggest CopyOnWriteArrayList creates copy of underlying ArrayList with every mutation operation e.g. add or set. Normally ...
5
votes
Accepted
Speech reorganization helper class
Returning boolean
A pattern
if (condition) return true;
return false
is to be avoided.
return condition;
...
5
votes
Accepted
Determine differences between two Strings, for use in undo/redo feature
These are my suggestions:
separate the string comparison algorithm from the technology (Parcelable).
This will help you to test your algorithm without the burden of technology and increases ...
5
votes
Accepted
Searching two different elements in a same list
There's no problem with the performance. Java 8 filtering actually doesn't scan the whole stream, so the processing will be done only until the first element meeting the predicate is hit. So you're ...
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/...
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 ...
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 ...
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:
...
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
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
android × 800java × 681
performance × 74
kotlin × 69
beginner × 61
sqlite × 38
multithreading × 31
xml × 30
asynchronous × 23
object-oriented × 22
image × 19
design-patterns × 18
error-handling × 17
game × 16
animation × 16
json × 13
datetime × 12
layout × 12
rx-java × 12
c# × 11
authentication × 11
classes × 11
singleton × 11
mvvm × 11
strings × 10