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 {
setupListLayoutManager()
}
getDirectoryAdapter()?.apply {
setupZoomListener(mZoomListener)
setupDragListener(true)
}
}
private fun setupGridLayoutManager() {
@ -360,20 +355,28 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
}
layoutManager.spanCount = config.dirColumnCnt
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()
private fun initZoomListener() {
if (config.viewTypeFolders == VIEW_TYPE_GRID) {
val layoutManager = directories_grid.layoutManager as GridLayoutManager
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() {
val currAdapter = directories_grid.adapter
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)
}.apply {
setupZoomListener(mZoomListener)
setupDragListener(true)
directories_grid.adapter = this
}
} else {
(currAdapter as DirectoryAdapter).updateDirs(mDirs)
}
setupScrollDirection()
}

View file

@ -176,8 +176,13 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
val currAdapter = media_grid.adapter
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)
}.apply {
setupZoomListener(mZoomListener)
setupDragListener(true)
media_grid.adapter = this
}
} else {
(currAdapter as MediaAdapter).updateMedia(mMedia)
@ -402,11 +407,6 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
} else {
setupListLayoutManager()
}
getMediaAdapter()?.apply {
setupZoomListener(mZoomListener)
setupDragListener(true)
}
}
private fun setupGridLayoutManager() {
@ -420,20 +420,28 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
}
layoutManager.spanCount = config.mediaColumnCnt
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()
private fun initZoomListener() {
if (config.viewTypeFiles == VIEW_TYPE_GRID) {
val layoutManager = media_grid.layoutManager as GridLayoutManager
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
}
}