Created
February 15, 2017 01:13
-
-
Save lawloretienne/0d15233208b6242594d9be29aa3cc8dc to your computer and use it in GitHub Desktop.
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 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