heecheon92 / Android-Project

Local Event App
0 stars 0 forks source link

Binding RecyclerViews and Creating Adapters #16

Open MoonWolf125 opened 5 years ago

MoonWolf125 commented 5 years ago

Standard practice is to bind all views to the class and create all adapters at the beginning of the onCreate method.

In MainActivity the RecyclerView is bound and CustomListAdapter is created in the Retrofit call. This against the standard and could cause a race condition where a the recyclerView or adapter could be referenced before they are created when the server sends a response. Using a method to set the data on the already created adapter is the best way to avoid these issues: https://github.com/heecheon92/Android-Project/blob/a05d23c117f810ca2ff297a08d27d7d918636451/FargoEventProject/app/src/main/java/activity/MainActivity.java#L110-L113