Created
July 31, 2014 05:19
-
-
Save IlyaEremin/52108a5f487e791eb71f to your computer and use it in GitHub Desktop.
static factory in fragments
This file contains hidden or 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 EditContactFragment extends Fragment { | |
// ... | |
public static EditContactFragment newInstance(Contact contact){ | |
EditContactFragment fragment = new EditContactFragment(); | |
Bundle contactInfo = new Bundle(); | |
contactInfo.putSerializable(Constants.BUNDLE_CONTACT, contact); | |
fragment.setArguments(contactInfo); | |
return fragment; | |
} | |
} | |
public class ClientClass { | |
// ... | |
fragment = EditContactFragment.newInstance(contact); | |
// ... | |
/* | |
in every client :\ | |
EditContactFragment fragment = new EditContactFragment(); | |
Bundle args = new Bundle(); | |
args.putSerializable(Constants.BUNDLE_CONTACT, contact); | |
fragment.setArguments(args); | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment