Revision beb325a0
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/effect/BaseEffect.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.effect; |
21 | 21 |
|
22 |
import java.lang.reflect.InvocationTargetException; |
|
22 | 23 |
import java.lang.reflect.Method; |
23 | 24 |
import android.content.SharedPreferences; |
24 | 25 |
|
... | ... | |
195 | 196 |
|
196 | 197 |
//////////////////////////////////////////////////////////////////////////////// |
197 | 198 |
|
198 |
public long startEffect(RubikRenderer renderer) |
|
199 |
public long startEffect(RubikRenderer renderer) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
|
|
199 | 200 |
{ |
200 |
Method method1, method2; |
|
201 |
BaseEffect baseEffect=null; |
|
201 |
Method method1 = mClass.getDeclaredMethod("create", int.class); |
|
202 | 202 |
|
203 |
try |
|
204 |
{ |
|
205 |
method1 = mClass.getDeclaredMethod("create", int.class); |
|
206 |
} |
|
207 |
catch(NoSuchMethodException ex) |
|
208 |
{ |
|
209 |
android.util.Log.e("BaseEffect", mClass.getSimpleName()+": 1 exception getting method: "+ex.getMessage()); |
|
210 |
return -1; |
|
211 |
} |
|
212 |
|
|
213 |
try |
|
214 |
{ |
|
215 |
if( method1!=null ) |
|
216 |
{ |
|
217 |
Object value = method1.invoke(null,mCurrentType); |
|
218 |
baseEffect = (BaseEffect)value; |
|
219 |
} |
|
220 |
} |
|
221 |
catch(Exception ex) |
|
222 |
{ |
|
223 |
android.util.Log.e("BaseEffect", mClass.getSimpleName()+": 1 exception invoking method: "+ex.getMessage()); |
|
224 |
return -2; |
|
225 |
} |
|
203 |
Object value1 = method1.invoke(null,mCurrentType); |
|
204 |
BaseEffect baseEffect = (BaseEffect)value1; |
|
226 | 205 |
|
227 |
try |
|
228 |
{ |
|
229 |
method2 = mClass.getDeclaredMethod("start", int.class, RubikRenderer.class); |
|
230 |
} |
|
231 |
catch(NoSuchMethodException ex) |
|
232 |
{ |
|
233 |
android.util.Log.e("BaseEffect", mClass.getSimpleName()+": 2 exception getting method: "+ex.getMessage()); |
|
234 |
return -3; |
|
235 |
} |
|
236 |
|
|
237 |
try |
|
238 |
{ |
|
239 |
if( method2!=null ) |
|
240 |
{ |
|
241 |
Integer translated = translatePos(mCurrentPos)+1; |
|
242 |
Object value = method2.invoke(baseEffect,translated,renderer); |
|
243 |
return (Long)value; |
|
244 |
} |
|
245 |
} |
|
246 |
catch(Exception ex) |
|
247 |
{ |
|
248 |
android.util.Log.e("BaseEffect", mClass.getSimpleName()+": 2 exception invoking method: "+ex.getMessage()); |
|
249 |
} |
|
206 |
Method method2 = mClass.getDeclaredMethod("start", int.class, RubikRenderer.class); |
|
250 | 207 |
|
251 |
return -4; |
|
208 |
Integer translated = translatePos(mCurrentPos)+1; |
|
209 |
Object value2 = method2.invoke(baseEffect,translated,renderer); |
|
210 |
return (Long)value2; |
|
252 | 211 |
} |
253 | 212 |
|
254 | 213 |
//////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Major restructuring - separate the Manipulated Objects (i.e. at the time being - Cubes of various sizes) and the class holding knowledge how those Objects move ( RubikCubeMovement ) into a separate package; remove all knowledge of Objects and the way they move from the main package.