I have this app:
MainActivity:
package com.HidiStudios.BeST;

import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;

import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.HidiStudios.BeST.R;
import com.google.android.gms.ads.AdError;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.FullScreenContentCallback;
import com.google.android.gms.ads.LoadAdError;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.OnUserEarnedRewardListener;
import com.google.android.gms.ads.initialization.InitializationStatus;
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;
import com.google.android.gms.ads.interstitial.InterstitialAd;
import com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback;
import com.google.android.gms.ads.rewarded.RewardItem;
import com.google.android.gms.ads.rewarded.RewardedAd;
import com.google.android.gms.ads.rewarded.RewardedAdLoadCallback;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;
import com.google.android.material.navigation.NavigationView;
import com.google.firebase.FirebaseApp;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.firestore.CollectionReference;
import com.google.firebase.firestore.DocumentReference;
import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.firestore.Query;
import com.google.firebase.firestore.QueryDocumentSnapshot;
import com.google.firebase.firestore.auth.User;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;


public class MainActivity extends AppCompatActivity {

    //variables
    private InterstitialAd mInterstitialAd;
    private RewardedAd mRewardedAd;
    private FirebaseAuth mAuth;
    private FirebaseFirestore db = FirebaseFirestore.getInstance();
    CollectionReference usersRef = db.collection("users");
    Query leaderboardQuery = usersRef.orderBy("score", Query.Direction.DESCENDING).limit(10);
    
    public int amount = 0;
    boolean state = false;


    private TextView mTextView;
    String text;


    //menu var
    DrawerLayout drawerLayout;
    NavigationView navigationView;
    ActionBarDrawerToggle drawerToggle;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // menuRelated
        menuConfig();

        //Initialize AdMob
        MobileAds.initialize(this, new OnInitializationCompleteListener() {
            @Override
            public void onInitializationComplete(@NonNull InitializationStatus initializationStatus) {
            }
        });

        //RewardedAdRelated
        loadRewardedAds();
        Button rewardedButton = findViewById(R.id.RewardedbtnAds);
        rewardedButton.setOnClickListener(view -> {
            showRewardedAds();
        });
        
        //InterstitialAdRelated
        loadInterstitialAd();
        Button interstitialButton = findViewById(R.id.IntbtnAds);
        interstitialButton.setOnClickListener(view -> {
           showInterstitialAd();
        });
        
        //BannerAdRelated
        Button bannerButton = findViewById(R.id.BannerbtnAds);
        bannerButton.setOnClickListener(view -> {
            bannerAd();
        });


        //ResetButtonRelated
        resetButton();

        //FirebaseAuth
        mAuth = FirebaseAuth.getInstance();
        FirebaseUser currentUser = mAuth.getCurrentUser(); //if user is signed in returns UID, else null
        updateUI(currentUser); //if userID is null, generated.

        //FirebaseDatabase

