Example usage for android.view MotionEvent getAction

List of usage examples for android.view MotionEvent getAction

Introduction

In this page you can find the example usage for android.view MotionEvent getAction.

Prototype

public final int getAction() 

Source Link

Document

Return the kind of action being performed.

Usage

From source file:com.bahram.relationshippoints.GUI.imageSlider.CirclePageIndicator.java

public boolean onTouchEvent(android.view.MotionEvent ev) {
    if (super.onTouchEvent(ev)) {
        return true;
    }//from   ww  w.j a  v  a2  s. c  om
    if ((mViewPager == null) || (mViewPager.getAdapter().getCount() == 0)) {
        return false;
    }

    final int action = ev.getAction() & MotionEventCompat.ACTION_MASK;
    switch (action) {
    case MotionEvent.ACTION_DOWN:
        mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
        mLastMotionX = ev.getX();
        break;

    case MotionEvent.ACTION_MOVE: {
        final int activePointerIndex = MotionEventCompat.findPointerIndex(ev, mActivePointerId);
        final float x = MotionEventCompat.getX(ev, activePointerIndex);
        final float deltaX = x - mLastMotionX;

        if (!mIsDragging) {
            if (Math.abs(deltaX) > mTouchSlop) {
                mIsDragging = true;
            }
        }

        if (mIsDragging) {
            mLastMotionX = x;
            if (mViewPager.isFakeDragging() || mViewPager.beginFakeDrag()) {
                mViewPager.fakeDragBy(deltaX);
            }
        }

        break;
    }

    case MotionEvent.ACTION_CANCEL:
    case MotionEvent.ACTION_UP:
        if (!mIsDragging) {
            final int count = mViewPager.getAdapter().getCount();
            final int width = getWidth();
            final float halfWidth = width / 2f;
            final float sixthWidth = width / 6f;

            if ((mCurrentPage > 0) && (ev.getX() < halfWidth - sixthWidth)) {
                if (action != MotionEvent.ACTION_CANCEL) {
                    mViewPager.setCurrentItem(mCurrentPage - 1);
                }
                return true;
            } else if ((mCurrentPage < count - 1) && (ev.getX() > halfWidth + sixthWidth)) {
                if (action != MotionEvent.ACTION_CANCEL) {
                    mViewPager.setCurrentItem(mCurrentPage + 1);
                }
                return true;
            }
        }

        mIsDragging = false;
        mActivePointerId = INVALID_POINTER;
        if (mViewPager.isFakeDragging()) {
            mViewPager.endFakeDrag();
        }
        break;

    case MotionEventCompat.ACTION_POINTER_DOWN: {
        final int index = MotionEventCompat.getActionIndex(ev);
        mLastMotionX = MotionEventCompat.getX(ev, index);
        mActivePointerId = MotionEventCompat.getPointerId(ev, index);
        break;
    }

    case MotionEventCompat.ACTION_POINTER_UP:
        final int pointerIndex = MotionEventCompat.getActionIndex(ev);
        final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex);
        if (pointerId == mActivePointerId) {
            final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
            mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex);
        }
        mLastMotionX = MotionEventCompat.getX(ev, MotionEventCompat.findPointerIndex(ev, mActivePointerId));
        break;
    }

    return true;
}

From source file:android.hqs.view.pager.indicator.CirclePageIndicator.java

