Example usage for android.view MotionEvent ACTION_UP

List of usage examples for android.view MotionEvent ACTION_UP

Introduction

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

Prototype

int ACTION_UP

To view the source code for android.view MotionEvent ACTION_UP.

Click Source Link

Document

Constant for #getActionMasked : A pressed gesture has finished, the motion contains the final release location as well as any intermediate points since the last down or move event.

Usage

From source file:android.support.design.widget.SwipeDismissBehavior.java

@Override
public boolean onInterceptTouchEvent(CoordinatorLayout parent, V child, MotionEvent event) {
    boolean dispatchEventToHelper = mInterceptingEvents;

    switch (MotionEventCompat.getActionMasked(event)) {
    case MotionEvent.ACTION_DOWN:
        mInterceptingEvents = parent.isPointInChildBounds(child, (int) event.getX(), (int) event.getY());
        dispatchEventToHelper = mInterceptingEvents;
        break;/*from   w w w.ja  v  a  2 s .c o  m*/
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_CANCEL:
        // Reset the ignore flag for next time
        mInterceptingEvents = false;
        break;
    }

    if (dispatchEventToHelper) {
        ensureViewDragHelper(parent);
        return mViewDragHelper.shouldInterceptTouchEvent(event);
    }
    return false;
}

From source file:com.azure.webapi.LoginManager.java

/**
 * Creates the UI for the interactive authentication process
 * //w  ww .j  a v  a 2  s . c  o  m
 * @param provider
 *            The provider used for the authentication process
 * @param startUrl
 *            The initial URL for the authentication process
 * @param endUrl
 *            The final URL for the authentication process
 * @param context
 *            The context used to create the authentication dialog
 * @param callback
 *            Callback to invoke when the authentication process finishes
 */
protected void showLoginUI(MobileServiceAuthenticationProvider provider, final String startUrl,
        final String endUrl, final Context context, LoginUIOperationCallback callback) {
    if (startUrl == null || startUrl == "") {
        throw new IllegalArgumentException("startUrl can not be null or empty");
    }

    if (endUrl == null || endUrl == "") {
        throw new IllegalArgumentException("endUrl can not be null or empty");
    }

    if (context == null) {
        throw new IllegalArgumentException("context can not be null");
    }

    final LoginUIOperationCallback externalCallback = callback;
    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    // Create the Web View to show the login page
    final WebView wv = new WebView(context);
    builder.setTitle("Connecting to a service");
    builder.setCancelable(true);
    builder.setOnCancelListener(new DialogInterface.OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            if (externalCallback != null) {
                externalCallback.onCompleted(null, new MobileServiceException("User Canceled"));
            }
        }
    });

    // Set cancel button's action
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (externalCallback != null) {
                externalCallback.onCompleted(null, new MobileServiceException("User Canceled"));
            }
            wv.destroy();
        }
    });

    wv.getSettings().setJavaScriptEnabled(true);

    wv.requestFocus(View.FOCUS_DOWN);
    wv.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View view, MotionEvent event) {
            int action = event.getAction();
            if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_UP) {
                if (!view.hasFocus()) {
                    view.requestFocus();
                }
            }

            return false;
        }
    });

    // Create a LinearLayout and add the WebView to the Layout
    LinearLayout layout = new LinearLayout(context);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.addView(wv);

    // Add a dummy EditText to the layout as a workaround for a bug
    // that prevents showing the keyboard for the WebView on some devices
    EditText dummyEditText = new EditText(context);
    dummyEditText.setVisibility(View.GONE);
    layout.addView(dummyEditText);

    // Add the layout to the dialog
    builder.setView(layout);

    final AlertDialog dialog = builder.create();

    wv.setWebViewClient(new WebViewClient() {

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            // If the URL of the started page matches with the final URL
            // format, the login process finished
            if (isFinalUrl(url)) {
                if (externalCallback != null) {
                    externalCallback.onCompleted(url, null);
                }

                dialog.dismiss();
            }

            super.onPageStarted(view, url, favicon);
        }

        // Checks if the given URL matches with the final URL's format
        private boolean isFinalUrl(String url) {
            if (url == null) {
                return false;
            }

            return url.startsWith(endUrl);
        }

        // Checks if the given URL matches with the start URL's format
        private boolean isStartUrl(String url) {
            if (url == null) {
                return false;
            }

            return url.startsWith(startUrl);
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            if (isStartUrl(url)) {
                if (externalCallback != null) {
                    externalCallback.onCompleted(null, new MobileServiceException(
                            "Logging in with the selected authentication provider is not enabled"));
                }

                dialog.dismiss();
            }
        }
    });

    wv.loadUrl(startUrl);
    dialog.show();
}

