From 504bc7892bfef6ba90d4294a3805baece63e1471 Mon Sep 17 00:00:00 2001 From: TheGood77 Date: Mon, 17 Feb 2025 14:07:19 +0600 Subject: [PATCH 1/2] [~] fix bug in tvApp --- .../screen/eventStory/EventStoryViewModel.kt | 3 ++- .../office/tv/screen/photo/BestPhotoScreen.kt | 8 ++++++- .../screen/photo/components/PhotoSlideShow.kt | 10 +++++++-- .../tv/screen/photo/components/PhotoUI.kt | 22 ++++++++----------- tvApp/src/main/res/values/strings.xml | 2 +- 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/tvApp/src/main/java/band/effective/office/tv/screen/eventStory/EventStoryViewModel.kt b/tvApp/src/main/java/band/effective/office/tv/screen/eventStory/EventStoryViewModel.kt index dd6d5f42..7b1bf29d 100644 --- a/tvApp/src/main/java/band/effective/office/tv/screen/eventStory/EventStoryViewModel.kt +++ b/tvApp/src/main/java/band/effective/office/tv/screen/eventStory/EventStoryViewModel.kt @@ -117,8 +117,9 @@ class EventStoryViewModel @Inject constructor( when (events) { is Either.Success -> { val teammates = events.data.filterIsInstance() + val employeeStories = teammates.processEmployeeInfo() updateStateAsSuccessfulFetch( - teammates.processEmployeeInfo() + + employeeStories + setDuolingoDataToStoryModel( events.data.filterIsInstance() ) + diff --git a/tvApp/src/main/java/band/effective/office/tv/screen/photo/BestPhotoScreen.kt b/tvApp/src/main/java/band/effective/office/tv/screen/photo/BestPhotoScreen.kt index 7ae4161f..29b1b950 100644 --- a/tvApp/src/main/java/band/effective/office/tv/screen/photo/BestPhotoScreen.kt +++ b/tvApp/src/main/java/band/effective/office/tv/screen/photo/BestPhotoScreen.kt @@ -8,7 +8,6 @@ import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusProperties import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.focus.onFocusChanged -import androidx.compose.ui.input.key.* import androidx.hilt.navigation.compose.hiltViewModel import androidx.tv.foundation.lazy.list.TvLazyListState import androidx.tv.foundation.lazy.list.rememberTvLazyListState @@ -83,6 +82,11 @@ fun BestPhotoScreen(viewModel: PhotoViewModel = hiltViewModel()) { ) }, onClickPlayButton = { viewModel.sendEvent(BestPhotoEvent.OnClickPlayButton) }, + onError = { num -> + viewModel.sendEvent( + BestPhotoEvent.OnClickNextItem(num) + ) + }, uiState = uiState, playButton = playButton, contentFocus = contentFocus, @@ -98,6 +102,7 @@ private fun PhotoContent( onClickPreviousItemButton: (Int) -> Unit, onClickNextItemButton: (Int) -> Unit, onClickPlayButton: () -> Unit, + onError: (Int) -> Unit, uiState: BestPhotoState, lazyListState: TvLazyListState, contentFocus: FocusRequester, @@ -124,6 +129,7 @@ private fun PhotoContent( down = playButton } .focusable(), + onError = onError, unsafeOkHttpClient = unsafeOkHttpClient ) }, diff --git a/tvApp/src/main/java/band/effective/office/tv/screen/photo/components/PhotoSlideShow.kt b/tvApp/src/main/java/band/effective/office/tv/screen/photo/components/PhotoSlideShow.kt index 31702fcb..6743a925 100644 --- a/tvApp/src/main/java/band/effective/office/tv/screen/photo/components/PhotoSlideShow.kt +++ b/tvApp/src/main/java/band/effective/office/tv/screen/photo/components/PhotoSlideShow.kt @@ -6,7 +6,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.tv.foundation.lazy.list.TvLazyListState import androidx.tv.foundation.lazy.list.TvLazyRow -import androidx.tv.foundation.lazy.list.items +import androidx.tv.foundation.lazy.list.itemsIndexed import androidx.tv.foundation.lazy.list.rememberTvLazyListState import band.effective.office.tv.screen.photo.model.Photo import okhttp3.OkHttpClient @@ -17,6 +17,7 @@ fun PhotoSlideShow( lazyListState: TvLazyListState = rememberTvLazyListState(), modifier: Modifier = Modifier, modifierForFocus: Modifier = Modifier, + onError: (Int) -> Unit, unsafeOkHttpClient: OkHttpClient ) { TvLazyRow( @@ -25,11 +26,16 @@ fun PhotoSlideShow( .fillMaxSize() .focusable() ) { - items(photos) { photo -> + itemsIndexed(photos) { photoIdx, photo -> PhotoUIItem( image = photo, modifier = modifierForFocus .fillMaxSize(), + onError = { + if (lazyListState.firstVisibleItemIndex == photoIdx) { + onError(photoIdx) + } + }, okHttpClient = unsafeOkHttpClient ) } diff --git a/tvApp/src/main/java/band/effective/office/tv/screen/photo/components/PhotoUI.kt b/tvApp/src/main/java/band/effective/office/tv/screen/photo/components/PhotoUI.kt index 62214e1b..3bbe6f99 100644 --- a/tvApp/src/main/java/band/effective/office/tv/screen/photo/components/PhotoUI.kt +++ b/tvApp/src/main/java/band/effective/office/tv/screen/photo/components/PhotoUI.kt @@ -3,17 +3,13 @@ package band.effective.office.tv.screen.photo.components import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.size -import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource -import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp import band.effective.office.tv.R import band.effective.office.tv.screen.load.LoadScreen import band.effective.office.tv.screen.photo.model.Photo @@ -23,12 +19,18 @@ import okhttp3.OkHttpClient @Composable -fun PhotoUIItem(image: Photo, modifier: Modifier = Modifier, okHttpClient: OkHttpClient) { +fun PhotoUIItem( + image: Photo, + modifier: Modifier = Modifier, + onError: () -> Unit, + okHttpClient: OkHttpClient +) { + val context = LocalContext.current val photoWith = LocalConfiguration.current.screenWidthDp.dp val photoHeight = LocalConfiguration.current.screenHeightDp.dp - val imageLoader = ImageLoader.Builder(LocalContext.current) + val imageLoader = ImageLoader.Builder(context) .okHttpClient(okHttpClient) .build() @@ -47,13 +49,7 @@ fun PhotoUIItem(image: Photo, modifier: Modifier = Modifier, okHttpClient: OkHtt contentDescription = null, contentScale = ContentScale.Fit, error = { - Text( - text = stringResource(id = R.string.error_show_photo), - fontSize = 40.sp, - color = Color.Red, - textAlign = TextAlign.Center, - modifier = Modifier.fillMaxSize() - ) + onError() } ) } diff --git a/tvApp/src/main/res/values/strings.xml b/tvApp/src/main/res/values/strings.xml index 3672a8b7..7ae16dd4 100644 --- a/tvApp/src/main/res/values/strings.xml +++ b/tvApp/src/main/res/values/strings.xml @@ -29,7 +29,7 @@ "Tоп по XP" "Топ по дням в ударном режиме" Профиль Duolingo - Мы пока не поддерживаем этот формат фото, позже все будет ок) + Произошла ошибка при загрузке следующего фото: %1$s Best Photo autoplay Выберите минимум одну категорию -- GitLab From 4aa96b0a088ab68c674ea9886fe0ed7e873050a3 Mon Sep 17 00:00:00 2001 From: KrugarValdes Date: Tue, 4 Mar 2025 16:10:46 +0600 Subject: [PATCH 2/2] [~] update event period from 1 month to 14 days --- .../office/tv/screen/leaderIdEvents/LeaderIdEventsViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tvApp/src/main/java/band/effective/office/tv/screen/leaderIdEvents/LeaderIdEventsViewModel.kt b/tvApp/src/main/java/band/effective/office/tv/screen/leaderIdEvents/LeaderIdEventsViewModel.kt index ec9c41b0..a43806b1 100644 --- a/tvApp/src/main/java/band/effective/office/tv/screen/leaderIdEvents/LeaderIdEventsViewModel.kt +++ b/tvApp/src/main/java/band/effective/office/tv/screen/leaderIdEvents/LeaderIdEventsViewModel.kt @@ -32,7 +32,7 @@ class LeaderIdEventsViewModel @Inject constructor( val finish = GregorianCalendar() init { - finish.set(Calendar.MONTH, GregorianCalendar().get(Calendar.MONTH) + 1) + finish.add(Calendar.DAY_OF_MONTH, 14) load() timer.init( scope = viewModelScope, callbackToEnd = { -- GitLab