couple adapter changes

This commit is contained in:
tibbi 2017-06-20 22:41:27 +02:00
parent e8168db2f7
commit 09441f80c7
4 changed files with 8 additions and 14 deletions

View File

@ -387,15 +387,13 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
} }
private fun setupAdapter() { private fun setupAdapter() {
val adapter = DirectoryAdapter(this, mDirs, this) {
itemClicked(it.path)
}
val currAdapter = directories_grid.adapter val currAdapter = directories_grid.adapter
if (currAdapter != null) { if (currAdapter != null) {
(currAdapter as DirectoryAdapter).updateDirs(mDirs) (currAdapter as DirectoryAdapter).updateDirs(mDirs)
} else { } else {
directories_grid.adapter = adapter directories_grid.adapter = DirectoryAdapter(this, mDirs, this) {
itemClicked(it.path)
}
} }
directories_fastscroller.setViews(directories_grid, directories_refresh_layout) directories_fastscroller.setViews(directories_grid, directories_refresh_layout)
} }

View File

@ -136,15 +136,13 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
if (isDirEmpty()) if (isDirEmpty())
return return
val adapter = MediaAdapter(this, mMedia, this) {
itemClicked(it.path)
}
val currAdapter = media_grid.adapter val currAdapter = media_grid.adapter
if (currAdapter != null) { if (currAdapter != null) {
(currAdapter as MediaAdapter).updateMedia(mMedia) (currAdapter as MediaAdapter).updateMedia(mMedia)
} else { } else {
media_grid.adapter = adapter media_grid.adapter = MediaAdapter(this, mMedia, this) {
itemClicked(it.path)
}
} }
media_fastscroller.setViews(media_grid, media_refresh_layout) media_fastscroller.setViews(media_grid, media_refresh_layout)
} }

View File

@ -58,7 +58,6 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
} }
updateTitle(selectedPositions.size) updateTitle(selectedPositions.size)
actMode?.invalidate()
} }
fun getProperView(itemView: View): View { fun getProperView(itemView: View): View {
@ -70,6 +69,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
fun updateTitle(cnt: Int) { fun updateTitle(cnt: Int) {
actMode?.title = "$cnt / ${dirs.size}" actMode?.title = "$cnt / ${dirs.size}"
actMode?.invalidate()
} }
fun updatePrimaryColor(color: Int) { fun updatePrimaryColor(color: Int) {
@ -275,7 +275,6 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
notifyItemChanged(i) notifyItemChanged(i)
} }
updateTitle(cnt) updateTitle(cnt)
actMode?.invalidate()
} }
private fun askConfirmDelete() { private fun askConfirmDelete() {

View File

@ -51,7 +51,6 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
} }
updateTitle(selectedPositions.size) updateTitle(selectedPositions.size)
actMode?.invalidate()
} }
fun getProperView(itemView: View): View { fun getProperView(itemView: View): View {
@ -63,6 +62,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
fun updateTitle(cnt: Int) { fun updateTitle(cnt: Int) {
actMode?.title = "$cnt / ${media.size}" actMode?.title = "$cnt / ${media.size}"
actMode?.invalidate()
} }
fun updatePrimaryColor(color: Int) { fun updatePrimaryColor(color: Int) {
@ -214,7 +214,6 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
notifyItemChanged(i) notifyItemChanged(i)
} }
updateTitle(cnt) updateTitle(cnt)
actMode?.invalidate()
} }
private fun askConfirmDelete() { private fun askConfirmDelete() {