Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialCarlos Monteiro
Courses Plus Student 4,758 PointsI loose my todo list items when device orientation changes.
Is there a better way to handle orientation changes within RxJava?
2 Answers
Xi Tao
3,221 PointsThat's one of the problems with the RxJava model, data is not shown until the data actually changes. So in this case after rotation no changes have been made to the data as a result there is no need to update the view, which is left blank. Now not only do you have to write a bunch of RxJava to push data to your views you still have to write a bunch of code to actually pull the data when you rebuild your view (on Rotation). Which makes RxJava sort of pointless in some situations. There are actually fewer push models of data that actually model your problem, and most of the time you can get away with a pull model.
The additional work to fix this problem is to code in the part where you pull data from your SavedInstanceState.
Daniel Ramirez
15,044 PointsIf you want a quick fix (although I'm not sure this is the right fix), you can simply change the constructor for TodoAdapter to this:
public TodoAdapter(Activity activity, TodoList todoList) {
inflater = LayoutInflater.from(activity);
subscriber = todoList;
data = todoList.getAll();
}
Michael Overman
5,474 PointsMichael Overman
5,474 PointsI do, too, sort of. The list still exists, but it is not visible until I add a new item, at which point the entire list reappears, with the new item. Can't figure out what's going on...