mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 00:17:58 +01:00
recreate the directory adapter if something thumbnail style related changes
This commit is contained in:
parent
e37fe3ab37
commit
c2ee93e039
2 changed files with 20 additions and 12 deletions
|
@ -84,6 +84,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
private var mStoredScrollHorizontally = true
|
private var mStoredScrollHorizontally = true
|
||||||
private var mStoredTextColor = 0
|
private var mStoredTextColor = 0
|
||||||
private var mStoredPrimaryColor = 0
|
private var mStoredPrimaryColor = 0
|
||||||
|
private var mStoredStyleString = ""
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
@ -189,6 +190,11 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
directories_horizontal_fastscroller.updatePrimaryColor()
|
directories_horizontal_fastscroller.updatePrimaryColor()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val styleString = "${config.folderStyle}${config.showFolderMediaCount}${config.limitFolderTitle}"
|
||||||
|
if (mStoredStyleString != styleString) {
|
||||||
|
setupAdapter(mDirs, forceRecreate = true)
|
||||||
|
}
|
||||||
|
|
||||||
directories_horizontal_fastscroller.updateBubbleColors()
|
directories_horizontal_fastscroller.updateBubbleColors()
|
||||||
directories_vertical_fastscroller.updateBubbleColors()
|
directories_vertical_fastscroller.updateBubbleColors()
|
||||||
directories_refresh_layout.isEnabled = config.enablePullToRefresh
|
directories_refresh_layout.isEnabled = config.enablePullToRefresh
|
||||||
|
@ -329,6 +335,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
mStoredScrollHorizontally = scrollHorizontally
|
mStoredScrollHorizontally = scrollHorizontally
|
||||||
mStoredTextColor = textColor
|
mStoredTextColor = textColor
|
||||||
mStoredPrimaryColor = primaryColor
|
mStoredPrimaryColor = primaryColor
|
||||||
|
mStoredStyleString = "$folderStyle$showFolderMediaCount$limitFolderTitle"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1141,13 +1148,13 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
directories_grid.beVisibleIf(directories_empty_placeholder.isGone())
|
directories_grid.beVisibleIf(directories_empty_placeholder.isGone())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupAdapter(dirs: ArrayList<Directory>, textToSearch: String = "") {
|
private fun setupAdapter(dirs: ArrayList<Directory>, textToSearch: String = "", forceRecreate: Boolean = false) {
|
||||||
val currAdapter = directories_grid.adapter
|
val currAdapter = directories_grid.adapter
|
||||||
val distinctDirs = dirs.distinctBy { it.path.getDistinctPath() }.toMutableList() as ArrayList<Directory>
|
val distinctDirs = dirs.distinctBy { it.path.getDistinctPath() }.toMutableList() as ArrayList<Directory>
|
||||||
val sortedDirs = getSortedDirectories(distinctDirs)
|
val sortedDirs = getSortedDirectories(distinctDirs)
|
||||||
var dirsToShow = getDirsToShow(sortedDirs, mDirs, mCurrentPathPrefix).clone() as ArrayList<Directory>
|
var dirsToShow = getDirsToShow(sortedDirs, mDirs, mCurrentPathPrefix).clone() as ArrayList<Directory>
|
||||||
|
|
||||||
if (currAdapter == null) {
|
if (currAdapter == null || forceRecreate) {
|
||||||
initZoomListener()
|
initZoomListener()
|
||||||
val fastscroller = if (config.scrollHorizontally) directories_horizontal_fastscroller else directories_vertical_fastscroller
|
val fastscroller = if (config.scrollHorizontally) directories_horizontal_fastscroller else directories_vertical_fastscroller
|
||||||
DirectoryAdapter(this, dirsToShow, this, directories_grid, isPickIntent(intent) || isGetAnyContentIntent(intent), fastscroller) {
|
DirectoryAdapter(this, dirsToShow, this, directories_grid, isPickIntent(intent) || isGetAnyContentIntent(intent), fastscroller) {
|
||||||
|
|
|
@ -48,13 +48,16 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
private val isListViewType = config.viewTypeFolders == VIEW_TYPE_LIST
|
private val isListViewType = config.viewTypeFolders == VIEW_TYPE_LIST
|
||||||
private var pinnedFolders = config.pinnedFolders
|
private var pinnedFolders = config.pinnedFolders
|
||||||
private var scrollHorizontally = config.scrollHorizontally
|
private var scrollHorizontally = config.scrollHorizontally
|
||||||
private var showMediaCount = config.showFolderMediaCount
|
|
||||||
private var animateGifs = config.animateGifs
|
private var animateGifs = config.animateGifs
|
||||||
private var cropThumbnails = config.cropThumbnails
|
private var cropThumbnails = config.cropThumbnails
|
||||||
private var groupDirectSubfolders = config.groupDirectSubfolders
|
private var groupDirectSubfolders = config.groupDirectSubfolders
|
||||||
private var currentDirectoriesHash = dirs.hashCode()
|
private var currentDirectoriesHash = dirs.hashCode()
|
||||||
private var lockedFolderPaths = ArrayList<String>()
|
private var lockedFolderPaths = ArrayList<String>()
|
||||||
|
|
||||||
|
private var showMediaCount = config.showFolderMediaCount
|
||||||
|
private var folderStyle = config.folderStyle
|
||||||
|
private var limitFolderTitle = config.limitFolderTitle
|
||||||
|
|
||||||
init {
|
init {
|
||||||
setupDragListener(true)
|
setupDragListener(true)
|
||||||
fillLockedFolders()
|
fillLockedFolders()
|
||||||
|
@ -63,12 +66,10 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
override fun getActionMenuId() = R.menu.cab_directories
|
override fun getActionMenuId() = R.menu.cab_directories
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
val layoutType = if (isListViewType) {
|
val layoutType = when {
|
||||||
R.layout.directory_item_list
|
isListViewType -> R.layout.directory_item_list
|
||||||
} else if (config.folderStyle == FOLDER_STYLE_SQUARE) {
|
folderStyle == FOLDER_STYLE_SQUARE -> R.layout.directory_item_grid_square
|
||||||
R.layout.directory_item_grid_square
|
else -> R.layout.directory_item_grid_rounded_corners
|
||||||
} else {
|
|
||||||
R.layout.directory_item_grid_rounded_corners
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return createViewHolder(layoutType, parent)
|
return createViewHolder(layoutType, parent)
|
||||||
|
@ -679,7 +680,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
dir_check.background?.applyColorFilter(primaryColor)
|
dir_check.background?.applyColorFilter(primaryColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scrollHorizontally && !isListViewType && config.folderStyle == FOLDER_STYLE_ROUNDED_CORNERS) {
|
if (scrollHorizontally && !isListViewType && folderStyle == FOLDER_STYLE_ROUNDED_CORNERS) {
|
||||||
(dir_thumbnail.layoutParams as RelativeLayout.LayoutParams).addRule(RelativeLayout.ABOVE, dir_name.id)
|
(dir_thumbnail.layoutParams as RelativeLayout.LayoutParams).addRule(RelativeLayout.ABOVE, dir_name.id)
|
||||||
|
|
||||||
val photoCntParams = (photo_cnt.layoutParams as RelativeLayout.LayoutParams)
|
val photoCntParams = (photo_cnt.layoutParams as RelativeLayout.LayoutParams)
|
||||||
|
@ -705,7 +706,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
dir_lock.beGone()
|
dir_lock.beGone()
|
||||||
val roundedCorners = when {
|
val roundedCorners = when {
|
||||||
isListViewType -> ROUNDED_CORNERS_SMALL
|
isListViewType -> ROUNDED_CORNERS_SMALL
|
||||||
config.folderStyle == FOLDER_STYLE_SQUARE -> ROUNDED_CORNERS_NONE
|
folderStyle == FOLDER_STYLE_SQUARE -> ROUNDED_CORNERS_NONE
|
||||||
else -> ROUNDED_CORNERS_BIG
|
else -> ROUNDED_CORNERS_BIG
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -721,7 +722,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
photo_cnt.text = directory.subfoldersMediaCount.toString()
|
photo_cnt.text = directory.subfoldersMediaCount.toString()
|
||||||
photo_cnt.beVisibleIf(showMediaCount == FOLDER_MEDIA_CNT_LINE)
|
photo_cnt.beVisibleIf(showMediaCount == FOLDER_MEDIA_CNT_LINE)
|
||||||
|
|
||||||
if (config.limitFolderTitle) {
|
if (limitFolderTitle) {
|
||||||
dir_name.setSingleLine()
|
dir_name.setSingleLine()
|
||||||
dir_name.ellipsize = TextUtils.TruncateAt.MIDDLE
|
dir_name.ellipsize = TextUtils.TruncateAt.MIDDLE
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue