Skip to content

Commit

Permalink
added nullable activity to CustomAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
Kunalapk committed Sep 22, 2020
1 parent 09d1fbc commit 7029083
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import com.kunalapk.smartrecyclerview.listener.SmartRecyclerViewListener
import com.kunalapk.smartrecyclerview.listener.ViewAttachListener
import com.kunalapk.smartrecyclerview.model.LoaderModel

class CustomAdapter<T>(private val activity:AppCompatActivity,private val isPaginated:Boolean): RecyclerView.Adapter<CustomViewHolder<T>>() {
class CustomAdapter<T>(private val activity:AppCompatActivity?,private val isPaginated:Boolean): RecyclerView.Adapter<CustomViewHolder<T>>() {

private var isLoading = false
private val customModelList:MutableList<Any> = arrayListOf()
Expand Down Expand Up @@ -65,7 +65,7 @@ class CustomAdapter<T>(private val activity:AppCompatActivity,private val isPagi
}

override fun onBindViewHolder(holder: CustomViewHolder<T>, position: Int) {
if (position >= itemCount - 3 && !isLoading) {
if (activity!=null && position >= itemCount - 3 && !isLoading) {
val mHandler = activity.getWindow().getDecorView().getHandler()
mHandler.post(Runnable {
if(!isLoading && isPaginated){
Expand Down

0 comments on commit 7029083

Please sign in to comment.