Revision cc5ec229
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/magic/RubikScoresView.java | ||
---|---|---|
20 | 20 |
package org.distorted.magic; |
21 | 21 |
|
22 | 22 |
import android.content.Context; |
23 |
import android.content.res.Resources; |
|
24 |
import android.graphics.BitmapFactory; |
|
23 | 25 |
import android.support.v4.app.FragmentActivity; |
24 | 26 |
import android.util.AttributeSet; |
25 | 27 |
import android.view.View; |
26 | 28 |
import android.widget.FrameLayout; |
29 |
import android.widget.ImageView; |
|
27 | 30 |
import android.widget.LinearLayout; |
28 | 31 |
import android.widget.TextView; |
29 | 32 |
|
... | ... | |
31 | 34 |
|
32 | 35 |
public class RubikScoresView extends FrameLayout |
33 | 36 |
{ |
34 |
int mPosition;
|
|
37 |
private boolean mCreated;
|
|
35 | 38 |
|
36 | 39 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
37 | 40 |
|
38 | 41 |
public RubikScoresView(Context context, AttributeSet attrs, int defStyle) |
39 | 42 |
{ |
40 | 43 |
super(context, attrs, defStyle); |
44 |
|
|
45 |
mCreated = false; |
|
41 | 46 |
} |
42 | 47 |
|
43 | 48 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
52 | 57 |
public RubikScoresView(Context context) |
53 | 58 |
{ |
54 | 59 |
super(context); |
55 |
} |
|
56 |
|
|
57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
58 |
|
|
59 |
public RubikScoresView(Context context, int position) |
|
60 |
{ |
|
61 |
super(context); |
|
62 | 60 |
|
63 |
mPosition = position; |
|
64 | 61 |
View view = inflate(context, R.layout.scores_downloading, null); |
65 | 62 |
addView(view); |
66 | 63 |
} |
... | ... | |
75 | 72 |
|
76 | 73 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
77 | 74 |
|
78 |
void prepareView(FragmentActivity act, final String[][][] values)
|
|
75 |
void prepareView(FragmentActivity act, final int[][] country, final String[][] name, final String[][] time)
|
|
79 | 76 |
{ |
77 |
if( mCreated ) return; |
|
78 |
|
|
80 | 79 |
removeAllViews(); |
81 | 80 |
|
82 | 81 |
View tab = inflate(act, R.layout.scores_tab, null); |
... | ... | |
91 | 90 |
|
92 | 91 |
for(int j=0; j<RubikScoresDownloader.MAX_PLACES; j++) |
93 | 92 |
{ |
94 |
String coun = values[i][j][0]; |
|
95 |
String name = values[i][j][1]; |
|
96 |
String time = values[i][j][2]; |
|
97 |
|
|
98 |
if( name!=null && name.length()>0 ) |
|
93 |
if( name[i][j] != null ) |
|
99 | 94 |
{ |
100 | 95 |
View row = inflate(act, R.layout.level_row, null); |
101 | 96 |
|
102 |
TextView textCoun = row.findViewById(R.id.level_row_country);
|
|
97 |
ImageView imgCoun = row.findViewById(R.id.level_row_country);
|
|
103 | 98 |
TextView textName = row.findViewById(R.id.level_row_name); |
104 | 99 |
TextView textTime = row.findViewById(R.id.level_row_time); |
105 | 100 |
|
106 |
textCoun.setText(coun);
|
|
107 |
textName.setText(name); |
|
108 |
textTime.setText(time); |
|
101 |
imgCoun.setImageResource(country[i][j]);
|
|
102 |
textName.setText(name[i][j]);
|
|
103 |
textTime.setText(time[i][j]);
|
|
109 | 104 |
|
110 | 105 |
level.addView(row); |
111 | 106 |
} |
... | ... | |
113 | 108 |
|
114 | 109 |
layout.addView(level); |
115 | 110 |
} |
111 |
|
|
112 |
mCreated = true; |
|
116 | 113 |
} |
117 | 114 |
} |
Also available in: Unified diff
Downloading High Scores: actually downloading scores!