mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-17 23:47:02 +05:30
Move data package to its own module
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
b5a3d6489b
commit
19817bf254
10 changed files with 50 additions and 19 deletions
|
@ -1,7 +1,6 @@
|
|||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'kotlin-android'
|
||||
id 'kotlin-kapt'
|
||||
}
|
||||
|
||||
android {
|
||||
|
@ -14,16 +13,6 @@ android {
|
|||
targetSdkVersion 30
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments = [
|
||||
"room.incremental" : "true",
|
||||
"room.expandProjection": "true"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
|
@ -33,14 +22,16 @@ android {
|
|||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
coreLibraryDesugaringEnabled true
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
compose true
|
||||
}
|
||||
|
||||
composeOptions {
|
||||
kotlinCompilerVersion '1.4.0'
|
||||
kotlinCompilerExtensionVersion "${compose_version}"
|
||||
|
@ -56,7 +47,7 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
|
|||
|
||||
dependencies {
|
||||
|
||||
kapt "androidx.room:room-compiler:$room_version"
|
||||
implementation(project(":data"))
|
||||
implementation 'androidx.core:core-ktx:1.5.0-alpha02'
|
||||
implementation 'androidx.appcompat:appcompat:1.3.0-alpha02'
|
||||
implementation "androidx.compose.foundation:foundation:$compose_version"
|
||||
|
@ -69,13 +60,10 @@ dependencies {
|
|||
implementation "androidx.compose.ui:ui-text:$compose_version"
|
||||
implementation "androidx.compose.ui:ui-text-android:$compose_version"
|
||||
implementation "androidx.compose.ui:ui-unit:$compose_version"
|
||||
implementation "androidx.room:room-runtime:$room_version"
|
||||
implementation "androidx.room:room-ktx:$room_version"
|
||||
implementation "androidx.ui:ui-tooling:$compose_version"
|
||||
implementation 'com.google.android.material:material:1.3.0-alpha02'
|
||||
testImplementation 'junit:junit:4.13'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
androidTestImplementation "androidx.ui:ui-test:$compose_version"
|
||||
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.0.10"
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
package dev.msfjarvis.todo.data.model
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneId
|
||||
|
||||
@Immutable
|
||||
@Entity(
|
||||
tableName = "todo_items",
|
||||
)
|
||||
data class TodoItem(
|
||||
@PrimaryKey val title: String,
|
||||
val time: LocalDateTime = LocalDateTime.now(ZoneId.of("GMT")),
|
||||
)
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* Copyright 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package dev.msfjarvis.todo.data.source
|
||||
|
||||
import androidx.room.TypeConverter
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
object DateTimeTypeConverters {
|
||||
@TypeConverter
|
||||
@JvmStatic
|
||||
fun toLocalDateTime(value: String?): LocalDateTime? {
|
||||
return value?.let { LocalDateTime.parse(value) }
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
@JvmStatic
|
||||
fun fromLocalDateTime(value: LocalDateTime?): String? {
|
||||
return value?.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package dev.msfjarvis.todo.data.source
|
||||
|
||||
import androidx.room.Database
|
||||
import androidx.room.RoomDatabase
|
||||
import androidx.room.TypeConverters
|
||||
import dev.msfjarvis.todo.data.model.TodoItem
|
||||
|
||||
@Database(
|
||||
entities = [
|
||||
TodoItem::class,
|
||||
],
|
||||
version = 1,
|
||||
exportSchema = false,
|
||||
)
|
||||
@TypeConverters(DateTimeTypeConverters::class)
|
||||
abstract class TodoDatabase : RoomDatabase() {
|
||||
abstract fun todoItemsDao(): TodoItemDao
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package dev.msfjarvis.todo.data.source
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Delete
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import androidx.room.Update
|
||||
import dev.msfjarvis.todo.data.model.TodoItem
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
/**
|
||||
* Room [Dao] for [TodoItem]
|
||||
*/
|
||||
@Dao
|
||||
abstract class TodoItemDao {
|
||||
|
||||
@Query("SELECT * FROM todo_items")
|
||||
abstract fun getAllItems(): Flow<List<TodoItem>>
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
abstract suspend fun insert(entity: TodoItem): Long
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
abstract suspend fun insertAll(vararg entity: TodoItem)
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
abstract suspend fun insertAll(entities: Collection<TodoItem>)
|
||||
|
||||
@Update(onConflict = OnConflictStrategy.REPLACE)
|
||||
abstract suspend fun update(entity: TodoItem)
|
||||
|
||||
@Delete
|
||||
abstract suspend fun delete(entity: TodoItem): Int
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue