Revision 8f200211
Added by Leszek Koltunski 8 months ago
src/main/java/org/distorted/objects/RubikObject.java | ||
---|---|---|
50 | 50 |
private int mNumScramble; |
51 | 51 |
private int mMeshState; |
52 | 52 |
private int mExtrasOrdinal; |
53 |
private Drawable mStaticIconD, mRescaledIconD; |
|
54 | 53 |
|
55 | 54 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
56 | 55 |
|
... | ... | |
76 | 75 |
|
77 | 76 |
mObjectVersion = ObjectType.getObjectVersion(ordinal); |
78 | 77 |
mExtrasVersion = ObjectType.getExtrasVersion(ordinal); |
79 |
|
|
80 |
mStaticIconD = null; |
|
81 |
mRescaledIconD= null; |
|
82 | 78 |
} |
83 | 79 |
|
84 | 80 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
136 | 132 |
|
137 | 133 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
138 | 134 |
|
139 |
private void createStaticIconDrawable(Activity act) |
|
140 |
{ |
|
141 |
if( mIconID>0 ) |
|
142 |
{ |
|
143 |
mStaticIconD = AppCompatResources.getDrawable(act,mIconID); |
|
144 |
} |
|
145 |
else |
|
146 |
{ |
|
147 |
RubikFiles files = RubikFiles.getInstance(); |
|
148 |
Bitmap bmp = files.getIcon(act,mLowerName+".png"); |
|
149 |
if( bmp==null ) mStaticIconD = AppCompatResources.getDrawable(act,R.drawable.unknown_icon); |
|
150 |
else mStaticIconD = new BitmapDrawable(act.getResources(), bmp); |
|
151 |
} |
|
152 |
} |
|
153 |
|
|
154 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
155 |
|
|
156 |
private void createRescaledIconDrawable(Activity act) |
|
135 |
private Drawable createIconDrawable(Activity act) |
|
157 | 136 |
{ |
158 | 137 |
if( mIconID>0 ) |
159 | 138 |
{ |
160 |
mRescaledIconD = AppCompatResources.getDrawable(act,mIconID);
|
|
139 |
return AppCompatResources.getDrawable(act,mIconID);
|
|
161 | 140 |
} |
162 | 141 |
else |
163 | 142 |
{ |
164 | 143 |
RubikFiles files = RubikFiles.getInstance(); |
165 | 144 |
Bitmap bmp = files.getIcon(act,mLowerName+".png"); |
166 |
if( bmp==null ) mRescaledIconD = AppCompatResources.getDrawable(act,R.drawable.unknown_icon);
|
|
167 |
else mRescaledIconD = new BitmapDrawable(act.getResources(), bmp);
|
|
145 |
if( bmp==null ) return AppCompatResources.getDrawable(act,R.drawable.unknown_icon);
|
|
146 |
else return new BitmapDrawable(act.getResources(), bmp);
|
|
168 | 147 |
} |
169 | 148 |
} |
170 | 149 |
|
... | ... | |
257 | 236 |
|
258 | 237 |
public void setIconTo(Activity act,ImageButton button) |
259 | 238 |
{ |
260 |
if( mStaticIconD==null ) createStaticIconDrawable(act);
|
|
261 |
button.setBackground(mStaticIconD);
|
|
239 |
Drawable icon = createIconDrawable(act);
|
|
240 |
button.setBackground(icon);
|
|
262 | 241 |
} |
263 | 242 |
|
264 | 243 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
265 | 244 |
|
266 | 245 |
public void setIconTo(Activity act,ImageView view) |
267 | 246 |
{ |
268 |
if( mRescaledIconD==null ) createRescaledIconDrawable(act);
|
|
269 |
view.setImageDrawable(mRescaledIconD);
|
|
247 |
Drawable icon = createIconDrawable(act);
|
|
248 |
view.setImageDrawable(icon);
|
|
270 | 249 |
} |
271 | 250 |
|
272 | 251 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Seriously lower memory usage.