Merge remote-tracking branch 'upstream/master' into master

pull/403/head
github-actions 6 years ago
commit b32c19486a
  1. 4
      app/src/main/java/io/legado/app/api/ReaderProvider.kt
  2. 6
      app/src/main/java/io/legado/app/api/controller/BookshelfController.kt
  3. 2
      app/src/main/java/io/legado/app/api/controller/SourceController.kt
  4. 14
      app/src/main/java/io/legado/app/base/adapter/CommonRecyclerAdapter.kt
  5. 2
      app/src/main/java/io/legado/app/service/DownloadService.kt
  6. 0
      app/src/main/java/io/legado/app/utils/EventBusExtensions.kt
  7. 4
      app/src/main/java/io/legado/app/web/HttpServer.kt
  8. 2
      app/src/main/java/io/legado/app/web/WebSocketServer.kt
  9. 2
      app/src/main/java/io/legado/app/web/utils/SourceDebugWebSocket.kt

@ -11,8 +11,8 @@ import android.database.*
import android.net.Uri
import android.os.Bundle
import com.google.gson.Gson
import io.legado.app.web.controller.BookshelfController
import io.legado.app.web.controller.SourceController
import io.legado.app.api.controller.BookshelfController
import io.legado.app.api.controller.SourceController
import io.legado.app.web.utils.ReturnData
import java.util.*

@ -1,4 +1,4 @@
package io.legado.app.web.controller
package io.legado.app.api.controller
import io.legado.app.App
import io.legado.app.constant.PreferKey
@ -79,6 +79,10 @@ object BookshelfController {
val returnData = ReturnData()
if (book != null) {
App.db.bookDao().insert(book)
if (ReadBook.book?.bookUrl == book.bookUrl) {
ReadBook.book = book
ReadBook.durChapterIndex = book.durChapterIndex
}
return returnData.setData("")
}
return returnData.setErrorMsg("格式不对")

@ -1,4 +1,4 @@
package io.legado.app.web.controller
package io.legado.app.api.controller
import android.text.TextUtils

@ -15,17 +15,17 @@ import java.util.*
*
* 通用的adapter 可添加headerfooter以及不同类型item
*/
abstract class CommonRecyclerAdapter<ITEM>(protected val context: Context):
abstract class CommonRecyclerAdapter<ITEM>(protected val context: Context) :
RecyclerView.Adapter<ItemViewHolder>() {
constructor(context: Context, vararg delegates: ItemViewDelegate<ITEM>): this(context) {
constructor(context: Context, vararg delegates: ItemViewDelegate<ITEM>) : this(context) {
addItemViewDelegates(*delegates)
}
constructor(
context: Context,
vararg delegates: Pair<Int, ItemViewDelegate<ITEM>>
): this(context) {
) : this(context) {
addItemViewDelegates(*delegates)
}
@ -57,15 +57,15 @@ abstract class CommonRecyclerAdapter<ITEM>(protected val context: Context):
recyclerView.adapter = this
}
fun <DELEGATE: ItemViewDelegate<ITEM>> addItemViewDelegate(viewType: Int, delegate: DELEGATE) {
fun <DELEGATE : ItemViewDelegate<ITEM>> addItemViewDelegate(viewType: Int, delegate: DELEGATE) {
itemDelegates[viewType] = delegate
}
fun <DELEGATE: ItemViewDelegate<ITEM>> addItemViewDelegate(delegate: DELEGATE) {
fun <DELEGATE : ItemViewDelegate<ITEM>> addItemViewDelegate(delegate: DELEGATE) {
itemDelegates[itemDelegates.size] = delegate
}
fun <DELEGATE: ItemViewDelegate<ITEM>> addItemViewDelegates(vararg delegates: DELEGATE) {
fun <DELEGATE : ItemViewDelegate<ITEM>> addItemViewDelegates(vararg delegates: DELEGATE) {
delegates.forEach {
addItemViewDelegate(it)
}
@ -365,7 +365,7 @@ abstract class CommonRecyclerAdapter<ITEM>(protected val context: Context):
super.onAttachedToRecyclerView(recyclerView)
val manager = recyclerView.layoutManager
if (manager is GridLayoutManager) {
manager.spanSizeLookup = object: GridLayoutManager.SpanSizeLookup() {
manager.spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
override fun getSpanSize(position: Int): Int {
return getItem(position)?.let {
if (isHeader(position) || isFooter(position)) manager.spanCount else getSpanSize(

@ -69,11 +69,9 @@ class DownloadService : BaseService() {
IntentAction.stop -> {
val downloadId = intent.getLongExtra("downloadId", 0)
downloads.remove(downloadId)
if (downloads.isEmpty()) {
stopSelf()
}
}
}
return super.onStartCommand(intent, flags, startId)
}

@ -2,8 +2,8 @@ package io.legado.app.web
import com.google.gson.Gson
import fi.iki.elonen.NanoHTTPD
import io.legado.app.web.controller.BookshelfController
import io.legado.app.web.controller.SourceController
import io.legado.app.api.controller.BookshelfController
import io.legado.app.api.controller.SourceController
import io.legado.app.web.utils.AssetsWeb
import io.legado.app.web.utils.ReturnData
import java.util.*

@ -1,7 +1,7 @@
package io.legado.app.web
import fi.iki.elonen.NanoWSD
import io.legado.app.web.controller.SourceDebugWebSocket
import io.legado.app.web.utils.SourceDebugWebSocket
class WebSocketServer(port: Int) : NanoWSD(port) {

@ -1,4 +1,4 @@
package io.legado.app.web.controller
package io.legado.app.web.utils
import fi.iki.elonen.NanoHTTPD
Loading…
Cancel
Save