Project

General

Profile

« Previous | Next » 

Revision 4ab3d91b

Added by Leszek Koltunski about 3 years ago

Remove class referencees from ObjectList.

View differences:

src/main/java/org/distorted/dialogs/RubikDialogPattern.java
104 104
    for(int i=0; i< RubikPatternList.NUM_OBJECTS; i++)
105 105
      {
106 106
      ObjectList list = RubikPatternList.getObject(i);
107
      int size             = RubikPatternList.getSize(i);
108
      int sizeIndex        = ObjectList.getSizeIndex(list.ordinal(),size);
109
      int iconID           = list.getIconIDs()[sizeIndex];
107
      int size        = RubikPatternList.getSize(i);
108
      int sizeIndex   = ObjectList.getSizeIndex(list.ordinal(),size);
109
      int iconID      = list.getIconIDs()[sizeIndex];
110 110

  
111 111
      ImageView imageView = new ImageView(act);
112 112
      imageView.setImageResource(iconID);
src/main/java/org/distorted/objects/ObjectList.java
28 28
import org.distorted.main.R;
29 29
import org.distorted.main.RubikActivity;
30 30

  
31
import java.lang.reflect.Field;
32

  
33 31
///////////////////////////////////////////////////////////////////////////////////////////////////
34 32

  
35 33
public enum ObjectList
......
43 41
                       {4 , 20, 24, R.raw.cube4, R.drawable.ui_small_cube4, R.drawable.ui_medium_cube4, R.drawable.ui_big_cube4, R.drawable.ui_huge_cube4} ,
44 42
                       {5 , 24, 28, R.raw.cube5, R.drawable.ui_small_cube5, R.drawable.ui_medium_cube5, R.drawable.ui_big_cube5, R.drawable.ui_huge_cube5}
45 43
                     },
46
         TwistyCube.class,
47 44
         0
48 45
       ),
49 46

  
......
51 48
         new int[][] {
52 49
                       {2 , 11, 11, R.raw.jing, R.drawable.ui_small_jing2, R.drawable.ui_medium_jing2, R.drawable.ui_big_jing2, R.drawable.ui_huge_jing2} ,
53 50
                     },
54
         TwistyJing.class,
55 51
         1
56 52
       ),
57 53

  
......
61 57
                       {4 , 15, 17, R.raw.pyra4, R.drawable.ui_small_pyra4, R.drawable.ui_medium_pyra4, R.drawable.ui_big_pyra4, R.drawable.ui_huge_pyra4} ,
62 58
                       {5 , 20, 23, R.raw.pyra5, R.drawable.ui_small_pyra5, R.drawable.ui_medium_pyra5, R.drawable.ui_big_pyra5, R.drawable.ui_huge_pyra5}
63 59
                     },
64
         TwistyPyraminx.class,
65 60
         1
66 61
       ),
67 62

  
......
70 65
                       {3 , 18, 18, R.raw.kilo3, R.drawable.ui_small_kilo3, R.drawable.ui_medium_kilo3, R.drawable.ui_big_kilo3, R.drawable.ui_huge_kilo3} ,
71 66
                       {5 , 33, 33, R.raw.kilo5, R.drawable.ui_small_kilo5, R.drawable.ui_medium_kilo5, R.drawable.ui_big_kilo5, R.drawable.ui_huge_kilo5} ,
72 67
                     },
73
         TwistyKilominx.class,
74 68
         2
75 69
       ),
76 70

  
......
79 73
                       {3 , 21, 21, R.raw.mega3, R.drawable.ui_small_mega3, R.drawable.ui_medium_mega3, R.drawable.ui_big_mega3, R.drawable.ui_huge_mega3} ,
80 74
                       {5 , 35, 37, R.raw.mega5, R.drawable.ui_small_mega5, R.drawable.ui_medium_mega5, R.drawable.ui_big_mega5, R.drawable.ui_huge_mega5} ,
81 75
                     },
82
         TwistyMegaminx.class,
83 76
         2
84 77
       ),
85 78

  
......
87 80
         new int[][] {
88 81
                       {2 , 18, 18, R.raw.ulti, R.drawable.ui_small_ulti, R.drawable.ui_medium_ulti, R.drawable.ui_big_ulti, R.drawable.ui_huge_ulti} ,
89 82
                     },
90
         TwistyUltimate.class,
91 83
         3
92 84
       ),
93 85

  
......
97 89
                       {3 , 18, 24, R.raw.diam3, R.drawable.ui_small_diam3, R.drawable.ui_medium_diam3, R.drawable.ui_big_diam3, R.drawable.ui_huge_diam3} ,
