Skip to content

Commit d373faf

Browse files
Merge pull request #3 from LebedevSergeyVach/develop
Develop to Main. Updating the code style and adding descriptions.
2 parents 55cecd5 + 7d304ff commit d373faf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+802
-223
lines changed

app/build.gradle.kts

+34-34
Original file line numberDiff line numberDiff line change
@@ -88,26 +88,29 @@ dependencies {
8888
androidTestImplementation(libs.androidx.espresso.core)
8989

9090
/**
91-
* Constraintlayout
91+
* OkHttp
9292
*
93-
* https://developer.android.com/jetpack/androidx/releases/constraintlayout
94-
* https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintLayout
93+
* https://github.com/square/okhttp
9594
*/
96-
implementation(libs.androidx.constraintlayout)
95+
implementation(platform(libs.okhttp.bom))
96+
implementation(libs.okhttp)
97+
implementation(libs.logging.interceptor)
9798

9899
/**
99-
* Serialization
100+
* Retrofit
100101
*
101-
* https://github.com/Kotlin/kotlinx.serialization
102+
* https://github.com/square/retrofit
103+
* https://github.com/square/retrofit/tree/trunk/retrofit-converters/kotlinx-serialization
102104
*/
103-
implementation(libs.kotlinx.serialization.json)
105+
implementation(libs.retrofit)
106+
implementation(libs.converter.kotlinx.serialization)
104107

105108
/**
106-
* SplashScreen
109+
* Serialization
107110
*
108-
* https://developer.android.com/reference/androidx/core/splashscreen/SplashScreen
111+
* https://github.com/Kotlin/kotlinx.serialization
109112
*/
110-
implementation(libs.androidx.core.splashscreen)
113+
implementation(libs.kotlinx.serialization.json)
111114

112115
/**
113116
* Android Jetpack's Navigation component
@@ -120,17 +123,10 @@ dependencies {
120123
/**
121124
* ViewModel Lifecycle
122125
*
123-
* https://developer.android.com/jetpack/androidx/releases/lifecycle
126+
* https://developer.android.com/topic/libraries/architecture/viewmodel
124127
*/
125128
implementation(libs.androidx.lifecycle.viewmodel.ktx)
126129

127-
/**
128-
* SkeletonLayout
129-
*
130-
* https://github.com/Faltenreich/SkeletonLayout
131-
*/
132-
implementation(libs.skeletonlayout)
133-
134130
/**
135131
* Glide
136132
* BlurTransformation glide-transformations
@@ -140,30 +136,34 @@ dependencies {
140136
implementation(libs.glide)
141137

142138
/**
143-
* Retrofit
139+
* DI Koin
144140
*
145-
* https://github.com/square/retrofit
146-
* https://github.com/square/retrofit/tree/trunk/retrofit-converters/kotlinx-serialization
141+
* https://github.com/InsertKoinIO/koin
147142
*/
148-
implementation(libs.retrofit)
149-
implementation(libs.converter.kotlinx.serialization)
143+
implementation(libs.koin.core)
144+
implementation(libs.koin.android)
145+
implementation(libs.koin.annotations)
146+
ksp(libs.koin.ksp.compiler)
150147

151148
/**
152-
* OkHttp
149+
* SplashScreen
153150
*
154-
* https://github.com/square/okhttp
151+
* https://developer.android.com/reference/androidx/core/splashscreen/SplashScreen
155152
*/
156-
implementation(platform(libs.okhttp.bom))
157-
implementation(libs.okhttp)
158-
implementation(libs.logging.interceptor)
153+
implementation(libs.androidx.core.splashscreen)
159154

160155
/**
161-
* DI Koin
156+
* Constraintlayout
162157
*
163-
* https://github.com/InsertKoinIO/koin
158+
* https://developer.android.com/jetpack/androidx/releases/constraintlayout
159+
* https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintLayout
164160
*/
165-
implementation(libs.koin.core)
166-
implementation(libs.koin.android)
167-
implementation(libs.koin.annotations)
168-
ksp(libs.koin.ksp.compiler)
161+
implementation(libs.androidx.constraintlayout)
162+
163+
/**
164+
* SkeletonLayout
165+
*
166+
* https://github.com/Faltenreich/SkeletonLayout
167+
*/
168+
implementation(libs.skeletonlayout)
169169
}

app/src/main/java/com/sequenia/App.kt

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ import org.koin.android.ext.koin.androidContext
1010
import org.koin.core.context.startKoin
1111
import org.koin.ksp.generated.module
1212

