bifan-wei / hwtxtreader Goto Github PK
View Code? Open in Web Editor NEW小说阅读器、轻量级Txt播放器 、文本播放组件、txt文件加载控件、Android阅读器。你可以通过该库快速实现加载播放txt文件,支持常见的阅读器设置操作。
小说阅读器、轻量级Txt播放器 、文本播放组件、txt文件加载控件、Android阅读器。你可以通过该库快速实现加载播放txt文件,支持常见的阅读器设置操作。
不是text,直接放String
默认的背景是白色,切换其他颜色后好像不能恢复
有两个疑问请教:
1loadTxtFile(Context context, String FilePath, String FileName)好像有问题
HwTxtPlayActivity.loadTxtFile(this,"${getExternalStorageDirectory()}/storyReader/末日乐园","第一章灰姑娘的恐惧.txt")访问失败,提示文件不存在
HwTxtPlayActivity.loadTxtFile(this,"${getExternalStorageDirectory()}/storyReader/末日乐园/第一章灰姑娘的恐惧.txt")访问成功
2.如何设置编码,上面的文件是以UTF-8写入的,读取时是乱码
类似file.appendText("somecontent", Charsets.UTF_8)
看了一下代码,关键代码似乎是DrawPrepareTask。
作者删除项目了?
java.lang.NullPointerException: Attempt to read from field 'android.widget.SeekBar com.bifan.txtreaderlib.ui.HwTxtPlayActivity$MenuHolder.mSeekBar' on a null object reference
at com.bifan.txtreaderlib.ui.HwTxtPlayActivity$12.onCurrentPage(HwTxtPlayActivity.java)
at com.bifan.txtreaderlib.main.TxtReaderBaseView.onProgressCallBack(TxtReaderBaseView.java)
at com.bifan.txtreaderlib.main.TxtReaderBaseView.onPageProgress(TxtReaderBaseView.java)
at com.bifan.txtreaderlib.main.TxtReaderBaseView$DataLoadListener$1.run(TxtReaderBaseView.java)
at android.os.Handler.handleCallback(Handler.java:754)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6337)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
无法引用
这个库我使用了,但是要是问到是如何实现的感觉还是不太好理解,paragraphindex和chartindex是如何确定进度的啊,然后每个页的字符数量都是确定的吗?
这个现在能读取sd卡里的TXT文件吗?
java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at com.bifan.txtreaderlib.main.ParagraphData.getParaStartCharIndex(ParagraphData.java)
at com.bifan.txtreaderlib.main.TxtReaderBaseView.getProgress(TxtReaderBaseView.java)
at com.bifan.txtreaderlib.main.TxtReaderView$1$1.run(TxtReaderView.java)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5491)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:961)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
请问一下,遇到\n的时候不换行怎么处理的
请问使用HwTxtPlayActivity能不能实现保存进度和下次打开的时候跳转过去
hi,你好,感谢分享源码!我是小白一枚,想修改下特定文字的样式,但是找不到你项目中关于修改英文和数字颜色的代码,请问下这部分代码在哪里?(位置越具体越好)
java.lang.IllegalArgumentException: width must be > 0
at android.graphics.Bitmap.checkWidthHeight(Bitmap.java:378)
at android.graphics.Bitmap.createBitmap(Bitmap.java:891)
at android.graphics.Bitmap.createBitmap(Bitmap.java:928)
at com.bifan.txtreaderlib.utils.TxtBitmapUtil.createBitmap(Unknown Source)
at com.bifan.txtreaderlib.tasks.TxtConfigInitTask.Run(Unknown Source)
at com.bifan.txtreaderlib.tasks.FileDataLoadTask.Run(Unknown Source)
at com.bifan.txtreaderlib.tasks.TxtFileLoader.load(Unknown Source)
at com.bifan.txtreaderlib.tasks.TxtFileLoader.load(Unknown Source)
at com.bifan.txtreaderlib.main.TxtReaderBaseView$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:818)
java.lang.NullPointerException: Attempt to read from field 'int com.bifan.txtreaderlib.main.PageParam.LinePadding' on a null object reference
at com.bifan.txtreaderlib.main.TxtReaderBaseView.findCharByPosition(TxtReaderBaseView.java)
at com.bifan.txtreaderlib.main.TxtReaderBaseView.onPressSelectText(TxtReaderBaseView.java)
at com.bifan.txtreaderlib.main.TxtReaderBaseView.onLongPress(TxtReaderBaseView.java)
at android.view.GestureDetector.dispatchLongPress(GestureDetector.java:770)
at android.view.GestureDetector.-wrap0(GestureDetector.java)
at android.view.GestureDetector$GestureHandler.handleMessage(GestureDetector.java:293)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6342)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
部分文本会全部乱码
java.lang.NullPointerException: Attempt to invoke interface method 'int com.bifan.txtreaderlib.interfaces.IParagraphData.getParagraphNum()' on a null object reference
at com.bifan.txtreaderlib.main.TxtReaderBaseView.getProgress(TxtReaderBaseView.java)
at com.bifan.txtreaderlib.main.TxtReaderBaseView.onPageProgress(TxtReaderBaseView.java)
at com.bifan.txtreaderlib.main.TxtReaderBaseView$DataLoadListener$1.run(TxtReaderBaseView.java)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5689)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
java.lang.NullPointerException
at com.bifan.txtreaderlib.main.PageDataPipeline.getPageStartFromProgress(PageDataPipeline.java)
at com.bifan.txtreaderlib.tasks.TxtPageLoadTask.Run(TxtPageLoadTask.java)
at com.bifan.txtreaderlib.tasks.TxtConfigInitTask.Run(TxtConfigInitTask.java)
at com.bifan.txtreaderlib.tasks.FileDataLoadTask.Run(FileDataLoadTask.java)
at com.bifan.txtreaderlib.tasks.TxtFileLoader.load(TxtFileLoader.java)
at com.bifan.txtreaderlib.tasks.TxtFileLoader.load(TxtFileLoader.java)
at com.bifan.txtreaderlib.main.TxtReaderBaseView$1.run(TxtReaderBaseView.java)
at java.lang.Thread.run(Thread.java:841)
现在的弄的是在
void onTextChanging(float x,float y,String selectText);
添加一个坐标,
然后
public void onTextChanging(float x,float y,String selectText) {
if(startCopy)
{
copyX = x;
copyY = y;
startCopy = false;
Log.e("LOG"," copyX = "+copyX+" copyY = "+copyY);
}
}
只选取第一次的坐标,得到后
copyTextWindow.showAsDropDown(mTxtReaderView,(int)copyX,(int)copyY);
这样大概就能显示在选择字段的中间位置。
在
ClipboardManager copy = (ClipboardManager)
getSystemService(Context.CLIPBOARD_SERVICE);
// 将选取的内容放入剪切板
copy.setText(content);
copyTextWindow.dismiss();
之后 怎么退出选取模式呢。
楼主能不能简单说下实现原理
为什么字体很单薄且模糊呢?跟支持粗体有关吗?
java.lang.NullPointerException: Attempt to read from field 'int com.bifan.txtreaderlib.main.PageParam.PageWidth' on a null object reference
现在默认是从左往右的
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.Paint.setColor(int)' on a null object reference
at com.bifan.txtreaderlib.utils.TxtBitmapUtil.createHorizontalPage(Unknown Source)
at com.bifan.txtreaderlib.tasks.BitmapProduceTask.Run(Unknown Source)
at com.bifan.txtreaderlib.tasks.DrawPrepareTask.Run(Unknown Source)
at com.bifan.txtreaderlib.tasks.TxtPageLoadTask.Run(Unknown Source)
at com.bifan.txtreaderlib.tasks.TxtConfigInitTask.Run(Unknown Source)
at com.bifan.txtreaderlib.tasks.FileDataLoadTask.Run(Unknown Source)
at com.bifan.txtreaderlib.tasks.TxtFileLoader.load(Unknown Source)
at com.bifan.txtreaderlib.tasks.TxtFileLoader.load(Unknown Source)
at com.bifan.txtreaderlib.main.TxtReaderBaseView$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:760)
没完全翻页的情况下,再退回,然后再继续翻下一页无法刷新当前页面的内容了
感谢 @bifan-wei 分享代码,本人小白,看楼主是以字符为对象保存的,请问英文小说不断词自动换行,好不好修改啊
现在我做的项目是这样子的。 内容是分开的,按照章节来,每次进去的时候都是先从后台获取章节内容然后loadStr() ,你上次写的这个接口(再次感谢~). 现在遇到的问题是:章节列表(这个也是从后台获取的),然后点击了根据章节id又去后台获取内容。如果页面没有滑动过,直接重新loadStr()页面的数据会切换到新获取的内容。但是只要滑动过后内容就无法更换。有没有什么方法把内容清空重新加载的啊。
java.lang.NullPointerException
at com.bifan.txtreaderlib.main.PageDataPipeline.getPageStartFromProgress(PageDataPipeline.java)
at com.bifan.txtreaderlib.tasks.TxtPageLoadTask.Run(TxtPageLoadTask.java)
at com.bifan.txtreaderlib.tasks.TxtConfigInitTask.Run(TxtConfigInitTask.java)
at com.bifan.txtreaderlib.tasks.FileDataLoadTask.Run(FileDataLoadTask.java)
at com.bifan.txtreaderlib.tasks.TxtFileLoader.load(TxtFileLoader.java)
at com.bifan.txtreaderlib.tasks.TxtFileLoader.load(TxtFileLoader.java)
at com.bifan.txtreaderlib.main.TxtReaderBaseView$1.run(TxtReaderBaseView.java)
at java.lang.Thread.run(Thread.java:841)
java.lang.NullPointerException: Attempt to invoke interface method 'int com.bifan.txtreaderlib.interfaces.IParagraphData.getCharNum()' on a null object reference
at com.bifan.txtreaderlib.main.TxtReaderView.loadFromProgress(TxtReaderView.java:22)
at com.bifan.txtreaderlib.ui.HwTxtPlayActivity$10.onTouch(HwTxtPlayActivity.java:22)
at android.view.View.dispatchTouchEvent(View.java:11784)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2974)
java.lang.NullPointerException: Attempt to invoke interface method 'int com.bifan.txtreaderlib.interfaces.IParagraphData.getParagraphNum()' on a null object reference
at com.bifan.txtreaderlib.main.PageDataPipeline.getPageStartFromProgress(PageDataPipeline.java)
at com.bifan.txtreaderlib.tasks.TxtPageLoadTask.Run(TxtPageLoadTask.java)
at com.bifan.txtreaderlib.tasks.TxtConfigInitTask.Run(TxtConfigInitTask.java)
at com.bifan.txtreaderlib.tasks.FileDataLoadTask.Run(FileDataLoadTask.java)
at com.bifan.txtreaderlib.tasks.TxtFileLoader.load(TxtFileLoader.java)
at com.bifan.txtreaderlib.tasks.TxtFileLoader.load(TxtFileLoader.java)
at com.bifan.txtreaderlib.main.TxtReaderBaseView$1.run(TxtReaderBaseView.java)
at java.lang.Thread.run(Thread.java:818)
使用自定义TxtReaderView时,默认的文字排列是竖向的,如何设置成横向排列的。
使用自定义TxtReaderView时,如何设置章节列表?因为我是网络获取的小说内容,可以获取到所有章节,然后获取制定章节的内容。
java.lang.NullPointerException
at com.bifan.txtreaderlib.main.TxtReaderBaseView.getProgress(TxtReaderBaseView.java)
at com.bifan.txtreaderlib.main.TxtReaderView$1$1.run(TxtReaderView.java)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:177)
at android.app.ActivityThread.main(ActivityThread.java:5493)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1225)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1041)
at dalvik.system.NativeStart.main(NativeStart.java)
好像没看到设置行间距的地方
我这边想添加一个翻书到最后一页的提示,好像没有翻书翻页的监听方法。。。要加在哪里
java.lang.NullPointerException
at com.bifan.txtreaderlib.utils.TxtBitmapUtil.createHorizontalPage(TxtBitmapUtil.java)
at com.bifan.txtreaderlib.tasks.BitmapProduceTask.Run(BitmapProduceTask.java)
at com.bifan.txtreaderlib.tasks.DrawPrepareTask.Run(DrawPrepareTask.java)
at com.bifan.txtreaderlib.tasks.TxtPageLoadTask.Run(TxtPageLoadTask.java)
at com.bifan.txtreaderlib.tasks.TxtConfigInitTask.Run(TxtConfigInitTask.java)
at com.bifan.txtreaderlib.tasks.FileDataLoadTask.Run(FileDataLoadTask.java)
at com.bifan.txtreaderlib.tasks.TxtFileLoader.load(TxtFileLoader.java)
at com.bifan.txtreaderlib.tasks.TxtFileLoader.load(TxtFileLoader.java)
at com.bifan.txtreaderlib.main.TxtReaderBaseView$1.run(TxtReaderBaseView.java)
at java.lang.Thread.run(Thread.java:841)
如果我想要加入书签功能,请问我该怎么做
有许多厂家需要引流。阅读的时候能否在下方加一个广告条呢?
部分文本会全部乱码
大佬
使用TxtReaderView的setStyle的时候改变背景颜色为黑色 字体为白色时 实际上背景变成蓝色 字体颜色也没有变化
在使用setTextSize设置字体大小时也没有变化
不知道什么情况
java.lang.NullPointerException: Attempt to invoke interface method 'int com.bifan.txtreaderlib.interfaces.IParagraphData.getCharNum()' on a null object reference
at com.bifan.txtreaderlib.main.TxtReaderView.loadFromProgress(TxtReaderView.java)
at com.bifan.txtreaderlib.ui.HwTxtPlayActivity$10.onTouch(HwTxtPlayActivity.java)
at android.view.View.dispatchTouchEvent(View.java:10206)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2765)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2398)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2765)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2398)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2765)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2398)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2765)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2398)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2765)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2398)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2765)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2398)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2765)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2398)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2765)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2398)
at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:471)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1864)
at android.app.Activity.dispatchTouchEvent(Activity.java:3227)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java)
at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:425)
at android.view.View.dispatchPointerEvent(View.java:10446)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:5421)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5220)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4677)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4737)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4696)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4865)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4704)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4922)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4677)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4737)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4696)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4704)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4677)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:7398)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:7372)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:7315)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:7574)
at android.view.ViewRootImpl$ColorWindowInputEventReceiver.onInputEvent(ViewRootImpl.java:9129)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
at android.os.MessageQueue.next(MessageQueue.java:328)
at android.os.Looper.loop(Looper.java:173)
at android.app.ActivityThread.main(ActivityThread.java:6802)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1103)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
翻页多张后,出现滑动到下一页内容依旧是当前页,退出重新进入后就没有了,只要滑动页数够多,基本每次都会出现
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.