public boolean onTouchEvent(android.view.MotionEvent ev) {
    if (super.onTouchEvent(ev)) {
        return true;
    }//  ww w  . jav  a  2s.  c o  m
    if ((mViewPager == null) || (mViewPager.getAdapter().getCount() == 0)) {
        return false;
    }

    final int action = ev.getAction() & MotionEventCompat.ACTION_MASK;
    switch (action) {
    case MotionEvent.ACTION_DOWN:
        mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
        mLastMotionX = ev.getX();
        break;

    case MotionEvent.ACTION_MOVE: {
        final int activePointerIndex = MotionEventCompat.findPointerIndex(ev, mActivePointerId);
        final float x = MotionEventCompat.getX(ev, activePointerIndex);
        final float deltaX = x - mLastMotionX;

        if (!mIsDragging) {
            if (Math.abs(deltaX) > mTouchSlop) {
                mIsDragging = true;
            }
        }

        if (mIsDragging) {
            mLastMotionX = x;
            if (mViewPager.isFakeDragging() || mViewPager.beginFakeDrag()) {
                mViewPager.fakeDragBy(deltaX);
            }
        }

        break;
    }

    case MotionEvent.ACTION_CANCEL:
    case MotionEvent.ACTION_UP:
        if (!mIsDragging) {
            final int count = mViewPager.getAdapter().getCount();
            final int width = getWidth();
            final float halfWidth = width / 2f;
            final float sixthWidth = width / 6f;

            if ((mCurrentPage > 0) && (ev.getX() < halfWidth - sixthWidth)) {
                if (action != MotionEvent.ACTION_CANCEL) {
                    mViewPager.setCurrentItem(mCurrentPage - 1);
                }
                return true;
            } else if ((mCurrentPage < count - 1) && (ev.getX() > halfWidth + sixthWidth)) {
                if (action != MotionEvent.ACTION_CANCEL) {
                    mViewPager.setCurrentItem(mCurrentPage + 1);
                }
                return true;
            }
        }

        mIsDragging = false;
        mActivePointerId = INVALID_POINTER;
        if (mViewPager.isFakeDragging())
            mViewPager.endFakeDrag();
        break;

    case MotionEventCompat.ACTION_POINTER_DOWN: {
        final int index = MotionEventCompat.getActionIndex(ev);
        mLastMotionX = MotionEventCompat.getX(ev, index);
        mActivePointerId = MotionEventCompat.getPointerId(ev, index);
        break;
    }

    case MotionEventCompat.ACTION_POINTER_UP:
        final int pointerIndex = MotionEventCompat.getActionIndex(ev);
        final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex);
        if (pointerId == mActivePointerId) {
            final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
            mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex);
        }
        mLastMotionX = MotionEventCompat.getX(ev, MotionEventCompat.findPointerIndex(ev, mActivePointerId));
        break;
    }

    return true;
}

From source file:com.danielme.android.webviewdemo.WebViewDemoActivity.java

@SuppressLint({ "SetJavaScriptEnabled", "NewApi" })
@Override//w  ww  . j  a va2s.  co  m
public void onCreate(Bundle savedInstanceState) {
    setTitle("?");
    AndroidUtil.removeStrict();
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    historyStack = new LinkedList<Link>();
    webview = (WebView) findViewById(R.id.webkit);
    faviconImageView = (ImageView) findViewById(R.id.favicon);

    urlEditText = (EditText) findViewById(R.id.url);
    progressBar = (ProgressBar) findViewById(R.id.progressbar);
    stopButton = ((Button) findViewById(R.id.stopButton));
    //favicon, deprecated since Android 4.3 but it's still necesary O_O ?
    WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath());

    freeQuotaSwitch = (Switch) findViewById(R.id.freeQuotaSwitch);

    leftQuotaText = (TextView) findViewById(R.id.leftQuota);

    SharedPreferences settings = getSharedPreferences("setting", 0);

    userid = settings.getString("userid", "123");
    tenantid = Integer.parseInt(settings.getString("tenantid", "3"));

    // check balance
    long balance = updateLeftQuota();

    freeQuotaSwitch.setChecked(balance > 0);
    tmMgr = new TMManager();

    // javascript and zoom
    webview.getSettings().setJavaScriptEnabled(true);
    webview.getSettings().setBuiltInZoomControls(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
        webview.getSettings().setPluginState(PluginState.ON);
    } else {
        //IMPORTANT!! this method is no longer available since Android 4.3
        //so the code doesn't compile anymore
        //webview.getSettings().setPluginsEnabled(true);
    }

    // downloads
    // webview.setDownloadListener(new CustomDownloadListener());

    webview.setWebViewClient(new CustomWebViewClient());

    webview.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int progress) {
            progressBar.setProgress(0);
            FrameLayout progressBarLayout = (FrameLayout) findViewById(R.id.progressBarLayout);
            progressBarLayout.setVisibility(View.VISIBLE);
            WebViewDemoActivity.this.setProgress(progress * 1000);

            TextView progressStatus = (TextView) findViewById(R.id.progressStatus);
            progressStatus.setText(progress + " %");
            progressBar.incrementProgressBy(progress);

            if (progress == 100) {
                progressBarLayout.setVisibility(View.GONE);
            }
        }

        @Override
        public void onReceivedTitle(WebView view, String title) {
            WebViewDemoActivity.this.setTitle(
                    getString(R.string.app_name) + " - " + WebViewDemoActivity.this.webview.getTitle());
            for (Link link : historyStack) {
                if (link.getUrl().equals(WebViewDemoActivity.this.webview.getUrl())) {
                    link.setTitle(title);
                }
            }
        }

        @Override
        public void onReceivedIcon(WebView view, Bitmap icon) {
            faviconImageView.setImageBitmap(icon);
            view.getUrl();
            boolean b = false;
            ListIterator<Link> listIterator = historyStack.listIterator();
            while (!b && listIterator.hasNext()) {
                Link link = listIterator.next();
                if (link.getUrl().equals(view.getUrl())) {
                    link.setFavicon(icon);
                    b = true;
                }
            }
        }

    });

    //http://stackoverflow.com/questions/2083909/android-webview-refusing-user-input
    webview.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
            case MotionEvent.ACTION_UP:
                if (!v.hasFocus()) {
                    v.requestFocus();
                }
                break;
            }
            return false;
        }

    });

}

