generated from teamqomunal/android-research-tech
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update: create simple fetch api using flow coroutine
- Loading branch information
1 parent
c528dbc
commit a294932
Showing
28 changed files
with
637 additions
and
59 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/qomunal/opensource/androidresearch/common/ext/GsonExt.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 com.qomunal.opensource.androidresearch.common.ext | ||
|
||
import com.google.gson.Gson | ||
import com.google.gson.reflect.TypeToken | ||
|
||
/** | ||
* Created by faisalamircs on 14/01/2024 | ||
* ----------------------------------------- | ||
* Name : Muhammad Faisal Amir | ||
* E-mail : [email protected] | ||
* Github : github.com/amirisback | ||
* ----------------------------------------- | ||
*/ | ||
|
||
|
||
inline fun <reified T> fromJson(json: String?): T { | ||
return Gson().fromJson(json, object : TypeToken<T>() {}.type) | ||
} |
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
27 changes: 27 additions & 0 deletions
27
app/src/main/java/com/qomunal/opensource/androidresearch/di/RepositoryModule.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,27 @@ | ||
package com.qomunal.opensource.androidresearch.di | ||
|
||
import com.qomunal.opensource.androidresearch.domain.news.repository.NewsRepository | ||
import com.qomunal.opensource.androidresearch.domain.news.repository.NewsRepositoryImpl | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
|
||
/** | ||
* Created by faisalamircs on 17/01/2024 | ||
* ----------------------------------------- | ||
* Name : Muhammad Faisal Amir | ||
* E-mail : [email protected] | ||
* Github : github.com/amirisback | ||
* ----------------------------------------- | ||
*/ | ||
|
||
|
||
@Module(includes = [ServiceModule::class]) | ||
@InstallIn(SingletonComponent::class) | ||
abstract class RepositoryModule { | ||
|
||
@Binds | ||
abstract fun provideNewsRepository(repository: NewsRepositoryImpl): NewsRepository | ||
|
||
} |
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
29 changes: 29 additions & 0 deletions
29
app/src/main/java/com/qomunal/opensource/androidresearch/di/UseCaseModule.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,29 @@ | ||
package com.qomunal.opensource.androidresearch.di | ||
|
||
import com.qomunal.opensource.androidresearch.domain.news.usecase.NewsUseCase | ||
import com.qomunal.opensource.androidresearch.domain.news.usecase.NewsUseCaseImpl | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.components.ViewModelComponent | ||
import dagger.hilt.android.scopes.ViewModelScoped | ||
|
||
/** | ||
* Created by faisalamircs on 17/01/2024 | ||
* ----------------------------------------- | ||
* Name : Muhammad Faisal Amir | ||
* E-mail : [email protected] | ||
* Github : github.com/amirisback | ||
* ----------------------------------------- | ||
*/ | ||
|
||
|
||
@Module | ||
@InstallIn(ViewModelComponent::class) | ||
abstract class UseCaseModule { | ||
|
||
@Binds | ||
@ViewModelScoped | ||
abstract fun provideNewsUseCase(useCase: NewsUseCaseImpl): NewsUseCase | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
app/src/main/java/com/qomunal/opensource/androidresearch/domain/Resource.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,7 @@ | ||
package com.qomunal.opensource.androidresearch.domain | ||
|
||
sealed class Resource<T>(val data: T? = null, val message: String? = null) { | ||
class Success<T>(data: T) : Resource<T>(data) | ||
class Loading<T>(data: T? = null) : Resource<T>(data) | ||
class Error<T>(message: String, data: T? = null) : Resource<T>(data, message) | ||
} |
4 changes: 3 additions & 1 deletion
4
...oidresearch/domain/meal/MealApiService.kt → ...arch/domain/meal/remote/MealApiService.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
package com.qomunal.opensource.androidresearch.model | ||
|
||
import androidx.annotation.Keep | ||
package com.qomunal.opensource.androidresearch.domain.meal.remote | ||
|
||
/** | ||
* Created by faisalamircs on 13/01/2024 | ||
* Created by faisalamircs on 14/01/2024 | ||
* ----------------------------------------- | ||
* Name : Muhammad Faisal Amir | ||
* E-mail : [email protected] | ||
|
@@ -12,7 +10,5 @@ import androidx.annotation.Keep | |
*/ | ||
|
||
|
||
@Keep | ||
data class MainModel( | ||
val tag: String | ||
) | ||
class MealRemoteDataSource { | ||
} |
2 changes: 1 addition & 1 deletion
2
...droidresearch/domain/meal/MealConstant.kt → ...research/domain/meal/util/MealConstant.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
2 changes: 1 addition & 1 deletion
2
...ce/androidresearch/domain/meal/MealUrl.kt → ...droidresearch/domain/meal/util/MealUrl.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
52 changes: 52 additions & 0 deletions
52
app/src/main/java/com/qomunal/opensource/androidresearch/domain/news/mapper/NewsMapper.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,52 @@ | ||
package com.qomunal.opensource.androidresearch.domain.news.mapper | ||
|
||
import com.qomunal.opensource.androidresearch.domain.news.response.ArticleResponse | ||
import com.qomunal.opensource.androidresearch.domain.news.response.SourceResponse | ||
import com.qomunal.opensource.androidresearch.model.ArticleModel | ||
import com.qomunal.opensource.androidresearch.model.SourceModel | ||
|
||
/** | ||
* Created by faisalamircs on 15/01/2024 | ||
* ----------------------------------------- | ||
* Name : Muhammad Faisal Amir | ||
* E-mail : [email protected] | ||
* Github : github.com/amirisback | ||
* ----------------------------------------- | ||
*/ | ||
|
||
|
||
object NewsMapper { | ||
|
||
object Source { | ||
fun mapResponseToDomain(input: SourceResponse): SourceModel { | ||
return SourceModel( | ||
id = input.id ?: "", | ||
name = input.name ?: "", | ||
description = input.description ?: "", | ||
url = input.url ?: "", | ||
category = input.category ?: "", | ||
language = input.language ?: "", | ||
country = input.country ?: "" | ||
) | ||
} | ||
} | ||
|
||
object Article { | ||
|
||
fun mapResponseToDomain(input: ArticleResponse): ArticleModel { | ||
return ArticleModel( | ||
source = Source.mapResponseToDomain(input.source ?: SourceResponse()), | ||
author = input.author ?: "", | ||
title = input.title ?: "", | ||
description = input.description ?: "", | ||
url = input.url ?: "", | ||
urlToImage = input.urlToImage ?: "", | ||
publishedAt = input.publishedAt ?: "", | ||
content = input.content ?: "" | ||
) | ||
} | ||
|
||
} | ||
|
||
|
||
} |
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
Oops, something went wrong.