Commit 50bca75d authored by Elena Berrios's avatar Elena Berrios
Browse files

Firebase in progress

parent 81e123d3
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -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;
@@ -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 {
+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;
@@ -21,6 +22,7 @@ import java.util.Vector;

public class LeaderboardActivity extends AppCompatActivity {

    //big_userScoreData
    private LinearLayout scoreListLayout;

    @SuppressLint("DefaultLocale")
@@ -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);
+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);
    }
}