Revision b3fff6fb
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objectlib/automator/ObjectAutomator.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.objectlib.automator; |
21 | 21 |
|
22 |
import java.lang.ref.WeakReference; |
|
23 |
|
|
24 |
import android.app.Activity; |
|
25 |
|
|
22 | 26 |
import org.distorted.library.main.DistortedNode; |
23 | 27 |
import org.distorted.library.main.DistortedScreen; |
24 | 28 |
import org.distorted.library.message.EffectListener; |
25 |
|
|
26 | 29 |
import org.distorted.library.type.Static4D; |
30 |
|
|
31 |
import org.distorted.objectlib.helpers.ObjectLibInterface; |
|
27 | 32 |
import org.distorted.objectlib.main.ObjectControl; |
28 |
import org.distorted.objectlib.main.ObjectPreRender; |
|
29 | 33 |
import org.distorted.objectlib.helpers.BlockController; |
30 |
import org.distorted.objectlib.helpers.TwistyActivity; |
|
31 | 34 |
import org.distorted.objectlib.main.TwistyObject; |
32 | 35 |
|
33 |
import java.lang.ref.WeakReference; |
|
34 |
|
|
35 | 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
36 | 37 |
|
37 | 38 |
public class ObjectAutomator implements EffectListener |
38 | 39 |
{ |
39 | 40 |
private static ObjectAutomator mControl; |
40 |
private ObjectControl mObjectControl; |
|
41 |
private final ObjectControl mObjectControl;
|
|
41 | 42 |
|
42 |
WeakReference<TwistyActivity> mRefAct;
|
|
43 |
WeakReference<Activity> mRefAct; |
|
43 | 44 |
boolean mWholeReturned, mRotateReturned; |
44 | 45 |
|
45 | 46 |
ObjectAutomatorWhole mWhole; |
... | ... | |
49 | 50 |
|
50 | 51 |
DistortedScreen getScreen() |
51 | 52 |
{ |
52 |
TwistyActivity act = mRefAct.get();
|
|
53 |
return act!=null ? act.getScreen() : null;
|
|
53 |
ObjectLibInterface inter = mObjectControl.getInterface();
|
|
54 |
return inter.getScreen();
|
|
54 | 55 |
} |
55 | 56 |
|
56 | 57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
64 | 65 |
|
65 | 66 |
Static4D getQuat() |
66 | 67 |
{ |
67 |
ObjectControl control = getObjectControl(); |
|
68 |
return control.getQuat(); |
|
68 |
return mObjectControl.getQuat(); |
|
69 | 69 |
} |
70 | 70 |
|
71 | 71 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
72 | 72 |
|
73 | 73 |
TwistyObject getObject() |
74 | 74 |
{ |
75 |
ObjectControl control = getObjectControl(); |
|
76 |
ObjectPreRender pre = control.getPreRender(); |
|
77 |
return pre.getObject(); |
|
75 |
return mObjectControl.getObject(); |
|
78 | 76 |
} |
79 | 77 |
|
80 | 78 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
115 | 113 |
for (DistortedNode node : screenNodes) screen.attach(node); |
116 | 114 |
} |
117 | 115 |
|
118 |
ObjectControl control = getObjectControl(); |
|
119 |
ObjectPreRender pre = control.getPreRender(); |
|
120 |
DistortedNode object = pre.getObject(); |
|
116 |
DistortedNode object = mObjectControl.getObject(); |
|
121 | 117 |
DistortedNode[] objectNodes = mRotate.getObjectNodes(); |
122 | 118 |
|
123 | 119 |
if( object!=null && objectNodes!=null ) |
... | ... | |
138 | 134 |
for (DistortedNode node : screenNodes) screen.detach(node); |
139 | 135 |
} |
140 | 136 |
|
141 |
ObjectControl control = getObjectControl(); |
|
142 |
ObjectPreRender pre = control.getPreRender(); |
|
143 |
DistortedNode object = pre.getObject(); |
|
137 |
DistortedNode object = mObjectControl.getObject(); |
|
144 | 138 |
DistortedNode[] objectNodes = mRotate.returnObjectNodes(); |
145 | 139 |
|
146 | 140 |
if( object!=null && objectNodes!=null ) |
... | ... | |
154 | 148 |
private void finishWhole() |
155 | 149 |
{ |
156 | 150 |
removeWholeObjects(); |
157 |
|
|
158 | 151 |
mWholeReturned = true; |
159 |
|
|
160 | 152 |
if( !mRotateReturned ) addRotateObjects(); |
161 | 153 |
} |
162 | 154 |
|
... | ... | |
166 | 158 |
{ |
167 | 159 |
removeRotateObjects(); |
168 | 160 |
mRotateReturned= true; |
169 |
mObjectControl.getPreRender().unblockEverything();
|
|
161 |
mObjectControl.unblockEverything(); |
|
170 | 162 |
} |
171 | 163 |
|
172 | 164 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
173 | 165 |
|
174 |
TwistyActivity getActivity()
|
|
166 |
Activity getActivity() |
|
175 | 167 |
{ |
176 | 168 |
return mRefAct.get(); |
177 | 169 |
} |
... | ... | |
213 | 205 |
|
214 | 206 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
215 | 207 |
|
216 |
public void animateAll(TwistyActivity act)
|
|
208 |
public void animateAll(Activity act) |
|
217 | 209 |
{ |
218 |
mObjectControl.getPreRender().blockEverything(BlockController.CONTROL_PLACE_0);
|
|
210 |
mObjectControl.blockEverything(BlockController.CONTROL_PLACE_0); |
|
219 | 211 |
mRefAct = new WeakReference<>(act); |
220 | 212 |
|
221 | 213 |
mWholeReturned = false; |
... | ... | |
226 | 218 |
|
227 | 219 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
228 | 220 |
|
229 |
public void animateRotate(TwistyActivity act)
|
|
221 |
public void animateRotate(Activity act) |
|
230 | 222 |
{ |
231 |
mObjectControl.getPreRender().blockEverything(BlockController.CONTROL_PLACE_1);
|
|
223 |
mObjectControl.blockEverything(BlockController.CONTROL_PLACE_1); |
|
232 | 224 |
mRefAct = new WeakReference<>(act); |
233 | 225 |
|
234 | 226 |
mWholeReturned = true; |
Also available in: Unified diff
Remove the concept of a 'TwistyActivity' altogether.