Skip to content

Commit

Permalink
Fix klihnt check
Browse files Browse the repository at this point in the history
  • Loading branch information
hieuwu committed Jun 2, 2024
1 parent 970d0a0 commit 1a0a791
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ResourceId>,
resourcesIds = requireArguments().getParcelableArray(RESOURCES_KEY)!!
.toList() as List<ResourceId>,
startAt = requireArguments().getInt(START_AT_KEY),
selectingEnabled = requireArguments().getBoolean(SELECTING_ENABLED_KEY),
selectedResources = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,19 +183,40 @@ 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()
GallerySideEffect.NotifyResourceChange -> notifyResourcesChanged()
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(
Expand All @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ class GalleryUpliftViewModel(
private lateinit var rootAndFav: RootAndFav
private lateinit var resourcesIds: List<ResourceId>

override val container: Container<GalleryState, GallerySideEffect> = container(GalleryState())
override val container: Container<GalleryState, GallerySideEffect> =
container(GalleryState())

var galleryItems: MutableList<GalleryPresenter.GalleryItem> = mutableListOf()
var diffResult: DiffUtil.DiffResult? = null
Expand Down Expand Up @@ -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)
Expand All @@ -161,7 +165,9 @@ class GalleryUpliftViewModel(
}
onTagsChanged()
intent {
postSideEffect(GallerySideEffect.DeleteResource(container.stateFlow.value.currentPos))
postSideEffect(
GallerySideEffect.DeleteResource(container.stateFlow.value.currentPos)
)
}
}

Expand Down Expand Up @@ -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
}
Expand All @@ -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 {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit 1a0a791

Please sign in to comment.