Commit f2039815 authored by Elena Berrios's avatar Elena Berrios
Browse files

Firebase functioning

parent 77560cdd
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -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
@@ -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());
                        }
+1 −1
Original line number Diff line number Diff line
@@ -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);
        }
+4 −4
Original line number Diff line number Diff line
@@ -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);
        }