Revision b82a9ac9
Added by Leszek Koltunski almost 6 years ago
src/main/java/org/distorted/library/effect/Effect.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.library.effect; |
21 | 21 |
|
22 |
import java.lang.reflect.Method; |
|
23 |
|
|
22 | 24 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
23 | 25 |
/** |
24 | 26 |
* Abstract Effect of any type. |
... | ... | |
125 | 127 |
|
126 | 128 |
return false; |
127 | 129 |
} |
130 |
|
|
131 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
132 |
// this will enable() all Fragment Effects twice (once for smooth variant, once for non-smooth) |
|
133 |
// but this shouldn't matter. |
|
134 |
/** |
|
135 |
* Enable all effects of a given type. |
|
136 |
* |
|
137 |
* @param type EffectType to enable. |
|
138 |
*/ |
|
139 |
public static void enableEffects(EffectType type) |
|
140 |
{ |
|
141 |
Method method=null; |
|
142 |
|
|
143 |
for(EffectName name: EffectName.values()) |
|
144 |
{ |
|
145 |
if( name.getType() == type ) |
|
146 |
{ |
|
147 |
Class<? extends Effect> cls = name.getEffectClass(); |
|
148 |
|
|
149 |
try |
|
150 |
{ |
|
151 |
method = cls.getMethod("enable"); |
|
152 |
} |
|
153 |
catch(NoSuchMethodException ex) |
|
154 |
{ |
|
155 |
android.util.Log.e("Effect", "exception getting method: "+ex.getMessage()); |
|
156 |
} |
|
157 |
|
|
158 |
try |
|
159 |
{ |
|
160 |
method.invoke(null); |
|
161 |
} |
|
162 |
catch(Exception ex) |
|
163 |
{ |
|
164 |
android.util.Log.e("Effect", "exception invoking method: "+ex.getMessage()); |
|
165 |
} |
|
166 |
} |
|
167 |
} |
|
168 |
} |
|
169 |
|
|
128 | 170 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
129 | 171 |
/** |
130 | 172 |
* Return the EffectType enum corresponding to this Effect. |
Also available in: Unified diff
Progress with the Earth app.