Loading app/src/main/java/com/example/game2d/FirebaseActivity.java +7 −1 Original line number Diff line number Diff line Loading @@ -150,6 +150,9 @@ public class FirebaseActivity extends AppCompatActivity { for (QueryDocumentSnapshot document : task.getResult()) { Map<String, Object> userScoreMap = document.getData(); Log.d(TAG, "ID: "+document.getId()); String name = (String) userScoreMap.get("username"); Double scores = (Double) userScoreMap.get("score"); /* for (Map.Entry<String, Object> entry : userScoreMap.entrySet()) { //String user = entry.getKey(); Object scoreObj = entry.getValue(); //this is the score value Loading @@ -164,9 +167,12 @@ public class FirebaseActivity extends AppCompatActivity { Log.d(TAG,"the username: "+scoreObj.toString()); } big_userScoreMap.scoreboard.put(scoreObj.toString(), score); } */ big_userScoreMap.scoreboard.put(name, scores); } } else { Log.w(TAG, "Error getting documents.", task.getException()); } Loading app/src/main/java/com/example/game2d/LeaderboardActivity.java +1 −1 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ public class LeaderboardActivity extends AppCompatActivity { scoreView.setTextSize(20); scoreView.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); scoreView.setFontFeatureSettings("press_start_2p"); scoreView.setText(String.format("%s: %d", username, scoreboardObj.scoreboard.get("scrub daddy"))); scoreView.setText(String.format("%s: %f", username, scoreboardObj.scoreboard.get(username))); // Add the TextView to the LinearLayout scoreListLayout.addView(scoreView); } Loading app/src/main/java/com/example/game2d/Scoreboard.java +4 −4 Original line number Diff line number Diff line Loading @@ -5,13 +5,13 @@ import java.util.HashMap; import java.util.Map; public class Scoreboard implements Serializable { public Map<String, Long> scoreboard; public Map<String, Double> scoreboard; Scoreboard() { scoreboard = new HashMap<String, Long>(); scoreboard = new HashMap<String, Double>(); } public void add(String username, long score) { public void add(String username, double score) { if (scoreboard != null) { scoreboard.put(username, score); } Loading Loading
app/src/main/java/com/example/game2d/FirebaseActivity.java +7 −1 Original line number Diff line number Diff line Loading @@ -150,6 +150,9 @@ public class FirebaseActivity extends AppCompatActivity { for (QueryDocumentSnapshot document : task.getResult()) { Map<String, Object> userScoreMap = document.getData(); Log.d(TAG, "ID: "+document.getId()); String name = (String) userScoreMap.get("username"); Double scores = (Double) userScoreMap.get("score"); /* for (Map.Entry<String, Object> entry : userScoreMap.entrySet()) { //String user = entry.getKey(); Object scoreObj = entry.getValue(); //this is the score value Loading @@ -164,9 +167,12 @@ public class FirebaseActivity extends AppCompatActivity { Log.d(TAG,"the username: "+scoreObj.toString()); } big_userScoreMap.scoreboard.put(scoreObj.toString(), score); } */ big_userScoreMap.scoreboard.put(name, scores); } } else { Log.w(TAG, "Error getting documents.", task.getException()); } Loading
app/src/main/java/com/example/game2d/LeaderboardActivity.java +1 −1 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ public class LeaderboardActivity extends AppCompatActivity { scoreView.setTextSize(20); scoreView.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); scoreView.setFontFeatureSettings("press_start_2p"); scoreView.setText(String.format("%s: %d", username, scoreboardObj.scoreboard.get("scrub daddy"))); scoreView.setText(String.format("%s: %f", username, scoreboardObj.scoreboard.get(username))); // Add the TextView to the LinearLayout scoreListLayout.addView(scoreView); } Loading
app/src/main/java/com/example/game2d/Scoreboard.java +4 −4 Original line number Diff line number Diff line Loading @@ -5,13 +5,13 @@ import java.util.HashMap; import java.util.Map; public class Scoreboard implements Serializable { public Map<String, Long> scoreboard; public Map<String, Double> scoreboard; Scoreboard() { scoreboard = new HashMap<String, Long>(); scoreboard = new HashMap<String, Double>(); } public void add(String username, long score) { public void add(String username, double score) { if (scoreboard != null) { scoreboard.put(username, score); } Loading