Exemplo n.º 1
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.º 2
0
 @JavascriptInterface
 public int getWebViewWidth() {
   if (notationWebView == null) {
     notationWebView = (WebView) findViewById(R.id.partitionHtml);
   }
   return notationWebView.getWidth();
 }
Exemplo n.º 3
0
 public void run() {
   if (mSelectionBounds != null) {
     mWebView.addView(mSelectionDragLayer);
     drawSelectionHandles();
     final int contentHeight =
         (int) Math.ceil(getDensityDependentValue(mWebView.getContentHeight(), mActivity));
     final int contentWidth = mWebView.getWidth();
     ViewGroup.LayoutParams layerParams = mSelectionDragLayer.getLayoutParams();
     layerParams.height = contentHeight;
     layerParams.width = Math.max(contentWidth, mContentWidth);
     mSelectionDragLayer.setLayoutParams(layerParams);
     if (mSelectionListener != null) {
       mSelectionListener.startSelection();
     }
   }
 }
Exemplo n.º 4
0
  void showInfo(final RSSItem item) {
    img = (ImageView) findViewById(R.id.imgnews);
    img.setImageBitmap(null);
    TextView tit = (TextView) findViewById(R.id.txtinfotitle);
    parentLayout = (LinearLayout) findViewById(R.id.wvcontainer);
    txtcon = (WebView) findViewById(R.id.txtcontent);
    head =
        ""
            + "<html xmlns:fb=\"http://ogp.me/ns/fb#\">\n"
            + "<head>\n"
            + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n"
            + "</head>\n"
            + "<body>"
            + "<p><div id=\"fb-root\"></div></p>"
            + "<script>"
            + "window.fbAsyncInit = function() {"
            + "FB.init({"
            + "appId      : '111569915535689', // App ID"
            + "status     : true, // check login status"
            + "cookie     : true, // enable cookies to allow the server to access the session"
            + "oauth      : true, // enable OAuth 2.0"
            + "xfbml      : true  // parse XFBML"
            + "});"
            + "};"
            + "</script>\n"
            + "<script src=\"http://connect.facebook.net/en_US/all.js#xfbml=1\"></script>";
    String loading = "";
    tail =
        "<p style=\"clear:both;\"><div id=\"facebook-comments-4159769\" class=\"facebook-comments inited\">"
            + "<fb:comments href=\""
            + item.getLink()
            + "\" num_posts=\"5\" width=\""
            + (txtcon.getWidth() * 80 / 100)
            + "\" colorscheme=\"dark\"></fb:comments>"
            + "</div></p>\n"
            + "</body></html>";

    txtcon.setWebViewClient(new FaceBookClient());
    txtcon.setWebChromeClient(new MyChromeClient());
    txtcon.getSettings().setJavaScriptEnabled(true);
    //    	txtcon.getSettings().setAppCacheEnabled(true);
    txtcon.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    txtcon.getSettings().setSupportMultipleWindows(true);
    txtcon.getSettings().setSupportZoom(true);
    txtcon.getSettings().setBuiltInZoomControls(true);
    txtcon.getSettings().setJavaScriptEnabled(true);
    txtcon.getSettings().setPluginsEnabled(true);
    txtcon.getSettings().setAllowFileAccess(true);

    tit.setText(item.getTitle());
    Uri u = Uri.parse(item.getLink());
    txtcon.loadDataWithBaseURL(
        u.getHost(),
        head + " " + item.getDescription() + loading + tail,
        "text/html",
        "UTF-8",
        null);
    new Thread(
            new Runnable() {
              String url = item.getEnclosure();
              RSSItem ite = item;

              public void run() {
                b = ImageDownloader.readImageByUrl(url);
                if (b == null)
                  handler.post(
                      new Runnable() {
                        public void run() {
                          img.setVisibility(View.GONE);
                        }
                      });
                else
                  handler.post(
                      new Runnable() {
                        public void run() {
                          img.setImageBitmap(b);
                        }
                      });
                final String s = getAdditionInfo(ite.getLink());
                handler.post(
                    new Runnable() {
                      public void run() {
                        Uri u = Uri.parse(item.getLink());
                        if (site != 4)
                          txtcon.loadDataWithBaseURL(
                              u.getHost(),
                              head + " " + ite.getDescription() + s + tail,
                              "text/html",
                              "UTF-8",
                              null);
                        else
                          txtcon.loadDataWithBaseURL(
                              u.getHost(), head + " " + s + tail, "text/html", "UTF-8", null);
                      }
                    });
              }
            })
        .start();
  }