        //CoinRelated
        loadCoins();




    }

    //menu
    public void menuConfig(){
        drawerLayout = findViewById(R.id.drawer_layout);
        navigationView = findViewById(R.id.nav_view);
        drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.open, R.string.close);
        drawerLayout.addDrawerListener(drawerToggle);
        drawerToggle.syncState();
        Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
        navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                int id = item.getItemId();
                navigationView.bringToFront();

                if (id == R.id.home) {
                    Toast.makeText(MainActivity.this, "Home pressed", Toast.LENGTH_SHORT).show();
                } else if (id == R.id.leaderboard) {
                    Toast.makeText(MainActivity.this, "Leaderboard pressed", Toast.LENGTH_SHORT).show();
                    openLeaderboardActivity();
                } else if (id == R.id.gallery) {
                    Toast.makeText(MainActivity.this, "Gallery pressed", Toast.LENGTH_SHORT).show();
                } else if (id == R.id.about) {
                    Toast.makeText(MainActivity.this, "About pressed", Toast.LENGTH_SHORT).show();
                } else if (id == R.id.login) {
                    Toast.makeText(MainActivity.this, "Login pressed", Toast.LENGTH_SHORT).show();
                } else if (id == R.id.share) {
                    Toast.makeText(MainActivity.this, "Share pressed", Toast.LENGTH_SHORT).show();
                } else if (id == R.id.rate_us) {
                    Toast.makeText(MainActivity.this, "Rate us pressed", Toast.LENGTH_SHORT).show();
                }

                // Close drawer after item is selected.
                drawerLayout.closeDrawer(GravityCompat.START);
                return false; // return true if you want to indicate the item was selected.
            }

        });
    }
    @Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        if (drawerToggle.onOptionsItemSelected(item)) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    //bannerAds
    private void bannerAd() {
        AdView mAdView = findViewById(R.id.adView);
        AdRequest BannerAdRequest = new AdRequest.Builder().build();
        if (!state) {
            mAdView.loadAd(BannerAdRequest);
            mAdView.setVisibility(View.VISIBLE);
            state = true;
        } else {
            mAdView.setVisibility(View.GONE);
            state = false;
        }
    }

    //interstitialAds
    private void loadInterstitialAd() {
        AdRequest interstitialAdRequest = new AdRequest.Builder().build();
        InterstitialAd.load(this,getString(R.string.INTERSTITIAL_AD_UNIT_ID), interstitialAdRequest, new InterstitialAdLoadCallback() {
            @Override
            public void onAdLoaded(@NonNull InterstitialAd interstitialAd) {
                super.onAdLoaded(interstitialAd);
                mInterstitialAd = interstitialAd;
                interstitialAd.setFullScreenContentCallback(new FullScreenContentCallback(){
                    @Override
                    public void onAdClicked() {
                        super.onAdClicked();
                    }
                    @Override
                    public void onAdDismissedFullScreenContent() {
                        mInterstitialAd = null;
                        loadInterstitialAd();
                    }

                    @Override
                    public void onAdFailedToShowFullScreenContent(@NonNull AdError adError) {
                        mInterstitialAd = null;
                    }
                });
            }

                @Override
                public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
                    mInterstitialAd = null;
                    //error message is managed in showInterstitialAds() function
                }
            });
    }
    private void showInterstitialAd() {
        if (mInterstitialAd!=null) {
            mInterstitialAd.show(MainActivity.this);
        } else {
            Log.d("TAG", "The interstitial ad is not ready yet. Try again!");
            loadInterstitialAd(); // Try to load again if it wasn’t ready when the button was clicked
        }
    }
    
    //rewardedAds
    private void loadRewardedAds() {
        AdRequest RewardedAdRequest = new AdRequest.Builder().build();
        RewardedAd.load(this, getString(R.string.REWARDED_AD_UNIT_ID), RewardedAdRequest, new RewardedAdLoadCallback() {
            @Override
            public void onAdLoaded(@NonNull RewardedAd rewardedAd) {
                super.onAdLoaded(rewardedAd);
                mRewardedAd = rewardedAd;
                rewardedAd.setFullScreenContentCallback(new FullScreenContentCallback() {
                    @Override
                    public void onAdClicked() {
                        super.onAdClicked();
                    }

                    @Override
                    public void onAdDismissedFullScreenContent() {
                        super.onAdDismissedFullScreenContent();
                        loadRewardedAds();
                    }

                    @Override
                    public void onAdFailedToShowFullScreenContent(@NonNull AdError adError) {
                        super.onAdFailedToShowFullScreenContent(adError);
                        mRewardedAd = null;
                    }
                });
            }
            @Override
            public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
                super.onAdFailedToLoad(loadAdError);
                mRewardedAd = null;
                //error message is managed in showRewardedAds() function
            }
        });
    }
    private void showRewardedAds() {

        if (mRewardedAd!=null) {
            mRewardedAd.show(MainActivity.this, new OnUserEarnedRewardListener() {
                @Override
                public void onUserEarnedReward(@NonNull RewardItem rewardItem) {
                    amount += rewardItem.getAmount();
                    text = getResources().getString(R.string.coins_message, amount);
                    mTextView.setText(text);
                    saveCoinAmount();
                    saveToDB(false);
                }
            });
        } else {
            Toast.makeText(MainActivity.this,"Rewarded ad is not ready yet. Try again!", Toast.LENGTH_SHORT).show();
        }
    }

    //coins
    private void loadCoins(){
        loadCoinAmount(); //this is local save
        readFromDB();
        mTextView=findViewById(R.id.Coins);
        text = getResources().getString(R.string.coins_message, amount);
        mTextView.setText(text);
    }
    private void loadCoinAmount() {
        SharedPreferences sharedPreferences = getSharedPreferences("UserPreferences", MODE_PRIVATE);
        amount = sharedPreferences.getInt("coinsAmount", 0);
    }
    private void saveCoinAmount() {
        SharedPreferences sharedPreferences = getSharedPreferences("UserPreferences", MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putInt("coinsAmount", amount);
        editor.apply();
    }


    //reset
    private void resetButton(){
        Button resetButton = findViewById(R.id.resetButton);
        resetButton.setOnClickListener(view -> {

            confirmResetCoins();
        });
    }
    private void confirmResetCoins(){
        AlertDialog.Builder confirmation = new AlertDialog.Builder(this);
            confirmation.setTitle("Are you sure?");
            confirmation.setMessage("Your coin balance will be reset to 0");
            confirmation.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    resetCoins();
                }
            });
            confirmation.setNegativeButton("No", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                }
            });
            confirmation.create().show();
    }
    private void resetCoins() {
        amount = 0;
        saveCoinAmount();
        saveToDB(false);
        text = getResources().getString(R.string.coins_message, amount);
        mTextView.setText(text);
        Toast.makeText(MainActivity.this, "Coins have been reset!", Toast.LENGTH_SHORT).show();
    }

    //FirebaseAuth
    private void updateUI(FirebaseUser user) {
        if (user==null) { //if there's no user signed in
            mAuth.signInAnonymously().addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (task.isSuccessful()) {
                        FirebaseUser user = mAuth.getCurrentUser();
                        updateUI(user);

                    } else {
                        updateUI(null);
                    }
                }
            });
        }
    }

    //Firebase DB
    private void saveToDB(boolean Create) {
        Map<String, Object> userdb = new HashMap<>();
        userdb.put("score", amount);

        if (Create) {
            usersRef.document(Objects.requireNonNull(mAuth.getUid())).set(userdb) //update-set
                    .addOnSuccessListener(new OnSuccessListener<Void>() {
                        @Override
                        public void onSuccess(Void unused) {
                            Log.d("TagDB", "Successfully added");
                        }
                    })
                    .addOnFailureListener(new OnFailureListener() {
                        @Override
                        public void onFailure(@NonNull Exception e) {
                            Log.w("TagDB","Error adding document",e);
                        }
                    });
        } else {
            usersRef.document(Objects.requireNonNull(mAuth.getUid())).update(userdb) //update-set
                    .addOnSuccessListener(new OnSuccessListener<Void>() {
                        @Override
                        public void onSuccess(Void unused) {
                            Log.d("TagDB", "Successfully modified");
                        }
                    })
                    .addOnFailureListener(new OnFailureListener() {
                        @Override
                        public void onFailure(@NonNull Exception e) {
                            Log.w("TagDB","Error adding document",e);
                        }
                    });

        }

    }
    private void addNick() {
        Map<String, Object> userdb = new HashMap<>();
        userdb.put("nickname", "Hidiadam");

        usersRef.document(Objects.requireNonNull(mAuth.getUid())).update(userdb) //update-set
                .addOnSuccessListener(new OnSuccessListener<Void>() {
                    @Override
                    public void onSuccess(Void unused) {
                        Log.d("TagDB", "Successfully added nick");
                    }
                })
                .addOnFailureListener(new OnFailureListener() {
                    @Override
                    public void onFailure(@NonNull Exception e) {
                        Log.w("TagDB","Error adding document nick",e);
                    }
                });
    }

    private void readNick() {
        String userId = mAuth.getUid(); // Get the current authenticated user’s ID
        if (userId == null) {
            // Handle the case where there is no authenticated user
            Log.w("TagDB", "User ID is null, can’t fetch data.");
            return;
        }

        DocumentReference docRef = usersRef.document(userId);
        docRef.get()
                .addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
                    @Override
                    public void onSuccess(DocumentSnapshot documentSnapshot) {
                        String nick = documentSnapshot.getString("nickname");
                        if (nick != null) {
                            // Retrieves the score from the document
                            Log.d("TagDB", "User Firebase nickname: " + nick);
                        } else {
                            Log.d("TagDB", "No such document!");
                        }
                    }
                })
                .addOnFailureListener(new OnFailureListener() {
                    @Override
                    public void onFailure(@NonNull Exception e) {
                        Log.w("TagDB", "Error fetching document", e);
                    }
                });
    }


    private void readFromDB() {
        String userId = mAuth.getUid(); // Get the current authenticated user’s ID
        if (userId == null) {
            // Handle the case where there is no authenticated user
            Log.w("TagDB", "User ID is null, can’t fetch data.");
            return;
        }

        DocumentReference docRef = usersRef.document(userId);
        docRef.get()
                .addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
                    @Override
                    public void onSuccess(DocumentSnapshot documentSnapshot) {
                        if (documentSnapshot.exists()) {
                            // Retrieves the score from the document
                            Long score = documentSnapshot.getLong("score");
                            if (Math.toIntExact(score) != amount) {
                                amount = Math.toIntExact(score);
                                mTextView=findViewById(R.id.Coins);
                                text = getResources().getString(R.string.coins_message, amount);
                                mTextView.setText(text);
                                Toast.makeText(MainActivity.this, "Local coin amount overridden by Firebase score.", Toast.LENGTH_SHORT).show();
                                saveCoinAmount();
                            }
                            Log.d("TagDB", "User Firebase score: " + score);
                        } else {
                            Log.d("TagDB", "No such document!");
                            saveToDB(true);

                        }
                    }
                })
                .addOnFailureListener(new OnFailureListener() {
                    @Override
                    public void onFailure(@NonNull Exception e) {
                        Log.w("TagDB", "Error fetching document", e);
                    }
                });
    }

    private void readLeaderboard () {
        leaderboardQuery.get().addOnCompleteListener(task -> {
            if (task.isSuccessful()) {
                for (QueryDocumentSnapshot document : task.getResult()) {
                    amount = document.getData().size();
                    Log.d("TagDB", String.valueOf(document.getData()));
                    // Convert the document to a User class if you have one
                    // User user = document.toObject(User.class);
                    // Add the user to your leaderboard adapter or processing list
                }
            } else {
                Log.w("TagDB", "Error getting documents.", task.getException());
                amount = 969696;
            }
        });
    }

    private void openLeaderboardActivity() {
        Intent intent = new Intent(this, LeaderboardActivity.class);
        startActivity(intent);
    }




}