From source file:android.support.v7.widget.FastScroller.java

@Override
public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent ev) {
    final boolean handled;
    if (mState == STATE_VISIBLE) {
        boolean insideVerticalThumb = isPointInsideVerticalThumb(ev.getX(), ev.getY());
        boolean insideHorizontalThumb = isPointInsideHorizontalThumb(ev.getX(), ev.getY());
        if (ev.getAction() == MotionEvent.ACTION_DOWN && (insideVerticalThumb || insideHorizontalThumb)) {
            if (insideHorizontalThumb) {
                mDragState = DRAG_X;//from   ww  w.  j a  v a2 s  .  co m
                mHorizontalDragX = (int) ev.getX();
            } else if (insideVerticalThumb) {
                mDragState = DRAG_Y;
                mVerticalDragY = (int) ev.getY();
            }

            setState(STATE_DRAGGING);
            handled = true;
        } else {
            handled = false;
        }
    } else if (mState == STATE_DRAGGING) {
        handled = true;
    } else {
        handled = false;
    }
    return handled;
}

From source file:com.aibinong.tantan.ui.widget.CircleNoPageIndicator.java

public boolean onTouchEvent(android.view.MotionEvent ev) {
    if (super.onTouchEvent(ev)) {
        return true;
    }//from w w  w  .jav  a 2 s.  co m
    //        if ((mViewPager == null) || (mViewPager.getAdapter().getCount() == 0)) {
    //            return false;
    //        }

    final int action = ev.getAction() & MotionEventCompat.ACTION_MASK;
    switch (action) {
    case MotionEvent.ACTION_DOWN:
        mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
        mLastMotionX = ev.getX();
        break;

    case MotionEvent.ACTION_MOVE: {
        final int activePointerIndex = MotionEventCompat.findPointerIndex(ev, mActivePointerId);
        final float x = MotionEventCompat.getX(ev, activePointerIndex);
        final float deltaX = x - mLastMotionX;

        if (!mIsDragging) {
            if (Math.abs(deltaX) > mTouchSlop) {
                mIsDragging = true;
            }
        }

        if (mIsDragging) {
            mLastMotionX = x;
            //                    if (mViewPager.isFakeDragging() || mViewPager.beginFakeDrag()) {
            //                        mViewPager.fakeDragBy(deltaX);
            //                    }
        }

        break;
    }

    case MotionEvent.ACTION_CANCEL:
    case MotionEvent.ACTION_UP:
        if (!mIsDragging) {
            final int count = mRealCountGetter.getRealCount();
            final int width = getWidth();
            final float halfWidth = width / 2f;
            final float sixthWidth = width / 6f;

            if ((mCurrentPage > 0) && (ev.getX() < halfWidth - sixthWidth)) {
                if (action != MotionEvent.ACTION_CANCEL) {
                    //                            mViewPager.setCurrentItem(mCurrentPage - 1);
                }
                return true;
            } else if ((mCurrentPage < count - 1) && (ev.getX() > halfWidth + sixthWidth)) {
                if (action != MotionEvent.ACTION_CANCEL) {
                    //                            mViewPager.setCurrentItem(mCurrentPage + 1);
                }
                return true;
            }
        }

        mIsDragging = false;
        mActivePointerId = INVALID_POINTER;
        //                if (mViewPager.isFakeDragging()) mViewPager.endFakeDrag();
        break;

    case MotionEventCompat.ACTION_POINTER_DOWN: {
        final int index = MotionEventCompat.getActionIndex(ev);
        mLastMotionX = MotionEventCompat.getX(ev, index);
        mActivePointerId = MotionEventCompat.getPointerId(ev, index);
        break;
    }

    case MotionEventCompat.ACTION_POINTER_UP:
        final int pointerIndex = MotionEventCompat.getActionIndex(ev);
        final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex);
        if (pointerId == mActivePointerId) {
            final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
            mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex);
        }
        mLastMotionX = MotionEventCompat.getX(ev, MotionEventCompat.findPointerIndex(ev, mActivePointerId));
        break;
    }

    return true;
}