From source file:com.arthurpitman.common.SlidingPanel.java

@Override
public boolean onTouchEvent(MotionEvent event) {
    float y = event.getY();
    int action = event.getActionMasked();
    int pointerId = event.getPointerId(event.getActionIndex());

    switch (action) {
    case MotionEvent.ACTION_POINTER_DOWN:
    case MotionEvent.ACTION_DOWN:
        startTouchY = y;//from w  ww  .j ava 2 s.  com
        startTouchScrollY = getScrollY();

        // if touch didn't occur on the actual control, ignore it
        float touchBoundary = viewHeight - collapsedHeight - startTouchScrollY;
        if (y < touchBoundary) {
            return false;
        }

        // start tracking velocity
        if (velocityTracker == null) {
            velocityTracker = VelocityTracker.obtain();
        } else {
            velocityTracker.clear();
        }
        velocityTracker.addMovement(event);
        break;

    case MotionEvent.ACTION_MOVE:
        // determine if a valid touch has started
        if (Math.abs(y - startTouchY) > touchSlop) {
            touchState = TOUCH_STARTED;
        }
        if (velocityTracker != null) {
            velocityTracker.addMovement(event);
        }

        // scroll as appropriate
        if (touchState == TOUCH_STARTED) {
            final int scrollDelta = (int) (startTouchY - y);
            scrollTo(0, Math.max(0, Math.min(viewHeight, startTouchScrollY + scrollDelta)));
        }
        break;

    case MotionEvent.ACTION_CANCEL:
    case MotionEvent.ACTION_POINTER_UP:
    case MotionEvent.ACTION_UP:
        if (touchState == TOUCH_STARTED) {
            final int currentScrollY = getScrollY();

            // get velocity
            float velocity = 0;
            if (velocityTracker != null) {
                velocityTracker.computeCurrentVelocity(1000);
                velocity = VelocityTrackerCompat.getYVelocity(velocityTracker, pointerId);
                velocityTracker.recycle();
                velocityTracker = null;
            }

            // snap to final scroll position
            int target = startTouchScrollY;
            if ((Math.abs(velocity) > minimumflingVelocity) || (Math.abs(y - startTouchY) > (viewHeight / 2))) {
                if (velocity < 0) {
                    target = viewHeight;
                } else {
                    target = 0;
                }
            }
            scroller.startScroll(0, currentScrollY, 0, target - currentScrollY);
            invalidate();
            touchState = TOUCH_NONE;
        }
        break;
    }
    return true;
}

From source file:com.app.gongza.libs.view.scrollablelayout.ScrollableLayout.java

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    float currentX = ev.getX();
    float currentY = ev.getY();
    float deltaY;
    int shiftX = (int) Math.abs(currentX - mDownX);
    int shiftY = (int) Math.abs(currentY - mDownY);
    switch (ev.getAction()) {
    case MotionEvent.ACTION_DOWN:
        mDisallowIntercept = false;/*from   w  ww .j a  v a2s .  co  m*/
        needCheckUpdown = true;
        updown = true;
        mDownX = currentX;
        mDownY = currentY;
        mLastY = currentY;
        checkIsClickHead((int) currentY, mHeadHeight, getScrollY());
        checkIsClickHeadExpand((int) currentY, mHeadHeight, getScrollY());
        initOrResetVelocityTracker();
        mVelocityTracker.addMovement(ev);
        mScroller.forceFinished(true);
        break;
    case MotionEvent.ACTION_MOVE:
        if (mDisallowIntercept) {
            break;
        }
        initVelocityTrackerIfNotExists();
        mVelocityTracker.addMovement(ev);
        deltaY = mLastY - currentY;
        if (needCheckUpdown) {
            if (shiftX > mTouchSlop && shiftX > shiftY) {
                needCheckUpdown = false;
                updown = false;
            } else if (shiftY > mTouchSlop && shiftY > shiftX) {
                needCheckUpdown = false;
                updown = true;
            }
        }

        if (updown && shiftY > mTouchSlop && shiftY > shiftX
                && (!isSticked() || mHelper.isTop() || isClickHeadExpand)) {

            if (childViewPager != null) {
                childViewPager.requestDisallowInterceptTouchEvent(true);
            }
            scrollBy(0, (int) (deltaY + 0.5));
        }
        mLastY = currentY;
        break;
    case MotionEvent.ACTION_UP:
        if (updown && shiftY > shiftX && shiftY > mTouchSlop) {
            mVelocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
            float yVelocity = -mVelocityTracker.getYVelocity();
            boolean dislowChild = false;
            if (Math.abs(yVelocity) > mMinimumVelocity) {
                mDirection = yVelocity > 0 ? DIRECTION.UP : DIRECTION.DOWN;
                if ((mDirection == DIRECTION.UP && isSticked())
                        || (!isSticked() && getScrollY() == 0 && mDirection == DIRECTION.DOWN)) {
                    dislowChild = true;
                } else {
                    mScroller.fling(0, getScrollY(), 0, (int) yVelocity, 0, 0, -Integer.MAX_VALUE,
                            Integer.MAX_VALUE);
                    mScroller.computeScrollOffset();
                    mLastScrollerY = getScrollY();
                    invalidate();
                }
            }
            if (!dislowChild && (isClickHead || !isSticked())) {
                int action = ev.getAction();
                ev.setAction(MotionEvent.ACTION_CANCEL);
                boolean dispathResult = super.dispatchTouchEvent(ev);
                ev.setAction(action);
                return dispathResult;
            }
        }
        break;
    default:
        break;
    }
    super.dispatchTouchEvent(ev);
    return true;
}

From source file:com.android.gallery3d.v5.filtershow.category.CategoryView.java

@Override
public boolean onTouchEvent(MotionEvent event) {
    boolean ret = super.onTouchEvent(event);
    FilterShowActivity activity = (FilterShowActivity) getContext();

    if (event.getActionMasked() == MotionEvent.ACTION_UP) {
        activity.startTouchAnimation(this, event.getX(), event.getY());
    }//from w w w .  ja  v a 2 s .  co m
    if (!canBeRemoved()) {
        return ret;
    }
    if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
        mStartTouchY = event.getY();
        mStartTouchX = event.getX();
    }
    if (event.getActionMasked() == MotionEvent.ACTION_UP) {
        setTranslationX(0);
        setTranslationY(0);
    }
    if (event.getActionMasked() == MotionEvent.ACTION_MOVE) {
        float delta = event.getY() - mStartTouchY;
        if (getOrientation() == CategoryView.VERTICAL) {
            delta = event.getX() - mStartTouchX;
        }
        if (Math.abs(delta) > mDeleteSlope) {
            activity.setHandlesSwipeForView(this, mStartTouchX, mStartTouchY);
        }
    }
    return true;
}

From source file:com.appunite.appunitevideoplayer.PlayerActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.player_activity);
    root = (ViewGroup) findViewById(R.id.root);
    root.setOnTouchListener(new OnTouchListener() {
        @Override//  w w w  . j  a v  a2s.  c  o m
        public boolean onTouch(View view, MotionEvent motionEvent) {
            if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
                toggleControlsVisibility();
            } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
                view.performClick();
            }
            return true;
        }
    });
    root.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE
                    || keyCode == KeyEvent.KEYCODE_MENU) {
                return false;
            }
            return mediaController.dispatchKeyEvent(event);
        }
    });

    shutterView = findViewById(R.id.shutter);

    videoFrame = (AspectRatioFrameLayout) findViewById(R.id.video_frame);
    surfaceView = (SurfaceView) findViewById(R.id.surface_view);
    surfaceView.getHolder().addCallback(this);

    subtitleLayout = (SubtitleLayout) findViewById(R.id.subtitles);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setNavigationIcon(R.drawable.ic_arrow_back);
    toolbar.setTitle(getIntent().getStringExtra(TITLE_TEXT_EXTRA));
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });

    mediaController = new MediaController(this);
    mediaController.setAnchorView(root);
    controllerView = (ViewGroup) findViewById(R.id.controller_view);
    controllerView.addView(mediaController);
    CookieHandler currentHandler = CookieHandler.getDefault();
    if (currentHandler != defaultCookieManager) {
        CookieHandler.setDefault(defaultCookieManager);
    }

    audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(this, this);
    audioCapabilitiesReceiver.register();

    progressBar = (ProgressBar) findViewById(R.id.progress_bar);

    playButton = (ImageView) findViewById(R.id.play_button_icon);
    final int playButtonIconDrawableId = getIntent().getIntExtra(PLAY_BUTTON_EXTRA, 0);
    if (playButtonIconDrawableId != 0) {
        playButton.setImageDrawable(ContextCompat.getDrawable(this, playButtonIconDrawableId));
        playButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                preparePlayer(true);
            }
        });
    }
}

