Created
January 3, 2018 06:59
-
-
Save wightwulf1944/5c95b35e64c14d92d1da7dbe448d937d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MasterActivity extends AppCompatActivity { | |
private MainViewModel viewModel; | |
@Override | |
protected void onCreate(@Nullable Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
viewModel = ViewModelProviders.of(this).get(MainViewModel.class); | |
if (savedInstanceState != null) { | |
String dataId = savedInstanceState.getString("dataId"); | |
viewModel.setDataId(dataId); | |
} | |
} | |
@Override | |
protected void onPause() { | |
super.onPause(); | |
viewModel.onPause(); | |
} | |
@Override | |
protected void onSaveInstanceState(Bundle outState) { | |
super.onSaveInstanceState(outState); | |
String dataId = viewModel.getDataId(); | |
outState.putString("dataId", dataId); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment