Skip to content

Commit

Permalink
Merge pull request #35 from merklol/develop
Browse files Browse the repository at this point in the history
v0.5.5
  • Loading branch information
merklol authored Aug 20, 2021
2 parents 9d5da21 + 42a9251 commit fb860e3
Show file tree
Hide file tree
Showing 34 changed files with 217 additions and 217 deletions.
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/AppConfiguration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object AppConfiguration {
const val CompileSdk = 30
const val MinSdk = 23
const val TargetSdk = 30
const val VersionCode = 8
const val VersionName = "0.5.4"
const val VersionCode = 9
const val VersionName = "0.5.5"
const val JvmTarget = "1.8"
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import androidx.room.Database
import androidx.room.RoomDatabase
import com.maximapps.core.data.models.LessonEntity

@Database(entities = [LessonEntity::class], version = 1, exportSchema = false)
@Database(entities = [LessonEntity::class], version = 2, exportSchema = false)
abstract class AppDatabase : RoomDatabase() {
abstract fun favoriteLessonsDao(): FavoriteLessonsDao
}
24 changes: 12 additions & 12 deletions core/src/main/java/com/maximapps/core/data/models/LessonEntity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ data class LessonEntity(
@PrimaryKey
val id: Int,
val email: String,
val title: String,
val shortTitle: String,
val primaryTitle: String,
val secondaryTitle: String,
val thumbnail: ByteArray,
val description: String,
val content: String,
val image: ByteArray,
val body: String,
val date: String
) {

Expand All @@ -48,11 +48,11 @@ data class LessonEntity(

if (id != other.id) return false
if (email != other.email) return false
if (title != other.title) return false
if (shortTitle != other.shortTitle) return false
if (primaryTitle != other.primaryTitle) return false
if (secondaryTitle != other.secondaryTitle) return false
if (description != other.description) return false
if (content != other.content) return false
if (!image.contentEquals(other.image)) return false
if (body != other.body) return false
if (!thumbnail.contentEquals(other.thumbnail)) return false
if (date != other.date) return false

return true
Expand All @@ -61,11 +61,11 @@ data class LessonEntity(
override fun hashCode(): Int {
var result = id
result = 31 * result + email.hashCode()
result = 31 * result + title.hashCode()
result = 31 * result + shortTitle.hashCode()
result = 31 * result + primaryTitle.hashCode()
result = 31 * result + secondaryTitle.hashCode()
result = 31 * result + description.hashCode()
result = 31 * result + content.hashCode()
result = 31 * result + image.contentHashCode()
result = 31 * result + body.hashCode()
result = 31 * result + thumbnail.contentHashCode()
result = 31 * result + date.hashCode()
return result
}
Expand Down
24 changes: 12 additions & 12 deletions core/src/main/java/com/maximapps/core/data/models/SharedLesson.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ import kotlinx.parcelize.Parcelize
@Parcelize
data class SharedLesson(
val id: Int,
val title: String,
val shortTitle: String,
val primaryTitle: String,
val secondaryTitle: String,
val thumbnail: ByteArray,
val description: String,
val content: String,
val image: ByteArray,
val body: String,
val date: String
) : Parcelable {
override fun equals(other: Any?): Boolean {
Expand All @@ -49,23 +49,23 @@ data class SharedLesson(
other as SharedLesson

if (id != other.id) return false
if (title != other.title) return false
if (shortTitle != other.shortTitle) return false
if (primaryTitle != other.primaryTitle) return false
if (secondaryTitle != other.secondaryTitle) return false
if (description != other.description) return false
if (content != other.content) return false
if (!image.contentEquals(other.image)) return false
if (body != other.body) return false
if (!thumbnail.contentEquals(other.thumbnail)) return false
if (date != other.date) return false

return true
}

override fun hashCode(): Int {
var result = id
result = 31 * result + title.hashCode()
result = 31 * result + shortTitle.hashCode()
result = 31 * result + primaryTitle.hashCode()
result = 31 * result + secondaryTitle.hashCode()
result = 31 * result + description.hashCode()
result = 31 * result + content.hashCode()
result = 31 * result + image.contentHashCode()
result = 31 * result + body.hashCode()
result = 31 * result + thumbnail.contentHashCode()
result = 31 * result + date.hashCode()
return result
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,31 @@ fun provideSampleData(context: Context) = listOf(
LessonEntity(
id = 0,
email = "[email protected]",
title = "Common Chinese Grammar Structures for 的 (de) vs. 得 (de) vs. 地(de)",
shortTitle = "Lesson 1",
primaryTitle = "Common Chinese Grammar Structures for 的 (de) vs. 得 (de) vs. 地(de)",
secondaryTitle = "Lesson 1",
description = "",
content = "[{\"type\": \"header1\", \"value\": \"Hello world!\"}]",
image = context.readBitmapFromAssets("sample_image.jpg").toByteArray(),
body = "[{\"type\": \"header1\", \"value\": \"Hello world!\"}]",
thumbnail = context.readBitmapFromAssets("sample_image.jpg").toByteArray(),
date = "20.20.2020"
),
LessonEntity(
id = 1,
email = "[email protected]",
title = "Watching videos is definitely one of the interesting and best ways to alleviate the pressure",
shortTitle = "Lesson 2",
primaryTitle = "Watching videos is definitely one of the interesting and best ways to alleviate the pressure",
secondaryTitle = "Lesson 2",
description = "",
content = "[{\"type\": \"header1\", \"value\": \"Hello world!\"}]",
image = context.readBitmapFromAssets("sample_image.jpg").toByteArray(),
body = "[{\"type\": \"header1\", \"value\": \"Hello world!\"}]",
thumbnail = context.readBitmapFromAssets("sample_image.jpg").toByteArray(),
date = "20.20.2020"
),
LessonEntity(
id = 2,
email = "[email protected]",
title = "Traveling in China – Business Etiquette and Culture",
shortTitle = "Lesson 3",
primaryTitle = "Traveling in China – Business Etiquette and Culture",
secondaryTitle = "Lesson 3",
description = "",
content = "[{\"type\": \"header1\", \"value\": \"Hello world!\"}]",
image = context.readBitmapFromAssets("sample_image.jpg").toByteArray(),
body = "[{\"type\": \"header1\", \"value\": \"Hello world!\"}]",
thumbnail = context.readBitmapFromAssets("sample_image.jpg").toByteArray(),
date = "20.20.2020"
)
)
24 changes: 12 additions & 12 deletions core/src/main/java/com/maximapps/core/domain/Lesson.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ package com.maximapps.core.domain

data class Lesson(
val id: Int,
val title: String,
val shortTitle: String,
val primaryTitle: String,
val secondaryTitle: String,
val thumbnail: ByteArray,
val description: String,
val content: String,
val image: ByteArray,
val body: String,
val date: String
) {
override fun equals(other: Any?): Boolean {
Expand All @@ -40,23 +40,23 @@ data class Lesson(
other as Lesson

if (id != other.id) return false
if (title != other.title) return false
if (shortTitle != other.shortTitle) return false
if (primaryTitle != other.primaryTitle) return false
if (secondaryTitle != other.secondaryTitle) return false
if (description != other.description) return false
if (content != other.content) return false
if (!image.contentEquals(other.image)) return false
if (body != other.body) return false
if (!thumbnail.contentEquals(other.thumbnail)) return false
if (date != other.date) return false

return true
}

override fun hashCode(): Int {
var result = id
result = 31 * result + title.hashCode()
result = 31 * result + shortTitle.hashCode()
result = 31 * result + primaryTitle.hashCode()
result = 31 * result + secondaryTitle.hashCode()
result = 31 * result + description.hashCode()
result = 31 * result + content.hashCode()
result = 31 * result + image.contentHashCode()
result = 31 * result + body.hashCode()
result = 31 * result + thumbnail.contentHashCode()
result = 31 * result + date.hashCode()
return result
}
Expand Down
32 changes: 16 additions & 16 deletions core/src/main/java/com/maximapps/core/domain/Mappers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ import com.maximapps.core.utils.toByteArray
fun Lesson.toLessonEntity(email: String) = LessonEntity(
id = id,
email = email,
title = title,
shortTitle = shortTitle,
primaryTitle = primaryTitle,
secondaryTitle = secondaryTitle,
thumbnail = thumbnail,
description = description,
content = content,
image = image,
body = body,
date = date
)

Expand All @@ -52,11 +52,11 @@ fun Lesson.toLessonEntity(email: String) = LessonEntity(
*/
fun LessonEntity.toLesson() = Lesson(
id = id,
title = title,
shortTitle = shortTitle,
primaryTitle = primaryTitle,
secondaryTitle = secondaryTitle,
thumbnail = thumbnail,
description = description,
content = content,
image = image,
body = body,
date = date
)

Expand All @@ -67,11 +67,11 @@ fun LessonEntity.toLesson() = Lesson(
*/
fun Lesson.toSharedLesson(imageBitmap: Bitmap) = SharedLesson(
id = id,
title = title,
shortTitle = shortTitle,
primaryTitle = primaryTitle,
secondaryTitle = secondaryTitle,
thumbnail = imageBitmap.toByteArray(),
description = description,
content = content,
image = imageBitmap.toByteArray(),
body = body,
date = date
)

Expand All @@ -82,10 +82,10 @@ fun Lesson.toSharedLesson(imageBitmap: Bitmap) = SharedLesson(
*/
fun SharedLesson.toLesson() = Lesson(
id = id,
title = title,
shortTitle = shortTitle,
primaryTitle = primaryTitle,
secondaryTitle = secondaryTitle,
thumbnail = thumbnail,
description = description,
content = content,
image = image,
body = body,
date = date
)
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class FavoritesFragment @Inject constructor(
onSwipeLeft = {
val item = adapter.getItemAt(it)
viewModel.removeFromFavorites(item)
showSnackBar(item.title, provider.snackBarActionText) {
showSnackBar(item.primaryTitle, provider.snackBarActionText) {
viewModel.saveToFavorites(item)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ internal class FavoritesDiffUtil(
old[oldItemPosition].id == new[newItemPosition].id

override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) =
old[oldItemPosition].title == new[newItemPosition].title
old[oldItemPosition].primaryTitle == new[newItemPosition].primaryTitle
&& old[oldItemPosition].date == new[newItemPosition].date
&& old[oldItemPosition].image.contentEquals(new[newItemPosition].image)
&& old[oldItemPosition].thumbnail.contentEquals(new[newItemPosition].thumbnail)
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ class FavoritesListAdapter : RecyclerView.Adapter<FavoritesListAdapter.ListItemV
) : RecyclerView.ViewHolder(binding.root) {

fun bind(lesson: Lesson) {
binding.title.text = lesson.title
binding.title.text = lesson.primaryTitle
binding.date.text = lesson.date
binding.imageHolder.setImageBitmap(lesson.image.toBitmap())
binding.imageHolder.setImageBitmap(lesson.thumbnail.toBitmap())

itemView.setOnClickListener {
val bitmap = binding.imageHolder.drawable.toBitmap()
Expand Down
18 changes: 9 additions & 9 deletions features/home/src/main/java/com/maximapps/home/data/Mappers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ import com.maximapps.home.data.models.Source
internal fun MutableList<Source>.toLessons() = map {
Lesson(
id = it.id,
template = it.template,
title = it.title,
shortTitle = it.shortTitle,
primaryTitle = it.primaryTitle,
secondaryTitle = it.secondaryTitle,
thumbnail = it.thumbnail,
description = it.description,
content = it.content,
imageSrc = it.imageSrc,
template = it.template,
body = it.body,
date = it.date
)
}
Expand All @@ -55,10 +55,10 @@ internal fun MutableList<Source>.toLessons() = map {
*/
internal fun Lesson.toSharedLesson(imageBitmap: Bitmap) = SharedLesson(
id = id,
title = title,
shortTitle = shortTitle,
primaryTitle = primaryTitle,
secondaryTitle = secondaryTitle,
thumbnail = imageBitmap.toByteArray(),
description = description,
content = content,
image = imageBitmap.toByteArray(),
body = body,
date = date
)
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ package com.maximapps.home.data.models
*/
data class Lesson(
val id: Int,
val template: Int,
val title: String,
val shortTitle: String,
val primaryTitle: String,
val secondaryTitle: String,
val thumbnail: String,
val description: String,
val content: String,
val imageSrc: String,
val template: Int,
val body: String,
val date: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ package com.maximapps.home.data.models
*/
internal data class Source(
var id: Int = 0,
var template: Int = 0,
var title: String = "",
var shortTitle: String = "",
var primaryTitle: String = "",
var secondaryTitle: String = "",
var thumbnail: String = "",
var description: String = "",
var content: String = "",
var imageSrc: String = "",
var template: Int = 0,
var body: String = "",
var date: String = ""
)
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ class LessonListAdapter(callback: DiffUtil.ItemCallback<Lesson>) :
override fun bind(lesson: Lesson) {
itemView.isEnabled = false

binding.title.text = lesson.title
binding.title.text = lesson.primaryTitle
binding.date.text = lesson.date
binding.imageHolder.load(lesson.imageSrc) {
binding.imageHolder.load(lesson.thumbnail) {
placeholder(R.drawable.ic_img_placeholder)
listener(onSuccess = { _, _ -> itemView.isEnabled = true })
}
Expand All @@ -139,9 +139,9 @@ class LessonListAdapter(callback: DiffUtil.ItemCallback<Lesson>) :
override fun bind(lesson: Lesson) {
itemView.isEnabled = false

binding.title.text = lesson.title
binding.title.text = lesson.primaryTitle
binding.date.text = lesson.date
binding.imageHolder.load(lesson.imageSrc) {
binding.imageHolder.load(lesson.thumbnail) {
placeholder(R.drawable.ic_img_placeholder)
listener(onSuccess = { _, _ -> itemView.isEnabled = true })
}
Expand Down
Loading

0 comments on commit fb860e3

Please sign in to comment.