AllAppsGridViewpublic class AllAppsGridView extends android.widget.GridView implements DragSource, AdapterView.OnItemClickListener, AdapterView.OnItemLongClickListener
Fields Summary |
---|
private DragController | mDragger | private Launcher | mLauncher | private android.graphics.Bitmap | mTexture | private android.graphics.Paint | mPaint | private int | mTextureWidth | private int | mTextureHeight |
Constructors Summary |
---|
public AllAppsGridView(android.content.Context context)
super(context);
| public AllAppsGridView(android.content.Context context, android.util.AttributeSet attrs)
this(context, attrs, com.android.internal.R.attr.gridViewStyle);
| public AllAppsGridView(android.content.Context context, android.util.AttributeSet attrs, int defStyle)
super(context, attrs, defStyle);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AllAppsGridView, defStyle, 0);
final int textureId = a.getResourceId(R.styleable.AllAppsGridView_texture, 0);
if (textureId != 0) {
mTexture = BitmapFactory.decodeResource(getResources(), textureId);
mTextureWidth = mTexture.getWidth();
mTextureHeight = mTexture.getHeight();
mPaint = new Paint();
mPaint.setDither(false);
}
a.recycle();
|
Methods Summary |
---|
public void | draw(android.graphics.Canvas canvas)
final Bitmap texture = mTexture;
final Paint paint = mPaint;
final int width = getWidth();
final int height = getHeight();
final int textureWidth = mTextureWidth;
final int textureHeight = mTextureHeight;
int x = 0;
int y;
while (x < width) {
y = 0;
while (y < height) {
canvas.drawBitmap(texture, x, y, paint);
y += textureHeight;
}
x += textureWidth;
}
super.draw(canvas);
| public void | onDropCompleted(android.view.View target, boolean success)
| protected void | onFinishInflate()
setOnItemClickListener(this);
setOnItemLongClickListener(this);
| public void | onItemClick(android.widget.AdapterView parent, android.view.View v, int position, long id)
ApplicationInfo app = (ApplicationInfo) parent.getItemAtPosition(position);
mLauncher.startActivitySafely(app.intent);
| public boolean | onItemLongClick(android.widget.AdapterView parent, android.view.View view, int position, long id)
if (!view.isInTouchMode()) {
return false;
}
ApplicationInfo app = (ApplicationInfo) parent.getItemAtPosition(position);
app = new ApplicationInfo(app);
mDragger.startDrag(view, this, app, DragController.DRAG_ACTION_COPY);
mLauncher.closeAllApplications();
return true;
| public void | setDragger(DragController dragger)
mDragger = dragger;
| void | setLauncher(Launcher launcher)
mLauncher = launcher;
|
|