implementing the media bubble text fetcher

This commit is contained in:
tibbi 2021-11-29 20:10:13 +01:00
parent 45fe153d54
commit daf9834d39
4 changed files with 56 additions and 64 deletions

View file

@ -61,8 +61,6 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
private var mLoadedInitialPhotos = false private var mLoadedInitialPhotos = false
private var mIsSearchOpen = false private var mIsSearchOpen = false
private var mLastSearchedText = "" private var mLastSearchedText = ""
private var mDateFormat = ""
private var mTimeFormat = ""
private var mLatestMediaId = 0L private var mLatestMediaId = 0L
private var mLatestMediaDateId = 0L private var mLatestMediaDateId = 0L
private var mLastMediaHandler = Handler() private var mLastMediaHandler = Handler()
@ -125,9 +123,6 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
mDateFormat = config.dateFormat
mTimeFormat = getTimeFormat()
if (mStoredAnimateGifs != config.animateGifs) { if (mStoredAnimateGifs != config.animateGifs) {
getMediaAdapter()?.updateAnimateGifs(config.animateGifs) getMediaAdapter()?.updateAnimateGifs(config.animateGifs)
} }
@ -167,6 +162,11 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
media_fastscroller.updateColors(adjustedPrimaryColor) media_fastscroller.updateColors(adjustedPrimaryColor)
media_refresh_layout.isEnabled = config.enablePullToRefresh media_refresh_layout.isEnabled = config.enablePullToRefresh
getMediaAdapter()?.apply {
dateFormat = config.dateFormat
timeFormat = getTimeFormat()
}
media_empty_text_placeholder.setTextColor(config.textColor) media_empty_text_placeholder.setTextColor(config.textColor)
media_empty_text_placeholder_2.setTextColor(getAdjustedPrimaryColor()) media_empty_text_placeholder_2.setTextColor(getAdjustedPrimaryColor())
@ -459,15 +459,6 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
}*/ }*/
} }
private fun getBubbleTextItem(index: Int, sorting: Int): String {
var realIndex = index
val mediaAdapter = getMediaAdapter()
if (mediaAdapter?.isASectionTitle(index) == true) {
realIndex++
}
return mediaAdapter?.getItemBubbleText(realIndex, sorting, mDateFormat, mTimeFormat) ?: ""
}
private fun checkLastMediaChanged() { private fun checkLastMediaChanged() {
if (isDestroyed || config.getFolderSorting(mPath) and SORT_BY_RANDOM != 0) { if (isDestroyed || config.getFolderSorting(mPath) and SORT_BY_RANDOM != 0) {
return return
@ -688,7 +679,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
} }
private fun setupGridLayoutManager() { private fun setupGridLayoutManager() {
val layoutManager = media_grid.layoutManager as MyGridLayoutManager /*val layoutManager = media_grid.layoutManager as MyGridLayoutManager
(media_grid.layoutParams as RelativeLayout.LayoutParams).apply { (media_grid.layoutParams as RelativeLayout.LayoutParams).apply {
topMargin = 0 topMargin = 0
bottomMargin = 0 bottomMargin = 0
@ -712,7 +703,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
1 1
} }
} }
} }*/
} }
private fun measureRecyclerViewContent(media: ArrayList<ThumbnailItem>) { private fun measureRecyclerViewContent(media: ArrayList<ThumbnailItem>) {
@ -810,7 +801,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
} }
private fun setupListLayoutManager() { private fun setupListLayoutManager() {
val layoutManager = media_grid.layoutManager as MyGridLayoutManager /*val layoutManager = media_grid.layoutManager as MyGridLayoutManager
layoutManager.spanCount = 1 layoutManager.spanCount = 1
layoutManager.orientation = RecyclerView.VERTICAL layoutManager.orientation = RecyclerView.VERTICAL
media_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) media_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
@ -821,7 +812,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
bottomMargin = smallMargin bottomMargin = smallMargin
} }
mZoomListener = null mZoomListener = null*/
} }
private fun increaseColumnCount() { private fun increaseColumnCount() {

View file

@ -248,15 +248,6 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
}*/ }*/
} }
private fun getBubbleTextItem(index: Int, sorting: Int): String {
var realIndex = index
val mediaAdapter = getMediaAdapter()
if (mediaAdapter?.isASectionTitle(index) == true) {
realIndex++
}
return mediaAdapter?.getItemBubbleText(realIndex, sorting, mDateFormat, mTimeFormat) ?: ""
}
private fun measureRecyclerViewContent(media: ArrayList<ThumbnailItem>) { private fun measureRecyclerViewContent(media: ArrayList<ThumbnailItem>) {
media_grid.onGlobalLayout { media_grid.onGlobalLayout {
if (config.scrollHorizontally) { if (config.scrollHorizontally) {

View file

@ -12,6 +12,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Toast import android.widget.Toast
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
import com.simplemobiletools.commons.dialogs.PropertiesDialog import com.simplemobiletools.commons.dialogs.PropertiesDialog
@ -43,7 +44,7 @@ class MediaAdapter(
activity: BaseSimpleActivity, var media: ArrayList<ThumbnailItem>, val listener: MediaOperationsListener?, val isAGetIntent: Boolean, activity: BaseSimpleActivity, var media: ArrayList<ThumbnailItem>, val listener: MediaOperationsListener?, val isAGetIntent: Boolean,
val allowMultiplePicks: Boolean, val path: String, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit val allowMultiplePicks: Boolean, val path: String, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit
) : ) :
MyRecyclerViewAdapter(activity, recyclerView, itemClick) { MyRecyclerViewAdapter(activity, recyclerView, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate {
private val INSTANT_LOAD_DURATION = 2000L private val INSTANT_LOAD_DURATION = 2000L
private val IMAGE_LOAD_DELAY = 100L private val IMAGE_LOAD_DELAY = 100L
@ -67,6 +68,10 @@ class MediaAdapter(
private var displayFilenames = config.displayFileNames private var displayFilenames = config.displayFileNames
private var showFileTypes = config.showThumbnailFileTypes private var showFileTypes = config.showThumbnailFileTypes
var sorting = config.getFolderSorting(if (config.showAll) SHOW_ALL else path)
var dateFormat = config.dateFormat
var timeFormat = activity.getTimeFormat()
init { init {
setupDragListener(true) setupDragListener(true)
enableInstantLoad() enableInstantLoad()
@ -508,10 +513,6 @@ class MediaAdapter(
}, INSTANT_LOAD_DURATION) }, INSTANT_LOAD_DURATION)
} }
fun getItemBubbleText(position: Int, sorting: Int, dateFormat: String, timeFormat: String): String {
return (media[position] as? Medium)?.getBubbleText(sorting, activity, dateFormat, timeFormat) ?: ""
}
private fun setupThumbnail(view: View, medium: Medium) { private fun setupThumbnail(view: View, medium: Medium) {
val isSelected = selectedKeys.contains(medium.path.hashCode()) val isSelected = selectedKeys.contains(medium.path.hashCode())
view.apply { view.apply {
@ -608,4 +609,13 @@ class MediaAdapter(
thumbnail_section.setTextColor(textColor) thumbnail_section.setTextColor(textColor)
} }
} }
override fun onChange(position: Int): String {
var realIndex = position
if (isASectionTitle(position)) {
realIndex++
}
return (media[realIndex] as? Medium)?.getBubbleText(sorting, activity, dateFormat, timeFormat) ?: ""
}
} }

View file

@ -1,11 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/media_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/media_holder" android:id="@+id/media_holder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
@ -36,6 +31,11 @@
android:textSize="@dimen/bigger_text_size" android:textSize="@dimen/bigger_text_size"
android:visibility="gone" /> android:visibility="gone" />
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/media_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller <com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
android:id="@+id/media_fastscroller" android:id="@+id/media_fastscroller"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -52,5 +52,5 @@
app:spanCount="@integer/media_columns_vertical_scroll" /> app:spanCount="@integer/media_columns_vertical_scroll" />
</com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller> </com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
</RelativeLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</RelativeLayout>