Refactor and cleanup code

This commit is contained in:
Koitharu
2020-02-02 16:38:44 +02:00
parent aa65f9b02c
commit a957021582
21 changed files with 20 additions and 208 deletions

View File

@@ -34,7 +34,7 @@ abstract class HistoryDao {
suspend fun update(entity: HistoryWithManga) = update(entity.manga.id, entity.history.page, entity.history.chapterId, entity.history.updatedAt)
@Transaction
suspend open fun upsert(entity: HistoryWithManga) {
open suspend fun upsert(entity: HistoryWithManga) {
if (update(entity) == 0) {
insertManga(entity.manga)
insert(entity.history)

View File

@@ -5,7 +5,6 @@ import org.koitharu.kotatsu.core.model.*
import org.koitharu.kotatsu.core.parser.BaseMangaRepository
import org.koitharu.kotatsu.domain.MangaLoaderContext
import org.koitharu.kotatsu.utils.ext.*
import kotlin.text.removeSurrounding
abstract class GroupleRepository(
private val source: MangaSource,

View File

@@ -1,11 +1,7 @@
package org.koitharu.kotatsu.core.parser.site
import androidx.core.text.parseAsHtml
import org.koitharu.kotatsu.core.model.*
import org.koitharu.kotatsu.core.parser.BaseMangaRepository
import org.koitharu.kotatsu.core.model.MangaSource
import org.koitharu.kotatsu.domain.MangaLoaderContext
import org.koitharu.kotatsu.core.exceptions.ParseException
import org.koitharu.kotatsu.utils.ext.*
class ReadmangaRepository(loaderContext: MangaLoaderContext) :
GroupleRepository(MangaSource.READMANGA_RU, loaderContext) {

View File

@@ -7,7 +7,7 @@ import androidx.preference.PreferenceManager
import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.utils.delegates.prefs.EnumPreferenceDelegate
class AppSettings private constructor(private val resources: Resources, private val prefs: SharedPreferences) : SharedPreferences by prefs {
class AppSettings private constructor(resources: Resources, private val prefs: SharedPreferences) : SharedPreferences by prefs {
constructor(context: Context) : this(context.resources, PreferenceManager.getDefaultSharedPreferences(context))

View File

@@ -6,12 +6,11 @@ import org.koitharu.kotatsu.core.db.MangaDatabase
import org.koitharu.kotatsu.core.db.entity.HistoryEntity
import org.koitharu.kotatsu.core.db.entity.HistoryWithManga
import org.koitharu.kotatsu.core.db.entity.MangaEntity
import org.koitharu.kotatsu.core.model.*
import org.koitharu.kotatsu.core.parser.MangaRepository
import java.io.Closeable
import org.koitharu.kotatsu.core.model.Manga
import org.koitharu.kotatsu.core.model.MangaHistory
import java.util.*
class HistoryRepository() : KoinComponent {
class HistoryRepository : KoinComponent {
private val db: MangaDatabase by inject()

View File

@@ -1,7 +1,9 @@
package org.koitharu.kotatsu.domain
import android.content.Context
import okhttp3.*
import okhttp3.FormBody
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import org.koin.core.KoinComponent
import org.koin.core.inject
import org.koitharu.kotatsu.utils.ext.await

View File

@@ -3,9 +3,7 @@ package org.koitharu.kotatsu.ui.common
import android.content.Context
import android.content.SharedPreferences
import android.os.Parcelable
import androidx.annotation.IdRes
import androidx.annotation.LayoutRes
import androidx.recyclerview.widget.RecyclerView
import moxy.MvpAppCompatFragment
import org.koin.android.ext.android.inject
import org.koitharu.kotatsu.core.prefs.AppSettings

View File

@@ -1,12 +1,8 @@
package org.koitharu.kotatsu.ui.common
import android.content.Context
import android.graphics.drawable.Drawable
import android.view.View
import androidx.annotation.DrawableRes
import com.google.android.material.chip.Chip
import com.google.android.material.shape.CornerFamily
import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.utils.ext.getThemeColor
class ChipsFactory(private val context: Context) {

View File

@@ -5,7 +5,6 @@ import android.util.AttributeSet
import android.widget.LinearLayout
import androidx.appcompat.widget.AppCompatImageView
import androidx.core.content.res.use
import moxy.MvpFacade.init
import org.koitharu.kotatsu.R

View File

@@ -2,11 +2,9 @@ package org.koitharu.kotatsu.ui.details
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import org.koitharu.kotatsu.core.model.Manga
import org.koitharu.kotatsu.core.model.MangaChapter
import org.koitharu.kotatsu.domain.ChapterExtra
import org.koitharu.kotatsu.ui.common.list.BaseRecyclerAdapter
import org.koitharu.kotatsu.ui.common.list.BaseViewHolder
import org.koitharu.kotatsu.ui.common.list.OnRecyclerItemClickListener
class ChaptersAdapter(onItemClickListener: OnRecyclerItemClickListener<MangaChapter>) :

View File

@@ -1,16 +1,13 @@
package org.koitharu.kotatsu.ui.reader
import android.content.Context
import android.util.LongSparseArray
import kotlinx.coroutines.*
import okhttp3.OkHttpClient
import okhttp3.Request
import org.koin.core.KoinComponent
import org.koin.core.inject
import org.koitharu.kotatsu.core.model.MangaPage
import org.koitharu.kotatsu.utils.ext.await
import org.koitharu.kotatsu.utils.ext.longHashCode
import java.io.Closeable
import java.io.File
import kotlin.coroutines.CoroutineContext

View File

@@ -3,7 +3,6 @@ package org.koitharu.kotatsu.ui.reader
import android.view.ViewGroup
import org.koitharu.kotatsu.core.model.MangaPage
import org.koitharu.kotatsu.ui.common.list.BaseRecyclerAdapter
import org.koitharu.kotatsu.ui.common.list.BaseViewHolder
class PagesAdapter(private val loader: PageLoader) : BaseRecyclerAdapter<MangaPage, Unit>() {

View File

@@ -31,7 +31,7 @@ class ReaderActivity : BaseActivity(), ReaderView {
supportActionBar?.setDisplayHomeAsUpEnabled(true)
bottomBar.inflateMenu(R.menu.opt_reader_bottom)
state = savedInstanceState?.getParcelable<ReaderState>(EXTRA_STATE)
state = savedInstanceState?.getParcelable(EXTRA_STATE)
?: intent.getParcelableExtra<ReaderState>(EXTRA_STATE)
?: let {
Toast.makeText(this, R.string.error_occurred, Toast.LENGTH_SHORT).show()

View File

@@ -5,8 +5,6 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import moxy.InjectViewState
import org.koitharu.kotatsu.BuildConfig
import org.koitharu.kotatsu.core.model.Manga
import org.koitharu.kotatsu.core.model.MangaChapter
import org.koitharu.kotatsu.domain.HistoryRepository
import org.koitharu.kotatsu.domain.MangaProviderFactory
import org.koitharu.kotatsu.ui.common.BasePresenter

View File

@@ -1,7 +1,6 @@
package org.koitharu.kotatsu.utils.ext
import android.annotation.SuppressLint
import org.intellij.lang.annotations.PrintFormat
import java.text.SimpleDateFormat
import java.util.*

View File

@@ -10,13 +10,11 @@ import android.widget.EditText
import android.widget.TextView
import androidx.annotation.LayoutRes
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.chip.Chip
import com.google.android.material.chip.ChipGroup
import kotlinx.android.synthetic.main.fragment_list.view.*
import org.koitharu.kotatsu.ui.common.ChipsFactory
fun View.hideKeyboard() {