DzmitrySlutskiy / EpamTraining2019

28 stars 20 forks source link

Homework 14.03 recycler view @egorikftp #111

Closed DoTheMonkeyBusiness closed 5 years ago

DoTheMonkeyBusiness commented 5 years ago

@egorikftp

RecyclerView: https://github.com/DoTheMonkeyBusiness/EpamAndroid/pull/6

@egorikftp when I change the screen rotation, the StudentWebService class is recreated and because of this the recycler does not save its state and errors occur.

DoTheMonkeyBusiness commented 5 years ago

@egorikftp I don't understand why, but when I go to the end of the list sometimes I get this error, help me fix it.

Screenshot_1

egorikftp commented 5 years ago

@DoTheMonkeyBusiness I will check your homework soon and found the root problem

DoTheMonkeyBusiness commented 5 years ago

@egorikftp Why 3 and 2 here if it should be 2 and 1?

image

egorikftp commented 5 years ago

@DoTheMonkeyBusiness

  1. RecyclerView doesn't save state (I see that you don't register your application in a manifest). Also in the final project, you won't allow using Koin library. I suggest trying to make your web service as singleton
  2. App crashes when I enter some text in student name and click Ok

About your crash above) Please try to make this code and scroll to the bottom of recyclerview and you will see what's wrong with your behavior. image

DoTheMonkeyBusiness commented 5 years ago

@egorikftp redid🙋‍♂️, now the app doesn't crash, but i'm don't understand this:

RecyclerView doesn't save state (I see that you don't register your application in a manifest).

egorikftp commented 5 years ago

@DoTheMonkeyBusiness I mean, that you told that after a rotation change your web service recreate. After that, I suggested you use Koin library. Then you added this di library into your project, but your service still recreates, all data pass to recycler view once again. In this case scroll position not save after rotation.

DoTheMonkeyBusiness commented 5 years ago

@egorikftp Redid🙋‍♂️

egorikftp commented 5 years ago

@DoTheMonkeyBusiness Done successfully