| 
						
						
						
					 | 
					 | 
					@ -1,6 +1,5 @@ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					package io.legado.app.api.controller | 
					 | 
					 | 
					 | 
					package io.legado.app.api.controller | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import android.net.Uri | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import androidx.core.graphics.drawable.toBitmap | 
					 | 
					 | 
					 | 
					import androidx.core.graphics.drawable.toBitmap | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.api.ReturnData | 
					 | 
					 | 
					 | 
					import io.legado.app.api.ReturnData | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.constant.PreferKey | 
					 | 
					 | 
					 | 
					import io.legado.app.constant.PreferKey | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -14,16 +13,13 @@ import io.legado.app.help.glide.ImageLoader | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.help.storage.AppWebDav | 
					 | 
					 | 
					 | 
					import io.legado.app.help.storage.AppWebDav | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.model.BookCover | 
					 | 
					 | 
					 | 
					import io.legado.app.model.BookCover | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.model.ReadBook | 
					 | 
					 | 
					 | 
					import io.legado.app.model.ReadBook | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.model.localBook.EpubFile | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.model.localBook.LocalBook | 
					 | 
					 | 
					 | 
					import io.legado.app.model.localBook.LocalBook | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.model.localBook.UmdFile | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.model.webBook.WebBook | 
					 | 
					 | 
					 | 
					import io.legado.app.model.webBook.WebBook | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.ui.book.read.page.provider.ImageProvider | 
					 | 
					 | 
					 | 
					import io.legado.app.ui.book.read.page.provider.ImageProvider | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.utils.* | 
					 | 
					 | 
					 | 
					import io.legado.app.utils.* | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import kotlinx.coroutines.delay | 
					 | 
					 | 
					 | 
					import kotlinx.coroutines.delay | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import kotlinx.coroutines.runBlocking | 
					 | 
					 | 
					 | 
					import kotlinx.coroutines.runBlocking | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import splitties.init.appCtx | 
					 | 
					 | 
					 | 
					import splitties.init.appCtx | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import java.io.File | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					object BookController { | 
					 | 
					 | 
					 | 
					object BookController { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -173,7 +169,6 @@ object BookController { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        var content: String? = BookHelp.getContent(book, chapter) | 
					 | 
					 | 
					 | 
					        var content: String? = BookHelp.getContent(book, chapter) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (content != null) { | 
					 | 
					 | 
					 | 
					        if (content != null) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            val contentProcessor = ContentProcessor.get(book.name, book.origin) | 
					 | 
					 | 
					 | 
					            val contentProcessor = ContentProcessor.get(book.name, book.origin) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            saveBookReadIndex(book, index) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            content = runBlocking { | 
					 | 
					 | 
					 | 
					            content = runBlocking { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                contentProcessor.getContent(book, chapter, content!!, includeTitle = false) | 
					 | 
					 | 
					 | 
					                contentProcessor.getContent(book, chapter, content!!, includeTitle = false) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    .joinToString("\n") | 
					 | 
					 | 
					 | 
					                    .joinToString("\n") | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -186,7 +181,6 @@ object BookController { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            content = runBlocking { | 
					 | 
					 | 
					 | 
					            content = runBlocking { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                WebBook.getContentAwait(this, bookSource, book, chapter).let { | 
					 | 
					 | 
					 | 
					                WebBook.getContentAwait(this, bookSource, book, chapter).let { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    val contentProcessor = ContentProcessor.get(book.name, book.origin) | 
					 | 
					 | 
					 | 
					                    val contentProcessor = ContentProcessor.get(book.name, book.origin) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    saveBookReadIndex(book, index) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    contentProcessor.getContent(book, chapter, it, includeTitle = false) | 
					 | 
					 | 
					 | 
					                    contentProcessor.getContent(book, chapter, it, includeTitle = false) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        .joinToString("\n") | 
					 | 
					 | 
					 | 
					                        .joinToString("\n") | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                } | 
					 | 
					 | 
					 | 
					                } | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -215,25 +209,6 @@ object BookController { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return returnData.setErrorMsg("格式不对") | 
					 | 
					 | 
					 | 
					        return returnData.setErrorMsg("格式不对") | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    /** | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * 保存进度 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     */ | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private fun saveBookReadIndex(book: Book, index: Int) { | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        book.durChapterIndex = index | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        book.durChapterTime = System.currentTimeMillis() | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        appDb.bookChapterDao.getChapter(book.bookUrl, index)?.let { | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            book.durChapterTitle = it.title | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        appDb.bookDao.update(book) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        AppWebDav.uploadBookProgress(book) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (ReadBook.book?.bookUrl == book.bookUrl) { | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            ReadBook.book = book | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            ReadBook.durChapterIndex = index | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            ReadBook.clearTextChapter() | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            ReadBook.loadContent(true) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    /** | 
					 | 
					 | 
					 | 
					    /** | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * 添加本地书籍 | 
					 | 
					 | 
					 | 
					     * 添加本地书籍 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     */ | 
					 | 
					 | 
					 | 
					     */ | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |