-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from AndroidStudy-bmsk/feat/9-scrap
[#9] 스크랩 기능을 추가
- Loading branch information
Showing
78 changed files
with
1,750 additions
and
413 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
root = true | ||
|
||
[*] | ||
|
||
# ktlint specific settings for Compose | ||
[*.kt] | ||
ktlint_function_naming_ignore_when_annotated_with=Composable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
build-logic/src/main/kotlin/lifemash.android.application.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
build-logic/src/main/kotlin/lifemash.android.no-hilt-library.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import org.bmsk.lifemash.configureCoroutineAndroid | ||
import org.bmsk.lifemash.configureHiltAndroid | ||
import org.bmsk.lifemash.configureKotest | ||
import org.bmsk.lifemash.configureKotlinAndroid | ||
|
||
plugins { | ||
id("com.android.library") | ||
id("lifemash.verify.detekt") | ||
} | ||
|
||
configureKotlinAndroid() | ||
configureKotest() | ||
configureCoroutineAndroid() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
core/data/src/main/kotlin/org/bmsk/lifemash/core/data/Mapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...ignsystem/src/main/kotlin/org/bmsk/lifemash/core/designsystem/effect/NoRippleClickable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.bmsk.lifemash.core.designsystem.effect | ||
|
||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.interaction.MutableInteractionSource | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
|
||
@Composable | ||
fun Modifier.noRippleClickable(onClick: () -> Unit): Modifier = this.clickable( | ||
interactionSource = remember { MutableInteractionSource() }, | ||
indication = null, | ||
onClick = onClick, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
core/model/src/main/kotlin/org/bmsk/lifemash/core/model/NewsModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package org.bmsk.lifemash.core.model | ||
|
||
import java.util.Date | ||
|
||
data class NewsModel( | ||
val title: String, | ||
val link: String, | ||
val pubDate: String, | ||
val pubDate: Date, | ||
val imageUrl: String? = null, | ||
) |
9 changes: 3 additions & 6 deletions
9
...bmsk/lifemash/core/data/DateParserTest.kt → ...msk/lifemash/core/model/DateParserTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
plugins { | ||
id("lifemash.kotlin.library") | ||
id("kotlinx-serialization") | ||
} | ||
|
||
dependencies { | ||
implementation(projects.core.model) | ||
implementation(libs.kotlinx.serialization.json) | ||
} |
28 changes: 28 additions & 0 deletions
28
...po/scrap/api/src/main/kotlin/org/bmsk/lifemash/core/repo/scrap/api/ScrapNewsRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.bmsk.lifemash.core.repo.scrap.api | ||
|
||
import org.bmsk.lifemash.core.model.NewsModel | ||
import java.util.Date | ||
|
||
interface ScrapNewsRepository { | ||
fun addNewsToDB(newsModel: NewsModel) | ||
|
||
fun getNewsFromDB(): List<NewsModel> | ||
|
||
fun deleteNewsFromDB(newsModel: NewsModel) | ||
|
||
fun deleteAllNewsFromDB() | ||
|
||
fun updateNewsFromDB(newsModel: NewsModel) | ||
|
||
fun updateAllNewsFromDB(newsModels: List<NewsModel>) | ||
|
||
fun getNewsByTitle(title: String): NewsModel? | ||
|
||
fun getNewsByLink(link: String): NewsModel? | ||
|
||
fun getNewsByPubDate(pubDate: Date): NewsModel? | ||
|
||
fun getNewsByImageUrl(imageUrl: String): NewsModel? | ||
|
||
fun getNewsByContent(content: String): NewsModel? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
plugins { | ||
id("lifemash.android.library") | ||
id("lifemash.android.hilt") | ||
id("kotlinx-serialization") | ||
alias(libs.plugins.ksp) | ||
} | ||
|
||
android { | ||
namespace = "org.bmsk.lifemash.core.repo.scrap" | ||
} | ||
|
||
dependencies { | ||
implementation(projects.core.repo.scrap.api) | ||
implementation(projects.core.model) | ||
|
||
implementation(libs.androidx.room.ktx) | ||
implementation(libs.androidx.room.runtime) | ||
ksp(libs.androidx.room.compiler) | ||
} |
12 changes: 12 additions & 0 deletions
12
core/repo/scrap/impl/src/main/kotlin/org/bmsk/lifemash/core/repo/scrap/impl/DateConverter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.bmsk.lifemash.core.repo.scrap.impl | ||
|
||
import androidx.room.TypeConverter | ||
import java.util.Date | ||
|
||
internal class DateConverter { | ||
@TypeConverter | ||
fun fromTimestamp(value: Long): Date = Date(value) | ||
|
||
@TypeConverter | ||
fun dateToTimestamp(date: Date): Long = date.time | ||
} |
18 changes: 18 additions & 0 deletions
18
core/repo/scrap/impl/src/main/kotlin/org/bmsk/lifemash/core/repo/scrap/impl/Mapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.bmsk.lifemash.core.repo.scrap.impl | ||
|
||
import org.bmsk.lifemash.core.model.NewsModel | ||
import org.bmsk.lifemash.core.repo.scrap.impl.entity.NewsEntity | ||
|
||
fun NewsModel.toEntity(): NewsEntity = NewsEntity( | ||
title = this.title, | ||
link = this.link, | ||
pubDate = this.pubDate, | ||
imageUrl = this.imageUrl, | ||
) | ||
|
||
fun NewsEntity.toModel(): NewsModel = NewsModel( | ||
title = this.title, | ||
link = this.link, | ||
pubDate = this.pubDate, | ||
imageUrl = this.imageUrl, | ||
) |
55 changes: 55 additions & 0 deletions
55
...ap/impl/src/main/kotlin/org/bmsk/lifemash/core/repo/scrap/impl/ScrapNewsRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package org.bmsk.lifemash.core.repo.scrap.impl | ||
|
||
import org.bmsk.lifemash.core.model.NewsModel | ||
import org.bmsk.lifemash.core.repo.scrap.api.ScrapNewsRepository | ||
import org.bmsk.lifemash.core.repo.scrap.impl.dao.ScrapNewsDao | ||
import org.bmsk.lifemash.core.repo.scrap.impl.entity.NewsEntity | ||
import java.util.Date | ||
import javax.inject.Inject | ||
|
||
internal class ScrapNewsRepositoryImpl @Inject constructor( | ||
private val scrapNewsDao: ScrapNewsDao, | ||
) : ScrapNewsRepository { | ||
|
||
override fun addNewsToDB(newsModel: NewsModel) { | ||
scrapNewsDao.insertNews(newsModel.toEntity()) | ||
} | ||
|
||
override fun getNewsFromDB(): List<NewsModel> = | ||
scrapNewsDao.getAllNews().map(NewsEntity::toModel) | ||
|
||
override fun deleteNewsFromDB(newsModel: NewsModel) { | ||
scrapNewsDao.deleteNews(newsModel.toEntity()) | ||
} | ||
|
||
override fun deleteAllNewsFromDB() { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun updateNewsFromDB(newsModel: NewsModel) { | ||
scrapNewsDao.updateNews(newsModel.toEntity()) | ||
} | ||
|
||
override fun updateAllNewsFromDB(newsModels: List<NewsModel>) { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun getNewsByTitle(title: String): NewsModel? { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun getNewsByLink(link: String): NewsModel? = | ||
scrapNewsDao.getNewsByLink(link)?.toModel() | ||
|
||
override fun getNewsByPubDate(pubDate: Date): NewsModel? { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun getNewsByImageUrl(imageUrl: String): NewsModel? { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun getNewsByContent(content: String): NewsModel? { | ||
TODO("Not yet implemented") | ||
} | ||
} |
Oops, something went wrong.