mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-06-05 22:09:15 +02:00
allow changing the column count at mimetype activity
This commit is contained in:
@ -12,6 +12,7 @@ import com.simplemobiletools.commons.extensions.*
|
|||||||
import com.simplemobiletools.commons.helpers.VIEW_TYPE_GRID
|
import com.simplemobiletools.commons.helpers.VIEW_TYPE_GRID
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.commons.models.FileDirItem
|
import com.simplemobiletools.commons.models.FileDirItem
|
||||||
|
import com.simplemobiletools.commons.views.MyGridLayoutManager
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
import com.simplemobiletools.filemanager.pro.adapters.ItemsAdapter
|
import com.simplemobiletools.filemanager.pro.adapters.ItemsAdapter
|
||||||
import com.simplemobiletools.filemanager.pro.dialogs.ChangeSortingDialog
|
import com.simplemobiletools.filemanager.pro.dialogs.ChangeSortingDialog
|
||||||
@ -121,9 +122,18 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun increaseColumnCount() {
|
override fun increaseColumnCount() {
|
||||||
|
if (config.getFolderViewType(currentMimeType) == VIEW_TYPE_GRID) {
|
||||||
|
config.fileColumnCnt = ++(mimetypes_list.layoutManager as MyGridLayoutManager).spanCount
|
||||||
|
columnCountChanged()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun reduceColumnCount() {}
|
override fun reduceColumnCount() {
|
||||||
|
if (config.getFolderViewType(currentMimeType) == VIEW_TYPE_GRID) {
|
||||||
|
config.fileColumnCnt = --(mimetypes_list.layoutManager as MyGridLayoutManager).spanCount
|
||||||
|
columnCountChanged()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun finishActMode() {}
|
override fun finishActMode() {}
|
||||||
|
|
||||||
@ -282,6 +292,22 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun columnCountChanged() {
|
||||||
|
invalidateOptionsMenu()
|
||||||
|
getRecyclerAdapter()?.apply {
|
||||||
|
notifyItemRangeChanged(0, listItems.size)
|
||||||
|
calculateContentHeight(listItems)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun calculateContentHeight(items: MutableList<ListItem>) {
|
||||||
|
val layoutManager = mimetypes_list.layoutManager as MyGridLayoutManager
|
||||||
|
val thumbnailHeight = layoutManager.getChildAt(0)?.height ?: 0
|
||||||
|
val fullHeight = ((items.size - 1) / layoutManager.spanCount + 1) * thumbnailHeight
|
||||||
|
items_fastscroller.setContentHeight(fullHeight)
|
||||||
|
items_fastscroller.setScrollToY(mimetypes_list.computeVerticalScrollOffset())
|
||||||
|
}
|
||||||
|
|
||||||
private fun tryToggleTemporarilyShowHidden() {
|
private fun tryToggleTemporarilyShowHidden() {
|
||||||
if (config.temporarilyShowHidden) {
|
if (config.temporarilyShowHidden) {
|
||||||
toggleTemporarilyShowHidden(false)
|
toggleTemporarilyShowHidden(false)
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:layoutAnimation="@anim/layout_animation"
|
android:layoutAnimation="@anim/layout_animation"
|
||||||
|
android:paddingTop="@dimen/small_margin"
|
||||||
android:scrollbars="none"
|
android:scrollbars="none"
|
||||||
app:layoutManager="com.simplemobiletools.commons.views.MyGridLayoutManager" />
|
app:layoutManager="com.simplemobiletools.commons.views.MyGridLayoutManager" />
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user