From source file:com.appeaser.sublimepickerlibrary.datepicker.DayPickerViewPager.java

@Override
public boolean onTouchEvent(MotionEvent ev) {
    if (!mCanPickRange) {
        return super.onTouchEvent(ev);
    }//from  www. ja  v  a 2s. com

    // looks like the ViewPager wants to step in
    if (mCheckForLongPress != null) {
        removeCallbacks(mCheckForLongPress);
    }

    if (mIsLongPressed && ev.getAction() == MotionEvent.ACTION_UP
            || ev.getAction() == MotionEvent.ACTION_CANCEL) {
        if (Config.DEBUG) {
            Log.i(TAG, "OTE: LONGPRESS && (UP || CANCEL)");
        }

        if (ev.getAction() == MotionEvent.ACTION_UP) {
            if (mDayPickerPagerAdapter != null) {
                mTempSelectedDate = mDayPickerPagerAdapter.resolveEndDateForRange((int) ev.getX(),
                        (int) ev.getY(), getCurrentItem(), false);
                mDayPickerPagerAdapter.onDateRangeSelectionEnded(mTempSelectedDate);
            }
        }

        mIsLongPressed = false;
        mInitialDownX = -1;
        mInitialDownY = -1;
        mScrollingDirection = NOT_SCROLLING;

        if (mScrollerRunnable != null) {
            removeCallbacks(mScrollerRunnable);
        }
        //return true;
    } else if (mIsLongPressed && ev.getAction() == MotionEvent.ACTION_DOWN) {
        if (Config.DEBUG) {
            Log.i(TAG, "OTE: LONGPRESS && DOWN");
        }

        mScrollingDirection = NOT_SCROLLING;
    } else if (mIsLongPressed && ev.getAction() == MotionEvent.ACTION_MOVE) {
        if (Config.DEBUG) {
            Log.i(TAG, "OTE: LONGPRESS && MOVE");
        }

        int direction = resolveDirectionForScroll(ev.getX());
        boolean directionChanged = mScrollingDirection != direction;

        if (directionChanged) {
            if (mScrollerRunnable != null) {
                removeCallbacks(mScrollerRunnable);
            }
        }

        if (mScrollerRunnable == null) {
            mScrollerRunnable = new ScrollerRunnable();
        }

        mScrollingDirection = direction;

        if (mScrollingDirection == NOT_SCROLLING) {
            if (mDayPickerPagerAdapter != null) {
                mTempSelectedDate = mDayPickerPagerAdapter.resolveEndDateForRange((int) ev.getX(),
                        (int) ev.getY(), getCurrentItem(), true);

                if (mTempSelectedDate != null) {
                    mDayPickerPagerAdapter.onDateRangeSelectionUpdated(mTempSelectedDate);
                }
            }
        } else if (directionChanged) { // SCROLLING_LEFT || SCROLLING_RIGHT
            post(mScrollerRunnable);
        }
    }

    return mIsLongPressed || super.onTouchEvent(ev);
}

