+ if (twoPanedMode) { // The device is in two-paned mode.
+ // Display `DomainsListFragment`.
+ DomainsListFragment domainsListFragment = new DomainsListFragment();
+ supportFragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainsListFragment).commit();
+ supportFragmentManager.executePendingTransactions();
+
+ // Populate the list of domains. `domainSettingsDatabaseId` highlights the domain that was highlighted before the rotation.
+ populateDomainsListView(goDirectlyToDatabaseId);
+ } else { // The device is in single-paned mode.
+ // Add the domain ID to be loaded to `argumentsBundle`.
+ Bundle argumentsBundle = new Bundle();
+ argumentsBundle.putInt(DomainSettingsFragment.DATABASE_ID, goDirectlyToDatabaseId);
+
+ // Add `argumentsBundle` to `domainSettingsFragment`.
+ DomainSettingsFragment domainSettingsFragment = new DomainSettingsFragment();
+ domainSettingsFragment.setArguments(argumentsBundle);
+
+ // Show `deleteMenuItem`.
+ deleteMenuItem.setVisible(true);
+
+ // Hide `add_domain_fab`.
+ addDomainFAB.hide();
+
+ // Display `domainSettingsFragment`.
+ supportFragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainSettingsFragment).commit();
+ }
+ } else { // Highlight the first domain.
+ // Display `DomainsListFragment`.
+ DomainsListFragment domainsListFragment = new DomainsListFragment();
+ supportFragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainsListFragment).commit();
+ supportFragmentManager.executePendingTransactions();
+
+ // Populate the list of domains. `-1` highlights the first domain.
+ populateDomainsListView(-1);
+ }