Move Category model and repository to domain and data layer (#8967)

To keep the commit from being 100+ files the interactors wasn't moved.

The domain module like the data module uses `tachiyomi` instead of `eu.kanade.tachiyomi` for package names
This commit is contained in:
Andreas
2023-01-22 16:12:29 +01:00
committed by GitHub
parent c2812fca24
commit d3a73fc228
47 changed files with 108 additions and 65 deletions

1
domain/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

19
domain/build.gradle.kts Normal file
View File

@@ -0,0 +1,19 @@
plugins {
id("com.android.library")
kotlin("android")
}
android {
namespace = "tachiyomi.domain"
defaultConfig {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}
}
dependencies {
implementation(platform(kotlinx.coroutines.bom))
implementation(kotlinx.bundles.coroutines)
}

View File

21
domain/proguard-rules.pro vendored Normal file
View File

@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest />

View File

@@ -0,0 +1,17 @@
package tachiyomi.domain.category.model
import java.io.Serializable
data class Category(
val id: Long,
val name: String,
val order: Long,
val flags: Long,
) : Serializable {
val isSystemCategory: Boolean = id == UNCATEGORIZED_ID
companion object {
const val UNCATEGORIZED_ID = 0L
}
}

View File

@@ -0,0 +1,8 @@
package tachiyomi.domain.category.model
data class CategoryUpdate(
val id: Long,
val name: String? = null,
val order: Long? = null,
val flags: Long? = null,
)

View File

@@ -0,0 +1,28 @@
package tachiyomi.domain.category.repository
import kotlinx.coroutines.flow.Flow
import tachiyomi.domain.category.model.Category
import tachiyomi.domain.category.model.CategoryUpdate
interface CategoryRepository {
suspend fun get(id: Long): Category?
suspend fun getAll(): List<Category>
fun getAllAsFlow(): Flow<List<Category>>
suspend fun getCategoriesByMangaId(mangaId: Long): List<Category>
fun getCategoriesByMangaIdAsFlow(mangaId: Long): Flow<List<Category>>
suspend fun insert(category: Category)
suspend fun updatePartial(update: CategoryUpdate)
suspend fun updatePartial(updates: List<CategoryUpdate>)
suspend fun updateAllFlags(flags: Long?)
suspend fun delete(categoryId: Long)
}