Esempio n. 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();
   }
 }
 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();
   }
 }
Esempio n. 3
0
 private static boolean canWebViewScroll(WebView view) {
   //noinspection deprecation
   return view.getMeasuredHeight() < view.getContentHeight() * view.getScale();
 }
Esempio n. 4
0
 @SuppressWarnings("deprecation")
 private float getScale(WebView webview) {
   return webview.getScale();
 }