Search code examples
androidlistviewandroid-recyclerviewuser-experience

What is the best way/UX to handle logic show item's detail from ListView/RecyclerView


I am working on a simple app with only two activity.

  • The first activity(named as StudentListActivity) have a recyclerview show the list of student. Each item is a student and list student data will get from server.
  • The second activity(named as StudentDetailActivity) is detail of specific student and be started when click on recyclerview's item in StudentListActivity.

And what I confuse is the way to get student detail data. I consider in two ways:

  1. When click on recyclerview's item in StudentListActivity, I will pass entire student object to StudentDetailActivity and show it regularly. This way will fast and alway available but come wrong in case of the student no longer exist but still show detail on StudentDetailActivity.
  2. I just pass only the student's id and call api to server in oder to get student info depend on that id. This way can avoid the case in the first way because we call to the server and ensure the student is existed on database. But it take time to call api, let user waiting for and maybe affect to user experience.

Any one tell me what is the best way/UX for that situation, or are there still other solutions. Suggest me, please!

Thanks,


Solution

  • From an UX perspective, I would do the following:

    Let's say in your RecyclerView, each item consists of a name, and image. When you navigate over to a detail activity for a specific student, I would pass on (along the id) the name and the image URL to the other activity and implement Activity Transitions. Something along the lines of:

    Source

    And from then on, I would use the id to retrieve the rest of the information. I would advise against sending large data over intents, as they were not designed for that purpose. Also if you make your Activity to depend on an object instead of an ID to start, you will have a hard time enable direct app linking and allowing users to share pages from your app. Also consider the Activity lifecycle, and what happens on configuration change. See more here, and see the following diagram:

    Source

    From an architectural perspective, I would suggest the following:

    Implement a local database, and ensure your network requests are cached properly. This will enable you more speedier results and an offline-ready application. Between your UI and data sources, implement a Repository pattern, along the lines of:

    Source