Skip to content

Commit

Permalink
epub翻页高度
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbxyyx committed Jul 5, 2024
1 parent 893e48f commit 1645efa
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/src/main/assets/www/epub.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
position: fixed;
width: 100%;
height: 70px;
bottom: 5px;
bottom: 20px;
z-index: 1000;
}
.focus {
Expand Down Expand Up @@ -153,10 +153,10 @@
console.log('book_id:' + book_id + ', cur:' + cur + ', pages:' + pages);

var page_tool_ele = document.getElementById('page-tool');
var pageToolHeight = page_tool_ele.clientHeight;
var pageToolHeight = page_tool_ele.offsetHeight;

var epub_tool_ele = document.getElementById('epub-tool');
var epubToolHeight = epub_tool_ele.clientHeight;
var epubToolHeight = epub_tool_ele.offsetHeight;

page_tool_ele.style.color = gold_theme['body']['color'];
page_tool_ele.style.background = gold_theme['body']['background'];
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/com/github/jsbxyyx/xbook/ViewActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.github.jsbxyyx.xbook.common.DataCallback;
import com.github.jsbxyyx.xbook.common.LogUtil;
import com.github.jsbxyyx.xbook.common.SPUtils;
import com.github.jsbxyyx.xbook.common.UiUtils;
import com.github.jsbxyyx.xbook.data.BookDbHelper;
import com.github.jsbxyyx.xbook.data.BookNetHelper;
import com.github.jsbxyyx.xbook.data.bean.Book;
Expand Down Expand Up @@ -48,6 +49,8 @@ protected void onCreate(Bundle savedInstanceState) {
bookDbHelper = new BookDbHelper(this);
bookNetHelper = new BookNetHelper();

int navH = UiUtils.getNavigationBarRealHeight(this);

Intent intent = getIntent();
String file_path = intent.getStringExtra("file_path");
bookId = intent.getStringExtra("book_id");
Expand Down Expand Up @@ -116,8 +119,8 @@ protected void onCreate(Bundle savedInstanceState) {
String url = String.format(
"http://127.0.0.1:%s/%s/%s?%s",
port, www, html,
String.format("cur=%s&pages=%s&book_id=%s&name=%s&t=%s",
cur, pages, bookId, name, System.currentTimeMillis())
String.format("cur=%s&pages=%s&book_id=%s&name=%s&t=%s&navh=%s",
cur, pages, bookId, name, System.currentTimeMillis(), navH)
);
webView.loadUrl(url);
} catch (IOException e) {
Expand Down
23 changes: 23 additions & 0 deletions app/src/main/java/com/github/jsbxyyx/xbook/common/UiUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.github.jsbxyyx.xbook.common;

import android.app.Activity;
import android.graphics.Rect;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

public class UiUtils {

public static int getNavigationBarRealHeight(Activity activity) {
Window window = activity.getWindow();
View decorView = window.getDecorView();
Rect rect = new Rect();
decorView.getWindowVisibleDisplayFrame(rect);
DisplayMetrics outMetrics = new DisplayMetrics();
WindowManager windowManager = window.getWindowManager();
windowManager.getDefaultDisplay().getRealMetrics(outMetrics);
return outMetrics.heightPixels - rect.bottom;
}

}

0 comments on commit 1645efa

Please sign in to comment.