From source file:com.android.utils.ExploreByTouchHelper.java

/**
 * Dispatches hover {@link MotionEvent}s to the virtual view hierarchy when
 * the Explore by Touch feature is enabled.
 * <p>/* w ww  . java2  s.  co m*/
 * This method should be called by overriding
 * {@link View#dispatchHoverEvent}:
 *
 * <pre>
 * &#64;Override
 * public boolean dispatchHoverEvent(MotionEvent event) {
 *   if (mHelper.dispatchHoverEvent(this, event) {
 *     return true;
 *   }
 *   return super.dispatchHoverEvent(event);
 * }
 * </pre>
 *
 * @param event The hover event to dispatch to the virtual view hierarchy.
 * @return Whether the hover event was handled.
 */
public boolean dispatchHoverEvent(MotionEvent event) {
    if (!mManager.isTouchExplorationEnabled()) {
        return false;
    }

    int virtualViewId = getVirtualViewIdAt(event.getX(), event.getY());
    if (virtualViewId == INVALID_ID) {
        virtualViewId = ROOT_ID;
    }

    switch (event.getAction()) {
    case MotionEvent.ACTION_HOVER_ENTER:
    case MotionEvent.ACTION_HOVER_MOVE:
        setHoveredVirtualViewId(virtualViewId);
        break;
    case MotionEvent.ACTION_HOVER_EXIT:
        setHoveredVirtualViewId(virtualViewId);
        break;
    }

    return true;
}

From source file:com.timemachine.controller.ControllerActivity.java

private void setupUI() {
    // Set layout listener
    View controllerView = findViewById(R.id.controllerView);
    ViewTreeObserver vto = controllerView.getViewTreeObserver();
    vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
        @Override// w  ww  .  jav  a2 s .c  o  m
        public void onGlobalLayout() {
            runOnUiThread(new Runnable() {
                public void run() {
                    locationSliderHeight = locationSlider.getHeight();
                    originLocationSliderContainerY = locationSliderContainer.getY();
                    originPlayPauseButtonY = playPause.getY();
                    minLocationSliderContainerY = originLocationSliderContainerY;
                    maxLocationSliderContainerY = originLocationSliderContainerY + locationSliderHeight;
                    midLocationSliderContainerY = (minLocationSliderContainerY + maxLocationSliderContainerY)
                            / 2;
                }
            });
            System.out.println("locationSliderHeight: " + locationSliderHeight);
            System.out.println("locationSliderContainerY: " + originLocationSliderContainerY);
            locationSlider.getViewTreeObserver().removeOnGlobalLayoutListener(this);
        }
    });

    // Connect to controller.html
    controllerURL = "http://" + ipText + ":8080/controller.html";
    locationSlider = (WebView) findViewById(R.id.webview);
    locationSliderContainer = (FrameLayout) findViewById(R.id.sliderContainer);
    locationSlider.setBackgroundColor(Color.TRANSPARENT);
    locationSlider.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
    locationSlider.setWebViewClient(new WebViewClient() {
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            System.out.println("onReceivedError");
            showConnectDialog("Error while connecting to controller. Connect again.");
        }

        @Override
        public void onLoadResource(WebView view, String url) {
            if (url.contains("thumbnail"))
                isMasterConnected = true;
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            isMasterConnectedTimerTask = null;
            isMasterConnectedTimerTask = new TimerTask() {
                @Override
                public void run() {
                    if (isMasterConnected == false)
                        showConnectDialog("Master is not loaded in the browser. Connect again.");
                }
            };
            isMasterConnectedTimer.schedule(isMasterConnectedTimerTask, 6000);
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            if (url.contains(controllerURL)) {
                drag.setVisibility(View.VISIBLE);
                playPause.setVisibility(View.VISIBLE);
                loadPreferences();
            }
            super.onPageFinished(view, url);
        }
    });
    try {
        locationSlider.loadUrl(controllerURL);
    } catch (Exception e) {
        e.printStackTrace();
    }

    // Set JavaScript Interface
    locationSlider.addJavascriptInterface(this, "androidObject");
    WebSettings webSettings = locationSlider.getSettings();
    webSettings.setJavaScriptEnabled(true);

    // Set the play-pause button
    playPause = (ImageButton) findViewById(R.id.playPauseButton);
    playPause.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            socket.emit("handlePlayPauseServer");
        }
    });
    socket.emit("setControllerPlayButton");

    // Set the drag button
    drag = (ImageButton) findViewById(R.id.drag);
    drag.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                dragYDiffBetweenFingerAndSliderTop = locationSliderContainer.getY() - event.getRawY();
                dragYDiffBetweenFingerAndPlayPauseTop = playPause.getY() - event.getRawY();
            }
            if (event.getAction() == MotionEvent.ACTION_MOVE) {
                // Move the slider based on current finger location
                float newSliderY = event.getRawY() + dragYDiffBetweenFingerAndSliderTop;
                float newPlayPauseY = event.getRawY() + dragYDiffBetweenFingerAndPlayPauseTop;
                if (newSliderY > minLocationSliderContainerY && newSliderY < maxLocationSliderContainerY) {
                    locationSliderContainer.setY(newSliderY);
                    playPause.setY(newPlayPauseY);
                }
            }
            if (event.getAction() == MotionEvent.ACTION_UP) {
                if (event.getEventTime() - event.getDownTime() <= tapTimeout) {
                    // Tap is detected, toggle the slider
                    System.out.println("onTap");
                    runOnUiThread(new Runnable() {
                        public void run() {
                            toggleSlider();
                        }
                    });
                } else {
                    // Not a tap gesture, slide up or down based on the slider's current position
                    if (locationSliderContainer.getY() > midLocationSliderContainerY)
                        slideDown();
                    else
                        slideUp();
                }
            }
            return true;
        }
    });

    // Set the Google map
    setUpMapIfNeeded();
}

