Skip to content

Commit

Permalink
ktlint formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrlzy committed Sep 5, 2024
1 parent 2186b2a commit a928af3
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import android.widget.Toast
import androidx.activity.addCallback
import androidx.core.content.FileProvider
import androidx.core.os.bundleOf
import androidx.core.view.doOnNextLayout
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.fragment.app.setFragmentResult
Expand Down Expand Up @@ -78,7 +77,7 @@ class GalleryUpliftFragment : Fragment() {
.toList() as List<ResourceId>,
rootAndFav = requireArguments()[ROOT_AND_FAV_KEY] as RootAndFav,
resourcesIds = requireArguments().getParcelableArray(RESOURCES_KEY)!!
.toList() as List<ResourceId>,
.toList() as List<ResourceId>
).apply {
App.instance.appComponent.inject(this@GalleryUpliftFragment)
}
Expand Down Expand Up @@ -228,7 +227,7 @@ class GalleryUpliftFragment : Fragment() {
statsStorage = statsStorage,
rootAndFav = rootAndFav,
index = index,
storage = storage,
storage = storage
)

is GallerySideEffect.ShowInfoAlert -> showInfoAlert(
Expand Down Expand Up @@ -305,7 +304,8 @@ class GalleryUpliftFragment : Fragment() {
requireContext().startActivity(intent)
} catch (e: ActivityNotFoundException) {
Toast.makeText(
requireContext(), getString(R.string.no_app_found_to_open_this_file),
requireContext(),
getString(R.string.no_app_found_to_open_this_file),
Toast.LENGTH_SHORT
).show()
}
Expand Down Expand Up @@ -702,7 +702,7 @@ class GalleryUpliftFragment : Fragment() {
resources: List<ResourceId>,
startAt: Int,
selectingEnabled: Boolean = false,
selectedResources: List<ResourceId> = emptyList(),
selectedResources: List<ResourceId> = emptyList()
) = GalleryUpliftFragment().apply {
arguments = Bundle().apply {
putParcelable(ROOT_AND_FAV_KEY, rootAndFav)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class GalleryUpliftViewModel(
val tagsStorageRepo: TagsStorageRepo,
val statsStorageRepo: StatsStorageRepo,
val scoreStorageRepo: ScoreStorageRepo,
val analytics: GalleryAnalytics,
val analytics: GalleryAnalytics
) : ContainerHost<GalleryState, GallerySideEffect>, ViewModel() {
private lateinit var index: ResourceIndex
private lateinit var tagsStorage: TagStorage
Expand Down Expand Up @@ -203,8 +203,8 @@ class GalleryUpliftViewModel(
reduce {
if (enabled) {
state.copy(
selectedResources = state.selectedResources
+ state.currentItem.id()
selectedResources = state.selectedResources +
state.currentItem.id()
)
} else {
state.copy(selectedResources = emptyList())
Expand Down Expand Up @@ -272,10 +272,10 @@ class GalleryUpliftViewModel(
}
}


fun onPageChanged(newPos: Int) = intent {
if (state.galleryItems.isEmpty())
if (state.galleryItems.isEmpty()) {
return@intent
}

reduce {
state.copy(currentPos = newPos)
Expand All @@ -295,7 +295,8 @@ class GalleryUpliftViewModel(
analytics.trackTagSelect()
router.navigateTo(
Screens.ResourcesScreenWithSelectedTag(
container.stateFlow.value.rootAndFav, tag
container.stateFlow.value.rootAndFav,
tag
)
)
}
Expand All @@ -311,7 +312,9 @@ class GalleryUpliftViewModel(
}
statsStorage.handleEvent(
StatsEvent.TagsChanged(
id, tags, newTags
id,
tags,
newTags
)
)
Timber.d(
Expand All @@ -333,12 +336,11 @@ class GalleryUpliftViewModel(
statsStorage = statsStorage,
rootAndFav = state.rootAndFav,
index = index,
storage = tagsStorage,
storage = tagsStorage
)
)
}


private fun checkResourceChanges(pos: Int) =
intent {
if (state.galleryItems.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class GalleryUpliftViewModelFactory @AssistedInject constructor(
val tagsStorageRepo: TagsStorageRepo,
val statsStorageRepo: StatsStorageRepo,
val scoreStorageRepo: ScoreStorageRepo,
val analytics: GalleryAnalytics,
val analytics: GalleryAnalytics
) : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
return GalleryUpliftViewModel(
Expand All @@ -48,7 +48,7 @@ class GalleryUpliftViewModelFactory @AssistedInject constructor(
tagsStorageRepo = tagsStorageRepo,
statsStorageRepo = statsStorageRepo,
scoreStorageRepo = scoreStorageRepo,
analytics = analytics,
analytics = analytics
) as T
}

Expand All @@ -59,7 +59,7 @@ class GalleryUpliftViewModelFactory @AssistedInject constructor(
@Assisted selectingEnabled: Boolean,
@Assisted rootAndFav: RootAndFav,
@Assisted("all") resourcesIds: List<ResourceId>,
@Assisted("selected") selectedResources: List<ResourceId>,
@Assisted("selected") selectedResources: List<ResourceId>
): GalleryUpliftViewModelFactory
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class PreviewImageViewHolderUplift(
override fun onTileLoadError(e: Exception?) {}

override fun onPreviewReleased() {}
})
}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ import java.nio.file.Path
class PreviewsPagerUplift(
val lifecycleScope: CoroutineScope,
val context: Context,
val viewModel: GalleryUpliftViewModel,
val viewModel: GalleryUpliftViewModel
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
private var galleryItems = emptyList<GalleryItem>()

fun dispatchUpdates(newItems: List<GalleryItem>) {
if (newItems == galleryItems)
if (newItems == galleryItems) {
return
}
val diff = DiffUtil.calculateDiff(
ResourceDiffUtilCallback(
galleryItems.map { it.resource.id },
Expand Down Expand Up @@ -107,8 +108,9 @@ class PreviewsPagerUplift(

override fun onViewRecycled(holder: RecyclerView.ViewHolder) {
super.onViewRecycled(holder)
if (holder is PreviewImageViewHolderUplift)
if (holder is PreviewImageViewHolderUplift) {
holder.onRecycled()
}
}

private fun getGestureDetector(): GestureDetectorCompat {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ sealed class GallerySideEffect {
) : GallerySideEffect()

// workaround to not show checkbox select animation when we change page
data object AbortSelectAnimation: GallerySideEffect()
data object AbortSelectAnimation : GallerySideEffect()

data object NotifyResourceChange : GallerySideEffect()
data object NotifyCurrentItemChange : GallerySideEffect()
Expand Down

0 comments on commit a928af3

Please sign in to comment.