Skip to content

Commit

Permalink
Fixed random range
Browse files Browse the repository at this point in the history
  • Loading branch information
m-i-n-a-r committed Feb 29, 2024
1 parent 5213439 commit aa642a1
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;

public class RouletteFragment extends androidx.fragment.app.Fragment implements OnClickListener, View.OnLongClickListener, TextView.OnEditorActionListener {
private MainActivity act;
Expand Down Expand Up @@ -282,12 +281,11 @@ private void mainThrow() {
}

int n;
Random ran = new Random();
if (inRangeMode) {
// Best way to generate number in range TODO not so best, it's bugged!
n = ThreadLocalRandom.current().nextInt(minValue, maxValue + 1);
// ThreadLocalRandom only works on specific Android versions, I can't use it now
n = ran.nextInt(maxValue - minValue + 1) + minValue;
} else {
Random ran = new Random();

n = ran.nextInt(options.size());
// Insert in the recent list
bottomSheet.updateRecent(options, getContext());
Expand Down

0 comments on commit aa642a1

Please sign in to comment.