blob: 0ae7a597ce61eeb2c31d64f3f36712de43fb33a7 [file] [log] [blame]
Winson Chung321e9ee2010-08-09 13:37:56 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.launcher2;
18
19import android.content.Context;
Winson Chung785d2eb2011-04-14 16:08:02 -070020import android.content.res.Resources;
Winson Chung321e9ee2010-08-09 13:37:56 -070021import android.util.AttributeSet;
Winson Chung321e9ee2010-08-09 13:37:56 -070022import android.view.MotionEvent;
23import android.view.View;
24import android.view.ViewDebug;
25import android.view.ViewGroup;
26
Winson Chung785d2eb2011-04-14 16:08:02 -070027import com.android.launcher.R;
28
Winson Chung321e9ee2010-08-09 13:37:56 -070029/**
30 * An abstraction of the original CellLayout which supports laying out items
31 * which span multiple cells into a grid-like layout. Also supports dimming
32 * to give a preview of its contents.
33 */
Michael Jurka8245a862011-02-01 17:53:59 -080034public class PagedViewCellLayout extends ViewGroup implements Page {
Winson Chung321e9ee2010-08-09 13:37:56 -070035 static final String TAG = "PagedViewCellLayout";
36
Winson Chung321e9ee2010-08-09 13:37:56 -070037 private int mCellCountX;
38 private int mCellCountY;
39 private int mCellWidth;
40 private int mCellHeight;
Winson Chungdf4b83d2010-10-20 17:49:27 -070041 private int mWidthGap;
42 private int mHeightGap;
Michael Jurka8245a862011-02-01 17:53:59 -080043 protected PagedViewCellLayoutChildren mChildren;
44 private PagedViewCellLayoutChildren mHolographicChildren;
Michael Jurkaabded662011-03-04 12:06:57 -080045 private boolean mAllowHardwareLayerCreation = false;
46 private boolean mCreateHardwareLayersIfAllowed = false;
Winson Chung321e9ee2010-08-09 13:37:56 -070047
Winson Chung321e9ee2010-08-09 13:37:56 -070048 public PagedViewCellLayout(Context context) {
49 this(context, null);
50 }
51
52 public PagedViewCellLayout(Context context, AttributeSet attrs) {
53 this(context, attrs, 0);
54 }
55
56 public PagedViewCellLayout(Context context, AttributeSet attrs, int defStyle) {
57 super(context, attrs, defStyle);
58
Winson Chung321e9ee2010-08-09 13:37:56 -070059 setAlwaysDrawnWithCacheEnabled(false);
60
61 // setup default cell parameters
Winson Chung785d2eb2011-04-14 16:08:02 -070062 Resources resources = context.getResources();
63 mCellWidth = resources.getDimensionPixelSize(R.dimen.apps_customize_cell_width);
64 mCellHeight = resources.getDimensionPixelSize(R.dimen.apps_customize_cell_height);
Winson Chung321e9ee2010-08-09 13:37:56 -070065 mCellCountX = LauncherModel.getCellCountX();
66 mCellCountY = LauncherModel.getCellCountY();
Winson Chungdf4b83d2010-10-20 17:49:27 -070067 mWidthGap = mHeightGap = -1;
Winson Chung321e9ee2010-08-09 13:37:56 -070068
Michael Jurka8245a862011-02-01 17:53:59 -080069 mChildren = new PagedViewCellLayoutChildren(context);
70 mChildren.setCellDimensions(mCellWidth, mCellHeight);
71 mChildren.setGap(mWidthGap, mHeightGap);
72
73 addView(mChildren);
74 mHolographicChildren = new PagedViewCellLayoutChildren(context);
75 mHolographicChildren.setAlpha(0f);
76 mHolographicChildren.setCellDimensions(mCellWidth, mCellHeight);
77 mHolographicChildren.setGap(mWidthGap, mHeightGap);
78
79 addView(mHolographicChildren);
Winson Chungb3347bb2010-08-19 14:51:28 -070080 }
Winson Chung321e9ee2010-08-09 13:37:56 -070081
Patrick Dubroy244d74c2011-05-19 16:48:48 -070082 public int getCellWidth() {
83 return mCellWidth;
84 }
85
86 public int getCellHeight() {
87 return mCellHeight;
88 }
89
Michael Jurkaabded662011-03-04 12:06:57 -080090 public void allowHardwareLayerCreation() {
91 // This is called after the first time we launch into All Apps. Before that point,
92 // there's no need for hardware layers here since there's a hardware layer set on the
93 // parent, AllAppsTabbed, during the AllApps transition -- creating hardware layers here
94 // before the animation is done slows down the animation
95 if (!mAllowHardwareLayerCreation) {
96 mAllowHardwareLayerCreation = true;
97 if (mCreateHardwareLayersIfAllowed) {
98 createHardwareLayers();
99 }
100 }
Michael Jurkac0759f52011-02-03 16:47:14 -0800101 }
102
Winson Chungb3347bb2010-08-19 14:51:28 -0700103 @Override
104 public void setAlpha(float alpha) {
Michael Jurka8245a862011-02-01 17:53:59 -0800105 mChildren.setAlpha(alpha);
106 mHolographicChildren.setAlpha(1.0f - alpha);
Winson Chung321e9ee2010-08-09 13:37:56 -0700107 }
108
Michael Jurkac0759f52011-02-03 16:47:14 -0800109 void destroyHardwareLayers() {
Michael Jurkaabded662011-03-04 12:06:57 -0800110 // called when a page is no longer visible (triggered by loadAssociatedPages ->
111 // removeAllViewsOnPage)
112 mCreateHardwareLayersIfAllowed = false;
113 if (mAllowHardwareLayerCreation) {
Michael Jurkac0759f52011-02-03 16:47:14 -0800114 mChildren.destroyHardwareLayer();
115 mHolographicChildren.destroyHardwareLayer();
116 }
117 }
118 void createHardwareLayers() {
Michael Jurkaabded662011-03-04 12:06:57 -0800119 // called when a page is visible (triggered by loadAssociatedPages -> syncPageItems)
120 mCreateHardwareLayersIfAllowed = true;
121 if (mAllowHardwareLayerCreation) {
Michael Jurkac0759f52011-02-03 16:47:14 -0800122 mChildren.createHardwareLayer();
123 mHolographicChildren.createHardwareLayer();
124 }
125 }
126
Winson Chung321e9ee2010-08-09 13:37:56 -0700127 @Override
128 public void cancelLongPress() {
129 super.cancelLongPress();
130
131 // Cancel long press for all children
132 final int count = getChildCount();
133 for (int i = 0; i < count; i++) {
134 final View child = getChildAt(i);
135 child.cancelLongPress();
136 }
137 }
138
Winson Chung6a70e9f2011-05-17 16:24:49 -0700139 /** Syncs the holographic icon views to the child icon views */
140 public void reloadHolographicIcons(boolean createHolographicOutlines) {
141 if (createHolographicOutlines) {
142 mChildren.loadHolographicOutlines();
143 } else {
144 mChildren.clearHolographicOutlines();
145 }
146 }
147
Winson Chung321e9ee2010-08-09 13:37:56 -0700148 public boolean addViewToCellLayout(View child, int index, int childId,
Winson Chung6a70e9f2011-05-17 16:24:49 -0700149 PagedViewCellLayout.LayoutParams params) {
Winson Chung321e9ee2010-08-09 13:37:56 -0700150 final PagedViewCellLayout.LayoutParams lp = params;
151
152 // Generate an id for each view, this assumes we have at most 256x256 cells
153 // per workspace screen
154 if (lp.cellX >= 0 && lp.cellX <= (mCellCountX - 1) &&
155 lp.cellY >= 0 && (lp.cellY <= mCellCountY - 1)) {
156 // If the horizontal or vertical span is set to -1, it is taken to
157 // mean that it spans the extent of the CellLayout
158 if (lp.cellHSpan < 0) lp.cellHSpan = mCellCountX;
159 if (lp.cellVSpan < 0) lp.cellVSpan = mCellCountY;
160
161 child.setId(childId);
Michael Jurka8245a862011-02-01 17:53:59 -0800162 mChildren.addView(child, index, lp);
Winson Chung321e9ee2010-08-09 13:37:56 -0700163
Michael Jurka8245a862011-02-01 17:53:59 -0800164 if (child instanceof PagedViewIcon) {
165 PagedViewIcon pagedViewIcon = (PagedViewIcon) child;
Michael Jurkaabded662011-03-04 12:06:57 -0800166 if (mAllowHardwareLayerCreation) {
Michael Jurkac0759f52011-02-03 16:47:14 -0800167 pagedViewIcon.disableCache();
168 }
Winson Chung6a70e9f2011-05-17 16:24:49 -0700169 mHolographicChildren.addView(pagedViewIcon.getHolographicOutlineView(),
170 index, lp);
Michael Jurka8245a862011-02-01 17:53:59 -0800171 }
Winson Chung321e9ee2010-08-09 13:37:56 -0700172 return true;
173 }
174 return false;
175 }
176
177 @Override
Michael Jurka8245a862011-02-01 17:53:59 -0800178 public void removeAllViewsOnPage() {
179 mChildren.removeAllViews();
180 mHolographicChildren.removeAllViews();
Michael Jurkac5e49022011-02-16 12:04:02 -0800181 destroyHardwareLayers();
Winson Chung321e9ee2010-08-09 13:37:56 -0700182 }
183
184 @Override
Michael Jurka8245a862011-02-01 17:53:59 -0800185 public void removeViewOnPageAt(int index) {
186 mChildren.removeViewAt(index);
Winson Chung6a70e9f2011-05-17 16:24:49 -0700187 mHolographicChildren.removeViewAt(index);
Michael Jurka8245a862011-02-01 17:53:59 -0800188 }
189
190 @Override
191 public int getPageChildCount() {
192 return mChildren.getChildCount();
193 }
194
195 @Override
196 public View getChildOnPageAt(int i) {
197 return mChildren.getChildAt(i);
198 }
199
200 @Override
201 public int indexOfChildOnPage(View v) {
202 return mChildren.indexOfChild(v);
203 }
204
Winson Chung97d85d22011-04-13 11:27:36 -0700205 public int getCellCountX() {
206 return mCellCountX;
207 }
208
209 public int getCellCountY() {
210 return mCellCountY;
211 }
212
Winson Chung321e9ee2010-08-09 13:37:56 -0700213 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
214 // TODO: currently ignoring padding
215
216 int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec);
217 int widthSpecSize = MeasureSpec.getSize(widthMeasureSpec);
218
219 int heightSpecMode = MeasureSpec.getMode(heightMeasureSpec);
220 int heightSpecSize = MeasureSpec.getSize(heightMeasureSpec);
221
222 if (widthSpecMode == MeasureSpec.UNSPECIFIED || heightSpecMode == MeasureSpec.UNSPECIFIED) {
223 throw new RuntimeException("CellLayout cannot have UNSPECIFIED dimensions");
224 }
225
226 final int cellWidth = mCellWidth;
227 final int cellHeight = mCellHeight;
228
229 int numWidthGaps = mCellCountX - 1;
230 int numHeightGaps = mCellCountY - 1;
231
232 int vSpaceLeft = heightSpecSize - mPaddingTop
233 - mPaddingBottom - (cellHeight * mCellCountY);
234 int heightGap = vSpaceLeft / numHeightGaps;
235
236 int hSpaceLeft = widthSpecSize - mPaddingLeft
237 - mPaddingRight - (cellWidth * mCellCountX);
238 int widthGap = hSpaceLeft / numWidthGaps;
239
240 // center it around the min gaps
241 int minGap = Math.min(widthGap, heightGap);
Winson Chung321e9ee2010-08-09 13:37:56 -0700242 /*
243 if (minGap < heightGap) {
244 // vertical space has shrunken, so change padding accordingly
245 paddingTop += ((heightGap - minGap) * (mCellCountY - 1)) / 2;
246 } else if (minGap < widthGap) {
247 // horizontal space has shrunken, so change padding accordingly
248 paddingLeft += ((widthGap - minGap) * (mCellCountX - 1)) / 2;
249 }
250 */
Winson Chungdf4b83d2010-10-20 17:49:27 -0700251 if (mWidthGap > -1 && mHeightGap > -1) {
252 widthGap = mWidthGap;
253 heightGap = mHeightGap;
254 } else {
255 widthGap = heightGap = minGap;
256 }
Winson Chung321e9ee2010-08-09 13:37:56 -0700257
258 int newWidth = mPaddingLeft + mPaddingRight + (mCellCountX * cellWidth) +
Winson Chungdf4b83d2010-10-20 17:49:27 -0700259 ((mCellCountX - 1) * widthGap);
Winson Chung321e9ee2010-08-09 13:37:56 -0700260 int newHeight = mPaddingTop + mPaddingBottom + (mCellCountY * cellHeight) +
Winson Chungdf4b83d2010-10-20 17:49:27 -0700261 ((mCellCountY - 1) * heightGap);
Winson Chung321e9ee2010-08-09 13:37:56 -0700262
263 final int count = getChildCount();
264 for (int i = 0; i < count; i++) {
265 View child = getChildAt(i);
Michael Jurka8245a862011-02-01 17:53:59 -0800266 int childWidthMeasureSpec =
267 MeasureSpec.makeMeasureSpec(newWidth, MeasureSpec.EXACTLY);
268 int childheightMeasureSpec =
269 MeasureSpec.makeMeasureSpec(newHeight, MeasureSpec.EXACTLY);
Winson Chung321e9ee2010-08-09 13:37:56 -0700270 child.measure(childWidthMeasureSpec, childheightMeasureSpec);
271 }
272
273 setMeasuredDimension(newWidth, newHeight);
274 }
275
Michael Jurka7ef959b2011-02-23 11:48:32 -0800276 int getContentWidth() {
Michael Jurkaa2eb1702011-05-12 14:57:05 -0700277 if (LauncherApplication.isScreenLarge()) {
Winson Chung785d2eb2011-04-14 16:08:02 -0700278 // Return the distance from the left edge of the content of the leftmost icon to
279 // the right edge of the content of the rightmost icon
Michael Jurka7ef959b2011-02-23 11:48:32 -0800280
Winson Chung785d2eb2011-04-14 16:08:02 -0700281 // icons are centered within cells, find out how much padding that accounts for
282 return getWidthBeforeFirstLayout() - (mCellWidth - Utilities.getIconContentSize());
283 } else {
284 return getWidthBeforeFirstLayout() + mPaddingLeft + mPaddingRight;
285 }
Michael Jurka0413dfa2011-04-05 16:52:32 -0700286 }
287
Winson Chung4b576be2011-04-27 17:40:20 -0700288 int getContentHeight() {
Patrick Dubroy4a5ad092011-05-23 16:15:09 -0700289 if (mCellCountY > 0) {
290 return mCellCountY * mCellHeight + (mCellCountY - 1) * Math.max(0, mHeightGap);
291 }
292 return 0;
Winson Chung4b576be2011-04-27 17:40:20 -0700293 }
294
Michael Jurkad92e7412011-04-05 17:07:27 -0700295 int getWidthBeforeFirstLayout() {
Patrick Dubroy4a5ad092011-05-23 16:15:09 -0700296 if (mCellCountX > 0) {
297 return mCellCountX * mCellWidth + (mCellCountX - 1) * Math.max(0, mWidthGap);
298 }
299 return 0;
Michael Jurka7ef959b2011-02-23 11:48:32 -0800300 }
301
Winson Chung321e9ee2010-08-09 13:37:56 -0700302 @Override
303 protected void onLayout(boolean changed, int l, int t, int r, int b) {
304 int count = getChildCount();
Winson Chung321e9ee2010-08-09 13:37:56 -0700305 for (int i = 0; i < count; i++) {
306 View child = getChildAt(i);
Michael Jurkaa2eb1702011-05-12 14:57:05 -0700307 if (LauncherApplication.isScreenLarge()) {
Winson Chung785d2eb2011-04-14 16:08:02 -0700308 child.layout(0, 0, r - l, b - t);
309 } else {
310 child.layout(mPaddingLeft, mPaddingTop, getMeasuredWidth() - mPaddingRight,
311 getMeasuredHeight() - mPaddingBottom);
312 }
Winson Chung321e9ee2010-08-09 13:37:56 -0700313 }
314 }
315
316 @Override
Winson Chung321e9ee2010-08-09 13:37:56 -0700317 public boolean onTouchEvent(MotionEvent event) {
318 return super.onTouchEvent(event) || true;
319 }
320
Winson Chung80baf5a2010-08-09 16:03:15 -0700321 public void enableCenteredContent(boolean enabled) {
Michael Jurka8245a862011-02-01 17:53:59 -0800322 mChildren.enableCenteredContent(enabled);
323 mHolographicChildren.enableCenteredContent(enabled);
Winson Chung80baf5a2010-08-09 16:03:15 -0700324 }
325
Winson Chung321e9ee2010-08-09 13:37:56 -0700326 @Override
327 protected void setChildrenDrawingCacheEnabled(boolean enabled) {
Michael Jurka8245a862011-02-01 17:53:59 -0800328 mChildren.setChildrenDrawingCacheEnabled(enabled);
329 mHolographicChildren.setChildrenDrawingCacheEnabled(enabled);
Winson Chung321e9ee2010-08-09 13:37:56 -0700330 }
331
332 public void setCellCount(int xCount, int yCount) {
333 mCellCountX = xCount;
334 mCellCountY = yCount;
335 requestLayout();
336 }
337
Winson Chungdf4b83d2010-10-20 17:49:27 -0700338 public void setGap(int widthGap, int heightGap) {
339 mWidthGap = widthGap;
340 mHeightGap = heightGap;
Michael Jurka8245a862011-02-01 17:53:59 -0800341 mChildren.setGap(widthGap, heightGap);
342 mHolographicChildren.setGap(widthGap, heightGap);
Winson Chungdf4b83d2010-10-20 17:49:27 -0700343 }
344
Winson Chung80baf5a2010-08-09 16:03:15 -0700345 public int[] getCellCountForDimensions(int width, int height) {
346 // Always assume we're working with the smallest span to make sure we
347 // reserve enough space in both orientations
348 int smallerSize = Math.min(mCellWidth, mCellHeight);
349
350 // Always round up to next largest cell
351 int spanX = (width + smallerSize) / smallerSize;
352 int spanY = (height + smallerSize) / smallerSize;
353
354 return new int[] { spanX, spanY };
355 }
356
Winson Chung321e9ee2010-08-09 13:37:56 -0700357 /**
358 * Start dragging the specified child
359 *
360 * @param child The child that is being dragged
361 */
362 void onDragChild(View child) {
363 PagedViewCellLayout.LayoutParams lp = (PagedViewCellLayout.LayoutParams) child.getLayoutParams();
364 lp.isDragging = true;
365 }
366
Winson Chunge3193b92010-09-10 11:44:42 -0700367 /**
368 * Estimates the number of cells that the specified width would take up.
369 */
Winson Chung80baf5a2010-08-09 16:03:15 -0700370 public int estimateCellHSpan(int width) {
Winson Chunge3193b92010-09-10 11:44:42 -0700371 // TODO: we need to take widthGap into effect
Winson Chung80baf5a2010-08-09 16:03:15 -0700372 return (width + mCellWidth) / mCellWidth;
373 }
Winson Chunge3193b92010-09-10 11:44:42 -0700374
375 /**
376 * Estimates the number of cells that the specified height would take up.
377 */
Winson Chung80baf5a2010-08-09 16:03:15 -0700378 public int estimateCellVSpan(int height) {
Winson Chunge3193b92010-09-10 11:44:42 -0700379 // TODO: we need to take heightGap into effect
Winson Chung80baf5a2010-08-09 16:03:15 -0700380 return (height + mCellHeight) / mCellHeight;
381 }
Winson Chunge3193b92010-09-10 11:44:42 -0700382
383 /**
384 * Estimates the width that the number of vSpan cells will take up.
385 */
386 public int estimateCellWidth(int hSpan) {
387 // TODO: we need to take widthGap into effect
388 return hSpan * mCellWidth;
389 }
390
391 /**
392 * Estimates the height that the number of vSpan cells will take up.
393 */
394 public int estimateCellHeight(int vSpan) {
395 // TODO: we need to take heightGap into effect
396 return vSpan * mCellHeight;
Winson Chung80baf5a2010-08-09 16:03:15 -0700397 }
398
Winson Chung321e9ee2010-08-09 13:37:56 -0700399 @Override
400 public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) {
401 return new PagedViewCellLayout.LayoutParams(getContext(), attrs);
402 }
403
404 @Override
405 protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
406 return p instanceof PagedViewCellLayout.LayoutParams;
407 }
408
409 @Override
410 protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {
411 return new PagedViewCellLayout.LayoutParams(p);
412 }
413
414 public static class LayoutParams extends ViewGroup.MarginLayoutParams {
415 /**
416 * Horizontal location of the item in the grid.
417 */
418 @ViewDebug.ExportedProperty
419 public int cellX;
420
421 /**
422 * Vertical location of the item in the grid.
423 */
424 @ViewDebug.ExportedProperty
425 public int cellY;
426
427 /**
428 * Number of cells spanned horizontally by the item.
429 */
430 @ViewDebug.ExportedProperty
431 public int cellHSpan;
432
433 /**
434 * Number of cells spanned vertically by the item.
435 */
436 @ViewDebug.ExportedProperty
437 public int cellVSpan;
438
439 /**
440 * Is this item currently being dragged
441 */
442 public boolean isDragging;
443
Winson Chung80baf5a2010-08-09 16:03:15 -0700444 // a data object that you can bind to this layout params
445 private Object mTag;
446
Winson Chung321e9ee2010-08-09 13:37:56 -0700447 // X coordinate of the view in the layout.
448 @ViewDebug.ExportedProperty
449 int x;
450 // Y coordinate of the view in the layout.
451 @ViewDebug.ExportedProperty
452 int y;
453
Winson Chung80baf5a2010-08-09 16:03:15 -0700454 public LayoutParams() {
455 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
456 cellHSpan = 1;
457 cellVSpan = 1;
458 }
459
Winson Chung321e9ee2010-08-09 13:37:56 -0700460 public LayoutParams(Context c, AttributeSet attrs) {
461 super(c, attrs);
462 cellHSpan = 1;
463 cellVSpan = 1;
464 }
465
466 public LayoutParams(ViewGroup.LayoutParams source) {
467 super(source);
468 cellHSpan = 1;
469 cellVSpan = 1;
470 }
471
472 public LayoutParams(LayoutParams source) {
473 super(source);
474 this.cellX = source.cellX;
475 this.cellY = source.cellY;
476 this.cellHSpan = source.cellHSpan;
477 this.cellVSpan = source.cellVSpan;
478 }
479
480 public LayoutParams(int cellX, int cellY, int cellHSpan, int cellVSpan) {
481 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
482 this.cellX = cellX;
483 this.cellY = cellY;
484 this.cellHSpan = cellHSpan;
485 this.cellVSpan = cellVSpan;
486 }
487
488 public void setup(int cellWidth, int cellHeight, int widthGap, int heightGap,
489 int hStartPadding, int vStartPadding) {
490
491 final int myCellHSpan = cellHSpan;
492 final int myCellVSpan = cellVSpan;
493 final int myCellX = cellX;
494 final int myCellY = cellY;
495
496 width = myCellHSpan * cellWidth + ((myCellHSpan - 1) * widthGap) -
497 leftMargin - rightMargin;
498 height = myCellVSpan * cellHeight + ((myCellVSpan - 1) * heightGap) -
499 topMargin - bottomMargin;
500
Michael Jurkaa2eb1702011-05-12 14:57:05 -0700501 if (LauncherApplication.isScreenLarge()) {
Winson Chung785d2eb2011-04-14 16:08:02 -0700502 x = hStartPadding + myCellX * (cellWidth + widthGap) + leftMargin;
503 y = vStartPadding + myCellY * (cellHeight + heightGap) + topMargin;
504 } else {
505 x = myCellX * (cellWidth + widthGap) + leftMargin;
506 y = myCellY * (cellHeight + heightGap) + topMargin;
507 }
Winson Chung321e9ee2010-08-09 13:37:56 -0700508 }
509
Winson Chung80baf5a2010-08-09 16:03:15 -0700510 public Object getTag() {
511 return mTag;
512 }
513
514 public void setTag(Object tag) {
515 mTag = tag;
516 }
517
Winson Chung321e9ee2010-08-09 13:37:56 -0700518 public String toString() {
Winson Chung80baf5a2010-08-09 16:03:15 -0700519 return "(" + this.cellX + ", " + this.cellY + ", " +
520 this.cellHSpan + ", " + this.cellVSpan + ")";
Winson Chung321e9ee2010-08-09 13:37:56 -0700521 }
522 }
523}
Michael Jurka8245a862011-02-01 17:53:59 -0800524
525interface Page {
526 public int getPageChildCount();
527 public View getChildOnPageAt(int i);
528 public void removeAllViewsOnPage();
529 public void removeViewOnPageAt(int i);
530 public int indexOfChildOnPage(View v);
531}