use a quicker way of formatting date and time at scrolling

This commit is contained in:
tibbi 2020-04-23 20:23:15 +02:00
parent f91c632a52
commit d55dc217c9
3 changed files with 20 additions and 2 deletions

View file

@ -58,7 +58,7 @@ android {
}
dependencies {
implementation 'com.simplemobiletools:commons:5.26.21'
implementation 'com.simplemobiletools:commons:5.26.23'
implementation 'com.github.Stericson:RootTools:df729dcb13'
implementation 'com.github.Stericson:RootShell:1.6'
implementation 'com.alexvasilkov:gesture-views:2.5.2'

View file

@ -62,6 +62,8 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
private val hasOTGConnected = activity.hasOTGConnected()
private var fontSize = 0f
private var smallerFontSize = 0f
private var dateFormat = ""
private var timeFormat = ""
var adjustedPrimaryColor = activity.getAdjustedPrimaryColor()
@ -69,6 +71,8 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
setupDragListener(true)
initDrawables()
updateFontSizes()
dateFormat = activity.config.dateFormat
timeFormat = activity.getTimeFormat()
}
override fun getActionMenuId() = R.menu.cab
@ -662,6 +666,12 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
notifyDataSetChanged()
}
fun updateDateTimeFormat() {
dateFormat = activity.config.dateFormat
timeFormat = activity.getTimeFormat()
notifyDataSetChanged()
}
override fun onViewRecycled(holder: ViewHolder) {
super.onViewRecycled(holder)
if (!activity.isDestroyed && !activity.isFinishing) {
@ -699,7 +709,7 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
} else {
item_details.text = listItem.size.formatSize()
item_date.beVisible()
item_date.text = listItem.modified.formatDate(activity)
item_date.text = listItem.modified.formatDate(activity, dateFormat, timeFormat)
val drawable = fileDrawables.getOrElse(fileName.substringAfterLast(".").toLowerCase(), { fileDrawable })
val options = RequestOptions()

View file

@ -47,6 +47,8 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
private var storedItems = ArrayList<ListItem>()
private var storedTextColor = 0
private var storedFontSize = 0
private var storedDateFormat = ""
private var storedTimeFormat = ""
lateinit var mView: View
@ -101,6 +103,10 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
mView.breadcrumbs.updateFontSize(context!!.getTextSize())
}
if (storedDateFormat != context!!.config.dateFormat || storedTimeFormat != context!!.getTimeFormat()) {
getRecyclerAdapter()?.updateDateTimeFormat()
}
mView.items_fastscroller.updateBubbleColors()
mView.items_fastscroller.allowBubbleDisplay = true
if (!isFirstResume) {
@ -119,6 +125,8 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
context!!.config.apply {
storedTextColor = textColor
storedFontSize = fontSize
storedDateFormat = dateFormat
storedTimeFormat = context.getTimeFormat()
}
}