Exemplo n.º 1
0
 @Override
 public void onClick(View arg0) {
   // TODO Auto-generated method stub
   switch (arg0.getId()) {
     case R.id.bGo:
       String theWebsite = url.getText().toString();
       ourBrow.loadUrl(theWebsite);
       // Hiding the keyboard after using EditText
       InputMethodManager imm =
           (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
       imm.hideSoftInputFromWindow(url.getWindowToken(), 0);
       break;
     case R.id.bBack:
       if (ourBrow.canGoBack()) ourBrow.goBack();
       break;
     case R.id.bForward:
       if (ourBrow.canGoForward()) ourBrow.goForward();
       break;
     case R.id.bRefresh:
       ourBrow.reload();
       break;
     case R.id.bHistory:
       ourBrow.clearHistory();
       break;
   }
 }
Exemplo n.º 2
0
  /**
   * Click handlers for buttons
   *
   * @param target Button that is clicked
   */
  public void onButtonClickHandler(View target) {
    try {

      if (target.getId() == R.id.buttonWebBack) {
        if (mWebView.canGoBack()) {
          mWebView.goBack();
        }
      } else if (target.getId() == R.id.buttonWebReload) {
        mWebView.reload();
      }
      //			else if (target.getId() == R.id.buttonWebStop)
      //			{
      //				mWebView.stopLoading();
      //			}
      else if (target.getId() == R.id.buttonWebForward) {
        if (mWebView.canGoForward()) {
          mWebView.goForward();
        }
      } else if (target.getId() == R.id.buttonClose) {
        finish();
      } else if (target.getId() == R.id.buttonShare) {
        Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(mWebView.getUrl()));
        startActivity(Intent.createChooser(i, getString(R.string.BTN_SHARING)));
      }
    } catch (Exception e) {

    }
  }
Exemplo n.º 3
0
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.Go:
        String URL = inputURL.getText().toString();
        browser.loadUrl(URL);
        InputMethodManager inputMethodManager =
            (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromInputMethod(inputURL.getWindowToken(), 0);
        break;

      case R.id.GoBK:
        if (browser.canGoBack()) browser.goBack();
        break;

      case R.id.GoFR:
        if (browser.canGoForward()) browser.goForward();
        break;

      case R.id.GoRF:
        browser.reload();
        break;

      case R.id.GoCR:
        browser.clearHistory();
        break;
    }
  }
Exemplo n.º 4
0
  public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
    float vx = Math.abs(velocityX); // 取其绝对值
    float vy = Math.abs(velocityY);
    // ----begin设置浮动框的弹出和收回--------------------
    if (vy > vx) {
      if (velocityY > 0) { // 设置弹出
        if (flag == false) {

          int height = myRelativeLayout.getHeight();
          Animation myTranslateAnimation = new TranslateAnimation(0, 0, -height, 0);
          myTranslateAnimation.setDuration(500);
          myRelativeLayout.setAnimation(myTranslateAnimation);
          myRelativeLayout.setVisibility(View.VISIBLE);

          flag = true;
        }

      } else if (velocityY < 0) { // 设置收回

        if (flag == true) {
          int height = myRelativeLayout.getHeight();
          Animation myTranslateAnimation = new TranslateAnimation(0, 0, 0, -height);
          myTranslateAnimation.setDuration(500);
          myRelativeLayout.setAnimation(myTranslateAnimation);
          myRelativeLayout.setVisibility(View.GONE);
          flag = false;
        }
      }

    } else
    // -----end设置浮动框的弹出和收回---------------------------------
    // -----begin设置左右滑动翻页-----------------------
    if (vx > vy) {
      if (velocityX > 0) { // 前一页
        if (myWebView.canGoBack()) {

          myWebView.goBack();

          int width = myWebView.getWidth();
          Animation myTranslateAnimation = new TranslateAnimation(0, width, 0, 0);
          myTranslateAnimation.setDuration(400);
          myWebView.setAnimation(myTranslateAnimation);
        }
      } else if (velocityX < 0) { // 后一页
        if (myWebView.canGoForward()) {

          myWebView.goForward();

          int width = myWebView.getWidth();
          Animation myTranslateAnimation = new TranslateAnimation(0, -width, 0, 0);
          myTranslateAnimation.setDuration(400);
          myWebView.setAnimation(myTranslateAnimation);
        }
      }
    }
    // -----end设置左右滑动翻页------------------------
    return false;
  }
Exemplo n.º 5
0
 /** Go forward in the history list */
 @SimpleFunction(
     description =
         "Go forward to the next page in the history list.   "
             + "Does nothing if there is no next page.")
 public void GoForward() {
   if (webview.canGoForward()) {
     webview.goForward();
   }
 }
Exemplo n.º 6
0
 public void onClick(View v) {
   if (webView != null) {
     switch (v.getId()) {
       case R.id.btnGoBack:
         webView.goBack();
         v.setEnabled(webView.canGoBack());
         break;
       case R.id.btnGoForward:
         webView.goForward();
         v.setEnabled(webView.canGoForward());
         break;
     }
   }
 }
Exemplo n.º 7
0
  private void optionUp(View view) {
    if (view.getId() == ID_BACK) {
      EventHandler.notify(notifyHandler, EventMessage.MSG_BROWSER_CLOSE, 0, 0, null);
    }
    if (view.getId() == ID_PRE_PAGE) {
      if (webView.canGoBack()) {
        webView.goBack();
      }
    }
    if (view.getId() == ID_NEXT_PAGE) {
      if (webView.canGoForward()) {
        webView.goForward();
      }
    }
    if (view.getId() == ID_FLASH) {
      webView.reload();
    }

    optionCancel(view);
  }
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.bGo:
        String theWebSite = url.getText().toString();
        ourBrow.loadUrl(theWebSite);
        // hiding the Keyboard after using an EditText
        InputMethodManager imm =
            (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(url.getWindowToken(), 0);
        break;

      case R.id.bBack:
        if (ourBrow.canGoBack()) {
          ourBrow.goBack();
          url.setText(ourBrow.getOriginalUrl());
        }
        break;

      case R.id.bRefresh:
        ourBrow.reload();
        break;

      case R.id.bForward:
        if (ourBrow.canGoForward()) {
          ourBrow.goForward();
          url.setText(ourBrow.getUrl());
        }
        break;

      case R.id.bHistory:
        ourBrow.clearHistory();
        url.setText("");
        break;
    }
  }
Exemplo n.º 9
0
 /** 菜单点击响应 */
 @Override
 public boolean onMenuItemSelected(int featureId, MenuItem item) {
   int id = item.getItemId();
   switch (id) {
     case MENU_BACK:
       goBack();
       break;
     case MENU_FORWARD:
       if (webView.canGoForward()) {
         webView.goForward();
       }
       break;
     case MENU_REFRESH:
       webView.reload();
       break;
     case MENU_ABOUT:
       showAbout();
       break;
     case MENU_EXIT:
       if_exit();
       break;
   }
   return true;
 }
Exemplo n.º 10
0
 public void forward(int index) {
   restoreWebView();
   webView.goForward();
 }
Exemplo n.º 11
0
 private void controlForward() {
   final WebView webView = (WebView) mRootView.findViewById(R.id.fragment_main_webview);
   if (webView.canGoForward()) webView.goForward();
 }
Exemplo n.º 12
0
 @Override
 public void goForward() {
   mWebView.goForward();
 }