13+
/**
14+
* Класс приложения для инициализации `Koin`.
15+
*
16+
* @see Application Базовый класс приложения.
17+
*/
1318
class App : Application() {
1419
override fun onCreate() {
1520
super.onCreate()

app/src/main/java/com/sequenia/activity/MainActivity.kt

+9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
package com.sequenia.activity
22

33
import android.os.Bundle
4+
45
import androidx.activity.enableEdgeToEdge
56
import androidx.appcompat.app.AppCompatActivity
7+
68
import androidx.core.view.ViewCompat
79
import androidx.core.view.WindowCompat
810
import androidx.core.view.WindowInsetsCompat
11+
912
import com.sequenia.databinding.ActivityMainBinding
1013

14+
/**
15+
* [MainActivity] - основная Activity приложения.
16+
*
17+
* @property binding ViewBinding для доступа к элементам разметки
18+
* @see WindowInsetsCompat Для работы с системными инсетами
19+
*/
1120
class MainActivity : AppCompatActivity() {
1221
override fun onCreate(savedInstanceState: Bundle?) {
1322
super.onCreate(savedInstanceState)

app/src/main/java/com/sequenia/activity/SplashActivity.kt

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ import androidx.appcompat.app.AppCompatActivity
1010
import androidx.core.splashscreen.SplashScreen
1111
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
1212

13-
13+
/**
14+
* [SplashActivity] - стартовая Activity приложения, отображающая экран-заставку.
15+
*
16+
* @property [SplashScreen] Используется для управления экраном-заставкой
17+
*/
1418
@SuppressLint("CustomSplashScreen")
1519
class SplashActivity : AppCompatActivity() {
1620
override fun onCreate(savedInstanceState: Bundle?) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.sequenia.adapter.common.film
2+
3+
import androidx.recyclerview.widget.DiffUtil
4+
import com.sequenia.adapter.main.MainScreenItemSealed.Film
5+
6+
/**
7+
* [FilmItemCallback] - реализация [DiffUtil.ItemCallback] для элементов типа [Film].
8+
*
9+
* Сравнивает фильмы по их уникальному идентификатору.
10+
*/
11+
class FilmItemCallback : DiffUtil.ItemCallback<Film>() {
12+
13+
/**
14+
* Определяет, являются ли элементы одинаковыми (по идентификатору).
15+
*
16+
* @param oldItem Старый элемент
17+
* @param newItem Новый элемент
18+
* @return true если фильмы имеют одинаковый ID
19+
*/
20+
override fun areItemsTheSame(oldItem: Film, newItem: Film): Boolean {
21+
return oldItem.data.id == newItem.data.id
22+
}
23+
24+
/**
25+
* Определяет, совпадает ли содержимое элементов.
26+
*
27+
* @param oldItem Старый элемент
28+
* @param newItem Новый элемент
29+
* @return true если фильмы полностью идентичны
30+
*/
31+
override fun areContentsTheSame(oldItem: Film, newItem: Film): Boolean {
32+
return oldItem == newItem
33+
}
34+
}

app/src/main/java/com/sequenia/adapter/common/film/FilmViewHolder.kt

+34-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.sequenia.adapter.common.film
22

3+
import android.graphics.Paint
34
import android.graphics.drawable.Drawable
45

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

1516
import com.sequenia.R
16-
import com.sequenia.data.film.FilmData
17+
import com.sequenia.data.FilmData
1718
import com.sequenia.databinding.CardFilmBinding
1819

20+
/**
21+
* [FilmViewHolder] - [RecyclerView.ViewHolder] для отображения карточки фильма.
22+
*
23+
* @property binding ViewBinding карточки фильма
24+
*
25+
* @see CardFilmBinding Для структуры разметки
26+
*/
1927
class FilmViewHolder(
2028
private val binding: CardFilmBinding,
2129
) : RecyclerView.ViewHolder(binding.root) {
30+
31+
/**
32+
* Привязывает данные фильма к View элементам.
33+
*
34+
* @param film Данные фильма для отображения
35+
*/
2236
fun bind(film: FilmData) {
2337
binding.textNameFilm.text = film.localizedName
24-
binding.textNameFilm.minHeight = binding.textNameFilm.paint.fontMetricsInt.let { paint ->
25-
paint.descent - paint.ascent + paint.leading
26-
} * 2
38+
binding.textNameFilm.minHeight =
39+
binding.textNameFilm.paint.fontMetricsInt.let { paint: Paint.FontMetricsInt ->
40+
paint.descent - paint.ascent + paint.leading
41+
} * 2
2742

2843
renderingImageAttachmentPoster(film = film)
2944
}
3045

46+
/**
47+
* Загружает и отображает постер фильма с обработкой состояний с использованием [Glide].
48+
*
49+
* - Показывает скелетон во время загрузки
50+
* - Использует крос-фейд анимацию (500 мс)
51+
* - Загружает уменьшенную копию как превью
52+
* - Кэширует изображения на диске
53+
* - Обрабатывает ошибки загрузки
54+
*
55+
* @param film Данные фильма, содержащие URL изображения
56+
*
57+
* @see [Glide] Для загрузки изображений
58+
* @see [RequestListener] Для обработки событий загрузки
59+
*/
3160
private fun renderingImageAttachmentPoster(film: FilmData) {
3261
binding.skeletonAttachment.showSkeleton()
3362

@@ -69,4 +98,4 @@ class FilmViewHolder(
6998
})
7099
.into(binding.imageFilmAttachment)
71100
}
72-
}
101+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.sequenia.adapter.common.genre
2+
3+
import androidx.recyclerview.widget.DiffUtil
4+
import com.sequenia.adapter.main.MainScreenItemSealed.Genre
5+
6+
/**
7+
* [GenreItemCallback] - реализация [DiffUtil.ItemCallback] для элементов типа [Genre].
8+
*
9+
* Сравнивает жанры по их названию.
10+
*/
11+
class GenreItemCallback : DiffUtil.ItemCallback<Genre>() {
12+
13+
/**
14+
* Определяет, являются ли элементы одинаковыми (по идентификатору).
15+
*
16+
* @param oldItem Старый элемент
17+
* @param newItem Новый элемент
18+
* @return true если жанры имеют одинаковое название
19+
*/
20+
override fun areItemsTheSame(oldItem: Genre, newItem: Genre): Boolean {
21+
return oldItem.name == newItem.name
22+
}
23+
24+
/**
25+
* Определяет, совпадает ли содержимое элементов.
26+
*
27+
* @param oldItem Старый элемент
28+
* @param newItem Новый элемент
29+
* @return true если жанры полностью идентичны
30+
*/
31+
override fun areContentsTheSame(oldItem: Genre, newItem: Genre): Boolean {
32+
return oldItem == newItem
33+
}
34+
}

app/src/main/java/com/sequenia/adapter/common/genre/GenreViewHolder.kt

+14-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,23 @@ import androidx.recyclerview.widget.RecyclerView
66
import com.sequenia.R
77
import com.sequenia.databinding.CardGenreBinding
88

9+
/**
10+
* [GenreViewHolder] - [RecyclerView.ViewHolder] для отображения жанра фильма.
11+
*
12+
* @property binding ViewBinding элемента жанра
13+
*
14+
* @see CardGenreBinding Для структуры разметки
15+
*/
916
class GenreViewHolder(
1017
private val binding: CardGenreBinding,
1118
) : RecyclerView.ViewHolder(binding.root) {
1219

20+
/**
21+
* Привязывает данные жанра к View элементам.
22+
*
23+
* @param textGenre Название жанра для отображения
24+
* @param isSelected Флаг выбранного состояния для окраски фона
25+
*/
1326
fun bind(textGenre: String, isSelected: Boolean) {
1427
binding.itemHeaderSeparator.text = textGenre
1528
binding.root.setBackgroundColor(
@@ -20,4 +33,4 @@ class GenreViewHolder(
2033
}
2134
)
2235
}
23-
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.sequenia.adapter.common.header
2+
3+
import androidx.recyclerview.widget.DiffUtil
4+
import com.sequenia.adapter.main.MainScreenItemSealed.Header
5+
6+
/**
7+
* [HeaderItemCallback] - реализация [DiffUtil.ItemCallback] для элементов типа [Header].
8+
*
9+
* Сравнивает заголовки по их текстовому содержимому.
10+
*/
11+
class HeaderItemCallback : DiffUtil.ItemCallback<Header>() {
12+
13+
/**
14+
* Определяет, являются ли элементы одинаковыми (по идентификатору).
15+
*
16+
* @param oldItem Старый элемент
17+
* @param newItem Новый элемент
18+
* @return true если заголовки имеют одинаковый текст
19+
*/
20+
override fun areItemsTheSame(oldItem: Header, newItem: Header): Boolean {
21+
return oldItem.title == newItem.title
22+
}
23+
24+
/**
25+
* Определяет, совпадает ли содержимое элементов.
26+
*
27+
* @param oldItem Старый элемент
28+
* @param newItem Новый элемент
29+
* @return true если заголовки полностью идентичны
30+
*/
31+
override fun areContentsTheSame(oldItem: Header, newItem: Header): Boolean {
32+
return oldItem == newItem
33+
}
34+
}

app/src/main/java/com/sequenia/adapter/common/header/HeaderViewHolder.kt

+12
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,22 @@ package com.sequenia.adapter.common.header
33
import androidx.recyclerview.widget.RecyclerView
44
import com.sequenia.databinding.ItemHeaderSeparatorBinding
55

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

17+
/**
18+
* Привязывает текст заголовка к View элементу.
19+
*
20+
* @param textHeader Текст заголовка для отображения
21+
*/
1022
fun bind(textHeader: String) {
1123
binding.itemHeaderSeparator.text = textHeader
1224
}

0 commit comments

Comments
 (0)