LeaderboardActivity:
package com.HidiStudios.BeST;

import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;

import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.MenuItem;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.material.navigation.NavigationView;
import com.google.firebase.firestore.CollectionReference;
import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.firestore.Query;
import com.google.firebase.firestore.QueryDocumentSnapshot;

import java.util.Objects;



public class LeaderboardActivity extends AppCompatActivity {

    DrawerLayout drawerLayout;
    NavigationView navigationView;
    ActionBarDrawerToggle drawerToggle;
    private FirebaseAuth mAuth;
    private FirebaseFirestore db = FirebaseFirestore.getInstance();
    CollectionReference usersRef = db.collection("users");

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_leaderboard);

        mAuth = FirebaseAuth.getInstance();
        
        menuConfig();

        leaderboard();
    }

    //menu
    public void menuConfig() {
        drawerLayout = findViewById(R.id.drawer_layout);
        navigationView = findViewById(R.id.nav_view);
        drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.open, R.string.close);
        drawerLayout.addDrawerListener(drawerToggle);
        drawerToggle.syncState();
        Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
        navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                int id = item.getItemId();
                navigationView.bringToFront();

                if (id == R.id.home) {
                    Toast.makeText(LeaderboardActivity.this, "Home pressed", Toast.LENGTH_SHORT).show();
                    Intent intent = new Intent(LeaderboardActivity.this, MainActivity.class);
                    startActivity(intent);
                } else if (id == R.id.leaderboard) {
                    Toast.makeText(LeaderboardActivity.this, "Contact pressed", Toast.LENGTH_SHORT).show();
                } else if (id == R.id.gallery) {
                    Toast.makeText(LeaderboardActivity.this, "Gallery pressed", Toast.LENGTH_SHORT).show();
                } else if (id == R.id.about) {
                    Toast.makeText(LeaderboardActivity.this, "About pressed", Toast.LENGTH_SHORT).show();
                } else if (id == R.id.login) {
                    Toast.makeText(LeaderboardActivity.this, "Login pressed", Toast.LENGTH_SHORT).show();
                } else if (id == R.id.share) {
                    Toast.makeText(LeaderboardActivity.this, "Share pressed", Toast.LENGTH_SHORT).show();
                } else if (id == R.id.rate_us) {
                    Toast.makeText(LeaderboardActivity.this, "Rate us pressed", Toast.LENGTH_SHORT).show();
                }

                // Close drawer after item is selected.
                drawerLayout.closeDrawer(GravityCompat.START);
                return false; // return true if you want to indicate the item was selected.
            }

        });

        AdView mAdView = findViewById(R.id.adView);
        AdRequest BannerAdRequest = new AdRequest.Builder().build();
        mAdView.loadAd(BannerAdRequest);
        mAdView.setVisibility(View.VISIBLE);

    }

    @Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        if (drawerToggle.onOptionsItemSelected(item)) {
            return true;
        }
        // handle other menu items here if necessary

        return super.onOptionsItemSelected(item);
    }


    //FirebaseDB
    private void leaderboard() {
        // Query to get all users ordered by score in descending order
        Query allUsersQuery = usersRef.orderBy("score", Query.Direction.DESCENDING);

        allUsersQuery.get().addOnCompleteListener(task -> {
            if (task.isSuccessful()) {
                LinearLayout leaderboardLayout = findViewById(R.id.leaderboardLayout);
                leaderboardLayout.removeAllViews(); // Clear the layout

                String currentUserId = mAuth.getUid(); // Get current user id
                int rank = 1; // Start counting ranks from the top player
                int currentUserRank = 0; // Added a variable to keep track of the current user rank

                boolean currentUserDisplayed = false;
                QueryDocumentSnapshot currentUserDoc = null;
                QueryDocumentSnapshot lastUserDoc = null;

                // Iterate through all documents to populate leaderboard and find current and last user
                for (QueryDocumentSnapshot document : task.getResult()) {
                    if (currentUserId.equals(document.getId())) {
                        currentUserDoc = document;
                        currentUserRank = rank;
                        // We exit from the for-loop as we found our current user.
                        break;
                    }
                    lastUserDoc = document;
                    rank++;
                }

                // Reset the rank counter
                rank = 1;

                // Iterate and display for the top 10 again, now that we have the current user document
                for (QueryDocumentSnapshot document : task.getResult()) {
                    if (rank <= 10) {
                        createLeaderboardEntry(document, leaderboardLayout, rank, currentUserId.equals(document.getId()));
                        if (currentUserId.equals(document.getId())) {
                            currentUserDisplayed = true; // The current user is within the top 10
                        }
                    }
                    lastUserDoc = document; // Keep track of the last user document for the worse score
                    rank++;
                }

                if (!currentUserDisplayed && currentUserDoc != null) {
                    // If the current user is not in the top 10, display their rank
                    placeholder(leaderboardLayout);
                    createLeaderboardEntry(currentUserDoc, leaderboardLayout, currentUserRank, true); // Use currentUserRank which has the accurate rank of the current user
                }

                if (lastUserDoc != null && rank > 10) {
                    // Display the last user with the worst score if there are more than 10 users
                    placeholder(leaderboardLayout);
                    createLeaderboardEntry(lastUserDoc, leaderboardLayout, rank - 1, false);
                }

            } else {
                Log.w("TagDB", "Error getting documents.", task.getException());
            }
        });
    }

    private void placeholder(LinearLayout leaderboardLayout) {
        TextView scoreView = new TextView(this);
        scoreView.setText("...");
        scoreView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
        scoreView.setGravity(Gravity.CENTER_HORIZONTAL);
        leaderboardLayout.addView(scoreView);
    }

    private void createLeaderboardEntry(DocumentSnapshot document, LinearLayout leaderboardLayout, int rank, boolean highlight) {
        TextView scoreView = new TextView(this);
        String nickname = document.getString("nickname");
        String score = document.getLong("score").toString();
        String text = rank > 0 ? rank + ". " : ""; // Add rank number if provided
        text += nickname != null ? nickname + " " + score : "Anonymous " + score;

        scoreView.setText(text);
        scoreView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
        scoreView.setGravity(Gravity.CENTER_HORIZONTAL);

        if (highlight) {
            // Highlight the current user; for example, by changing the text color
            scoreView.setTextColor(ContextCompat.getColor(this, R.color.highlight_color)); // Make sure to define highlight_color in your colors.xml
        }

        leaderboardLayout.addView(scoreView);
    }

}

Both does contain the menu related stuff.
How can I merge these into one common, and manage it in one place?