Skip to content

Commit

Permalink
added supoort to detect current visible item position
Browse files Browse the repository at this point in the history
  • Loading branch information
Kunalapk committed Jan 10, 2021
1 parent 7b8a6dd commit c8a2137
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class SmartRecyclerView<T> : SwipeRefreshLayout {
private var videoSurfaceDefaultHeight = 0
private var screenDefaultHeight = 0
private var mCurrentItemLocation = IntArray(2)
private var mActivity:AppCompatActivity? = null


constructor(context: Context):super(context){ }
Expand Down Expand Up @@ -82,7 +81,6 @@ class SmartRecyclerView<T> : SwipeRefreshLayout {
fun initSmartRecyclerView(activity: AppCompatActivity, smartRecyclerViewListener: SmartRecyclerViewListener<T>, isPaginated: Boolean, layoutManager: RecyclerView.LayoutManager){
this.smartRecyclerViewListener = smartRecyclerViewListener
this.isPaginated = isPaginated
this.mActivity = activity
this.setOnRefreshListener(onRefreshListener)
attachAdapterToRecyclerView(activity, smartRecyclerViewListener, layoutManager)
}
Expand All @@ -106,10 +104,10 @@ class SmartRecyclerView<T> : SwipeRefreshLayout {
}

fun detectCurrentVisibleItem(detectCurrentVisibleItem: Boolean){
if(mActivity!=null && detectCurrentVisibleItem){
if(mActivity?.getSystemService(Context.WINDOW_SERVICE) is WindowManager){
if(detectCurrentVisibleItem){
if(context?.getSystemService(Context.WINDOW_SERVICE) is WindowManager){
val point = Point()
(mActivity?.getSystemService(Context.WINDOW_SERVICE) as WindowManager).defaultDisplay.getSize(point)
(context?.getSystemService(Context.WINDOW_SERVICE) as WindowManager).defaultDisplay.getSize(point)
videoSurfaceDefaultHeight = point.x
screenDefaultHeight = point.y
recyclerView?.addOnScrollListener(onScrollListener)
Expand Down

0 comments on commit c8a2137

Please sign in to comment.