1 |
f2a9be6d
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2020 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
|
|
// This file is part of Magic Cube. //
|
5 |
|
|
// //
|
6 |
|
|
// Magic Cube is free software: you can redistribute it and/or modify //
|
7 |
|
|
// it under the terms of the GNU General Public License as published by //
|
8 |
|
|
// the Free Software Foundation, either version 2 of the License, or //
|
9 |
|
|
// (at your option) any later version. //
|
10 |
|
|
// //
|
11 |
|
|
// Magic Cube is distributed in the hope that it will be useful, //
|
12 |
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14 |
|
|
// GNU General Public License for more details. //
|
15 |
|
|
// //
|
16 |
|
|
// You should have received a copy of the GNU General Public License //
|
17 |
|
|
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. //
|
18 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19 |
|
|
|
20 |
|
|
package org.distorted.magic;
|
21 |
|
|
|
22 |
|
|
import android.content.Context;
|
23 |
b8b38548
|
Leszek Koltunski
|
import android.support.v4.app.FragmentActivity;
|
24 |
f2a9be6d
|
Leszek Koltunski
|
import android.util.AttributeSet;
|
25 |
|
|
import android.view.View;
|
26 |
|
|
import android.widget.FrameLayout;
|
27 |
b8b38548
|
Leszek Koltunski
|
import android.widget.LinearLayout;
|
28 |
|
|
import android.widget.TextView;
|
29 |
f2a9be6d
|
Leszek Koltunski
|
|
30 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
31 |
|
|
|
32 |
|
|
public class RubikScoresView extends FrameLayout
|
33 |
|
|
{
|
34 |
|
|
int mPosition;
|
35 |
|
|
|
36 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
37 |
|
|
|
38 |
|
|
public RubikScoresView(Context context, AttributeSet attrs, int defStyle)
|
39 |
|
|
{
|
40 |
|
|
super(context, attrs, defStyle);
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
44 |
|
|
|
45 |
|
|
public RubikScoresView(Context context, AttributeSet attrs)
|
46 |
|
|
{
|
47 |
|
|
super(context, attrs);
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
51 |
|
|
|
52 |
|
|
public RubikScoresView(Context context)
|
53 |
|
|
{
|
54 |
|
|
super(context);
|
55 |
|
|
}
|
56 |
|
|
|
57 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
58 |
|
|
|
59 |
|
|
public RubikScoresView(Context context, int position)
|
60 |
|
|
{
|
61 |
|
|
super(context);
|
62 |
|
|
|
63 |
|
|
mPosition = position;
|
64 |
b8b38548
|
Leszek Koltunski
|
View view = inflate(context, R.layout.scores_downloading, null);
|
65 |
|
|
addView(view);
|
66 |
f2a9be6d
|
Leszek Koltunski
|
}
|
67 |
|
|
|
68 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
69 |
|
|
|
70 |
d8aa4ba8
|
Leszek Koltunski
|
void prepareView(FragmentActivity act, final String[][][] values)
|
71 |
b8b38548
|
Leszek Koltunski
|
{
|
72 |
|
|
removeAllViews();
|
73 |
|
|
|
74 |
|
|
View tab = inflate(act, R.layout.scores_tab, null);
|
75 |
|
|
LinearLayout layout = tab.findViewById(R.id.tabLayout);
|
76 |
|
|
addView(tab);
|
77 |
|
|
|
78 |
d8aa4ba8
|
Leszek Koltunski
|
for(int i=0; i<RubikActivity.MAX_SCRAMBLE; i++)
|
79 |
b8b38548
|
Leszek Koltunski
|
{
|
80 |
d8aa4ba8
|
Leszek Koltunski
|
LinearLayout level = (LinearLayout)inflate(act, R.layout.level_records, null);
|
81 |
b8b38548
|
Leszek Koltunski
|
TextView text = level.findViewById(R.id.levelTitle);
|
82 |
d8aa4ba8
|
Leszek Koltunski
|
text.setText(act.getString(R.string.sc_placeholder,(i+1)));
|
83 |
b8b38548
|
Leszek Koltunski
|
|
84 |
d8aa4ba8
|
Leszek Koltunski
|
for(int j=0; j<RubikScoresDownloader.MAX_PLACES; j++)
|
85 |
|
|
{
|
86 |
|
|
String coun = values[i][j][0];
|
87 |
|
|
String name = values[i][j][1];
|
88 |
|
|
String time = values[i][j][2];
|
89 |
b8b38548
|
Leszek Koltunski
|
|
90 |
d8aa4ba8
|
Leszek Koltunski
|
if( name!=null && name.length()>0 )
|
91 |
|
|
{
|
92 |
|
|
View row = inflate(act, R.layout.level_row, null);
|
93 |
b8b38548
|
Leszek Koltunski
|
|
94 |
d8aa4ba8
|
Leszek Koltunski
|
TextView textCoun = row.findViewById(R.id.level_row_country);
|
95 |
|
|
TextView textName = row.findViewById(R.id.level_row_name);
|
96 |
|
|
TextView textTime = row.findViewById(R.id.level_row_time);
|
97 |
b8b38548
|
Leszek Koltunski
|
|
98 |
d8aa4ba8
|
Leszek Koltunski
|
textCoun.setText(coun);
|
99 |
|
|
textName.setText(name);
|
100 |
|
|
textTime.setText(time);
|
101 |
b8b38548
|
Leszek Koltunski
|
|
102 |
d8aa4ba8
|
Leszek Koltunski
|
level.addView(row);
|
103 |
|
|
}
|
104 |
|
|
}
|
105 |
b8b38548
|
Leszek Koltunski
|
|
106 |
d8aa4ba8
|
Leszek Koltunski
|
layout.addView(level);
|
107 |
b8b38548
|
Leszek Koltunski
|
}
|
108 |
f2a9be6d
|
Leszek Koltunski
|
}
|
109 |
|
|
}
|