Created
September 2, 2015 13:40
-
-
Save mauricegavin/6133c25cd62da883e44a to your computer and use it in GitHub Desktop.
A template starting point for a standard Fragment
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 ReportListFragment extends Fragment { | |
//region Lifecycle methods | |
public static ReportListFragment newInstance(String userId) { | |
ReportListFragment fragment = new ReportListFragment(); | |
Bundle args = new Bundle(); | |
args.putString(Constants.USER_ID, userId); | |
fragment.setArguments(args); | |
return fragment; | |
} | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
String userId = null; | |
if (getArguments() != null) { | |
userId = getArguments().getString(Constants.USER_ID); | |
} | |
} | |
@Override | |
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | |
// Inflate the layout for this fragment | |
View view = inflater.inflate(R.layout.fragment_layout, container, false); | |
return view; | |
} | |
@Override | |
public void onDestroyView() { | |
super.onDestroyView(); | |
} | |
//endregion | |
//region Fragment callback listener declaration, binding and releasing | |
private ReportListFragmentListener mListener; | |
@Override | |
public void onAttach(Activity activity) { | |
super.onAttach(activity); | |
try { | |
mListener = (ReportListFragmentListener) activity; | |
} catch (ClassCastException e) { | |
throw new ClassCastException(activity.toString() | |
+ " must implement ReportListFragmentListener"); | |
} | |
} | |
@Override | |
public void onDetach() { | |
super.onDetach(); | |
mListener = null; | |
} | |
public interface ReportListFragmentListener { | |
/** | |
* This method requests that the parent listener Activity swaps in a DetailReportFragment | |
* @param patientCaseId the patientCaseId of the detailed report requested | |
*/ | |
public void openDetailedReport(String patientCaseId); | |
} | |
//endregion | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment