add the fast scroll to directory view too

This commit is contained in:
tibbi 2017-03-04 20:26:43 +01:00
parent 084d685993
commit 956ffafe9e
5 changed files with 32 additions and 14 deletions

View file

@ -64,7 +64,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
mIsThirdPartyIntent = mIsPickImageIntent || mIsPickVideoIntent || mIsGetImageContentIntent || mIsGetVideoContentIntent ||
mIsGetAnyContentIntent || mIsSetWallpaperIntent
directories_holder.setOnRefreshListener({ getDirectories() })
directories_refresh_layout.setOnRefreshListener({ getDirectories() })
mDirs = ArrayList<Directory>()
mStoredAnimateGifs = config.animateGifs
storeStoragePaths()
@ -107,7 +107,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
super.onPause()
mCurrAsyncTask?.shouldStop = true
storeDirectories()
directories_holder.isRefreshing = false
directories_refresh_layout.isRefreshing = false
mIsGettingDirs = false
mStoredAnimateGifs = config.animateGifs
}
@ -152,7 +152,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
val token = object : TypeToken<List<Directory>>() {}.type
val dirs = Gson().fromJson<ArrayList<Directory>>(config.directories, token) ?: ArrayList<Directory>(1)
if (dirs.size == 0) {
directories_holder.isRefreshing = true
directories_refresh_layout.isRefreshing = true
} else {
gotDirectories(dirs)
}
@ -324,7 +324,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
}
fun gotDirectories(dirs: ArrayList<Directory>) {
directories_holder.isRefreshing = false
directories_refresh_layout.isRefreshing = false
mIsGettingDirs = false
if (dirs.hashCode() == mDirs.hashCode())
@ -347,6 +347,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
}
directories_grid.adapter = adapter
directories_fastscroller.setViews(directories_grid, directories_refresh_layout)
}
override fun refreshItems() {

View file

@ -54,7 +54,7 @@ class FastScroller : LinearLayout {
}
private fun updateHandlePosition() {
if (handle.isSelected)
if (handle.isSelected || recyclerView == null)
return
val verticalScrollOffset = recyclerView!!.computeVerticalScrollOffset()

View file

@ -2,16 +2,31 @@
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/directories_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/directories_holder"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content">
<com.simplemobiletools.gallery.views.MyScalableRecyclerView
android:id="@+id/directories_grid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:scrollbars="none"
app:layoutManager="android.support.v7.widget.GridLayoutManager"
app:spanCount="@integer/directory_columns"/>
<com.simplemobiletools.gallery.views.FastScroller
android:id="@+id/directories_fastscroller"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:paddingLeft="@dimen/normal_margin"
android:paddingStart="@dimen/normal_margin"/>
</RelativeLayout>
</android.support.v4.widget.SwipeRefreshLayout>

View file

@ -25,7 +25,8 @@
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:paddingLeft="@dimen/normal_margin"/>
android:paddingLeft="@dimen/normal_margin"
android:paddingStart="@dimen/normal_margin"/>
</RelativeLayout>
</android.support.v4.widget.SwipeRefreshLayout>

View file

@ -8,6 +8,7 @@
android:id="@+id/fastscroller_handle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0"
android:background="@drawable/fastscroller_handle"/>
</merge>