98 90
                       {4 , 32, 32, R.raw.diam4, R.drawable.ui_small_diam4, R.drawable.ui_medium_diam4, R.drawable.ui_big_diam4, R.drawable.ui_huge_diam4} ,
99 91
                     },
100
         TwistyDiamond.class,
101 92
         3
102 93
       ),
103 94

  
......
105 96
         new int[][] {
106 97
                       {3 , 10, 10, R.raw.dino, R.drawable.ui_small_dino, R.drawable.ui_medium_dino, R.drawable.ui_big_dino, R.drawable.ui_huge_dino} ,
107 98
                     },
108
         TwistyDino6.class,
109 99
         4
110 100
       ),
111 101

  
......
113 103
         new int[][] {
114 104
                       {3 , 7, 7, R.raw.dino, R.drawable.ui_small_din4, R.drawable.ui_medium_din4, R.drawable.ui_big_din4, R.drawable.ui_huge_din4} ,
115 105
                     },
116
         TwistyDino4.class,
117 106
         4
118 107
       ),
119 108

  
......
121 110
         new int[][] {
122 111
                       {3 , 14, 16, R.raw.redi, R.drawable.ui_small_redi, R.drawable.ui_medium_redi, R.drawable.ui_big_redi, R.drawable.ui_huge_redi} ,
123 112
                     },
124
         TwistyRedi.class,
125 113
         4
126 114
       ),
127 115

  
......
129 117
         new int[][] {
130 118
                       {3 , 18, 20, R.raw.heli, R.drawable.ui_small_heli, R.drawable.ui_medium_heli, R.drawable.ui_big_heli, R.drawable.ui_huge_heli} ,
131 119
                     },
132
         TwistyHelicopter.class,
133 120
         4
134 121
       ),
135 122

  
......
138 125
                       {2 , 11, 11, R.raw.skew2, R.drawable.ui_small_skewb, R.drawable.ui_medium_skewb, R.drawable.ui_big_skewb, R.drawable.ui_huge_skewb} ,
139 126
                       {3 , 17, 21, R.raw.skew3, R.drawable.ui_small_skewm, R.drawable.ui_medium_skewm, R.drawable.ui_big_skewm, R.drawable.ui_huge_skewm} ,
140 127
                     },
141
         TwistySkewb.class,
142 128
         5
143 129
       ),
144 130

  
......
146 132
         new int[][] {
147 133
                       {2 , 8, 8, R.raw.ivy, R.drawable.ui_small_ivy, R.drawable.ui_medium_ivy, R.drawable.ui_big_ivy, R.drawable.ui_huge_ivy} ,
148 134
                     },
149
         TwistyIvy.class,
150 135
         5
151 136
       ),
152 137

  
......
154 139
         new int[][] {
155 140
                       {3 , 16, 19, R.raw.rex, R.drawable.ui_small_rex, R.drawable.ui_medium_rex, R.drawable.ui_big_rex, R.drawable.ui_huge_rex} ,
156 141
                     },
157
         TwistyRex.class,
158 142
         5
159 143
       ),
160 144

  
......
162 146
         new int[][] {
163 147
                       {3 , 16, 16, R.raw.ban1, R.drawable.ui_small_ban1, R.drawable.ui_medium_ban1, R.drawable.ui_big_ban1, R.drawable.ui_huge_ban1} ,
164 148
                     },
165
         TwistyBandagedFused.class,
166 149
         6
167 150
       ),
168 151

  
......
170 153
         new int[][] {
171 154
                       {3 , 16, 16, R.raw.ban2, R.drawable.ui_small_ban2, R.drawable.ui_medium_ban2, R.drawable.ui_big_ban2, R.drawable.ui_huge_ban2} ,
172 155
                     },
173
         TwistyBandaged2Bar.class,
174 156
         6
175 157
       ),
176 158

  
......
178 160
         new int[][] {
179 161
                       {3 , 16, 16, R.raw.ban3, R.drawable.ui_small_ban3, R.drawable.ui_medium_ban3, R.drawable.ui_big_ban3, R.drawable.ui_huge_ban3} ,
180 162
                     },
181
         TwistyBandaged3Plate.class,
182 163
         6
183 164
       ),
184 165

  
......
186 167
         new int[][] {
187 168
                       {3 , 16, 16, R.raw.ban4, R.drawable.ui_small_ban4, R.drawable.ui_medium_ban4, R.drawable.ui_big_ban4, R.drawable.ui_huge_ban4} ,
188 169
                     },
189
         TwistyBandagedEvil.class,
190 170
         6
191 171
       ),
