예제 #1
0
 private void invalidateDividersForWebView(
     WebView view, final boolean setForTop, boolean setForBottom, boolean hasButtons) {
   if (setForTop) {
     mDrawTopDivider =
         mTitleBar != null
             && mTitleBar.getVisibility() != View.GONE
             &&
             // Not scrolled to the top.
             view.getScrollY() + view.getPaddingTop() > 0;
   }
   if (setForBottom) {
     //noinspection deprecation
     mDrawBottomDivider =
         hasButtons
             && view.getScrollY() + view.getMeasuredHeight() - view.getPaddingBottom()
                 < view.getContentHeight() * view.getScale();
   }
 }
예제 #2
0
 private void getVerse() {
   if (webview.getScrollY() != 0) {
     verse = "";
     webview.loadUrl("javascript:getFirstVisibleVerse();");
     synchronized (verseLock) {
       if (verse.equals("")) {
         try {
           verseLock.wait(3000);
         } catch (InterruptedException e) {
         }
       }
     }
   }
 }
 public void setLastReadState() {
   if (content != null) {
     // save last position and zoom
     WebView wv = (WebView) findViewById(R.id.webView1);
     content.setLastXScroll(wv.getScrollX());
     content.setLastYScroll(wv.getScrollY());
     content.setLastZoom(wv.getScale());
     try {
       content = dao.updateNovelContent(content);
     } catch (Exception ex) {
       ex.printStackTrace();
     }
     if (wv.getContentHeight() <= wv.getScrollY() + wv.getBottom()) {
       try {
         PageModel page = content.getPageModel();
         page.setFinishedRead(true);
         page = dao.updatePageModel(page);
         Log.d(
             TAG,
             "Update Content: "
                 + content.getLastXScroll()
                 + " "
                 + content.getLastYScroll()
                 + " "
                 + content.getLastZoom());
       } catch (Exception ex) {
         ex.printStackTrace();
         Log.d(TAG, "Error updating PageModel for Content: " + content.getPage());
       }
     }
     SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
     SharedPreferences.Editor editor = sharedPrefs.edit();
     editor.putString(Constants.PREF_LAST_READ, content.getPage());
     editor.commit();
   }
 }
예제 #4
0
  @Override
  public boolean dispatchTouchEvent(MotionEvent e) {
    int scrollY = webview.getScrollY();
    if (scrollY == 0
        || (float) scrollY
            >= webview.getContentHeight() * getScale(webview) - webview.getHeight()) {
      setDisplayZoomControls(true);
    } else {
      setDisplayZoomControls(false);
    }

    super.dispatchTouchEvent(e);

    // getActionMasked since api-8
    switch (e.getAction() & MotionEvent.ACTION_MASK) {
      case MotionEvent.ACTION_CANCEL:
      case MotionEvent.ACTION_UP:
        scale = getScale(webview);
        break;
    }

    return mGestureDetector.onTouchEvent(e);
  }