-
Notifications
You must be signed in to change notification settings - Fork 7
homework #47
base: main
Are you sure you want to change the base?
homework #47
Conversation
setForeground(getForegroundInfo()) | ||
val url = inputData.getString("1") | ||
Log.i("test", url!!) | ||
val fileName = url.substring(url.lastIndexOf("/") + 1) |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Используй koin + Dependency Inversion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут у меня не работает через koin
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
либо делай private, либо это одна и та же переменная
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
К переменной isPremium нельзя обратиться
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Эти аннотации тут не нужны. Можно разделить на itunes, library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно разделить на itunes, library. Почему нельзя сделать так, как сделано?
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Обсуждали на уроке в чём проблема
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Честно, не помню
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Фрагменты дублируются 1 в 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Надо выносить в общий фрагмент или можно оставить все так, как есть?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Как думаешь в чём проблема?
@@ -17,7 +16,7 @@ class PurchaseStateInteractorGooglePlay( | |||
} | |||
|
|||
val _isPremium = MutableStateFlow(false) | |||
override val isPremium: StateFlow<Boolean> = _isPremium | |||
override var isPremium: StateFlow<Boolean> = _isPremium |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Во все классы будешь копировать?
No description provided.