Project

General

Profile

« Previous | Next » 

Revision 49c0eecc

Added by Leszek Koltunski over 7 years ago

Some progress with Effect classes.

11 apps compile now.

View differences:

src/main/java/org/distorted/examples/effectqueue/EffectQueueActivity.java
45 45
public class EffectQueueActivity extends Activity implements AdapterView.OnItemSelectedListener
46 46
  {
47 47
  private Spinner mAdd, mID, mName, mType;
48
  private static ArrayAdapter<Effect> mAdapterID;
48
  private static ArrayAdapter<Long> mAdapterID;
49 49

  
50 50
  private int mPosID, mPosName, mPosType;
51 51
  private TableLayout mLayoutList;
52 52

  
53
  private HashMap<Effect,TableRow> mMap = new HashMap<>();
53
  private HashMap<Long,TableRow> mMap = new HashMap<>();
54 54

  
55 55
///////////////////////////////////////////////////////////////////////////////////////////////////
56 56

  
......
75 75
    mName.setOnItemSelectedListener(this);
76 76
    mType.setOnItemSelectedListener(this);
77 77

  
78
    ArrayList<Effect> itemsEffect  = new ArrayList<>();
78
    ArrayList<Long> itemsId  = new ArrayList<>();
79 79

  
80 80
    String[] itemsName = new String[] { getText(R.string.distort   ).toString(),
81 81
                                        getText(R.string.sink      ).toString(),
......
85 85

  
86 86
    String[] itemsType = new String[] {"VERTEX", "FRAGMENT"};
87 87

  
88
    mAdapterID = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, itemsEffect);
88
    mAdapterID = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, itemsId);
89 89
    mAdapterID.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
90 90
    mID.setAdapter(mAdapterID);
91 91

  
......
170 170
    {
171 171
    try
172 172
      {
173
      Effect currEffect = (Effect)mID.getItemAtPosition(mPosID);
173
      Long currEffect = (Long)mID.getItemAtPosition(mPosID);
174 174
      EffectQueueSurfaceView v = (EffectQueueSurfaceView) this.findViewById(R.id.effects2dSurfaceView);
175
      v.getRenderer().getEffects().abortEffect(currEffect);
175
      v.getRenderer().getEffects().abortById(currEffect);
176 176
      }
177 177
    catch(IndexOutOfBoundsException ex)
178 178
      {
......
223 223
    {
224 224
    if( success )  // we really added a new effect
225 225
      {
226
      mAdapterID.add(effect);
226
      mAdapterID.add(effect.getID());
227 227
      mAdapterID.notifyDataSetChanged();
228 228

  
229 229
      TableRow tr = new TableRow(this);
......
249 249
      b4.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
250 250
      tr.addView(b4);
251 251

  
252
      mMap.put(effect,tr);
252
      mMap.put(effect.getID(),tr);
253 253

  
254 254
      mLayoutList.addView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT));
255 255
      }
......
261 261

  
262 262
///////////////////////////////////////////////////////////////////////////////////////////////////
263 263

  
264
  public void effectRemoved(final Effect effect)
264
  public void effectRemoved(final long id)
265 265
    {
266 266
    runOnUiThread(new Runnable()
267 267
      {
268 268
      public void run()
269 269
        {
270
        mAdapterID.remove(effect);
270
        mAdapterID.remove(id);
271 271
        mAdapterID.notifyDataSetChanged();
272 272

  
273
        TableRow row = mMap.remove(effect);
273
        TableRow row = mMap.remove(id);
274 274

  
275 275
        if( row!=null )
276 276
          {
......
278 278
          }
279 279
        else
280 280
          {
281
          android.util.Log.e("EFFECTS2D", "Impossible: id="+effect.getID()+" not in the map!");
281
          android.util.Log.e("EFFECTS2D", "Impossible: id="+id+" not in the map!");
282 282
          }
283 283
        }
284 284
      });
......
286 286

  
287 287
///////////////////////////////////////////////////////////////////////////////////////////////////
288 288

  
289
  public void effectFinished(final Effect effect)
289
  public void effectFinished(final long id)
290 290
    {
291 291
    runOnUiThread(new Runnable()
292 292
      {
293 293
      public void run()
294 294
        {
295
        TableRow row = mMap.get(effect);
295
        TableRow row = mMap.get(id);
296 296

  
297 297
        if( row!=null )
298 298
          {

Also available in: Unified diff