From source file:com.android.messaging.ui.conversationlist.ConversationListSwipeHelper.java

@Override
public boolean onInterceptTouchEvent(final RecyclerView recyclerView, final MotionEvent event) {
    if (event.getPointerCount() > 1) {
        // Ignore subsequent pointers.
        return false;
    }//  www .j a  va2  s.  c o  m

    // We are not yet tracking a swipe gesture. Begin detection by spying on
    // touch events bubbling down to our children.
    final int action = event.getActionMasked();
    switch (action) {
    case MotionEvent.ACTION_DOWN:
        if (!hasGestureSwipeTarget()) {
            onGestureStart();

            mVelocityTracker.addMovement(event);
            mInitialX = event.getX();
            mInitialY = event.getY();

            final View viewAtPoint = mRecyclerView.findChildViewUnder(mInitialX, mInitialY);
            final ConversationListItemView child = (ConversationListItemView) viewAtPoint;
            if (viewAtPoint instanceof ConversationListItemView && child != null && child.isSwipeAnimatable()) {
                // Begin detecting swipe on the target for the rest of the gesture.
                mListItemView = child;
                if (mListItemView.isAnimating()) {
                    mListItemView = null;
                }
            } else {
                mListItemView = null;
            }
        }
        break;
    case MotionEvent.ACTION_MOVE:
        if (hasValidGestureSwipeTarget()) {
            mVelocityTracker.addMovement(event);

            final int historicalCount = event.getHistorySize();
            // First consume the historical events, then consume the current ones.
            for (int i = 0; i < historicalCount + 1; i++) {
                float currX;
                float currY;
                if (i < historicalCount) {
                    currX = event.getHistoricalX(i);
                    currY = event.getHistoricalY(i);
                } else {
                    currX = event.getX();
                    currY = event.getY();
                }
                final float deltaX = currX - mInitialX;
                final float deltaY = currY - mInitialY;
                final float absDeltaX = Math.abs(deltaX);
                final float absDeltaY = Math.abs(deltaY);

                if (!mIsSwiping && absDeltaY > mTouchSlop
                        && absDeltaY > (ERROR_FACTOR_MULTIPLIER * absDeltaX)) {
                    // Stop detecting swipe for the remainder of this gesture.
                    onGestureEnd();
                    return false;
                }

                if (absDeltaX > mTouchSlop) {
                    // Swipe detected. Return true so we can handle the gesture in
                    // onTouchEvent.
                    mIsSwiping = true;

                    // We don't want to suddenly jump the slop distance.
                    mInitialX = event.getX();
                    mInitialY = event.getY();

                    onSwipeGestureStart(mListItemView);
                    return true;
                }
            }
        }
        break;
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_CANCEL:
        if (hasGestureSwipeTarget()) {
            onGestureEnd();
        }
        break;
    }

    // Start intercepting touch events from children if we detect a swipe.
    return mIsSwiping;
}

From source file:com.nextgis.maplibui.formcontrol.Sign.java

@Override
public boolean onTouchEvent(@NonNull MotionEvent event) {

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

    switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
        if (!mNotInitialized)
            touchStart(x, y);//from   w  w  w .  j ava2s .  c  o m
        break;

    case MotionEvent.ACTION_MOVE:
        if (!mNotInitialized) {
            touchMove(x, y);
            postInvalidate();
        }
        break;

    case MotionEvent.ACTION_UP:
        int posX = getWidth() - mClearImageSize - mClearBuff;
        //Log.d(Constants.TAG, "x: " + event.getX() + " y: " + event.getY() + " posX: " + posX + " posY: " + mClearBuff);
        if (event.getX() > posX && event.getY() < mClearImageSize + mClearBuff) {
            onClearSign();
        } else if (!mNotInitialized) {
            touchUp();
            invalidate();
        }
        break;

    default:
        break;
    }

    return true;
}

From source file:com.adguard.android.commons.BrowserUtils.java

