Project

General

Profile

Download (4.6 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / magic / RubikScoresView.java @ a675474f

1
///////////////////////////////////////////////////////////////////////////////////////////////////
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
import android.support.v4.app.FragmentActivity;
24
import android.util.AttributeSet;
25
import android.view.View;
26
import android.widget.FrameLayout;
27
import android.widget.LinearLayout;
28
import android.widget.TextView;
29

    
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
    View view = inflate(context, R.layout.scores_downloading, null);
65
    addView(view);
66
    }
67

    
68
///////////////////////////////////////////////////////////////////////////////////////////////////
69

    
70
  void exception(final String exce)
71
    {
72
    TextView text = findViewById(R.id.downloading_text);
73
    text.setText(exce);
74
    }
75

    
76
///////////////////////////////////////////////////////////////////////////////////////////////////
77

    
78
  void prepareView(FragmentActivity act, final String[][][] values)
79
    {
80
    removeAllViews();
81

    
82
    View tab = inflate(act, R.layout.scores_tab, null);
83
    LinearLayout layout = tab.findViewById(R.id.tabLayout);
84
    addView(tab);
85

    
86
    for(int i=0; i<RubikActivity.MAX_SCRAMBLE; i++)
87
      {
88
      LinearLayout level = (LinearLayout)inflate(act, R.layout.level_records, null);
89
      TextView text = level.findViewById(R.id.levelTitle);
90
      text.setText(act.getString(R.string.sc_placeholder,(i+1)));
91

    
92
      for(int j=0; j<RubikScoresDownloader.MAX_PLACES; j++)
93
        {
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 )
99
          {
100
          View row = inflate(act, R.layout.level_row, null);
101

    
102
          TextView textCoun = row.findViewById(R.id.level_row_country);
103
          TextView textName = row.findViewById(R.id.level_row_name);
104
          TextView textTime = row.findViewById(R.id.level_row_time);
105

    
106
          textCoun.setText(coun);
107
          textName.setText(name);
108
          textTime.setText(time);
109

    
110
          level.addView(row);
111
          }
112
        }
113

    
114
      layout.addView(level);
115
      }
116
    }
117
  }
(7-7/11)