Revision b3fff6fb
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objectlib/main/ObjectControl.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.objectlib.main; |
21 | 21 |
|
22 |
import java.lang.ref.WeakReference; |
|
23 |
|
|
22 |
import android.app.Activity; |
|
24 | 23 |
import android.content.SharedPreferences; |
25 | 24 |
import android.util.DisplayMetrics; |
26 | 25 |
import android.view.MotionEvent; |
... | ... | |
30 | 29 |
import org.distorted.library.type.Static4D; |
31 | 30 |
|
32 | 31 |
import org.distorted.objectlib.helpers.MovesFinished; |
33 |
import org.distorted.objectlib.helpers.ObjectStateActioner; |
|
34 |
import org.distorted.objectlib.helpers.TwistyActivity; |
|
32 |
import org.distorted.objectlib.helpers.ObjectLibInterface; |
|
35 | 33 |
|
36 | 34 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
37 | 35 |
|
... | ... | |
52 | 50 |
|
53 | 51 |
private final Static4D CAMERA_POINT = new Static4D(0, 0, 0, 0); |
54 | 52 |
|
55 |
private final WeakReference<TwistyActivity> mAct; |
|
56 |
private final ObjectStateActioner mActioner; |
|
53 |
private final ObjectLibInterface mInterface; |
|
57 | 54 |
private final ObjectPreRender mPreRender; |
58 | 55 |
private Movement mMovement; |
59 | 56 |
private boolean mDragging, mBeginningRotation, mContinuingRotation; |
... | ... | |
189 | 186 |
|
190 | 187 |
if( down ) |
191 | 188 |
{ |
192 |
int color = mActioner.getCurrentColor();
|
|
189 |
int color = mInterface.getCurrentColor();
|
|
193 | 190 |
mLastCubitFace = mMovement.getTouchedFace(); |
194 | 191 |
float[] point = mMovement.getTouchedPoint3D(); |
195 | 192 |
mLastCubit = object.getCubit(point); |
196 | 193 |
mPreRender.setTextureMap( mLastCubit, mLastCubitFace, color ); |
197 |
mLastCubitColor = mActioner.cubitIsLocked(object.getObjectType(),mLastCubit);
|
|
194 |
mLastCubitColor = mInterface.cubitIsLocked(object.getObjectType(),mLastCubit);
|
|
198 | 195 |
} |
199 | 196 |
} |
200 | 197 |
} |
201 | 198 |
else |
202 | 199 |
{ |
203 |
final TwistyActivity act = mAct.get(); |
|
204 | 200 |
mDragging = (!mIsLocked || mIsAutomatic); |
205 | 201 |
mBeginningRotation = false; |
206 | 202 |
mContinuingRotation = false; |
207 |
if( !mDragging ) mActioner.failedToDrag(act);
|
|
203 |
if( !mDragging ) mInterface.failedToDrag();
|
|
208 | 204 |
} |
209 | 205 |
} |
210 | 206 |
} |
... | ... | |
257 | 253 |
|
258 | 254 |
if( angle!=0 ) |
259 | 255 |
{ |
260 |
TwistyActivity act = mAct.get(); |
|
261 |
|
|
262 | 256 |
int basicAngle= object.getBasicAngle()[mCurrentAxis]; |
263 | 257 |
int realAngle = (angle*basicAngle)/360; |
264 |
|
|
265 |
mActioner.onFinishRotation(act,mCurrentAxis,mCurrentRow,realAngle); |
|
258 |
mInterface.onFinishRotation(mCurrentAxis,mCurrentRow,realAngle); |
|
266 | 259 |
} |
267 | 260 |
|
268 | 261 |
mContinuingRotation = false; |
... | ... | |
314 | 307 |
|
315 | 308 |
object.beginNewRotation( mCurrentAxis, mCurrentRow ); |
316 | 309 |
|
317 |
TwistyActivity act = mAct.get(); |
|
318 |
mActioner.onBeginRotation(act); |
|
310 |
mInterface.onBeginRotation(); |
|
319 | 311 |
|
320 | 312 |
addSpeedProbe(x,y); |
321 | 313 |
|
... | ... | |
504 | 496 |
return mPreRender; |
505 | 497 |
} |
506 | 498 |
|
499 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
500 |
|
|
501 |
public ObjectLibInterface getInterface() |
|
502 |
{ |
|
503 |
return mInterface; |
|
504 |
} |
|
505 |
|
|
507 | 506 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
508 | 507 |
// PUBLIC API |
509 | 508 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
510 | 509 |
|
511 |
public ObjectControl(TwistyActivity act, ObjectStateActioner actioner)
|
|
510 |
public ObjectControl(Activity act, ObjectLibInterface actioner)
|
|
512 | 511 |
{ |
513 | 512 |
mIsAutomatic = false; |
514 | 513 |
|
... | ... | |
527 | 526 |
mDensity = dm.densityDpi; |
528 | 527 |
|
529 | 528 |
mPreRender = new ObjectPreRender(act,this,actioner); |
530 |
mAct = new WeakReference<>(act); |
|
531 |
mActioner = actioner; |
|
529 |
mInterface = actioner; |
|
532 | 530 |
} |
533 | 531 |
|
534 | 532 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Remove the concept of a 'TwistyActivity' altogether.