-
-
Save OyaCanli/bb7ade590b2e45a55259b7fc09c72da5 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
//Inside fragment | |
private void saveToy() { | |
// Verify that toy name is not empty | |
if (TextUtils.isEmpty(mViewModel.getToyBeingModified().getToyName())) { | |
Toast.makeText(requireContext(), R.string.toy_empty_warning, Toast.LENGTH_SHORT).show(); | |
return; | |
} | |
mViewModel.saveToy(); | |
returnToListFragment(); | |
} | |
//Inside view model | |
public void saveToy(){ | |
if(!mIsEdit){ | |
insertToy(mToyBeingModified); | |
} else { | |
updateToy(mToyBeingModified); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment