@@ -84,19 +84,6 @@ public class TasksController extends BaseController
8484
8585 private ControllerResult mControllerResult ;
8686
87- public TasksController () {
88- }
89-
90- /**
91- * This constructor is used by Conductor to recreate the Controller if it has been destroyed.
92- *
93- * @param args The {@link Bundle} object containing the previous state of the Controller.
94- */
95- public TasksController (Bundle args ) {
96- super (args );
97- mCurrentFiltering = (TasksFilterType ) args .getSerializable (CURRENT_FILTERING_KEY );
98- }
99-
10087 @ NonNull
10188 @ Override
10289 protected View onCreateView (@ NonNull LayoutInflater inflater , @ NonNull ViewGroup container ) {
@@ -175,7 +162,6 @@ private void setupPresenter() {
175162 if (mCurrentFiltering != null ) {
176163 mPresenter .setFiltering (mCurrentFiltering );
177164 }
178-
179165 }
180166
181167 @ Override
@@ -200,12 +186,26 @@ protected void onAttach(@NonNull View view) {
200186 }
201187 }
202188
189+ @ Override
190+ protected void onDetach (@ NonNull View view ) {
191+ super .onDetach (view );
192+ // The Controller is kept in a retained Fragment during configuration changes, just save the
193+ // to a member variable.
194+ mCurrentFiltering = mPresenter .getFiltering ();
195+ }
196+
203197 @ Override
204198 protected void onSaveInstanceState (@ NonNull Bundle outState ) {
205199 super .onSaveInstanceState (outState );
206200 outState .putSerializable (CURRENT_FILTERING_KEY , mPresenter .getFiltering ());
207201 }
208202
203+ @ Override
204+ protected void onRestoreInstanceState (@ NonNull Bundle savedInstanceState ) {
205+ super .onRestoreInstanceState (savedInstanceState );
206+ mCurrentFiltering = (TasksFilterType ) savedInstanceState .getSerializable (CURRENT_FILTERING_KEY );
207+ }
208+
209209 @ Override
210210 public boolean onOptionsItemSelected (MenuItem item ) {
211211 switch (item .getItemId ()) {
0 commit comments