-
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.
[MERGE/#46] merge develop into ocr-feat-text-recognition
- Loading branch information
Showing
151 changed files
with
1,435 additions
and
188 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
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 was deleted.
Oops, something went wrong.
5 changes: 3 additions & 2 deletions
5
.../java/com/keyneez/data/entity/LikeData.kt โ ...ava/com/keyneez/data/entity/SearchData.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,7 +1,8 @@ | ||
package com.keyneez.data.entity | ||
|
||
data class LikeData( | ||
data class SearchData( | ||
val background: Int, | ||
val date: String, | ||
val title: String | ||
val title: String, | ||
val liked: Boolean | ||
) |
37 changes: 37 additions & 0 deletions
37
app/src/main/java/com/keyneez/data/model/response/ResponseGetContentDeatilDto.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,37 @@ | ||
package com.keyneez.data.model.response | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseGetContentDeatilDto( | ||
@SerialName("content_key") | ||
val key: Int?, | ||
@SerialName("content_title") | ||
val title: String?, | ||
@SerialName("content_link") | ||
val link: String?, | ||
@SerialName("content_img") | ||
val img: String?, | ||
@SerialName("place") | ||
val place: String?, | ||
@SerialName("introduction") | ||
val introduction: String?, | ||
@SerialName("benefit") | ||
val benefit: String?, | ||
@SerialName("usage") | ||
val usage: String?, | ||
@SerialName("start_at") | ||
val start: String?, | ||
@SerialName("end_at") | ||
val end: String?, | ||
@SerialName("liked") | ||
val liked: Boolean, | ||
@SerialName("category") | ||
val category: List<String> | ||
) { | ||
@Serializable | ||
data class Category( | ||
val category: String? | ||
) | ||
} |
27 changes: 27 additions & 0 deletions
27
app/src/main/java/com/keyneez/data/model/response/ResponseIdDto.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.keyneez.data.model.response | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseIdDto( | ||
@SerialName("user_key") val key: Int, | ||
@SerialName("user_name") val name: String, | ||
@SerialName("user_age") val age: String?, | ||
@SerialName("user_gender") val gender: String?, | ||
@SerialName("user_phone") val phone: String, | ||
@SerialName("user_birth") val birth: String, | ||
@SerialName("user_school") val school: String?, | ||
@SerialName("user_character") val userCharacter: Int?, | ||
@SerialName("user_password") val password: String?, | ||
@SerialName("user_benefit") val benefit: Boolean?, | ||
@SerialName("user_ocr") val ocrImg: String?, | ||
@SerialName("ocr_dir") val ocrDir: Boolean?, | ||
val Characters: Character? | ||
) { | ||
@Serializable | ||
data class Character( | ||
val character: String?, | ||
@SerialName("character_img") val characterImg: String? | ||
) | ||
} |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/keyneez/data/model/response/ResponseLikeDto.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.keyneez.data.model.response | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseLikeDto( | ||
@SerialName("content_key") | ||
val key: Int, | ||
@SerialName("content_title") | ||
val title: String, | ||
@SerialName("start_at") | ||
val start: String?, | ||
@SerialName("end_at") | ||
val end: String?, | ||
@SerialName("content_img") | ||
val background: String | ||
) |
10 changes: 9 additions & 1 deletion
10
app/src/main/java/com/keyneez/data/repository/ContentRepository.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,3 +1,11 @@ | ||
package com.keyneez.data.repository | ||
|
||
interface ContentRepository | ||
import com.keyneez.data.model.response.ResponseGetContentDeatilDto | ||
import com.keyneez.data.model.response.ResponseLikeDto | ||
import com.keyneez.data.model.response.wrapper.BaseResponse | ||
|
||
interface ContentRepository { | ||
suspend fun getLike(): Result<BaseResponse<List<ResponseLikeDto>>> | ||
|
||
suspend fun getDetail(contentId: Int): Result<BaseResponse<ResponseGetContentDeatilDto>> | ||
} |
12 changes: 11 additions & 1 deletion
12
app/src/main/java/com/keyneez/data/repository/ContentRepositoryImpl.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,18 @@ | ||
package com.keyneez.data.repository | ||
|
||
import com.keyneez.data.model.response.ResponseGetContentDeatilDto | ||
import com.keyneez.data.model.response.ResponseLikeDto | ||
import com.keyneez.data.model.response.wrapper.BaseResponse | ||
import com.keyneez.data.source.ContentDataSource | ||
import javax.inject.Inject | ||
|
||
class ContentRepositoryImpl @Inject constructor( | ||
private val contentDataSource: ContentDataSource | ||
) : ContentRepository | ||
) : ContentRepository { | ||
|
||
override suspend fun getLike(): Result<BaseResponse<List<ResponseLikeDto>>> = | ||
kotlin.runCatching { contentDataSource.getLike() } | ||
|
||
override suspend fun getDetail(contentId: Int): Result<BaseResponse<ResponseGetContentDeatilDto>> = | ||
kotlin.runCatching { contentDataSource.getDetail(contentId) } | ||
} |
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
16 changes: 15 additions & 1 deletion
16
app/src/main/java/com/keyneez/data/service/ContentService.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,3 +1,17 @@ | ||
package com.keyneez.data.service | ||
|
||
interface ContentService | ||
import com.keyneez.data.model.response.ResponseGetContentDeatilDto | ||
import com.keyneez.data.model.response.ResponseLikeDto | ||
import com.keyneez.data.model.response.wrapper.BaseResponse | ||
import retrofit2.http.GET | ||
import retrofit2.http.Path | ||
|
||
interface ContentService { | ||
@GET("content/liked") | ||
suspend fun getLike(): BaseResponse<List<ResponseLikeDto>> | ||
|
||
@GET("content/view/{content_id}") | ||
suspend fun getDetail( | ||
@Path("content_id") contentId: Int | ||
): BaseResponse<ResponseGetContentDeatilDto> | ||
} |
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
11 changes: 10 additions & 1 deletion
11
app/src/main/java/com/keyneez/data/source/ContentDataSource.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,17 @@ | ||
package com.keyneez.data.source | ||
|
||
import com.keyneez.data.model.response.ResponseGetContentDeatilDto | ||
import com.keyneez.data.model.response.ResponseLikeDto | ||
import com.keyneez.data.model.response.wrapper.BaseResponse | ||
import com.keyneez.data.service.ContentService | ||
import javax.inject.Inject | ||
|
||
class ContentDataSource @Inject constructor( | ||
private val contentService: ContentService | ||
) | ||
) { | ||
|
||
suspend fun getLike(): BaseResponse<List<ResponseLikeDto>> = contentService.getLike() | ||
|
||
suspend fun getDetail(contentId: Int): BaseResponse<ResponseGetContentDeatilDto> = | ||
contentService.getDetail(contentId) | ||
} |
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
19 changes: 18 additions & 1 deletion
19
app/src/main/java/com/keyneez/presentation/main/detail/DetailActivity.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
43 changes: 42 additions & 1 deletion
43
app/src/main/java/com/keyneez/presentation/main/detail/DetailViewModel.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,5 +1,46 @@ | ||
package com.keyneez.presentation.main.detail | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.MutableLiveData | ||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import com.keyneez.data.model.response.ResponseGetContentDeatilDto | ||
import com.keyneez.data.repository.ContentRepository | ||
import com.keyneez.util.UiState | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.launch | ||
import timber.log.Timber | ||
import javax.inject.Inject | ||
|
||
class DetailViewModel : ViewModel() | ||
@HiltViewModel | ||
class DetailViewModel @Inject constructor( | ||
private val contentRepository: ContentRepository | ||
) : ViewModel() { | ||
|
||
private val _detailContent = MutableLiveData<ResponseGetContentDeatilDto>() | ||
val detailContent: LiveData<ResponseGetContentDeatilDto> | ||
get() = _detailContent | ||
|
||
private val _stateMessage = MutableLiveData<UiState>() | ||
val stateMessage: LiveData<UiState> | ||
get() = _stateMessage | ||
|
||
fun getDetail(contentId: Int) { | ||
viewModelScope.launch { | ||
contentRepository.getDetail(contentId) | ||
.onSuccess { response -> | ||
if (response.data == null) { | ||
Timber.d("GET DETAIL LIST IS NULL") | ||
_stateMessage.value = UiState.Failure(100) | ||
return@onSuccess | ||
} | ||
Timber.d("GET DETAIL LIST SUCCESS") | ||
Timber.d("response : $response") | ||
_detailContent.value = response.data!! | ||
_stateMessage.value = UiState.Success | ||
}.onFailure { throwable -> | ||
Timber.e("$throwable") | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.