summaryrefslogtreecommitdiff
path: root/java/org/neocities/autoart/ballbounce/Highscores.java
blob: 092992e68e81dd80125efc2ad4c844a12cc28c00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package org.neocities.autoart.ballbounce;

import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.TypedValue;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class Highscores extends AppCompatActivity {

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

        SharedPreferences prefs = getSharedPreferences("ballBounceHighscores", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = prefs.edit();


        RelativeLayout rl = (RelativeLayout) findViewById(R.id.highscores_layout);

        int n = 0;

        for (int i = 0; i < Game.NUM_MODES; i++)
        {
            if (!prefs.contains("mode"+i))
                continue;
            TextView tv = new TextView(this);
            tv.setText(Game.MODE_NAMES[i] + ": " + (prefs.getInt("mode" + i, -1)));
            tv.setId(n + 100);

            tv.setTextColor(Color.rgb(0, 0, 0));
            tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
            RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                    RelativeLayout.LayoutParams.WRAP_CONTENT,
                    RelativeLayout.LayoutParams.WRAP_CONTENT);
            if (n > 0)
                params.addRule(RelativeLayout.BELOW, n+99);
            else
                params.addRule(RelativeLayout.BELOW, R.id.highscores_title);

            tv.setLayoutParams(params);
            rl.addView(tv);
            n++;


        }

    }
}