diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index 45f1ff116..a4b0a63ff 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -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 } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 13a19da56..4ce1e497c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -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) } - media_grid.adapter = adapter + 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 } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt index 11ffbbf8e..e6d29001e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -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, val listener: MediaOperationsListener?, val itemClick: (Medium) -> Unit) : +class MediaAdapter(val activity: SimpleActivity, var media: MutableList, val listener: MediaOperationsListener?, val itemClick: (Medium) -> Unit) : RecyclerView.Adapter() { val multiSelector = MultiSelector() val views = ArrayList() @@ -167,6 +167,11 @@ class MediaAdapter(val activity: SimpleActivity, val media: MutableList, override fun getItemCount() = media.size + fun updateMedia(newMedia: ArrayList) { + media = newMedia + notifyDataSetChanged() + } + fun updateDisplayFilenames(display: Boolean) { displayFilenames = display notifyDataSetChanged()