mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +01:00
adding a couple customization fixes
This commit is contained in:
parent
9f12a3a6f1
commit
650c04d3c3
2 changed files with 44 additions and 6 deletions
|
@ -654,16 +654,36 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
|
||||
private fun calculateContentWidth(directories: ArrayList<Directory>) {
|
||||
val layoutManager = directories_grid.layoutManager as MyGridLayoutManager
|
||||
|
||||
val fullWidth = if (config.folderStyle == FOLDER_STYLE_SQUARE) {
|
||||
val thumbnailWidth = layoutManager.getChildAt(0)?.width ?: 0
|
||||
val fullWidth = ((directories.size - 1) / layoutManager.spanCount + 1) * thumbnailWidth
|
||||
((directories.size - 1) / layoutManager.spanCount + 1) * thumbnailWidth
|
||||
} else {
|
||||
val thumbnailWidth = (layoutManager.getChildAt(0)?.width ?: 0) + resources.getDimension(R.dimen.medium_margin).toInt() * 2
|
||||
val columnCount = (directories.size - 1) / layoutManager.spanCount + 1
|
||||
columnCount * thumbnailWidth
|
||||
}
|
||||
|
||||
directories_horizontal_fastscroller.setContentWidth(fullWidth)
|
||||
directories_horizontal_fastscroller.setScrollToX(directories_grid.computeHorizontalScrollOffset())
|
||||
}
|
||||
|
||||
private fun calculateContentHeight(directories: ArrayList<Directory>) {
|
||||
val layoutManager = directories_grid.layoutManager as MyGridLayoutManager
|
||||
|
||||
val fullHeight = if (config.folderStyle == FOLDER_STYLE_SQUARE) {
|
||||
val thumbnailHeight = layoutManager.getChildAt(0)?.height ?: 0
|
||||
val fullHeight = ((directories.size - 1) / layoutManager.spanCount + 1) * thumbnailHeight
|
||||
((directories.size - 1) / layoutManager.spanCount + 1) * thumbnailHeight
|
||||
} else {
|
||||
var thumbnailHeight = (layoutManager.getChildAt(0)?.height ?: 0)
|
||||
if (config.viewTypeFolders == VIEW_TYPE_GRID) {
|
||||
thumbnailHeight += resources.getDimension(R.dimen.medium_margin).toInt() * 2
|
||||
}
|
||||
|
||||
val rowCount = (directories.size - 1) / layoutManager.spanCount + 1
|
||||
rowCount * thumbnailHeight
|
||||
}
|
||||
|
||||
directories_vertical_fastscroller.setContentHeight(fullHeight)
|
||||
directories_vertical_fastscroller.setScrollToY(directories_grid.computeVerticalScrollOffset())
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import android.graphics.drawable.Icon
|
|||
import android.view.Menu
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.RelativeLayout
|
||||
import com.bumptech.glide.Glide
|
||||
import com.google.gson.Gson
|
||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
|
@ -61,7 +62,14 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
|||
override fun getActionMenuId() = R.menu.cab_directories
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val layoutType = if (isListViewType) R.layout.directory_item_list else R.layout.directory_item_grid_square
|
||||
val layoutType = if (isListViewType) {
|
||||
R.layout.directory_item_list
|
||||
} else if (config.folderStyle == FOLDER_STYLE_SQUARE) {
|
||||
R.layout.directory_item_grid_square
|
||||
} else {
|
||||
R.layout.directory_item_grid_rounded_corners
|
||||
}
|
||||
|
||||
return createViewHolder(layoutType, parent)
|
||||
}
|
||||
|
||||
|
@ -670,13 +678,23 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
|||
dir_check.background?.applyColorFilter(primaryColor)
|
||||
}
|
||||
|
||||
if (scrollHorizontally && !isListViewType && config.folderStyle == FOLDER_STYLE_ROUNDED_CORNERS) {
|
||||
(dir_name.layoutParams as RelativeLayout.LayoutParams).removeRule(RelativeLayout.BELOW)
|
||||
(dir_thumbnail.layoutParams as RelativeLayout.LayoutParams).addRule(RelativeLayout.ABOVE, dir_name.id)
|
||||
}
|
||||
|
||||
if (lockedFolderPaths.contains(directory.path)) {
|
||||
dir_lock.beVisible()
|
||||
dir_lock.background = ColorDrawable(config.backgroundColor)
|
||||
dir_lock.applyColorFilter(config.backgroundColor.getContrastColor())
|
||||
} else {
|
||||
dir_lock.beGone()
|
||||
val roundedCorners = if (isListViewType) ROUNDED_CORNERS_SMALL else ROUNDED_CORNERS_NONE
|
||||
val roundedCorners = when {
|
||||
isListViewType -> ROUNDED_CORNERS_SMALL
|
||||
config.folderStyle == FOLDER_STYLE_SQUARE -> ROUNDED_CORNERS_NONE
|
||||
else -> ROUNDED_CORNERS_BIG
|
||||
}
|
||||
|
||||
activity.loadImage(thumbnailType, directory.tmb, dir_thumbnail, scrollHorizontally, animateGifs, cropThumbnails, roundedCorners)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue