Revision 65bc1da3
Added by Leszek Koltunski 12 months ago
src/main/java/org/distorted/dialogs/RubikDialogScoresView.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package org.distorted.dialogs; |
11 | 11 |
|
12 |
import android.annotation.SuppressLint; |
|
13 | 12 |
import android.content.Context; |
14 | 13 |
import android.content.res.Resources; |
15 | 14 |
import androidx.fragment.app.FragmentActivity; |
... | ... | |
64 | 63 |
|
65 | 64 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
66 | 65 |
|
67 |
@SuppressLint("DefaultLocale") |
|
68 |
LinearLayout createSection(FragmentActivity act, int tab, String title, int level, final String[] country, final String[] name, final float[] time) |
|
66 |
LinearLayout createSection(FragmentActivity act, int tab, String title, int level, final String[] country, final String[] name, final int[] time) |
|
69 | 67 |
{ |
70 | 68 |
LinearLayout levelLayout = (LinearLayout)inflate(act, R.layout.dialog_scores_scramble_title, null); |
71 | 69 |
TextView text = levelLayout.findViewById(R.id.scoresScrambleTitle); |
... | ... | |
79 | 77 |
RubikScores scores = RubikScores.getInstance(); |
80 | 78 |
|
81 | 79 |
boolean inserted = false; |
82 |
long myRecordInMillis = scores.getRecord(tab, level);
|
|
83 |
float myRecordInSeconds = (myRecordInMillis/10)/100.0f;
|
|
80 |
int myRecordInMillis = scores.getRecord(tab, level);
|
|
81 |
String myRecord = ( myRecordInMillis<RubikScores.NO_RECORD ) ? formatRecord(myRecordInMillis) : "??";
|
|
84 | 82 |
String myName = scores.getName(); |
85 | 83 |
if( myName.length()==0 ) myName = act.getString(R.string.you); |
86 | 84 |
int myCountryID = res.getIdentifier( scores.getCountry(), "drawable", packageName); |
87 |
String myRecord = ( myRecordInMillis<RubikScores.NO_RECORD ) ? String.format("%.2f", myRecordInSeconds) : "??"; |
|
88 | 85 |
String theirTime; |
89 | 86 |
int theirCountryID; |
90 | 87 |
|
... | ... | |
97 | 94 |
{ |
98 | 95 |
if( name[j] != null ) |
99 | 96 |
{ |
100 |
if( myRecordInSeconds<time[j] && !inserted )
|
|
97 |
if( myRecordInMillis<time[j] && !inserted )
|
|
101 | 98 |
{ |
102 | 99 |
inserted = true; |
103 | 100 |
View row = createRow(act, myCountryID, myName, myRecord, height, red); |
... | ... | |
110 | 107 |
{ |
111 | 108 |
if( equals ) inserted=true; |
112 | 109 |
theirCountryID = res.getIdentifier( country[j], "drawable", packageName); |
113 |
theirTime = String.format("%.2f", time[j]);
|
|
110 |
theirTime = formatRecord(time[j]);
|
|
114 | 111 |
View row = createRow(act, theirCountryID, name[j], theirTime, height, equals ? red:white); |
115 | 112 |
levelLayout.addView(row); |
116 | 113 |
} |
... | ... | |
126 | 123 |
return levelLayout; |
127 | 124 |
} |
128 | 125 |
|
126 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
127 |
|
|
128 |
private String formatRecord(int time) |
|
129 |
{ |
|
130 |
time /= 10; |
|
131 |
int millis = time%100; |
|
132 |
time /= 100; |
|
133 |
int seconds = time%60; |
|
134 |
int minutes = time/60; |
|
135 |
|
|
136 |
return minutes + (seconds<10 ? ":0" : ":") + seconds + (millis<10 ? ".0" : ".") + millis; |
|
137 |
} |
|
138 |
|
|
129 | 139 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
130 | 140 |
|
131 | 141 |
private View createRow(FragmentActivity act, int countryID, String name, String time, int height, int color) |
Also available in: Unified diff
Improve the way we display time in the Scores dialog