Ejemplo 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;
   }
 }
Ejemplo n.º 2
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;
    }
  }
Ejemplo n.º 3
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) {

    }
  }
Ejemplo 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;
  }
Ejemplo n.º 5
0
  public void refreshWebButtonState() {
    if (webView != null) {
      View btnForward = view.findViewById(R.id.btnGoForward);
      View btnBack = view.findViewById(R.id.btnGoBack);

      btnBack.setEnabled(webView.canGoBack());
      btnForward.setEnabled(webView.canGoForward());
    }
  }
Ejemplo n.º 6
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();
   }
 }
Ejemplo n.º 7
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;
     }
   }
 }
Ejemplo n.º 8
0
 private void changeButtonState(WebView webview) {
   if (mButtonBack != null && mButtonForward != null) {
     if (webview.canGoBack()) {
       mButtonBack.setEnabled(true);
     } else {
       mButtonBack.setEnabled(false);
     }
     if (webview.canGoForward()) {
       mButtonForward.setEnabled(true);
     } else {
       mButtonForward.setEnabled(false);
     }
   }
 }
Ejemplo n.º 9
0
  public void setWebView(WebView webView) {
    this.webView = webView;

    View webButtons = view.findViewById(R.id.webButtons);
    webButtons.setVisibility(webView != null ? View.VISIBLE : View.GONE);

    View btnForward = view.findViewById(R.id.btnGoForward);
    View btnBack = view.findViewById(R.id.btnGoBack);

    btnForward.setOnClickListener(this);
    btnBack.setOnClickListener(this);

    if (webView != null) {
      btnBack.setEnabled(webView.canGoBack());
      btnForward.setEnabled(webView.canGoForward());
    }
  }
Ejemplo n.º 10
0
  @Override
  public void onPageFinished(WebView view, String url) {
    // TODO Auto-generated method stub

    // 平板電腦程式 - 隱藏環狀等待迴圈
    mActivity.setProgressBarIndeterminateVisibility(false);
    mActivity.setTitle(R.string.app_name);
    mBtnReload.setEnabled(true);
    mBtnStop.setEnabled(false);

    if (mWebView.canGoBack()) mBtnGoBack.setEnabled(true);
    else mBtnGoBack.setEnabled(false);

    if (mWebView.canGoForward()) mBtnGoForward.setEnabled(true);
    else mBtnGoForward.setEnabled(false);

    super.onPageFinished(view, url);
  }
Ejemplo n.º 11
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);
  }
Ejemplo n.º 12
0
  @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;
    }
  }
Ejemplo n.º 13
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;
 }
Ejemplo n.º 14
0
 private void controlForward() {
   final WebView webView = (WebView) mRootView.findViewById(R.id.fragment_main_webview);
   if (webView.canGoForward()) webView.goForward();
 }
Ejemplo n.º 15
0
 @Override
 public boolean canGoForward() {
   return mWebView.canGoForward();
 }
Ejemplo n.º 16
0
 /** @return true if the WebViewer can go forward in the history list */
 @SimpleFunction(description = "Returns true if the WebViewer can go forward in the history list.")
 public boolean CanGoForward() {
   return webview.canGoForward();
 }