编程知识 cdmana.com

Android nurreaderview reader (supporting string &. TXT file)

NurReader

Introduce

function

 Support string and <.txt> file 
 You can set the reverse direction  =》( It's Uighur - Hazak - Right to left characters like Arabic and other languages )
 The universal controller comes with it  =》 font size & Night mode & Turn the page quickly ( With the progress bar )( You can customize )
 Styles can be customized  =》 The background color & font size & The font color & The color of the controller, etc 

effect :


Software architecture

reader - It can quickly interpret strings ( Support .TXT file ) And the text is automatically divided into each page .

To configure

  1. The root directory of the project build.gradle To configure
	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}
  1. Add dependency
	dependencies {
			....
	        implementation 'com.gitee.nurApplication:nur-reader:1.0.1'
	}

Use the latest version

Instructions

  1. xml
    <com.nurmemet.readbook.widget.NurReaderView
        android:id="@+id/nurReaderView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
  1. java
        NurReaderView nurReaderView = findViewById(R.id.nurReaderView);

        ReaderBuilder readerBuilder = new ReaderBuilder(this) {
            @Override
            public String getData() {
//                FileUtils.readTxt(FileUtils.PATH + "test.txt");// Read local TXT file 
// 				   Want to read local txt Don't forget the permissions for files ...
                return "Hello word!";
            }

            @Override
            public String getTitle() {
                return "Title";
            }
        };
        nurReaderView.init(readerBuilder);

There's no controller on the top ( Font size and other functions ); If you want the time function, you have to use readerBuilder Of setCntroller(NurController nurController) Method .NurController Is an abstract class , You can inherit it and customize it controller , You can also use the default controller for example :

        readerBuilder.setCntroller(new NurReaderController(this, new NurReaderController.OnClickIconListener() {
            /**
             *  Click the back button 
             */
            @Override
            public void onBackPress(View v) {
                finish();
            }

            /**
             *  Click the collect button 
             */
            @Override
            public void onCollectionPress(View v) {
            }
        }));

The effect is as follows :
[ Picture upload failed ...(image-d17b42-1605095163921)]

Parameters

We call nurReaderView.init(ReaderBuilder builder) After that, he started to work . It needs some configuration before it starts to work, which is ReaderBuilder class :

ReaderBuilder.java abstract class :
Method notes
setLayoutManager(LinearLayoutManager layoutManager) By default HORIZONTAL Of LinearLayoutManager
setStackFromEnd(boolean value) The layout is reversed
isStackFromEnd() Whether the layout is reversed
addOnChangeListener(OnChangeListener onChangeListener) Monitoring page turning
setController(NurController nurController) controller
getData() The data content
getTitle() subject

If you want to customize the implementation controller, you can inherit NurController Class and then call ReaderBuilder.setController(NurController nurController) Method

NurController.java abstract class :
Method notes
getToolbar(ViewGroup group) Tollbar
getController(ViewGroup group) controller
main() initialization view And then called
getTitle() obtain title
setTheme(NurReaderThemeData attribute) Set the style
setCurrentPercent(int percent, int max) According to percent X AutoPager Chrome

If you want to change the style, use NurController Of setTheme(NurReaderThemeData attribute) Method

NurReaderThemeData.java
Method notes
setBgColor(int bgColor) The background color
setTextSize(float textSize) font size
setTextColor(int textColor) The font color
setTypeface(Typeface typeface) typeface /font
setControllerColor(int controllerColor) Controller background color

Come here first , There are some ways you can go in and see .

There may be some BUG. If you find out, please leave a message and I will change it ...


版权声明
本文为[nur01]所创,转载请带上原文链接,感谢

Scroll to Top