fix #480, make sure drag selection is always available

This commit is contained in:
tibbi 2017-11-30 10:08:16 +01:00
parent dbb1eee9c7
commit 7f596a3993
2 changed files with 51 additions and 34 deletions

View file

@ -342,11 +342,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
} else { } else {
setupListLayoutManager() setupListLayoutManager()
} }
getDirectoryAdapter()?.apply {
setupZoomListener(mZoomListener)
setupDragListener(true)
}
} }
private fun setupGridLayoutManager() { private fun setupGridLayoutManager() {
@ -360,20 +355,28 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
} }
layoutManager.spanCount = config.dirColumnCnt layoutManager.spanCount = config.dirColumnCnt
mZoomListener = object : MyRecyclerView.MyZoomListener { }
override fun zoomIn() {
if (layoutManager.spanCount > 1) {
reduceColumnCount()
getRecyclerAdapter().finishActMode()
}
}
override fun zoomOut() { private fun initZoomListener() {
if (layoutManager.spanCount < MAX_COLUMN_COUNT) { if (config.viewTypeFolders == VIEW_TYPE_GRID) {
increaseColumnCount() val layoutManager = directories_grid.layoutManager as GridLayoutManager
getRecyclerAdapter().finishActMode() mZoomListener = object : MyRecyclerView.MyZoomListener {
override fun zoomIn() {
if (layoutManager.spanCount > 1) {
reduceColumnCount()
getRecyclerAdapter().finishActMode()
}
}
override fun zoomOut() {
if (layoutManager.spanCount < MAX_COLUMN_COUNT) {
increaseColumnCount()
getRecyclerAdapter().finishActMode()
}
} }
} }
} else {
mZoomListener = null
} }
} }
@ -554,12 +557,18 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
private fun setupAdapter() { private fun setupAdapter() {
val currAdapter = directories_grid.adapter val currAdapter = directories_grid.adapter
if (currAdapter == null) { if (currAdapter == null) {
directories_grid.adapter = DirectoryAdapter(this, mDirs, this, directories_grid, isPickIntent(intent) || isGetAnyContentIntent(intent)) { initZoomListener()
DirectoryAdapter(this, mDirs, this, directories_grid, isPickIntent(intent) || isGetAnyContentIntent(intent)) {
itemClicked((it as Directory).path) itemClicked((it as Directory).path)
}.apply {
setupZoomListener(mZoomListener)
setupDragListener(true)
directories_grid.adapter = this
} }
} else { } else {
(currAdapter as DirectoryAdapter).updateDirs(mDirs) (currAdapter as DirectoryAdapter).updateDirs(mDirs)
} }
setupScrollDirection() setupScrollDirection()
} }

View file

@ -176,8 +176,13 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
val currAdapter = media_grid.adapter val currAdapter = media_grid.adapter
if (currAdapter == null) { if (currAdapter == null) {
media_grid.adapter = MediaAdapter(this, mMedia, this, mIsGetImageIntent || mIsGetVideoIntent || mIsGetAnyIntent, mAllowPickingMultiple, media_grid) { initZoomListener()
MediaAdapter(this, mMedia, this, mIsGetImageIntent || mIsGetVideoIntent || mIsGetAnyIntent, mAllowPickingMultiple, media_grid) {
itemClicked((it as Medium).path) itemClicked((it as Medium).path)
}.apply {
setupZoomListener(mZoomListener)
setupDragListener(true)
media_grid.adapter = this
} }
} else { } else {
(currAdapter as MediaAdapter).updateMedia(mMedia) (currAdapter as MediaAdapter).updateMedia(mMedia)
@ -402,11 +407,6 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
} else { } else {
setupListLayoutManager() setupListLayoutManager()
} }
getMediaAdapter()?.apply {
setupZoomListener(mZoomListener)
setupDragListener(true)
}
} }
private fun setupGridLayoutManager() { private fun setupGridLayoutManager() {
@ -420,20 +420,28 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
} }
layoutManager.spanCount = config.mediaColumnCnt layoutManager.spanCount = config.mediaColumnCnt
mZoomListener = object : MyRecyclerView.MyZoomListener { }
override fun zoomIn() {
if (layoutManager.spanCount > 1) {
reduceColumnCount()
getRecyclerAdapter().finishActMode()
}
}
override fun zoomOut() { private fun initZoomListener() {
if (layoutManager.spanCount < MAX_COLUMN_COUNT) { if (config.viewTypeFiles == VIEW_TYPE_GRID) {
increaseColumnCount() val layoutManager = media_grid.layoutManager as GridLayoutManager
getRecyclerAdapter().finishActMode() mZoomListener = object : MyRecyclerView.MyZoomListener {
override fun zoomIn() {
if (layoutManager.spanCount > 1) {
reduceColumnCount()
getRecyclerAdapter().finishActMode()
}
}
override fun zoomOut() {
if (layoutManager.spanCount < MAX_COLUMN_COUNT) {
increaseColumnCount()
getRecyclerAdapter().finishActMode()
}
} }
} }
} else {
mZoomListener = null
} }
} }