From 216e51beff5a20062b79881f6149ff1f54c36f46 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 29 Sep 2017 22:52:30 +0200 Subject: [PATCH] rename photo_video_item to photo_video_item_grid --- .../gallery/adapters/DirectoryAdapter.kt | 6 +-- .../gallery/adapters/MediaAdapter.kt | 13 ++--- ...deo_item.xml => photo_video_item_grid.xml} | 0 .../main/res/layout/photo_video_item_list.xml | 53 +++++++++++++++++++ 4 files changed, 62 insertions(+), 10 deletions(-) rename app/src/main/res/layout/{photo_video_item.xml => photo_video_item_grid.xml} (100%) create mode 100644 app/src/main/res/layout/photo_video_item_list.xml diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt index 5b0f851bc..c70d13194 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -430,10 +430,8 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList= Build.VERSION_CODES.JELLY_BEAN_MR1 && activity.isDestroyed) - return - - Glide.with(activity).clear(view.dir_thumbnail) + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1 || !activity.isDestroyed) + Glide.with(activity).clear(view.dir_thumbnail) } } 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 5441df3c2..3c71c7f6c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -18,8 +18,9 @@ import com.simplemobiletools.commons.extensions.beVisibleIf import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.activities.SimpleActivity import com.simplemobiletools.gallery.extensions.* +import com.simplemobiletools.gallery.helpers.VIEW_TYPE_LIST import com.simplemobiletools.gallery.models.Medium -import kotlinx.android.synthetic.main.photo_video_item.view.* +import kotlinx.android.synthetic.main.photo_video_item_grid.view.* import java.io.File import java.util.* @@ -28,6 +29,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, val multiSelector = MultiSelector() val config = activity.config + val isListViewType = config.viewTypeFiles == VIEW_TYPE_LIST var actMode: ActionMode? = null var itemViews = SparseArray() @@ -242,7 +244,8 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, } override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder { - val view = LayoutInflater.from(parent?.context).inflate(R.layout.photo_video_item, parent, false) + val layoutType = if (isListViewType) R.layout.photo_video_item_list else R.layout.photo_video_item_grid + val view = LayoutInflater.from(parent?.context).inflate(layoutType, parent, false) return ViewHolder(view, adapterListener, activity, multiSelectorMode, multiSelector, listener, isPickIntent, itemClick) } @@ -345,10 +348,8 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, } fun stopLoad() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && activity.isDestroyed) - return - - Glide.with(activity).clear(view.medium_thumbnail) + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1 || !activity.isDestroyed) + Glide.with(activity).clear(view.medium_thumbnail) } } diff --git a/app/src/main/res/layout/photo_video_item.xml b/app/src/main/res/layout/photo_video_item_grid.xml similarity index 100% rename from app/src/main/res/layout/photo_video_item.xml rename to app/src/main/res/layout/photo_video_item_grid.xml diff --git a/app/src/main/res/layout/photo_video_item_list.xml b/app/src/main/res/layout/photo_video_item_list.xml new file mode 100644 index 000000000..a8fdf5d21 --- /dev/null +++ b/app/src/main/res/layout/photo_video_item_list.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + +