GridLayoutInterface.java revision 1bb0c42b2a62f580eea4764d6a4434ffecfbf353
1package com.cooliris.media;
2
3public final class GridLayoutInterface extends LayoutInterface {
4    GridLayoutInterface(int numRows) {
5        mNumRows = numRows;
6        mSpacingX = (int) (20 * Gallery.PIXEL_DENSITY);
7        mSpacingY = (int) (40 * Gallery.PIXEL_DENSITY);
8    }
9
10    public void getPositionForSlotIndex(int slotIndex, int itemWidth, int itemHeight, Vector3f outPosition) {
11        outPosition.x = (slotIndex / mNumRows) * (itemWidth + mSpacingX);
12        outPosition.y = (slotIndex % mNumRows) * (itemHeight + mSpacingY);
13        int maxY = (mNumRows - 1) * (itemHeight + mSpacingY);
14        outPosition.y -= (maxY >> 1);
15        outPosition.z = 0;
16    }
17
18    public int mNumRows;
19    public int mSpacingX;
20    public int mSpacingY;
21}
22