From 1a0a7910e7cd9bcc38c8512ff0bff973045bd78a Mon Sep 17 00:00:00 2001 From: Hieu Vu Date: Sun, 2 Jun 2024 20:13:33 +0700 Subject: [PATCH] Fix klihnt check --- .../screen/gallery/GalleryFragment.kt | 4 +- .../galleryuplift/GalleryUpliftFragment.kt | 54 +++++++++++++++---- .../galleryuplift/GalleryUpliftViewModel.kt | 31 ++++++++--- 3 files changed, 71 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/dev/arkbuilders/navigator/presentation/screen/gallery/GalleryFragment.kt b/app/src/main/java/dev/arkbuilders/navigator/presentation/screen/gallery/GalleryFragment.kt index c2d43bab..269edbe0 100644 --- a/app/src/main/java/dev/arkbuilders/navigator/presentation/screen/gallery/GalleryFragment.kt +++ b/app/src/main/java/dev/arkbuilders/navigator/presentation/screen/gallery/GalleryFragment.kt @@ -63,8 +63,8 @@ class GalleryFragment : private val presenter by moxyPresenter { GalleryPresenter( rootAndFav = requireArguments()[ROOT_AND_FAV_KEY] as RootAndFav, - resourcesIds = requireArguments().getParcelableArray(RESOURCES_KEY)!!.toList() - as List, + resourcesIds = requireArguments().getParcelableArray(RESOURCES_KEY)!! + .toList() as List, startAt = requireArguments().getInt(START_AT_KEY), selectingEnabled = requireArguments().getBoolean(SELECTING_ENABLED_KEY), selectedResources = ( diff --git a/app/src/main/java/dev/arkbuilders/navigator/presentation/screen/gallery/galleryuplift/GalleryUpliftFragment.kt b/app/src/main/java/dev/arkbuilders/navigator/presentation/screen/gallery/galleryuplift/GalleryUpliftFragment.kt index de57c3f2..ed8a9f58 100644 --- a/app/src/main/java/dev/arkbuilders/navigator/presentation/screen/gallery/galleryuplift/GalleryUpliftFragment.kt +++ b/app/src/main/java/dev/arkbuilders/navigator/presentation/screen/gallery/galleryuplift/GalleryUpliftFragment.kt @@ -183,11 +183,28 @@ class GalleryUpliftFragment : Fragment() { private fun handleSideEffect(sideEffect: GallerySideEffect) { with(sideEffect) { when (this) { - is GallerySideEffect.ControlVisible -> setControlsVisibility(isVisible) + is GallerySideEffect.ControlVisible -> + setControlsVisibility(visible = isVisible) + is GallerySideEffect.DeleteResource -> deleteResource(pos) - is GallerySideEffect.DisplayPreviewTags -> displayPreviewTags(data.resourceId, data.tags) - is GallerySideEffect.DisplaySelectedFile -> displaySelected(data.selected, data.showAnim, data.selectedCount, data.itemCount) - is GallerySideEffect.DisplayStorageException -> displayStorageException(storageException.label, storageException.messenger) + is GallerySideEffect.DisplayPreviewTags -> displayPreviewTags( + resource = data.resourceId, + tags = data.tags + ) + + is GallerySideEffect.DisplaySelectedFile -> displaySelected( + selected = data.selected, + showAnim = data.showAnim, + selectedCount = data.selectedCount, + itemCount = data.itemCount + ) + + is GallerySideEffect.DisplayStorageException -> + displayStorageException( + label = storageException.label, + msg = storageException.messenger + ) + is GallerySideEffect.EditResource -> editResource(path) GallerySideEffect.NavigateBack -> onBackClick() GallerySideEffect.NotifyCurrentItemChange -> notifyCurrentItemChanged() @@ -195,7 +212,11 @@ class GalleryUpliftFragment : Fragment() { GallerySideEffect.NotifyResourceScoresChanged -> notifyResourceScoresChanged() GallerySideEffect.NotifyTagsChanged -> notifyTagsChanged() is GallerySideEffect.OpenLink -> openLink(url) - is GallerySideEffect.SetUpPreview -> setupPreview(data.position, data.meta) + is GallerySideEffect.SetUpPreview -> setupPreview( + pos = data.position, + meta = data.meta + ) + is GallerySideEffect.ShareLink -> shareLink(url) is GallerySideEffect.ShareResource -> shareResource(path) is GallerySideEffect.ShowEditTagsDialog -> showEditTagsDialog( @@ -206,11 +227,26 @@ class GalleryUpliftFragment : Fragment() { index = data.index, storage = data.storage, ) - is GallerySideEffect.ShowInfoAlert -> showInfoAlert(infoData.path, infoData.resource, infoData.metadata) - is GallerySideEffect.ShowProgressWithText -> setProgressVisibility(text.isVisible, text.text) - is GallerySideEffect.ToastIndexFailedPath -> toastIndexFailedPath(path) + + is GallerySideEffect.ShowInfoAlert -> showInfoAlert( + path = infoData.path, + resource = infoData.resource, + metadata = infoData.metadata + ) + + is GallerySideEffect.ShowProgressWithText -> setProgressVisibility( + isVisible = text.isVisible, + withText = text.text + ) + + is GallerySideEffect.ToastIndexFailedPath -> toastIndexFailedPath( + path + ) + GallerySideEffect.UpdatePagerAdapter -> updatePagerAdapter() - GallerySideEffect.UpdatePagerAdapterWithDiff -> updatePagerAdapterWithDiff() + GallerySideEffect.UpdatePagerAdapterWithDiff -> + updatePagerAdapterWithDiff() + is GallerySideEffect.ViewInExternalApp -> viewInExternalApp(path) is GallerySideEffect.ToggleSelect -> toggleSelecting(isEnabled) } diff --git a/app/src/main/java/dev/arkbuilders/navigator/presentation/screen/gallery/galleryuplift/GalleryUpliftViewModel.kt b/app/src/main/java/dev/arkbuilders/navigator/presentation/screen/gallery/galleryuplift/GalleryUpliftViewModel.kt index 6eefa466..a87d367f 100644 --- a/app/src/main/java/dev/arkbuilders/navigator/presentation/screen/gallery/galleryuplift/GalleryUpliftViewModel.kt +++ b/app/src/main/java/dev/arkbuilders/navigator/presentation/screen/gallery/galleryuplift/GalleryUpliftViewModel.kt @@ -85,7 +85,8 @@ class GalleryUpliftViewModel( private lateinit var rootAndFav: RootAndFav private lateinit var resourcesIds: List - override val container: Container = container(GalleryState()) + override val container: Container = + container(GalleryState()) var galleryItems: MutableList = mutableListOf() var diffResult: DiffUtil.DiffResult? = null @@ -149,7 +150,10 @@ class GalleryUpliftViewModel( analytics.trackResRemove() Timber.d( LogTags.GALLERY_SCREEN, - "[remove_resource] clicked at position ${container.stateFlow.value.currentPos}" + buildString { + append("[remove_resource] clicked at position ") + append("${container.stateFlow.value.currentPos}") + } ) deleteResource(currentItem.id()) galleryItems.removeAt(container.stateFlow.value.currentPos) @@ -161,7 +165,9 @@ class GalleryUpliftViewModel( } onTagsChanged() intent { - postSideEffect(GallerySideEffect.DeleteResource(container.stateFlow.value.currentPos)) + postSideEffect( + GallerySideEffect.DeleteResource(container.stateFlow.value.currentPos) + ) } } @@ -257,7 +263,9 @@ class GalleryUpliftViewModel( intent { reduce { viewModelScope.launch { - state.copy(sortByScores = preferences.get(PreferenceKey.SortByScores)) + state.copy( + sortByScores = preferences.get(PreferenceKey.SortByScores) + ) } state } @@ -278,7 +286,11 @@ class GalleryUpliftViewModel( } fun onPlayButtonClick() = intent { - postSideEffect(GallerySideEffect.ViewInExternalApp(index.getPath(currentItem.id())!!)) + postSideEffect( + GallerySideEffect.ViewInExternalApp( + index.getPath(currentItem.id())!! + ) + ) } fun onInfoFabClick() = viewModelScope.launch { @@ -303,7 +315,8 @@ class GalleryUpliftViewModel( analytics.trackResShare() Timber.d( LogTags.GALLERY_SCREEN, - "[share_resource] clicked at position ${container.stateFlow.value.currentPos}" + "[share_resource] clicked at position " + + "${container.stateFlow.value.currentPos}" ) val path = index.getPath(currentItem.id())!! if (currentItem.metadata is Metadata.Link) { @@ -323,7 +336,11 @@ class GalleryUpliftViewModel( reduce { state.copy(selectingEnabled = !state.selectingEnabled) } - postSideEffect(GallerySideEffect.ToggleSelect(container.stateFlow.value.selectingEnabled)) + postSideEffect( + GallerySideEffect.ToggleSelect( + container.stateFlow.value.selectingEnabled + ) + ) } _selectedResources.clear() if (container.stateFlow.value.selectingEnabled) {