Project

General

Profile

« Previous | Next » 

Revision d3d639b1

Added by Leszek Koltunski over 2 years ago

Bandaged 3x3 UI: delete created objects.

View differences:

src/main/java/org/distorted/bandaged/BandagedCreatorActivity.java
232 232
      mScreen.addObject(this,name);
233 233
      }
234 234

  
235
///////////////////////////////////////////////////////////////////////////////////////////////////
236

  
237
    public void deleteObject(String name)
238
      {
239
      mScreen.deleteObject(this,name);
240
      }
241

  
242
///////////////////////////////////////////////////////////////////////////////////////////////////
243

  
244
    public void playObject(String name)
245
      {
246

  
247
      }
248

  
235 249
///////////////////////////////////////////////////////////////////////////////////////////////////
236 250

  
237 251
    public void iconCreationDone(Bitmap bmp)
src/main/java/org/distorted/bandaged/BandagedCreatorObjectView.java
37 37

  
38 38
///////////////////////////////////////////////////////////////////////////////////////////////////
39 39

  
40
  private void playObject()
41
    {
42

  
43
    }
44

  
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46

  
47
  private void deleteObject()
48
    {
49

  
50
    }
51

  
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53

  
54
  public BandagedCreatorObjectView(BandagedCreatorActivity act, String name, boolean leftmost)
40
  public BandagedCreatorObjectView(final BandagedCreatorActivity act, String name, boolean leftmost)
55 41
    {
56 42
    mName = name;
57 43
    LayoutInflater inflater = act.getLayoutInflater();
......
90 76
      @Override
91 77
      public void onClick(View v)
92 78
        {
93
        playObject();
79
        act.playObject(mName);
94 80
        }
95 81
      });
96 82

  
......
99 85
      @Override
100 86
      public void onClick(View v)
101 87
        {
102
        deleteObject();
88
        act.deleteObject(mName);
103 89
        }
104 90
      });
105 91
    }
......
110 96
    {
111 97
    return mPane;
112 98
    }
99

  
100
///////////////////////////////////////////////////////////////////////////////////////////////////
101

  
102
  public boolean objectNameIs(String name)
103
    {
104
    return mName.equals(name);
105
    }
113 106
}
src/main/java/org/distorted/bandaged/BandagedCreatorScreen.java
19 19

  
20 20
package org.distorted.bandaged;
21 21

  
22
import java.util.ArrayList;
23

  
22 24
import android.app.Activity;
23 25
import android.graphics.Bitmap;
24 26
import android.view.View;
......
36 38
  private TransparentImageButton mBackButton, mResetButton, mDoneButton;
37 39
  private LinearLayout mObjectView;
38 40
  private int mNumObjects;
41
  private ArrayList<BandagedCreatorObjectView> mViews;
39 42

  
40 43
///////////////////////////////////////////////////////////////////////////////////////////////////
41 44

  
42 45
  public BandagedCreatorScreen()
43 46
    {
44 47
    mNumObjects = 0;
48
    mViews = new ArrayList<>();
45 49
    }
46 50

  
47 51
///////////////////////////////////////////////////////////////////////////////////////////////////
......
141 145
    LinearLayout pane = view.getPane();
142 146
    mObjectView.addView(pane);
143 147
    mNumObjects++;
148
    mViews.add(view);
149
    }
150

  
151
///////////////////////////////////////////////////////////////////////////////////////////////////
152

  
153
  void deleteObject(BandagedCreatorActivity act, String name)
154
    {
155
    for(int v=0; v<mNumObjects; v++)
156
      {
157
      BandagedCreatorObjectView view = mViews.get(v);
158

  
159
      if( view.objectNameIs(name) )
160
        {
161
        LinearLayout pane = view.getPane();
162
        mObjectView.removeView(pane);
163
        mViews.remove(view);
164
        mNumObjects--;
165

  
166
        if( v==0 && mNumObjects>0 )
167
          {
168
          int width = act.getScreenWidthInPixels();
169
          BandagedCreatorObjectView v2 = mViews.get(v);
170
          LinearLayout p2 = v2.getPane();
171
          int lMargin = (int)(width*RubikActivity.LARGE_MARGIN);;
172

  
173
          LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( (int)(width*0.36f), LinearLayout.LayoutParams.MATCH_PARENT);
174
          params.bottomMargin = lMargin;
175
          params.topMargin    = lMargin;
176
          params.leftMargin   = lMargin;
177
          params.rightMargin  = lMargin;
178

  
179
          p2.setLayoutParams(params);
180
          }
181

  
182
        break;
183
        }
184
      }
144 185
    }
145 186

  
146 187
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff