Revision b8b38548
Added by Leszek Koltunski almost 6 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.support.v4.app.FragmentActivity; |
|
| 23 | 24 |
import android.util.AttributeSet; |
| 24 | 25 |
import android.view.View; |
| 25 | 26 |
import android.widget.FrameLayout; |
| 27 |
import android.widget.LinearLayout; |
|
| 28 |
import android.widget.TextView; |
|
| 26 | 29 |
|
| 27 | 30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 28 | 31 |
|
| ... | ... | |
| 58 | 61 |
super(context); |
| 59 | 62 |
|
| 60 | 63 |
mPosition = position; |
| 64 |
View view = inflate(context, R.layout.scores_downloading, null); |
|
| 65 |
addView(view); |
|
| 61 | 66 |
} |
| 62 | 67 |
|
| 63 | 68 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 64 | 69 |
|
| 65 |
@Override |
|
| 66 |
public void onAttachedToWindow() |
|
| 70 |
private int getLevelLayoutID(int level) |
|
| 67 | 71 |
{
|
| 68 |
super.onAttachedToWindow(); |
|
| 72 |
return 100+level; |
|
| 73 |
} |
|
| 69 | 74 |
|
| 70 |
Context context = getContext(); |
|
| 71 |
View view = inflate(context, R.layout.scores_downloading, null); |
|
| 72 |
addView(view); |
|
| 75 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 76 |
|
|
| 77 |
public void prepareView(FragmentActivity act) |
|
| 78 |
{
|
|
| 79 |
removeAllViews(); |
|
| 80 |
|
|
| 81 |
View tab = inflate(act, R.layout.scores_tab, null); |
|
| 82 |
LinearLayout layout = tab.findViewById(R.id.tabLayout); |
|
| 83 |
addView(tab); |
|
| 84 |
|
|
| 85 |
for(int i=1; i<=RubikActivity.MAX_SCRAMBLE; i++) |
|
| 86 |
{
|
|
| 87 |
View level = inflate(act, R.layout.level_records, null); |
|
| 88 |
level.setId(getLevelLayoutID(i)); |
|
| 89 |
TextView text = level.findViewById(R.id.levelTitle); |
|
| 90 |
text.setText(act.getString(R.string.sc_placeholder,i)); |
|
| 91 |
|
|
| 92 |
layout.addView(level); |
|
| 93 |
} |
|
| 94 |
} |
|
| 95 |
|
|
| 96 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 97 |
|
|
| 98 |
public void fillRow(FragmentActivity act, int level, String place, int time, String name, String country) |
|
| 99 |
{
|
|
| 100 |
if( level>=0 && level<RubikActivity.MAX_SCRAMBLE ) |
|
| 101 |
{
|
|
| 102 |
LinearLayout layout = findViewById(getLevelLayoutID(level+1)); |
|
| 103 |
View rowLay = inflate(act, R.layout.level_row, null); |
|
| 104 |
|
|
| 105 |
TextView textName = rowLay.findViewById(R.id.level_row_name); |
|
| 106 |
TextView textTime = rowLay.findViewById(R.id.level_row_time); |
|
| 107 |
TextView textCountry = rowLay.findViewById(R.id.level_row_country); |
|
| 108 |
|
|
| 109 |
float real_time = time/10.0f; |
|
| 110 |
|
|
| 111 |
textName.setText(name); |
|
| 112 |
textTime.setText( String.valueOf(real_time) ); |
|
| 113 |
textCountry.setText(country); |
|
| 114 |
|
|
| 115 |
layout.addView(rowLay); |
|
| 116 |
} |
|
| 117 |
else |
|
| 118 |
{
|
|
| 119 |
android.util.Log.e("receive", "level invalid: "+level);
|
|
| 120 |
} |
|
| 73 | 121 |
} |
| 74 | 122 |
} |
Also available in: Unified diff
Downloading High Scores