192 172

  
......
194 174
         new int[][] {
195 175
                       {3 , 24, 24, R.raw.square1, R.drawable.ui_small_square1, R.drawable.ui_medium_square1, R.drawable.ui_big_square1, R.drawable.ui_huge_square1} ,
196 176
                     },
197
         TwistySquare1.class,
198 177
         7
199 178
       ),
200 179

  
......
202 181
         new int[][] {
203 182
                       {3 , 24, 24, R.raw.square2, R.drawable.ui_small_square2, R.drawable.ui_medium_square2, R.drawable.ui_big_square2, R.drawable.ui_huge_square2} ,
204 183
                     },
205
         TwistySquare2.class,
206 184
         7
207 185
       ),
208 186

  
......
211 189
                       {2 , 12, 12, R.raw.mirr2, R.drawable.ui_small_mirr2, R.drawable.ui_medium_mirr2, R.drawable.ui_big_mirr2, R.drawable.ui_huge_mirr2} ,
212 190
                       {3 , 16, 17, R.raw.mirr3, R.drawable.ui_small_mirr3, R.drawable.ui_medium_mirr3, R.drawable.ui_big_mirr3, R.drawable.ui_huge_mirr3} ,
213 191
                     },
214
         TwistyMirror.class,
215 192
         7
216 193
       ),
217 194
  ;
......
223 200
  public static final int MAX_OBJECT_SIZE;
224 201

  
225 202
  private final int[] mObjectSizes, mDBLevels, mNumScrambles, mSmallIconIDs, mMediumIconIDs, mBigIconIDs, mHugeIconIDs, mResourceIDs;
226
  private final Class<? extends TwistyObject> mObjectClass;
227 203
  private final int mRow, mNumSizes;
228 204

  
229 205
  private static final ObjectList[] objects;
......
495 471

  
496 472
///////////////////////////////////////////////////////////////////////////////////////////////////
497 473

  
498
  public static int[] retFaceColors(ObjectList object)
499
    {
500
    Field field;
501
    int[] faceColors=null;
502

  
503
    try
504
      {
505
      field = object.mObjectClass.getDeclaredField("FACE_COLORS");
506
      field.setAccessible(true);
507
      Object obj = field.get(null);
508
      faceColors = (int[]) obj;
509
      }
510
    catch(NoSuchFieldException ex)
511
      {
512
      android.util.Log.e("RubikObjectList", object.mObjectClass.getSimpleName()+": no such field exception getting field: "+ex.getMessage());
513
      }
514
    catch(IllegalAccessException ex)
515
      {
516
      android.util.Log.e("RubikObjectList", object.mObjectClass.getSimpleName()+": illegal access exception getting field: "+ex.getMessage());
517
      }
518

  
519
    return faceColors;
520
    }
521

  
522
///////////////////////////////////////////////////////////////////////////////////////////////////
523

  
524
  ObjectList(int[][] info, Class<? extends TwistyObject> object , int row)
474
  ObjectList(int[][] info, int row)
525 475
    {
526 476
    mNumSizes = info.length;
527 477

  
......
546 496
      mHugeIconIDs[i]  = info[i][7];
547 497
      }
548 498

  
549
    mObjectClass= object;
550
    mRow        = row;
499
    mRow  = row;
551 500
    }
552 501

  
553 502
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/screens/RubikScreenSolver.java
85 85
    RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
86 86
    play.setObjectAndSize(act, currentObject, currentObjectSize);
87 87

  
88
    mFaceColors = ObjectList.retFaceColors(currentObject);
89
    mNumFaces   = mFaceColors!=null ? mFaceColors.length : 0;
88
    generateFaceColors();
90 89

  
91 90
    // TOP ////////////////////////////
92 91
    LinearLayout layoutTop = act.findViewById(R.id.upperBar);
......
125 124
    layoutBot.addView(layoutRight);
126 125
    }
127 126

  
127
///////////////////////////////////////////////////////////////////////////////////////////////////
128

  
129
  public void generateFaceColors()
130
    {
131
    mFaceColors= new int[] {  TwistyObject.COLOR_YELLOW,
132
                              TwistyObject.COLOR_WHITE,
133
                              TwistyObject.COLOR_BLUE ,
134
                              TwistyObject.COLOR_GREEN,
135
                              TwistyObject.COLOR_RED   ,
136
                              TwistyObject.COLOR_ORANGE };
137
    mNumFaces = 6;
138
    }
139

  
128 140
///////////////////////////////////////////////////////////////////////////////////////////////////
129 141

  
130 142
  private void setupBitmaps()

Also available in: Unified diff