FileDocCategorySizeDatePackage
LauncherAppWidgetHostView.javaAPI DocAndroid 1.5 API3341Wed May 06 22:42:46 BST 2009com.android.launcher

LauncherAppWidgetHostView

public class LauncherAppWidgetHostView extends android.appwidget.AppWidgetHostView
{@inheritDoc}

Fields Summary
private boolean
mHasPerformedLongPress
private CheckForLongPress
mPendingCheckForLongPress
private android.view.LayoutInflater
mInflater
Constructors Summary
public LauncherAppWidgetHostView(android.content.Context context)

        super(context);
        mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    
Methods Summary
protected android.view.ViewgetErrorView()

        return mInflater.inflate(R.layout.appwidget_error, this, false);
    
public booleanonInterceptTouchEvent(android.view.MotionEvent ev)

        // Consume any touch events for ourselves after longpress is triggered
        if (mHasPerformedLongPress) {
            mHasPerformedLongPress = false;
            return true;
        }
            
        // Watch for longpress events at this level to make sure
        // users can always pick up this widget
        switch (ev.getAction()) {
            case MotionEvent.ACTION_DOWN: {
                postCheckForLongClick();
                break;
            }
            
            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_CANCEL:
                mHasPerformedLongPress = false;
                if (mPendingCheckForLongPress != null) {
                    removeCallbacks(mPendingCheckForLongPress);
                }
                break;
        }
        
        // Otherwise continue letting touch events fall through to children
        return false;
    
private voidpostCheckForLongClick()

        mHasPerformedLongPress = false;

        if (mPendingCheckForLongPress == null) {
            mPendingCheckForLongPress = new CheckForLongPress();
        }
        mPendingCheckForLongPress.rememberWindowAttachCount();
        postDelayed(mPendingCheckForLongPress, ViewConfiguration.getLongPressTimeout());