Replace Default FastScroller (Closes #79)

This commit is contained in:
LooKeR
2022-01-12 17:02:37 +05:30
parent f66d91ed9f
commit 9c82a9f7c4
11 changed files with 50 additions and 330 deletions

View File

@ -18,13 +18,14 @@ import com.looker.droidify.screen.BaseFragment
import com.looker.droidify.ui.adapters.AppListAdapter
import com.looker.droidify.ui.viewmodels.AppListViewModel
import com.looker.droidify.utility.RxUtils
import com.looker.droidify.widget.RecyclerFastScroller
import com.looker.droidify.utility.extension.resources.getDrawableCompat
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.core.Observable
import io.reactivex.rxjava3.disposables.Disposable
import io.reactivex.rxjava3.schedulers.Schedulers
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import me.zhanghai.android.fastscroll.FastScrollerBuilder
class AppListFragment() : BaseFragment(), CursorOwner.Callback {
@ -67,7 +68,10 @@ class AppListFragment() : BaseFragment(), CursorOwner.Callback {
recycledViewPool.setMaxRecycledViews(AppListAdapter.ViewType.PRODUCT.ordinal, 30)
val adapter = AppListAdapter { screenActivity.navigateProduct(it.packageName) }
this.adapter = adapter
RecyclerFastScroller(this)
FastScrollerBuilder(this)
.useMd2Style()
.setThumbDrawable(this.context.getDrawableCompat(R.drawable.scrollbar_thumb))
.build()
recyclerView = this
}
}

View File

@ -17,11 +17,12 @@ import com.looker.droidify.entity.Repository
import com.looker.droidify.ui.adapters.AppListAdapter
import com.looker.droidify.ui.viewmodels.MainNavFragmentViewModelX
import com.looker.droidify.utility.RxUtils
import com.looker.droidify.widget.RecyclerFastScroller
import com.looker.droidify.utility.extension.resources.getDrawableCompat
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.schedulers.Schedulers
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import me.zhanghai.android.fastscroll.FastScrollerBuilder
class ExploreFragment : MainNavFragmentX(), CursorOwner.Callback {
@ -51,7 +52,10 @@ class ExploreFragment : MainNavFragmentX(), CursorOwner.Callback {
setHasFixedSize(true)
recycledViewPool.setMaxRecycledViews(AppListAdapter.ViewType.PRODUCT.ordinal, 30)
adapter = AppListAdapter { mainActivityX.navigateProduct(it.packageName) }
RecyclerFastScroller(this)
FastScrollerBuilder(this)
.useMd2Style()
.setThumbDrawable(this.context.getDrawableCompat(R.drawable.scrollbar_thumb))
.build()
}
return binding.root
}

View File

@ -8,6 +8,7 @@ import android.view.ViewGroup
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.looker.droidify.R
import com.looker.droidify.database.CursorOwner
import com.looker.droidify.databinding.FragmentInstalledXBinding
import com.looker.droidify.entity.ProductItem
@ -16,11 +17,12 @@ import com.looker.droidify.ui.items.HAppItem
import com.looker.droidify.ui.items.VAppItem
import com.looker.droidify.ui.viewmodels.MainNavFragmentViewModelX
import com.looker.droidify.utility.RxUtils
import com.looker.droidify.widget.RecyclerFastScroller
import com.looker.droidify.utility.extension.resources.getDrawableCompat
import com.mikepenz.fastadapter.FastAdapter
import com.mikepenz.fastadapter.adapters.ItemAdapter
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.schedulers.Schedulers
import me.zhanghai.android.fastscroll.FastScrollerBuilder
class InstalledFragment : MainNavFragmentX(), CursorOwner.Callback {
@ -55,7 +57,10 @@ class InstalledFragment : MainNavFragmentX(), CursorOwner.Callback {
isMotionEventSplittingEnabled = false
isVerticalScrollBarEnabled = false
adapter = installedFastAdapter
RecyclerFastScroller(this)
FastScrollerBuilder(this)
.useMd2Style()
.setThumbDrawable(this.context.getDrawableCompat(R.drawable.scrollbar_thumb))
.build()
}
updatedFastAdapter = FastAdapter.with(updatedItemAdapter)
updatedFastAdapter?.setHasStableIds(true)
@ -64,7 +69,10 @@ class InstalledFragment : MainNavFragmentX(), CursorOwner.Callback {
isMotionEventSplittingEnabled = false
isVerticalScrollBarEnabled = false
adapter = updatedFastAdapter
RecyclerFastScroller(this)
FastScrollerBuilder(this)
.useMd2Style()
.setThumbDrawable(this.context.getDrawableCompat(R.drawable.scrollbar_thumb))
.build()
}
return binding.root
}

View File

@ -8,6 +8,7 @@ import android.view.ViewGroup
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.looker.droidify.R
import com.looker.droidify.database.CursorOwner
import com.looker.droidify.databinding.FragmentLatestXBinding
import com.looker.droidify.entity.ProductItem
@ -16,11 +17,12 @@ import com.looker.droidify.ui.items.HAppItem
import com.looker.droidify.ui.items.VAppItem
import com.looker.droidify.ui.viewmodels.MainNavFragmentViewModelX
import com.looker.droidify.utility.RxUtils
import com.looker.droidify.widget.RecyclerFastScroller
import com.looker.droidify.utility.extension.resources.getDrawableCompat
import com.mikepenz.fastadapter.FastAdapter
import com.mikepenz.fastadapter.adapters.ItemAdapter
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.schedulers.Schedulers
import me.zhanghai.android.fastscroll.FastScrollerBuilder
class LatestFragment : MainNavFragmentX(), CursorOwner.Callback {
@ -55,7 +57,10 @@ class LatestFragment : MainNavFragmentX(), CursorOwner.Callback {
isMotionEventSplittingEnabled = false
isVerticalScrollBarEnabled = false
adapter = updatedFastAdapter
RecyclerFastScroller(this)
FastScrollerBuilder(this)
.useMd2Style()
.setThumbDrawable(this.context.getDrawableCompat(R.drawable.scrollbar_thumb))
.build()
}
newFastAdapter = FastAdapter.with(newItemAdapter)
newFastAdapter?.setHasStableIds(true)
@ -64,7 +69,10 @@ class LatestFragment : MainNavFragmentX(), CursorOwner.Callback {
isMotionEventSplittingEnabled = false
isVerticalScrollBarEnabled = false
adapter = newFastAdapter
RecyclerFastScroller(this)
FastScrollerBuilder(this)
.useMd2Style()
.setThumbDrawable(this.context.getDrawableCompat(R.drawable.scrollbar_thumb))
.build()
}
return binding.root
}