realm / realm-android-adapters

Adapters for combining Realm Java with Android UI components and framework classes
realm.io
Apache License 2.0
414 stars 134 forks source link

How do I detect OnScrolled in RecycleView with RealmRecyclerViewAdapter? It won't call #167

Open LeeSeungYongg opened 10 months ago

LeeSeungYongg commented 10 months ago

What do you want to achieve?

In RecycleView with Realm data, I need to detect the last item currently see through scrolling. So I added the listener so that RecycleView can check onScrolled.

Expected Results

Detecting onScrolled method

Actual Results

onScrolled is not called.. How do I detect OnScrolled in RecycleView with RealmRecyclerViewAdapter??

Code Sample


receivedAdapter = TestListAdapter(this@NotificationsActivity, receivedNotiRealmResults)
recyclerView.adapter = receivedAdapter
recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
    override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
        super.onScrolled(recyclerView, dx, dy)
        //TODO: check. but is not called.
    }
})

class TestListAdapter(internal var activity: Activity, data: OrderedRealmCollection<TestNotification>)
    : RealmRecyclerViewAdapter<TestNotification, TestListAdapter.MyViewHolder>(data, true) {
    ....
    }

Version of Realm and tooling

Realm version(s): 10.16.1 and adapter is 4.0.0

Android Studio version: Giraffe 2022.3.1 Patch3

device: Android 12