Project

General

Profile

« Previous | Next » 

Revision d8aa4ba8

Added by Leszek Koltunski over 4 years ago

Downloading High Scores: optimizations

View differences:

src/main/java/org/distorted/magic/RubikScoresView.java
67 67

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

  
70
  private int getLevelLayoutID(int level)
71
    {
72
    return 100+level;
73
    }
74

  
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76

  
77
  public void prepareView(FragmentActivity act)
70
  void prepareView(FragmentActivity act, final String[][][] values)
78 71
    {
79 72
    removeAllViews();
80 73

  
......
82 75
    LinearLayout layout = tab.findViewById(R.id.tabLayout);
83 76
    addView(tab);
84 77

  
85
    for(int i=1; i<=RubikActivity.MAX_SCRAMBLE; i++)
78
    for(int i=0; i<RubikActivity.MAX_SCRAMBLE; i++)
86 79
      {
87
      View level = inflate(act, R.layout.level_records, null);
88
      level.setId(getLevelLayoutID(i));
80
      LinearLayout level = (LinearLayout)inflate(act, R.layout.level_records, null);
89 81
      TextView text = level.findViewById(R.id.levelTitle);
90
      text.setText(act.getString(R.string.sc_placeholder,i));
82
      text.setText(act.getString(R.string.sc_placeholder,(i+1)));
91 83

  
92
      layout.addView(level);
93
      }
94
    }
84
      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];
95 89

  
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);
90
        if( name!=null && name.length()>0 )
91
          {
92
          View row = inflate(act, R.layout.level_row, null);
104 93

  
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);
94
          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);
108 97

  
109
      float real_time = time/10.0f;
98
          textCoun.setText(coun);
99
          textName.setText(name);
100
          textTime.setText(time);
110 101

  
111
      textName.setText(name);
112
      textTime.setText( String.valueOf(real_time) );
113
      textCountry.setText(country);
102
          level.addView(row);
103
          }
104
        }
114 105

  
115
      layout.addView(rowLay);
116
      }
117
    else
118
      {
119
      android.util.Log.e("receive", "level invalid: "+level);
106
      layout.addView(level);
120 107
      }
121 108
    }
122 109
  }

Also available in: Unified diff