Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

homework #47

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

davydenkokolya2
Copy link

No description provided.

setForeground(getForegroundInfo())
val url = inputData.getString("1")
Log.i("test", url!!)
val fileName = url.substring(url.lastIndexOf("/") + 1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Работу с файлами в отдельный класс.


private val downloadNotification: DownloadNotification = DownloadNotification(appContext)
private val baseUrl = inputData.getString("2")
private val remoteDataSourceRetrofit = RemoteDataSourceRetrofit()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Используй koin + Dependency Inversion

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут у меня не работает через koin

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сделай, чтобы работало. https://insert-koin.io/docs/reference/koin-android/workmanager/

startConnection()
}

val _isPremium = MutableStateFlow(false)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

либо делай private, либо это одна и та же переменная

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

К переменной isPremium нельзя обратиться

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ну а зачем две isPremium тогда?

interface RemoteDataSource {
suspend fun getItunesAlbums(): List<AlbumModel>

suspend fun getItunesTracks(@Query("albumId") albumId: Long): TracksWithAlbums
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Эти аннотации тут не нужны. Можно разделить на itunes, library.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно разделить на itunes, library. Почему нельзя сделать так, как сделано?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно оставить. Но аннотации надо убрать.

.build()

override suspend fun getItunesAlbums(): List<AlbumModel> {
return (retrofit.create() as MusicApi).getItunesAlbums()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

При каждом запросе тяжёлая операция создания MusicApi.

holder.textAlbum.text = item.name

holder.imageAlbum.clipToOutline = true
holder.imageAlbum.outlineProvider = object : ViewOutlineProvider() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Как думаешь в чём проблема?

class ITunesMusicFragment : Fragment() {

lateinit var viewBinder: ITunesMusicFragmentBinder
private val albumsViewModel: AlbumsViewModel by inject()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Как думаешь в чём проблема?

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

albumsViewModel.loadAlbums(RemoteApiType.ITUNES)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Обсуждали на уроке в чём проблема

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Честно, не помню

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Обработать переворот экрана - не грузить данные при перевороте повторно

import kotlinx.coroutines.launch
import org.koin.android.ext.android.inject

class LibraryMusicFragment : Fragment() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Фрагменты дублируются 1 в 1.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Надо выносить в общий фрагмент или можно оставить все так, как есть?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Выноси

holder.imageTrack.clipToOutline = true
holder.imageTrack.outlineProvider = object: ViewOutlineProvider() {
override fun getOutline(p0: View, p1: Outline) {
p1.setRoundRect(0, 0, p0.width, p0.height, 8.0F)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Как думаешь в чём проблема?

@davydenkokolya2 davydenkokolya2 requested a review from krottv July 4, 2022 15:29
@@ -17,7 +16,7 @@ class PurchaseStateInteractorGooglePlay(
}

val _isPremium = MutableStateFlow(false)
override val isPremium: StateFlow<Boolean> = _isPremium
override var isPremium: StateFlow<Boolean> = _isPremium
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Оставляй val.

holder.imageAlbum.outlineProvider = object : ViewOutlineProvider() {
holder.imageAlbum.apply {
load(item.image)
outlineProvider = object : ViewOutlineProvider() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

дублирование кода -переноси в общие функции.


override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TracksViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_track, parent, false)

return TracksViewHolder(view)
}

private fun dpToPx(dp: Int): Float = dp * Resources.getSystem().displayMetrics.density
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Во все классы будешь копировать?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants