Loading app/src/main/java/com/example/game2d/FirebaseActivity.java +5 −3 Original line number Diff line number Diff line Loading @@ -46,7 +46,8 @@ public class FirebaseActivity extends AppCompatActivity { TextView nameScore, chalkScore; //public Map<String, Object> userScoreMap; public Map<String, Long> big_userScoreMap = new HashMap<>(); //public Map<String, Long> big_userScoreMap = new HashMap<>(); Scoreboard big_userScoreMap = new Scoreboard(); int bestChalk; float percent; Loading Loading @@ -154,13 +155,14 @@ public class FirebaseActivity extends AppCompatActivity { if (scoreObj instanceof Long) { //if it's the score_value score = (Long) scoreObj; //big_userScoreMap.put(document.getId(),score); Log.d(TAG,"BIG size : "+ big_userScoreMap.size()); //Log.d(TAG,"BIG size : "+ big_userScoreMap.size()); //Log.d(TAG, "User: " + user + ", Score: " + score); } else { //else it's the username Log.d(TAG,"the username: "+scoreObj.toString()); } big_userScoreMap.put(scoreObj.toString(),score); // add <username,score> into the big big_userScoreMap.add(scoreObj.toString(),score); // add <username,score> into the big } } } else { Loading app/src/main/java/com/example/game2d/LeaderboardActivity.java +3 −1 Original line number Diff line number Diff line package com.example.game2d; import static com.example.game2d.MapUtil.sortByValue; //import static com.example.game2d.FirebaseActivity.; import android.annotation.SuppressLint; import android.graphics.Typeface; Loading @@ -21,6 +22,7 @@ import java.util.Vector; public class LeaderboardActivity extends AppCompatActivity { //big_userScoreData private LinearLayout scoreListLayout; @SuppressLint("DefaultLocale") Loading @@ -30,7 +32,7 @@ public class LeaderboardActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_leaderboard); Typeface customFont = Typeface.createFromAsset(getAssets(), "custom_font.ttf"); //Typeface customFont = Typeface.createFromAsset(getAssets(), "custom_font.ttf"); // Get reference to the LinearLayout that will hold the scores scoreListLayout = findViewById(R.id.score_list_layout); Loading app/src/main/java/com/example/game2d/Scoreboard.java 0 → 100644 +12 −0 Original line number Diff line number Diff line package com.example.game2d; import java.util.HashMap; import java.util.Map; public class Scoreboard { public Map<String, Long> scoreboard; public void add(String username, long score) { scoreboard.put(username,score); } } Loading
app/src/main/java/com/example/game2d/FirebaseActivity.java +5 −3 Original line number Diff line number Diff line Loading @@ -46,7 +46,8 @@ public class FirebaseActivity extends AppCompatActivity { TextView nameScore, chalkScore; //public Map<String, Object> userScoreMap; public Map<String, Long> big_userScoreMap = new HashMap<>(); //public Map<String, Long> big_userScoreMap = new HashMap<>(); Scoreboard big_userScoreMap = new Scoreboard(); int bestChalk; float percent; Loading Loading @@ -154,13 +155,14 @@ public class FirebaseActivity extends AppCompatActivity { if (scoreObj instanceof Long) { //if it's the score_value score = (Long) scoreObj; //big_userScoreMap.put(document.getId(),score); Log.d(TAG,"BIG size : "+ big_userScoreMap.size()); //Log.d(TAG,"BIG size : "+ big_userScoreMap.size()); //Log.d(TAG, "User: " + user + ", Score: " + score); } else { //else it's the username Log.d(TAG,"the username: "+scoreObj.toString()); } big_userScoreMap.put(scoreObj.toString(),score); // add <username,score> into the big big_userScoreMap.add(scoreObj.toString(),score); // add <username,score> into the big } } } else { Loading
app/src/main/java/com/example/game2d/LeaderboardActivity.java +3 −1 Original line number Diff line number Diff line package com.example.game2d; import static com.example.game2d.MapUtil.sortByValue; //import static com.example.game2d.FirebaseActivity.; import android.annotation.SuppressLint; import android.graphics.Typeface; Loading @@ -21,6 +22,7 @@ import java.util.Vector; public class LeaderboardActivity extends AppCompatActivity { //big_userScoreData private LinearLayout scoreListLayout; @SuppressLint("DefaultLocale") Loading @@ -30,7 +32,7 @@ public class LeaderboardActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_leaderboard); Typeface customFont = Typeface.createFromAsset(getAssets(), "custom_font.ttf"); //Typeface customFont = Typeface.createFromAsset(getAssets(), "custom_font.ttf"); // Get reference to the LinearLayout that will hold the scores scoreListLayout = findViewById(R.id.score_list_layout); Loading
app/src/main/java/com/example/game2d/Scoreboard.java 0 → 100644 +12 −0 Original line number Diff line number Diff line package com.example.game2d; import java.util.HashMap; import java.util.Map; public class Scoreboard { public Map<String, Long> scoreboard; public void add(String username, long score) { scoreboard.put(username,score); } }