From b0c664842fc1022a7a02c3a0543f010d3443800e Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 19 Feb 2021 18:51:43 +0100 Subject: [PATCH] splitting photo and video thumbnails to remove redundant views --- app/build.gradle | 2 +- .../gallery/pro/adapters/MediaAdapter.kt | 50 +++++++++----- app/src/main/res/layout/photo_item_grid.xml | 64 ++++++++++++++++++ app/src/main/res/layout/photo_item_list.xml | 67 +++++++++++++++++++ ...ideo_item_grid.xml => video_item_grid.xml} | 17 +---- ...ideo_item_list.xml => video_item_list.xml} | 21 +----- 6 files changed, 167 insertions(+), 54 deletions(-) create mode 100644 app/src/main/res/layout/photo_item_grid.xml create mode 100644 app/src/main/res/layout/photo_item_list.xml rename app/src/main/res/layout/{photo_video_item_grid.xml => video_item_grid.xml} (82%) rename app/src/main/res/layout/{photo_video_item_list.xml => video_item_list.xml} (79%) diff --git a/app/build.gradle b/app/build.gradle index 45c4a2882..f0c02e997 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -77,7 +77,7 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:5.33.33' + implementation 'com.simplemobiletools:commons:5.33.34' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'it.sephiroth.android.exif:library:1.0.1' implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.22' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt index be2dc4688..d04509ef1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt @@ -31,18 +31,24 @@ import com.simplemobiletools.gallery.pro.interfaces.MediaOperationsListener import com.simplemobiletools.gallery.pro.models.Medium import com.simplemobiletools.gallery.pro.models.ThumbnailItem import com.simplemobiletools.gallery.pro.models.ThumbnailSection -import kotlinx.android.synthetic.main.photo_video_item_grid.view.* +import kotlinx.android.synthetic.main.photo_item_grid.view.* import kotlinx.android.synthetic.main.thumbnail_section.view.* +import kotlinx.android.synthetic.main.video_item_grid.view.* +import kotlinx.android.synthetic.main.video_item_grid.view.media_item_holder +import kotlinx.android.synthetic.main.video_item_grid.view.medium_check +import kotlinx.android.synthetic.main.video_item_grid.view.medium_name +import kotlinx.android.synthetic.main.video_item_grid.view.medium_thumbnail import java.util.* class MediaAdapter(activity: BaseSimpleActivity, var media: ArrayList, val listener: MediaOperationsListener?, val isAGetIntent: Boolean, val allowMultiplePicks: Boolean, val path: String, recyclerView: MyRecyclerView, fastScroller: FastScroller? = null, itemClick: (Any) -> Unit) : - MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) { + MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) { private val INSTANT_LOAD_DURATION = 2000L private val IMAGE_LOAD_DELAY = 100L private val ITEM_SECTION = 0 - private val ITEM_MEDIUM = 1 + private val ITEM_MEDIUM_VIDEO_PORTRAIT = 1 + private val ITEM_MEDIUM_PHOTO = 2 private val config = activity.config private val viewType = config.getFolderViewType(if (config.showAll) SHOW_ALL else path) @@ -72,9 +78,17 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: ArrayList ITEM_SECTION + (tmbItem as Medium).isVideo() || tmbItem.isPortrait() -> ITEM_MEDIUM_VIDEO_PORTRAIT + else -> ITEM_MEDIUM_PHOTO } } @@ -507,13 +521,13 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: ArrayList + + + + + + + + + + + diff --git a/app/src/main/res/layout/photo_item_list.xml b/app/src/main/res/layout/photo_item_list.xml new file mode 100644 index 000000000..2d4d31776 --- /dev/null +++ b/app/src/main/res/layout/photo_item_list.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + diff --git a/app/src/main/res/layout/photo_video_item_grid.xml b/app/src/main/res/layout/video_item_grid.xml similarity index 82% rename from app/src/main/res/layout/photo_video_item_grid.xml rename to app/src/main/res/layout/video_item_grid.xml index cc3fc718d..0f2e96213 100644 --- a/app/src/main/res/layout/photo_video_item_grid.xml +++ b/app/src/main/res/layout/video_item_grid.xml @@ -13,7 +13,7 @@ android:layout_height="match_parent" /> - - - -