Project

General

Profile

« Previous | Next » 

Revision 7bb30586

Added by Leszek Koltunski 7 months ago

Remove all old UI 1.0 classes

View differences:

src/main/java/org/distorted/main/MainObjectPopup.java
37 37

  
38 38
  private final PopupWindow mPopup;
39 39
  private final int mMenuTextSize;
40
  private Button[] mLevel;
40 41

  
41 42
///////////////////////////////////////////////////////////////////////////////////////////////////
42 43

  
......
162 163
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(levelWidth,levelHeight);
163 164
    params.setMargins(margin,-margin,margin,-margin);
164 165

  
165
    Button[] level = new Button[LEVELS_SHOWN+1];
166
    mLevel = new Button[LEVELS_SHOWN+1];
166 167

  
167
    level[0] = layout.findViewById(R.id.level0);
168
    level[1] = layout.findViewById(R.id.level1);
169
    level[2] = layout.findViewById(R.id.level2);
170
    level[3] = layout.findViewById(R.id.level3);
171
    level[4] = layout.findViewById(R.id.level4);
172
    level[5] = layout.findViewById(R.id.level5);
173
    level[6] = layout.findViewById(R.id.level6);
174
    level[7] = layout.findViewById(R.id.level7);
175
    level[8] = layout.findViewById(R.id.levelM);
168
    mLevel[0] = layout.findViewById(R.id.level0);
169
    mLevel[1] = layout.findViewById(R.id.level1);
170
    mLevel[2] = layout.findViewById(R.id.level2);
171
    mLevel[3] = layout.findViewById(R.id.level3);
172
    mLevel[4] = layout.findViewById(R.id.level4);
173
    mLevel[5] = layout.findViewById(R.id.level5);
174
    mLevel[6] = layout.findViewById(R.id.level6);
175
    mLevel[7] = layout.findViewById(R.id.level7);
176
    mLevel[8] = layout.findViewById(R.id.levelM);
176 177

  
177 178
    int numScramble  = object==null ? 1 : object.getNumScramble();
178 179
    int min = Math.min(numScramble,LEVELS_SHOWN);
179 180

  
180 181
    if( numScramble>=1 && numScramble<=7 )
181 182
      {
182
      level[numScramble].setText(R.string.levelM);
183
      for(int i=numScramble+1; i<=8; i++) level[i].setVisibility(GONE);
183
      mLevel[numScramble].setText(R.string.levelM);
184
      for(int i=numScramble+1; i<=8; i++) mLevel[i].setVisibility(GONE);
184 185
      }
185 186

  
186 187
    for(int i=0; i<=min; i++)
187 188
      {
188
      level[i].setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize);
189
      level[i].setLayoutParams(params);
190
      level[i].setPadding(0,0,0,0);
189
      mLevel[i].setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize);
190
      mLevel[i].setLayoutParams(params);
191
      mLevel[i].setPadding(0,0,0,0);
191 192

  
193
      final int ii=i;
192 194
      boolean free = i==0;
193 195
      int scrambles = (i>0 && i<min) ? i : numScramble;
194 196

  
195
      level[i].setOnClickListener( new View.OnClickListener()
197
      mLevel[i].setOnClickListener( new View.OnClickListener()
196 198
        {
197 199
        @Override
198 200
        public void onClick(View v)
199 201
          {
200 202
          mPopup.dismiss();
201
          act.switchToPlay(object,scrambles,free);
203
          act.switchToPlay(object,scrambles,free,ii);
202 204
          }
203 205
        });
204 206
      }
......
206 208
    int index = (numScramble>=1 && numScramble<=7) ? numScramble : LEVELS_SHOWN;
207 209
    LinearLayout.LayoutParams params2 = new LinearLayout.LayoutParams(levelWidth,levelHeight);
208 210
    params2.setMargins(margin,-margin,margin,margin);
209
    level[index].setLayoutParams(params2);
211
    mLevel[index].setLayoutParams(params2);
212

  
213
    setupLevelButtonVisibilityAndColor(act);
214
    }
215

  
216
///////////////////////////////////////////////////////////////////////////////////////////////////
217

  
218
  private void setupLevelButtonVisibilityAndColor(MainActivity act)
219
    {
220
    /*
221
    int currObject = RubikObjectList.getCurrObject();
222
    RubikObject object = RubikObjectList.getObject(currObject);
223
    int numScramble = object==null ? 1 : object.getNumScramble();
224
    RubikScores scores = RubikScores.getInstance();
225
    Resources res = act.getResources();
226
    ColorStateList colorG = ColorStateList.valueOf(res.getColor(R.color.green));
227
    ColorStateList colorD = ColorStateList.valueOf(res.getColor(R.color.dark_grey));
228

  
229
    for(int level=0; level<=LEVELS_SHOWN; level++)
230
      {
231
      boolean isSolved = scores.isSolved(currObject,level);
232
      mLevel[level].setBackgroundTintList( isSolved ? colorG : colorD);
233
      }
234

  
235
    if( numScramble<=LEVELS_SHOWN || mOldNumScramble<=LEVELS_SHOWN )
236
      {
237
      if( numScramble<mOldNumScramble )
238
        {
239
        int max = Math.min(LEVELS_SHOWN,mOldNumScramble-1);
240
        for(int level=numScramble; level<=max; level++) mLevel[level].setVisibility(View.INVISIBLE);
241
        mLevel[numScramble-1].setText(R.string.levelM);
242
        }
243
      if( numScramble>mOldNumScramble )
244
        {
245
        int max = Math.min(LEVELS_SHOWN,numScramble-1);
246
        mLevel[mOldNumScramble-1].setText( String.valueOf(mOldNumScramble) );
247

  
248
        for(int level=mOldNumScramble; level<=max; level++)
249
          {
250
          mLevel[level].setVisibility(View.VISIBLE);
251
          if( level<max ) mLevel[level].setText( String.valueOf(level+1) );
252
          else            mLevel[level].setText( R.string.levelM );
253
          }
254
        }
255
      }
256

  
257
    mOldNumScramble = numScramble;
258
    */
210 259
    }
211 260

  
212 261
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff