recreate whole thumbnails view on toggling horizontal scroll
This commit is contained in:
parent
2d8ab6647d
commit
73e5333eef
4 changed files with 46 additions and 39 deletions
|
@ -138,8 +138,9 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mStoredScrollHorizontally != config.scrollHorizontally) {
|
if (mStoredScrollHorizontally != config.scrollHorizontally) {
|
||||||
getRecyclerAdapter()?.updateScrollHorizontally(config.viewTypeFolders != VIEW_TYPE_LIST && config.scrollHorizontally)
|
mLoadedInitialPhotos = false
|
||||||
setupScrollDirection()
|
directories_grid.adapter = null
|
||||||
|
getDirectories()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mStoredTextColor != config.textColor) {
|
if (mStoredTextColor != config.textColor) {
|
||||||
|
@ -382,6 +383,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
private fun toggleTemporarilyShowHidden(show: Boolean) {
|
private fun toggleTemporarilyShowHidden(show: Boolean) {
|
||||||
mLoadedInitialPhotos = false
|
mLoadedInitialPhotos = false
|
||||||
config.temporarilyShowHidden = show
|
config.temporarilyShowHidden = show
|
||||||
|
directories_grid.adapter = null
|
||||||
getDirectories()
|
getDirectories()
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,8 +61,6 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
private var mIsSearchOpen = false
|
private var mIsSearchOpen = false
|
||||||
private var mLatestMediaId = 0L
|
private var mLatestMediaId = 0L
|
||||||
private var mLatestMediaDateId = 0L
|
private var mLatestMediaDateId = 0L
|
||||||
private var mSectionTitleHeight = 0
|
|
||||||
private var mThumbnailHeight = 0
|
|
||||||
private var mLastMediaHandler = Handler()
|
private var mLastMediaHandler = Handler()
|
||||||
private var mTempShowHiddenHandler = Handler()
|
private var mTempShowHiddenHandler = Handler()
|
||||||
private var mCurrAsyncTask: GetMediaAsynctask? = null
|
private var mCurrAsyncTask: GetMediaAsynctask? = null
|
||||||
|
@ -126,8 +124,9 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mStoredScrollHorizontally != config.scrollHorizontally) {
|
if (mStoredScrollHorizontally != config.scrollHorizontally) {
|
||||||
getMediaAdapter()?.updateScrollHorizontally(config.viewTypeFiles != VIEW_TYPE_LIST || !config.scrollHorizontally)
|
mLoadedInitialPhotos = false
|
||||||
setupScrollDirection()
|
media_grid.adapter = null
|
||||||
|
getMedia()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mStoredTextColor != config.textColor) {
|
if (mStoredTextColor != config.textColor) {
|
||||||
|
@ -591,33 +590,50 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun measureRecyclerViewContent(media: ArrayList<ThumbnailItem>) {
|
private fun measureRecyclerViewContent(media: ArrayList<ThumbnailItem>) {
|
||||||
val layoutManager = media_grid.layoutManager as MyGridLayoutManager
|
|
||||||
media_grid.onGlobalLayout {
|
media_grid.onGlobalLayout {
|
||||||
val hasSections = config.getFolderGrouping(mPath) and GROUP_BY_NONE == 0
|
if (config.scrollHorizontally) {
|
||||||
mSectionTitleHeight = if (hasSections) layoutManager.getChildAt(0)?.height ?: 0 else 0
|
calculateContentWidth(media)
|
||||||
mThumbnailHeight = if (hasSections) layoutManager.getChildAt(1)?.height ?: 0 else layoutManager.getChildAt(0)?.height ?: 0
|
} else {
|
||||||
|
calculateContentHeight(media)
|
||||||
var fullHeight = 0
|
|
||||||
var curSectionItems = 0
|
|
||||||
media.forEach {
|
|
||||||
if (it is ThumbnailSection) {
|
|
||||||
fullHeight += mSectionTitleHeight
|
|
||||||
if (curSectionItems != 0) {
|
|
||||||
val rows = ((curSectionItems - 1) / layoutManager.spanCount + 1)
|
|
||||||
fullHeight += rows * mThumbnailHeight
|
|
||||||
}
|
|
||||||
curSectionItems = 0
|
|
||||||
} else {
|
|
||||||
curSectionItems++
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fullHeight += ((curSectionItems - 1) / layoutManager.spanCount + 1) * mThumbnailHeight
|
|
||||||
media_vertical_fastscroller.setContentHeight(fullHeight)
|
|
||||||
media_vertical_fastscroller.setScrollTo(media_grid.computeVerticalScrollOffset())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun calculateContentWidth(media: ArrayList<ThumbnailItem>) {
|
||||||
|
val layoutManager = media_grid.layoutManager as MyGridLayoutManager
|
||||||
|
val mThumbnailWidth = layoutManager.getChildAt(0)?.width ?: 0
|
||||||
|
val fullWidth = ((media.size - 1) / layoutManager.spanCount + 1) * mThumbnailWidth
|
||||||
|
media_horizontal_fastscroller.setContentWidth(fullWidth)
|
||||||
|
media_horizontal_fastscroller.setScrollTo(media_grid.computeHorizontalScrollOffset())
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun calculateContentHeight(media: ArrayList<ThumbnailItem>) {
|
||||||
|
val layoutManager = media_grid.layoutManager as MyGridLayoutManager
|
||||||
|
val hasSections = config.getFolderGrouping(mPath) and GROUP_BY_NONE == 0 && !config.scrollHorizontally
|
||||||
|
val mSectionTitleHeight = if (hasSections) layoutManager.getChildAt(0)?.height ?: 0 else 0
|
||||||
|
val mThumbnailHeight = if (hasSections) layoutManager.getChildAt(1)?.height ?: 0 else layoutManager.getChildAt(0)?.height
|
||||||
|
?: 0
|
||||||
|
|
||||||
|
var fullHeight = 0
|
||||||
|
var curSectionItems = 0
|
||||||
|
media.forEach {
|
||||||
|
if (it is ThumbnailSection) {
|
||||||
|
fullHeight += mSectionTitleHeight
|
||||||
|
if (curSectionItems != 0) {
|
||||||
|
val rows = ((curSectionItems - 1) / layoutManager.spanCount + 1)
|
||||||
|
fullHeight += rows * mThumbnailHeight
|
||||||
|
}
|
||||||
|
curSectionItems = 0
|
||||||
|
} else {
|
||||||
|
curSectionItems++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fullHeight += ((curSectionItems - 1) / layoutManager.spanCount + 1) * mThumbnailHeight
|
||||||
|
media_vertical_fastscroller.setContentHeight(fullHeight)
|
||||||
|
media_vertical_fastscroller.setScrollTo(media_grid.computeVerticalScrollOffset())
|
||||||
|
}
|
||||||
|
|
||||||
private fun initZoomListener() {
|
private fun initZoomListener() {
|
||||||
if (config.viewTypeFiles == VIEW_TYPE_GRID) {
|
if (config.viewTypeFiles == VIEW_TYPE_GRID) {
|
||||||
val layoutManager = media_grid.layoutManager as MyGridLayoutManager
|
val layoutManager = media_grid.layoutManager as MyGridLayoutManager
|
||||||
|
|
|
@ -442,11 +442,6 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateScrollHorizontally(scrollHorizontally: Boolean) {
|
|
||||||
this.scrollHorizontally = scrollHorizontally
|
|
||||||
notifyDataSetChanged()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setupView(view: View, directory: Directory) {
|
private fun setupView(view: View, directory: Directory) {
|
||||||
view.apply {
|
view.apply {
|
||||||
dir_name.text = directory.name
|
dir_name.text = directory.name
|
||||||
|
|
|
@ -335,7 +335,6 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
|
||||||
enableInstantLoad()
|
enableInstantLoad()
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
finishActMode()
|
finishActMode()
|
||||||
fastScroller?.measureRecyclerView()
|
|
||||||
}, 100L)
|
}, 100L)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -356,11 +355,6 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateScrollHorizontally(scrollHorizontally: Boolean) {
|
|
||||||
this.scrollHorizontally = scrollHorizontally
|
|
||||||
notifyDataSetChanged()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun enableInstantLoad() {
|
private fun enableInstantLoad() {
|
||||||
loadImageInstantly = true
|
loadImageInstantly = true
|
||||||
delayHandler.postDelayed({
|
delayHandler.postDelayed({
|
||||||
|
|
Loading…
Reference in a new issue