mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57:59 +01:00
update media screen items on delete, dont recreate
This commit is contained in:
parent
f06fc85bdb
commit
ac9132bf6b
3 changed files with 16 additions and 5 deletions
|
@ -14,7 +14,7 @@ import android.view.Menu
|
|||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import com.simplemobiletools.filepicker.extensions.*
|
||||
import com.simplemobiletools.gallery.*
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.adapters.DirectoryAdapter
|
||||
import com.simplemobiletools.gallery.asynctasks.GetDirectoriesAsynctask
|
||||
import com.simplemobiletools.gallery.dialogs.ChangeSortingDialog
|
||||
|
@ -302,6 +302,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
val adapter = DirectoryAdapter(this, mDirs, this) {
|
||||
itemClicked(it.path)
|
||||
}
|
||||
|
||||
directories_grid.adapter = adapter
|
||||
directories_grid.setOnTouchListener { view, motionEvent -> checkDelete(); false }
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import com.bumptech.glide.Glide
|
|||
import com.bumptech.glide.request.animation.GlideAnimation
|
||||
import com.bumptech.glide.request.target.SimpleTarget
|
||||
import com.simplemobiletools.filepicker.extensions.*
|
||||
import com.simplemobiletools.gallery.*
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.adapters.MediaAdapter
|
||||
import com.simplemobiletools.gallery.asynctasks.GetMediaAsynctask
|
||||
import com.simplemobiletools.gallery.dialogs.ChangeSortingDialog
|
||||
|
@ -87,7 +87,12 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
itemClicked(it.path)
|
||||
}
|
||||
|
||||
val currAdapter = media_grid.adapter
|
||||
if (currAdapter != null) {
|
||||
(currAdapter as MediaAdapter).updateMedia(mMedia)
|
||||
} else {
|
||||
media_grid.adapter = adapter
|
||||
}
|
||||
media_grid.setOnTouchListener { view, motionEvent -> checkDelete(); false }
|
||||
}
|
||||
|
||||
|
|
|
@ -14,20 +14,20 @@ import com.simplemobiletools.filepicker.asynctasks.CopyMoveTask
|
|||
import com.simplemobiletools.filepicker.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.filepicker.extensions.toast
|
||||
import com.simplemobiletools.fileproperties.dialogs.PropertiesDialog
|
||||
import com.simplemobiletools.gallery.helpers.Config
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
||||
import com.simplemobiletools.gallery.dialogs.CopyDialog
|
||||
import com.simplemobiletools.gallery.extensions.beVisibleIf
|
||||
import com.simplemobiletools.gallery.extensions.shareMedia
|
||||
import com.simplemobiletools.gallery.extensions.shareMedium
|
||||
import com.simplemobiletools.gallery.helpers.Config
|
||||
import com.simplemobiletools.gallery.models.Medium
|
||||
import kotlinx.android.synthetic.main.photo_video_item.view.*
|
||||
import kotlinx.android.synthetic.main.photo_video_tmb.view.*
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
class MediaAdapter(val activity: SimpleActivity, val media: MutableList<Medium>, val listener: MediaOperationsListener?, val itemClick: (Medium) -> Unit) :
|
||||
class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>, val listener: MediaOperationsListener?, val itemClick: (Medium) -> Unit) :
|
||||
RecyclerView.Adapter<MediaAdapter.ViewHolder>() {
|
||||
val multiSelector = MultiSelector()
|
||||
val views = ArrayList<View>()
|
||||
|
@ -167,6 +167,11 @@ class MediaAdapter(val activity: SimpleActivity, val media: MutableList<Medium>,
|
|||
|
||||
override fun getItemCount() = media.size
|
||||
|
||||
fun updateMedia(newMedia: ArrayList<Medium>) {
|
||||
media = newMedia
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
fun updateDisplayFilenames(display: Boolean) {
|
||||
displayFilenames = display
|
||||
notifyDataSetChanged()
|
||||
|
|
Loading…
Reference in a new issue