35 |
35 |
import org.distorted.library.main.DistortedEffects;
|
36 |
36 |
|
37 |
37 |
import java.util.ArrayList;
|
38 |
|
import java.lang.ref.WeakReference;
|
39 |
38 |
|
40 |
39 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
41 |
40 |
|
42 |
41 |
public class Effects3DTab extends Fragment implements AdapterView.OnItemSelectedListener
|
43 |
42 |
{
|
44 |
|
private WeakReference<Effects3DActivity> mAct;
|
45 |
43 |
private EffectType mType;
|
46 |
44 |
private ArrayList<Effects3DEffect> mList;
|
47 |
45 |
private int mEffectAdd;
|
... | ... | |
56 |
54 |
{
|
57 |
55 |
mList = new ArrayList<>();
|
58 |
56 |
mEffectAdd = 0;
|
|
57 |
|
|
58 |
android.util.Log.e("tab", "TAB CONSTRUCTOR");
|
59 |
59 |
}
|
60 |
60 |
|
61 |
61 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
62 |
62 |
|
63 |
|
void setParams(EffectType type, WeakReference<Effects3DActivity> act, int tab, int layout, int spinner)
|
|
63 |
@Override
|
|
64 |
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
64 |
65 |
{
|
65 |
|
mTab = tab;
|
66 |
|
mLayout = layout;
|
67 |
|
mSpinner = spinner;
|
68 |
|
mType = type;
|
69 |
|
mAct = act;
|
70 |
|
mEffects = act.get().getEffects();
|
|
66 |
Bundle args = getArguments();
|
|
67 |
|
|
68 |
int position = args.getInt("position");
|
|
69 |
|
|
70 |
switch(position)
|
|
71 |
{
|
|
72 |
case 0: mTab = R.layout.effects3dtab1;
|
|
73 |
mLayout = R.id.effects3dlayout1;
|
|
74 |
mSpinner = R.id.effects3dspinner1;
|
|
75 |
mType = EffectType.VERTEX;
|
|
76 |
break;
|
|
77 |
case 1: mTab = R.layout.effects3dtab2;
|
|
78 |
mLayout = R.id.effects3dlayout2;
|
|
79 |
mSpinner = R.id.effects3dspinner2;
|
|
80 |
mType = EffectType.FRAGMENT;
|
|
81 |
break;
|
|
82 |
case 2: mTab = R.layout.effects3dtab3;
|
|
83 |
mLayout = R.id.effects3dlayout3;
|
|
84 |
mSpinner = R.id.effects3dspinner3;
|
|
85 |
mType = EffectType.POSTPROCESS;
|
|
86 |
break;
|
|
87 |
}
|
71 |
88 |
|
72 |
|
android.util.Log.e("tab", "setparams: "+type.name() );
|
|
89 |
Effects3DActivity act = (Effects3DActivity)getActivity();
|
|
90 |
mEffects = act.getEffects();
|
73 |
91 |
|
74 |
92 |
createEffectNames(mType);
|
75 |
93 |
mEffectStrings = new String[mEffectNames.length];
|
... | ... | |
77 |
95 |
for (int i = 0; i < mEffectNames.length; i++)
|
78 |
96 |
{
|
79 |
97 |
mEffectStrings[i] = mEffectNames[i].name();
|
80 |
|
|
81 |
|
android.util.Log.d("tab", " effect: "+mEffectStrings[i]);
|
82 |
98 |
}
|
83 |
|
}
|
84 |
99 |
|
85 |
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
100 |
android.util.Log.e("tab", "onCreateView, this is fragment position "+position+" type="+mType.name());
|
86 |
101 |
|
87 |
|
@Override
|
88 |
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
89 |
|
{
|
90 |
102 |
View rootView = inflater.inflate( mTab, container, false);
|
91 |
103 |
return rootView;
|
92 |
104 |
}
|
... | ... | |
99 |
111 |
super.onStart();
|
100 |
112 |
|
101 |
113 |
android.util.Log.e("tab", "onStart, type="+mType.name());
|
|
114 |
}
|
|
115 |
|
|
116 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
102 |
117 |
|
103 |
|
Effects3DActivity act = mAct.get();
|
|
118 |
@Override
|
|
119 |
public void onResume()
|
|
120 |
{
|
|
121 |
super.onResume();
|
|
122 |
|
|
123 |
android.util.Log.e("tab", "onResume, type="+mType.name());
|
|
124 |
|
|
125 |
Effects3DActivity act = (Effects3DActivity)getActivity();
|
104 |
126 |
|
105 |
127 |
ArrayAdapter<String> adapterEffect = new ArrayAdapter<>( act, android.R.layout.simple_spinner_item, mEffectStrings);
|
106 |
128 |
adapterEffect.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
107 |
129 |
|
108 |
130 |
Spinner effectSpinner = act.findViewById(mSpinner);
|
|
131 |
|
|
132 |
if( mSpinner == R.id.effects3dspinner1 ) android.util.Log.e("tab", "onStart, mSpinner correct");
|
|
133 |
if( effectSpinner==null ) android.util.Log.e("tab", "onStart, effectSpinner null");
|
|
134 |
|
109 |
135 |
effectSpinner.setOnItemSelectedListener(this);
|
110 |
136 |
effectSpinner.setAdapter(adapterEffect);
|
111 |
137 |
|
... | ... | |
132 |
158 |
|
133 |
159 |
private void resetData()
|
134 |
160 |
{
|
135 |
|
Effects3DSurfaceView view = mAct.get().findViewById(R.id.effects3dSurfaceView);
|
|
161 |
Effects3DActivity act = (Effects3DActivity)getActivity();
|
|
162 |
Effects3DSurfaceView view = act.findViewById(R.id.effects3dSurfaceView);
|
136 |
163 |
view.getRenderer().showRegionAndCenter(false,false);
|
137 |
164 |
}
|
138 |
165 |
|
... | ... | |
140 |
167 |
|
141 |
168 |
void newEffect()
|
142 |
169 |
{
|
143 |
|
Effects3DEffect eff = new Effects3DEffect(mEffectNames[mEffectAdd], mAct.get() );
|
|
170 |
Effects3DActivity act = (Effects3DActivity)getActivity();
|
|
171 |
Effects3DEffect eff = new Effects3DEffect(mEffectNames[mEffectAdd], act );
|
144 |
172 |
mList.add(eff);
|
145 |
173 |
|
146 |
|
LinearLayout layout = mAct.get().findViewById(mLayout);
|
|
174 |
LinearLayout layout = act.findViewById(mLayout);
|
147 |
175 |
View view = eff.createView();
|
148 |
176 |
layout.addView(view);
|
149 |
177 |
|
... | ... | |
161 |
189 |
|
162 |
190 |
eff.apply(mEffects);
|
163 |
191 |
|
164 |
|
Effects3DActivity act = mAct.get();
|
165 |
192 |
boolean region = act.getShowRegion();
|
166 |
193 |
boolean center = act.getShowCenter();
|
167 |
194 |
|
... | ... | |
196 |
223 |
|
197 |
224 |
void removeAll()
|
198 |
225 |
{
|
199 |
|
Effects3DActivity act = mAct.get();
|
|
226 |
Effects3DActivity act = (Effects3DActivity)getActivity();
|
200 |
227 |
|
201 |
228 |
mList.clear();
|
202 |
229 |
LinearLayout layout = act.findViewById(mLayout);
|
... | ... | |
215 |
242 |
{
|
216 |
243 |
if( effect.thisView(v) )
|
217 |
244 |
{
|
218 |
|
LinearLayout layout = mAct.get().findViewById(mLayout);
|
|
245 |
Effects3DActivity act = (Effects3DActivity)getActivity();
|
|
246 |
LinearLayout layout = act.findViewById(mLayout);
|
219 |
247 |
View view;
|
220 |
248 |
|
221 |
249 |
view = effect.getEffect();
|
Some progress with Effects3D app