Skip to content

Develop to Main. Updating the code style and adding descriptions. #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -88,26 +88,29 @@ dependencies {
androidTestImplementation(libs.androidx.espresso.core)

/**
* Constraintlayout
* OkHttp
*
* https://developer.android.com/jetpack/androidx/releases/constraintlayout
* https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintLayout
* https://github.com/square/okhttp
*/
implementation(libs.androidx.constraintlayout)
implementation(platform(libs.okhttp.bom))
implementation(libs.okhttp)
implementation(libs.logging.interceptor)

/**
* Serialization
* Retrofit
*
* https://github.com/Kotlin/kotlinx.serialization
* https://github.com/square/retrofit
* https://github.com/square/retrofit/tree/trunk/retrofit-converters/kotlinx-serialization
*/
implementation(libs.kotlinx.serialization.json)
implementation(libs.retrofit)
implementation(libs.converter.kotlinx.serialization)

/**
* SplashScreen
* Serialization
*
* https://developer.android.com/reference/androidx/core/splashscreen/SplashScreen
* https://github.com/Kotlin/kotlinx.serialization
*/
implementation(libs.androidx.core.splashscreen)
implementation(libs.kotlinx.serialization.json)

/**
* Android Jetpack's Navigation component
Expand All @@ -120,17 +123,10 @@ dependencies {
/**
* ViewModel Lifecycle
*
* https://developer.android.com/jetpack/androidx/releases/lifecycle
* https://developer.android.com/topic/libraries/architecture/viewmodel
*/
implementation(libs.androidx.lifecycle.viewmodel.ktx)

/**
* SkeletonLayout
*
* https://github.com/Faltenreich/SkeletonLayout
*/
implementation(libs.skeletonlayout)

/**
* Glide
* BlurTransformation glide-transformations
Expand All @@ -140,30 +136,34 @@ dependencies {
implementation(libs.glide)

/**
* Retrofit
* DI Koin
*
* https://github.com/square/retrofit
* https://github.com/square/retrofit/tree/trunk/retrofit-converters/kotlinx-serialization
* https://github.com/InsertKoinIO/koin
*/
implementation(libs.retrofit)
implementation(libs.converter.kotlinx.serialization)
implementation(libs.koin.core)
implementation(libs.koin.android)
implementation(libs.koin.annotations)
ksp(libs.koin.ksp.compiler)

/**
* OkHttp
* SplashScreen
*
* https://github.com/square/okhttp
* https://developer.android.com/reference/androidx/core/splashscreen/SplashScreen
*/
implementation(platform(libs.okhttp.bom))
implementation(libs.okhttp)
implementation(libs.logging.interceptor)
implementation(libs.androidx.core.splashscreen)

/**
* DI Koin
* Constraintlayout
*
* https://github.com/InsertKoinIO/koin
* https://developer.android.com/jetpack/androidx/releases/constraintlayout
* https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintLayout
*/
implementation(libs.koin.core)
implementation(libs.koin.android)
implementation(libs.koin.annotations)
ksp(libs.koin.ksp.compiler)
implementation(libs.androidx.constraintlayout)

/**
* SkeletonLayout
*
* https://github.com/Faltenreich/SkeletonLayout
*/
implementation(libs.skeletonlayout)
}
5 changes: 5 additions & 0 deletions app/src/main/java/com/sequenia/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import org.koin.android.ext.koin.androidContext
import org.koin.core.context.startKoin
import org.koin.ksp.generated.module

