Skip to content

Instantly share code, notes, and snippets.

@lawloretienne
Created February 15, 2017 01:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lawloretienne/0d15233208b6242594d9be29aa3cc8dc to your computer and use it in GitHub Desktop.
Save lawloretienne/0d15233208b6242594d9be29aa3cc8dc to your computer and use it in GitHub Desktop.
public abstract class BaseFragment extends Fragment {
// region Member Variables
protected List<Call> calls;
// endregion
// region Lifecycle Methods
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
calls = new ArrayList<>();
}
@Override
public void onDestroyView() {
super.onDestroyView();
for (final Call call : calls) {
try {
call.cancel();
} catch (NetworkOnMainThreadException e) {
e.printStackTrace();
}
}
calls.clear();
}
// region
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment