Project

General

Profile

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

magiccube / src / main / java / org / distorted / dialog / RubikDialogScoresView.java @ d5fb0e7e

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.dialog;
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.ImageView;
28
import android.widget.LinearLayout;
29
import android.widget.TextView;
30

    
31
import org.distorted.magic.R;
32
import org.distorted.network.RubikScoresDownloader;
33

    
34
///////////////////////////////////////////////////////////////////////////////////////////////////
35

    
36
public class RubikDialogScoresView extends FrameLayout
37
  {
38
  LinearLayout mLayout;
39

    
40
///////////////////////////////////////////////////////////////////////////////////////////////////
41

    
42
  public RubikDialogScoresView(Context context, AttributeSet attrs, int defStyle)
43
    {
44
    super(context, attrs, defStyle);
45
    }
46

    
47
///////////////////////////////////////////////////////////////////////////////////////////////////
48

    
49
  public RubikDialogScoresView(Context context, AttributeSet attrs)
50
    {
51
    super(context, attrs);
52
    }
53

    
54
///////////////////////////////////////////////////////////////////////////////////////////////////
55

    
56
  public RubikDialogScoresView(Context context)
57
    {
58
    super(context);
59

    
60
    View view = inflate(context, R.layout.dialog_scores_downloading, null);
61
    addView(view);
62
    }
63

    
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65

    
66
  void exception(final String exce)
67
    {
68
    TextView text = findViewById(R.id.downloading_text);
69
    text.setText(exce);
70
    }
71

    
72
///////////////////////////////////////////////////////////////////////////////////////////////////
73

    
74
  void prepareView(FragmentActivity act)
75
    {
76
    removeAllViews();
77

    
78
    View tab = inflate(act, R.layout.dialog_scores_tab, null);
79
    mLayout = tab.findViewById(R.id.tabLayout);
80
    addView(tab);
81
    }
82

    
83
///////////////////////////////////////////////////////////////////////////////////////////////////
84

    
85
  void addSection(LinearLayout section)
86
    {
87
    mLayout.addView(section);
88
    }
89

    
90
///////////////////////////////////////////////////////////////////////////////////////////////////
91

    
92
  LinearLayout createSection(FragmentActivity act, int scramble, final int[] country, final String[] name, final String[] time)
93
    {
94
    LinearLayout level = (LinearLayout)inflate(act, R.layout.dialog_scores_scramble_title, null);
95
    TextView text = level.findViewById(R.id.scoresScrambleTitle);
96
    text.setText(act.getString(R.string.sc_placeholder,(scramble+1)));
97

    
98
    for(int j = 0; j< RubikScoresDownloader.MAX_PLACES; j++)
99
      {
100
      if( name[j] != null )
101
        {
102
        View row = inflate(act, R.layout.dialog_scores_scramble_row, null);
103

    
104
        ImageView imgCoun = row.findViewById(R.id.scoresScrambleRowCountry);
105
        TextView textName = row.findViewById(R.id.scoresScrambleRowName);
106
        TextView textTime = row.findViewById(R.id.scoresScrambleRowTime);
107

    
108
        imgCoun.setImageResource(country[j]);
109
        textName.setText(name[j]);
110
        textTime.setText(time[j]);
111

    
112
        level.addView(row);
113
        }
114
      }
115

    
116
    return level;
117
    }
118
  }
(5-5/6)