예제 #1
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;
    }
  }
예제 #2
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;
   }
 }
예제 #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) {

    }
  }
예제 #4
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    if (id == android.R.id.home) {
      onBackPressed();
      return true;
    } else if (id == R.id.menu_refresh) {
      myWebView.reload();
    }

    // This button will only appear if we have a feed item
    else if (id == R.id.menu_comments && hasFeedItem) {

      // Go to the comments
      Intent intent = new Intent(getApplicationContext(), CommentActivity.class);
      Bundle b = new Bundle();
      b.putParcelable("feedItem", feedItem);
      intent.putExtra("thumbnail", thumbnail);
      intent.putExtras(b);
      startActivity(intent);
    }

    return super.onOptionsItemSelected(item);
  }
예제 #5
0
 @Override
 public boolean shouldOverrideUrlLoading(WebView view, String url) {
   progressBar = ProgressDialog.show(context, "请稍等", "加载中...");
   view.loadUrl(url);
   view.reload();
   return true;
 }
 @Override
 public boolean shouldOverrideUrlLoading(WebView view, String url) {
   if (url.startsWith("file")) {
     // Keep local assets in this WebView.
     return false;
   } else if (url.startsWith("mailto:")) {
     try {
       MailTo mt = MailTo.parse(url);
       Intent i = new Intent(Intent.ACTION_SEND);
       i.setType("message/rfc822");
       i.putExtra(Intent.EXTRA_EMAIL, new String[] {mt.getTo()});
       i.putExtra(Intent.EXTRA_SUBJECT, mt.getSubject());
       context.startActivity(i);
       view.reload();
     } catch (ActivityNotFoundException e) {
       Log.w(TAG, "Problem with Intent.ACTION_SEND", e);
       new AlertDialog.Builder(context)
           .setTitle("Contact Info")
           .setMessage("Please send your feedback to: [email protected]")
           .setPositiveButton(
               "Done",
               new DialogInterface.OnClickListener() {
                 public void onClick(DialogInterface dialog, int which) {
                   Log.d("AlertDialog", "Positive");
                 }
               })
           .show();
     }
     return true;
   } else {
     // Open external URLs in Browser.
     startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
     return true;
   }
 }
예제 #7
0
 public void reload(int index) {
   if (mNativeViewView != null) {
     mNativeViewView.invalidate();
   } else {
     webView.reload();
   }
 }
        @Override
        public void onRefresh() {
          // Refreshs the web view.
          wvExample.reload();

          // Hides the refresh icon on the top of the SwipeRefreshLayout view.
          srlExample.setRefreshing(false);
        }
예제 #9
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   if (item.getItemId() == R.id.action_reload_page) { // reload web view
     if (BuildConfig.DEBUG) {
       Log.d(TAG, "Reload the web view");
     }
     if (webView != null) {
       webView.reload();
     }
     return true;
   } else {
     return super.onOptionsItemSelected(item);
   }
 }
예제 #10
0
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.menu_load:
       menuItem = item;
       menuItem.setActionView(R.layout.progressbar);
       menuItem.expandActionView();
       wv.reload();
       Toast.makeText(this, "Refreshing :)", Toast.LENGTH_LONG).show();
       break;
     case android.R.id.home:
       finish(); // remove from the stack
       //			NavUtils.navigateUpFromSameTask(this);
       break;
     default:
       return super.onOptionsItemSelected(item);
   }
   return true;
 }
  // Handle menu-clicks
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    // Share
    if (item.getTitle().toString().equals(getString(R.string.share))) {
      Intent sharingIntent = new Intent(Intent.ACTION_SEND);
      sharingIntent.setType("text/plain");
      sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, Pages.values()[0].shareText);
      sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "");
      startActivity(Intent.createChooser(sharingIntent, getString(R.string.share_using)));
      return super.onOptionsItemSelected(item);
    }

    // Refresh
    if (item.getTitle().toString().equals(getString(R.string.refresh))) {
      if (actual.url != null) {
        System.out.println(actual.url);
        webView.reload();
        webView.loadUrl(actual.url);
      }
      return super.onOptionsItemSelected(item);
    }

    // Page
    for (Pages p : Pages.values()) {
      if (p.title.equals(item.getTitle().toString())) {
        if (p.url.contains("http:") || p.url.contains("http:")) {
          changePage(p);
        } else {

          // Handle special Intents (e.g. for mailto: in the menu)

          Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(p.url));
          PackageManager manager = getPackageManager();
          List<ResolveInfo> infos = manager.queryIntentActivities(intent, 0);
          if (infos.size() > 0) {
            startActivity(intent);
          }
        }
      }
    }
    return super.onOptionsItemSelected(item);
  }
예제 #12
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);
  }
예제 #13
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       finish();
       return true;
     case R.id.web_refresh:
       mWebView.reload();
       return true;
     case R.id.web_open:
       Intent intent = new Intent();
       intent.setAction(Intent.ACTION_VIEW);
       Uri uri = Uri.parse(mUrl);
       intent.setData(uri);
       if (intent.resolveActivity(getPackageManager()) != null) {
         startActivity(intent);
       } else {
         Toast.makeText(this, getString(R.string.web_no_tips), Toast.LENGTH_SHORT).show();
       }
       return true;
   }
   return super.onOptionsItemSelected(item);
 }
예제 #14
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;
 }
 public boolean shouldOverrideUrlLoading(WebView paramWebView, String paramString) {
   Object localObject;
   if (paramString.startsWith("mailto:")) {
     localObject = a;
     paramString = MailTo.parse(paramString);
     paramString =
         a(
             paramString.getTo(),
             paramString.getSubject(),
             paramString.getBody(),
             paramString.getCc());
   }
   try {
     ((Activity) localObject).startActivity(paramString);
     paramWebView.reload();
     return true;
     localObject = new HashMap();
     ((Map) localObject).put("Referer", WebActivity.c(a));
     paramWebView.loadUrl(paramString, (Map) localObject);
     return true;
   } catch (Exception paramString) {
     for (; ; ) {}
   }
 }
예제 #16
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;
    }
  }
예제 #17
0
 @Override
 public void onRefresh() {
   webView.reload();
   swipeRefreshLayout.setRefreshing(false);
 }
 /** Handle page refresh */
 private void doRefresh() {
   webView.reload();
 }
예제 #19
0
 @Override
 public void reload() {
   mWebView.reload();
 }
예제 #20
0
 @Override
 public void reload() {
   webViewClient.updateWhite(adBlock.isWhite(getUrl()));
   super.reload();
 }
예제 #21
0
 private void controlReload() {
   final WebView webView = (WebView) mRootView.findViewById(R.id.fragment_main_webview);
   webView.reload();
 }
예제 #22
0
 private void refresh() {
   mWebView.reload();
 }