/**
* Класс приложения для инициализации `Koin`.
*
* @see Application Базовый класс приложения.
*/
class App : Application() {
override fun onCreate() {
super.onCreate()
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/com/sequenia/activity/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
package com.sequenia.activity

import android.os.Bundle

import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity

import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat

import com.sequenia.databinding.ActivityMainBinding

/**
* [MainActivity] - основная Activity приложения.
*
* @property binding ViewBinding для доступа к элементам разметки
* @see WindowInsetsCompat Для работы с системными инсетами
*/
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/com/sequenia/activity/SplashActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.core.splashscreen.SplashScreen
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen


/**
* [SplashActivity] - стартовая Activity приложения, отображающая экран-заставку.
*
* @property [SplashScreen] Используется для управления экраном-заставкой
*/
@SuppressLint("CustomSplashScreen")
class SplashActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.sequenia.adapter.common.film

import androidx.recyclerview.widget.DiffUtil
import com.sequenia.adapter.main.MainScreenItemSealed.Film

/**
* [FilmItemCallback] - реализация [DiffUtil.ItemCallback] для элементов типа [Film].
*
* Сравнивает фильмы по их уникальному идентификатору.
*/
class FilmItemCallback : DiffUtil.ItemCallback<Film>() {

/**
* Определяет, являются ли элементы одинаковыми (по идентификатору).
*
* @param oldItem Старый элемент
* @param newItem Новый элемент
* @return true если фильмы имеют одинаковый ID
*/
override fun areItemsTheSame(oldItem: Film, newItem: Film): Boolean {
return oldItem.data.id == newItem.data.id
}

/**
* Определяет, совпадает ли содержимое элементов.
*
* @param oldItem Старый элемент
* @param newItem Новый элемент
* @return true если фильмы полностью идентичны
*/
override fun areContentsTheSame(oldItem: Film, newItem: Film): Boolean {
return oldItem == newItem
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.sequenia.adapter.common.film

import android.graphics.Paint
import android.graphics.drawable.Drawable

import androidx.recyclerview.widget.RecyclerView
Expand All @@ -13,21 +14,49 @@ import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.target.Target

import com.sequenia.R
import com.sequenia.data.film.FilmData
import com.sequenia.data.FilmData
import com.sequenia.databinding.CardFilmBinding

/**
* [FilmViewHolder] - [RecyclerView.ViewHolder] для отображения карточки фильма.
*
* @property binding ViewBinding карточки фильма
*
* @see CardFilmBinding Для структуры разметки
*/
class FilmViewHolder(
private val binding: CardFilmBinding,
) : RecyclerView.ViewHolder(binding.root) {

/**
* Привязывает данные фильма к View элементам.
*
* @param film Данные фильма для отображения
*/
fun bind(film: FilmData) {
binding.textNameFilm.text = film.localizedName
binding.textNameFilm.minHeight = binding.textNameFilm.paint.fontMetricsInt.let { paint ->
paint.descent - paint.ascent + paint.leading
} * 2
binding.textNameFilm.minHeight =
binding.textNameFilm.paint.fontMetricsInt.let { paint: Paint.FontMetricsInt ->
paint.descent - paint.ascent + paint.leading
} * 2

renderingImageAttachmentPoster(film = film)
}

/**
* Загружает и отображает постер фильма с обработкой состояний с использованием [Glide].
*
* - Показывает скелетон во время загрузки
* - Использует крос-фейд анимацию (500 мс)
* - Загружает уменьшенную копию как превью
* - Кэширует изображения на диске
* - Обрабатывает ошибки загрузки
*
* @param film Данные фильма, содержащие URL изображения
*
* @see [Glide] Для загрузки изображений
* @see [RequestListener] Для обработки событий загрузки
*/
private fun renderingImageAttachmentPoster(film: FilmData) {
binding.skeletonAttachment.showSkeleton()

Expand Down Expand Up @@ -69,4 +98,4 @@ class FilmViewHolder(
})
.into(binding.imageFilmAttachment)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.sequenia.adapter.common.genre

import androidx.recyclerview.widget.DiffUtil
import com.sequenia.adapter.main.MainScreenItemSealed.Genre

/**
* [GenreItemCallback] - реализация [DiffUtil.ItemCallback] для элементов типа [Genre].
*
* Сравнивает жанры по их названию.
*/
class GenreItemCallback : DiffUtil.ItemCallback<Genre>() {

/**
* Определяет, являются ли элементы одинаковыми (по идентификатору).
*
* @param oldItem Старый элемент
* @param newItem Новый элемент
* @return true если жанры имеют одинаковое название
*/
override fun areItemsTheSame(oldItem: Genre, newItem: Genre): Boolean {
return oldItem.name == newItem.name
}

/**
* Определяет, совпадает ли содержимое элементов.
*
* @param oldItem Старый элемент
* @param newItem Новый элемент
* @return true если жанры полностью идентичны
*/
override fun areContentsTheSame(oldItem: Genre, newItem: Genre): Boolean {
return oldItem == newItem
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,23 @@ import androidx.recyclerview.widget.RecyclerView
import com.sequenia.R
import com.sequenia.databinding.CardGenreBinding

/**
* [GenreViewHolder] - [RecyclerView.ViewHolder] для отображения жанра фильма.
*
* @property binding ViewBinding элемента жанра
*
* @see CardGenreBinding Для структуры разметки
*/
class GenreViewHolder(
private val binding: CardGenreBinding,
) : RecyclerView.ViewHolder(binding.root) {

/**
* Привязывает данные жанра к View элементам.
*
* @param textGenre Название жанра для отображения
* @param isSelected Флаг выбранного состояния для окраски фона
*/
fun bind(textGenre: String, isSelected: Boolean) {
binding.itemHeaderSeparator.text = textGenre
binding.root.setBackgroundColor(
Expand All @@ -20,4 +33,4 @@ class GenreViewHolder(
}
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.sequenia.adapter.common.header

import androidx.recyclerview.widget.DiffUtil
import com.sequenia.adapter.main.MainScreenItemSealed.Header

/**
* [HeaderItemCallback] - реализация [DiffUtil.ItemCallback] для элементов типа [Header].
*
* Сравнивает заголовки по их текстовому содержимому.
*/
class HeaderItemCallback : DiffUtil.ItemCallback<Header>() {

/**
* Определяет, являются ли элементы одинаковыми (по идентификатору).
*
* @param oldItem Старый элемент
* @param newItem Новый элемент
* @return true если заголовки имеют одинаковый текст
*/
override fun areItemsTheSame(oldItem: Header, newItem: Header): Boolean {
return oldItem.title == newItem.title
}

/**
* Определяет, совпадает ли содержимое элементов.
*
* @param oldItem Старый элемент
* @param newItem Новый элемент
* @return true если заголовки полностью идентичны
*/
override fun areContentsTheSame(oldItem: Header, newItem: Header): Boolean {
return oldItem == newItem
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,22 @@ package com.sequenia.adapter.common.header
import androidx.recyclerview.widget.RecyclerView
import com.sequenia.databinding.ItemHeaderSeparatorBinding

/**
* [HeaderViewHolder] - [RecyclerView.ViewHolder] для отображения заголовков секций.
*
* @property binding ViewBinding элемента заголовка
*
* @see ItemHeaderSeparatorBinding Для структуры разметки
*/
class HeaderViewHolder(
private val binding: ItemHeaderSeparatorBinding,
) : RecyclerView.ViewHolder(binding.root) {

/**
* Привязывает текст заголовка к View элементу.
*
* @param textHeader Текст заголовка для отображения
*/
fun bind(textHeader: String) {
binding.itemHeaderSeparator.text = textHeader
}
Expand Down
Loading