public static void showBrowserInstallDialog(final Context context) {
    // Touch listener for changing colors of CardViews
    View.OnTouchListener touchListener = new View.OnTouchListener() {
        @Override// w ww. j  a  v  a 2s . c  o m
        public boolean onTouch(View v, MotionEvent event) {
            int action = event.getActionMasked();
            if (action == MotionEvent.ACTION_DOWN) {
                ((CardView) v).setCardBackgroundColor(R.color.card_view_background_pressed);
            } else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL
                    || action == MotionEvent.ACTION_OUTSIDE) {
                ((CardView) v).setCardBackgroundColor(R.color.white);
            }
            return false;
        }
    };

    final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View dialogLayout = inflater.inflate(R.layout.select_browser_dialog, null);
    AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.AlertDialog);
    builder.setNegativeButton(android.R.string.cancel, null);
    builder.setView(dialogLayout);
    final AlertDialog dialog = builder.create();

    View cardView = dialogLayout.findViewById(R.id.browser_yandex);
    cardView.setOnTouchListener(touchListener);
    cardView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ActivityUtils.startMarket(context, YANDEX_BROWSER_PACKAGE, REFERRER);
            dialog.dismiss();
        }
    });

    cardView = dialogLayout.findViewById(R.id.browser_samsung);
    cardView.setOnTouchListener(touchListener);
    cardView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ActivityUtils.startMarket(context, SAMSUNG_BROWSER_PACKAGE, null);
            dialog.dismiss();
        }
    });

    dialog.show();
}

From source file:com.tarun.smartwomen.WebViewDemoActivity.java

@SuppressLint({ "JavascriptInterface", "SetJavaScriptEnabled" })
@Override//from w  w  w  .  jav  a  2 s.c o  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.mainn);

    Intent intent = getIntent();
    reg = intent.getBooleanExtra("reg", false);

    i = (ImageView) findViewById(R.id.hj);

    try {

        big = new GifAnimationDrawable(getResources().openRawResource(R.raw.anim2));
        // big.setOneShot(true);
        android.util.Log.v("GifAnimationDrawable", "===>Four");
    } catch (IOException ioe) {

    }

    i.setImageDrawable(big);
    big.setVisible(true, true);

    sp = getSharedPreferences("your_prefs", Activity.MODE_PRIVATE);
    // historyStack = new LinkedList<Link>();
    webview = (WebView) findViewById(R.id.webkit);

    WebSettings webSettings = webview.getSettings();
    webSettings.setJavaScriptEnabled(true);

    webSettings.setDomStorageEnabled(true);
    // webview.addJavascriptInterface(new WebViewDemoActivity(), "Android");
    // webview.getSettings().setJavaScriptEnabled(true);

    webview.getSettings().setBuiltInZoomControls(true);

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

    // Internet

    ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(
            Context.CONNECTIVITY_SERVICE);
    connected = false;
    if ((null != connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE) && connectivityManager
            .getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState() == NetworkInfo.State.CONNECTED)
            || (null != connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI) && connectivityManager
                    .getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED)) {
        // we are connected to a network
        connected = true;
    }

    if (connected == false) {
        /*
         * Toast.makeText(Rss.this,
         * "Connect to internet and Restart Application",
         * Toast.LENGTH_SHORT).show();
         */
        webview.setVisibility(View.INVISIBLE);

        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(WebViewDemoActivity.this);

        // alertDialogBuilder.setTitle("Please connect to Internet");
        alertDialogBuilder.setMessage(
                "In order to provide the freshest recipes and juicing information this app must be connected to the internet, please check your internet settings");
        // set positive button: Yes message

        alertDialogBuilder.setNegativeButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                // cancel the alert box and put a Toast to the user

                startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0);
            }
        });
        AlertDialog alertDialog = alertDialogBuilder.create();
        // show alert
        alertDialog.show();

    }

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

    webview.setWebViewClient(new CustomWebViewClient());

    webview.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int progress) {

        }

        @Override
        public void onReceivedTitle(WebView view, String title) {
        }

        @Override
        public void onReceivedIcon(WebView view, Bitmap icon) {

        }

    });

    // 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;
        }

    });

    if (reg == true) {
        if (Locale.getDefault().getLanguage().equals("es")) {

            webview.loadUrl("http://om-msmartwoman.com/member/register");
            // webview.loadUrl("http://live-juice-guru.gotpantheon.com/user/login");
        } else {
            webview.loadUrl("http://om-msmartwoman.com/member/register");
        }

        webview.requestFocus();
    } else {
        uhdj = sp.getString("your_int_key", "0");

        Log.e("Url is here ..............................", uhdj);
        // Welcome page loaded from assets directory
        if (Locale.getDefault().getLanguage().equals("es")) {

            webview.loadUrl(uhdj);
            // webview.loadUrl("http://live-juice-guru.gotpantheon.com/user/login");
        } else {
            webview.loadUrl(uhdj);
        }

        webview.requestFocus();
    }

}