use the new fastscroller at the filepicker dialog
This commit is contained in:
parent
6eb890b43b
commit
4c911ca5e6
3 changed files with 24 additions and 20 deletions
|
@ -12,6 +12,7 @@ import com.bumptech.glide.load.resource.bitmap.CenterCrop
|
|||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
||||
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||
import com.simplemobiletools.commons.R
|
||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
|
@ -24,7 +25,7 @@ import java.util.*
|
|||
class FilepickerItemsAdapter(
|
||||
activity: BaseSimpleActivity, val fileDirItems: List<FileDirItem>, recyclerView: MyRecyclerView,
|
||||
itemClick: (Any) -> Unit
|
||||
) : MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) {
|
||||
) : MyRecyclerViewAdapter(activity, recyclerView, null, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate {
|
||||
|
||||
private lateinit var fileDrawable: Drawable
|
||||
private lateinit var folderDrawable: Drawable
|
||||
|
@ -32,6 +33,8 @@ class FilepickerItemsAdapter(
|
|||
private val hasOTGConnected = activity.hasOTGConnected()
|
||||
private var fontSize = 0f
|
||||
private val cornerRadius = resources.getDimension(R.dimen.rounded_corner_radius_small).toInt()
|
||||
private val dateFormat = activity.baseConfig.dateFormat
|
||||
private val timeFormat = activity.getTimeFormat()
|
||||
|
||||
init {
|
||||
initDrawables()
|
||||
|
@ -144,4 +147,6 @@ class FilepickerItemsAdapter(
|
|||
fileDrawable = resources.getDrawable(R.drawable.ic_file_generic)
|
||||
fileDrawables = getFilePlaceholderDrawables(activity)
|
||||
}
|
||||
|
||||
override fun onChange(position: Int) = fileDirItems.getOrNull(position)?.getBubbleText(activity, dateFormat, timeFormat) ?: ""
|
||||
}
|
||||
|
|
|
@ -43,8 +43,6 @@ class FilePickerDialog(
|
|||
private var mFirstUpdate = true
|
||||
private var mPrevPath = ""
|
||||
private var mScrollStates = HashMap<String, Parcelable>()
|
||||
private val mDateFormat = activity.baseConfig.dateFormat
|
||||
private val mTimeFormat = activity.getTimeFormat()
|
||||
|
||||
private lateinit var mDialog: AlertDialog
|
||||
private var mDialogView = activity.layoutInflater.inflate(R.layout.dialog_filepicker, null)
|
||||
|
@ -103,6 +101,8 @@ class FilePickerDialog(
|
|||
(layoutParams as CoordinatorLayout.LayoutParams).bottomMargin = secondaryFabBottomMargin
|
||||
}
|
||||
|
||||
val adjustedPrimaryColor = activity.getAdjustedPrimaryColor()
|
||||
mDialogView.filepicker_fastscroller.updateColors(adjustedPrimaryColor, adjustedPrimaryColor.getContrastColor())
|
||||
mDialogView.filepicker_fab_show_hidden.apply {
|
||||
beVisibleIf(!showHidden && canAddShowHiddenButton)
|
||||
setOnClickListener {
|
||||
|
@ -183,18 +183,12 @@ class FilePickerDialog(
|
|||
mDialogView.apply {
|
||||
filepicker_list.adapter = adapter
|
||||
filepicker_breadcrumbs.setBreadcrumb(currPath)
|
||||
filepicker_fastscroller.setViews(filepicker_list) {
|
||||
filepicker_fastscroller.updateBubbleText(sortedItems.getOrNull(it)?.getBubbleText(context, mDateFormat, mTimeFormat) ?: "")
|
||||
}
|
||||
|
||||
if (context.areSystemAnimationsEnabled) {
|
||||
filepicker_list.scheduleLayoutAnimation()
|
||||
}
|
||||
|
||||
layoutManager.onRestoreInstanceState(mScrollStates[currPath.trimEnd('/')])
|
||||
filepicker_list.onGlobalLayout {
|
||||
filepicker_fastscroller.setScrollToY(filepicker_list.computeVerticalScrollOffset())
|
||||
}
|
||||
}
|
||||
|
||||
mFirstUpdate = false
|
||||
|
|
|
@ -25,27 +25,32 @@
|
|||
android:paddingEnd="@dimen/small_margin"
|
||||
android:paddingBottom="@dimen/small_margin" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/filepicker_list"
|
||||
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||
android:id="@+id/filepicker_fastscroller"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/filepicker_breadcrumbs"
|
||||
android:layoutAnimation="@anim/layout_animation"
|
||||
android:scrollbars="none"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/filepicker_breadcrumbs">
|
||||
|
||||
<com.simplemobiletools.commons.views.FastScroller
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/filepicker_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layoutAnimation="@anim/layout_animation"
|
||||
android:scrollbars="none"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||
|
||||
</com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
|
||||
|
||||
<!--<com.simplemobiletools.commons.views.FastScroller
|
||||
android:id="@+id/filepicker_fastscroller"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignTop="@+id/filepicker_list"
|
||||
android:layout_alignBottom="@+id/filepicker_list"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:paddingStart="@dimen/normal_margin">
|
||||
|
||||
<include layout="@layout/fastscroller_handle_vertical" />
|
||||
|
||||
</com.simplemobiletools.commons.views.FastScroller>
|
||||
</com.simplemobiletools.commons.views.FastScroller>-->
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
|
|
Loading…
Reference in a new issue