-
-
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.
- Loading branch information
1 parent
66c087c
commit 9b6c9a7
Showing
16 changed files
with
172 additions
and
185 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Binary file not shown.
8 changes: 0 additions & 8 deletions
8
.../main/kotlin/com/d4rk/englishwithlidia/plus/constants/media/MediaNotificationConstants.kt
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
app/src/main/kotlin/com/d4rk/englishwithlidia/plus/data/model/api/ApiResponse.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,21 @@ | ||
package com.d4rk.englishwithlidia.plus.data.model.api | ||
|
||
import kotlinx.serialization.ExperimentalSerializationApi | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.json.JsonNames | ||
|
||
@Serializable | ||
data class ApiResponse( | ||
val data: List<NetworkLesson> | ||
) | ||
|
||
@Serializable | ||
data class NetworkLesson @OptIn(ExperimentalSerializationApi::class) constructor( | ||
val id: Int, | ||
val title: String, | ||
val banner: String, | ||
@JsonNames("lessonDetails.title") val lessonDetailsTitle: String, | ||
@JsonNames("lessonDetails.audioUrl") val lessonDetailsAudioUrl: String, | ||
@JsonNames("lessonDetails.lessonIntro") val lessonDetailsLessonIntro: String, | ||
@JsonNames("lessonDetails.lessonSummary") val lessonDetailsLessonSummary: String | ||
) |
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
123 changes: 0 additions & 123 deletions
123
.../kotlin/com/d4rk/englishwithlidia/plus/notifications/managers/MediaNotificationManager.kt
This file was deleted.
Oops, something went wrong.
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
60 changes: 33 additions & 27 deletions
60
app/src/main/kotlin/com/d4rk/englishwithlidia/plus/ui/home/repository/LessonRepository.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,36 +1,42 @@ | ||
package com.d4rk.englishwithlidia.plus.ui.home.repository | ||
|
||
import android.content.Context | ||
import com.d4rk.englishwithlidia.plus.R | ||
import com.d4rk.englishwithlidia.plus.data.model.api.ApiResponse | ||
import com.d4rk.englishwithlidia.plus.data.model.ui.lessons.UiLessonDetails | ||
import com.d4rk.englishwithlidia.plus.data.model.ui.lessons.UiLessonsAsset | ||
import io.ktor.client.HttpClient | ||
import io.ktor.client.call.body | ||
import io.ktor.client.engine.cio.CIO | ||
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation | ||
import io.ktor.client.request.get | ||
import io.ktor.serialization.kotlinx.json.json | ||
|
||
class LessonRepository(private val context: Context) { | ||
class LessonRepository { | ||
private val client = HttpClient(CIO) { | ||
install(ContentNegotiation) { | ||
json() | ||
} | ||
} | ||
|
||
fun getLessonData(): List<UiLessonsAsset> { | ||
return listOf( | ||
UiLessonsAsset( | ||
id = 1, | ||
title = context.getString(R.string.lesson_1_title), | ||
banner = R.drawable.im_lesson1, | ||
lessonDetails = UiLessonDetails( | ||
title = context.getString(R.string.lesson_1_title), | ||
audioResId = R.raw.lesson1, | ||
lessonIntro = context.getString(R.string.introduction_first_lesson), | ||
lessonSummary = context.getString(R.string.summary_first_lesson) | ||
) | ||
), | ||
UiLessonsAsset( | ||
id = 2, | ||
title = context.getString(R.string.lesson_2_title), | ||
banner = R.drawable.im_lesson2, | ||
lessonDetails = UiLessonDetails( | ||
title = context.getString(R.string.lesson_2_title), | ||
audioResId = R.raw.lesson2, | ||
lessonIntro = context.getString(R.string.introduction_second_lesson), | ||
lessonSummary = context.getString(R.string.summary_second_lesson) | ||
suspend fun getLessonData(): List<UiLessonsAsset> { | ||
val url = | ||
"https://script.googleusercontent.com/macros/echo?user_content_key=IqfXaaMa5_xVh9PXgCkTSSvJ5oXI2E6ovHb-xZ-9oeDNzYVvgbAQub1KyRTJ8iBLSdRQS9gDeA6vYWII3idMI7fMbNijCwsvm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_1xSncGQajx_ryfhECjZEnJ73NK6pJWSpPRfbuzxijC-yIhItdrlA4B3P1J--f1LjXLtmxSn7AD8ey3pHscewS7Oo7Ec-OFT-mp7LnhIc8L9DWUmcQiBQTNz9Jw9Md8uu&lib=MSUzLTgsn65WMd0y5_jDbxNmCwTyR-I_G" | ||
return try { | ||
val response: ApiResponse = client.get(url).body() | ||
response.data.map { networkLesson -> | ||
UiLessonsAsset( | ||
id = networkLesson.id, | ||
title = networkLesson.title, | ||
banner = networkLesson.banner, | ||
lessonDetails = UiLessonDetails( | ||
title = networkLesson.lessonDetailsTitle, | ||
audioUrl = networkLesson.lessonDetailsAudioUrl, | ||
lessonIntro = networkLesson.lessonDetailsLessonIntro, | ||
lessonSummary = networkLesson.lessonDetailsLessonSummary | ||
) | ||
) | ||
), | ||
) | ||
} | ||
} catch (e: Exception) { | ||
emptyList() | ||
} | ||
} | ||
} |
Oops, something went wrong.