From source file:com.borax12.materialdaterangepicker.date.MonthView.java

@Override
public boolean onTouchEvent(@NonNull MotionEvent event) {
    switch (event.getAction()) {
    case MotionEvent.ACTION_UP:
        final int day = getDayFromLocation(event.getX(), event.getY());
        if (day >= 0) {
            onDayClick(day);/*  ww w. java 2  s  . com*/
        }
        break;
    }
    return true;
}

From source file:com.example.appf.CS3570.java

@Override
public boolean onTouchEvent(MotionEvent e) {
    // MotionEvent reports input details from the touch screen
    // and other input controls. In this case, you are only
    // interested in events where the touch position changed.

    float x = e.getX();
    float y = e.getY();

    switch (e.getAction()) {
    case MotionEvent.ACTION_DOWN:
        if (mother.out != null) {
            mother.out.println("{\"type\": \"DOWN\", \"x\": " + x + ", \"y\": " + y + "}\0");
        }/*  ww  w .  ja va 2s .  c  om*/
        break;
    case MotionEvent.ACTION_UP:
        if (mother.out != null) {
            mother.out.println("{\"type\": \"UP\", \"x\": " + x + ", \"y\": " + y + "}\0");
        }
        break;
    case MotionEvent.ACTION_MOVE:

        float dx = x - mPreviousX;
        float dy = y - mPreviousY;

        // reverse direction of rotation above the mid-line
        if (y > getHeight() / 2) {
            dx = dx * -1;
        }

        // reverse direction of rotation to left of the mid-line
        if (x < getWidth() / 2) {
            dy = dy * -1;
        }

        //mRenderer.mAngle += (dx + dy) * TOUCH_SCALE_FACTOR;  // = 180.0f / 320
        //mRenderer.mTetra.rotate(dx, 0, 1, 0);
        //mRenderer.mTetra.rotate(dy, 1, 0, 0);
        //mRenderer.mCamera.rotateY((double)(dx * TOUCH_SCALE_FACTOR));
        //mRenderer.mCamera.rotateX((double)(dy * TOUCH_SCALE_FACTOR));
        if (mother.out != null) {
            Log.e("eee", "{\"type\": \"MOVE\", \"x\": " + x + ", \"y\": " + y + "}");
            mother.out.println("{\"type\": \"MOVE\", \"x\": " + x + ",  \"y\": " + y + "}\0");
        }
        requestRender();
    }

    mPreviousX = x;
    mPreviousY = y;
    return true;
}