Commit cbac1a8e authored by Varun Patil's avatar Varun Patil

Add some null checks

parent ecafd9b9
......@@ -230,6 +230,8 @@ public class CalendarFragment extends BaseFragment {
@Override
public void onResponse(Call<NewsFeedResponse> call, Response<NewsFeedResponse> response) {
if (response.isSuccessful()) {
if (getActivity() == null || getView() == null) return;
// Concatenate the response
NewsFeedResponse newsFeedResponse = response.body();
List<Event> eventList = newsFeedResponse.getEvents();
......
......@@ -231,7 +231,7 @@ public class MapFragment extends Fragment implements TextWatcher,
@Override
public void onResponse(Call<List<Venue>> call, Response<List<Venue>> response) {
if (response.isSuccessful()) {
if (getActivity() == null || getView() == null) return;
if (getActivity() == null || getView() == null || getContext() == null) return;
// Setup fade animation for background
int colorFrom = Utils.getAttrColor(getContext(), R.attr.themeColor);
......@@ -241,6 +241,7 @@ public class MapFragment extends Fragment implements TextWatcher,
colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animator) {
if (getActivity() == null || getView() == null) return;
getView().findViewById(R.id.main_container).setBackgroundColor(
(int) animator.getAnimatedValue()
);
......@@ -249,6 +250,7 @@ public class MapFragment extends Fragment implements TextWatcher,
colorAnimation.start();
// Show the location fab
if (getView() == null) return;
((FloatingActionButton) getView().findViewById(R.id.locate_fab)).show();
// Show the map and data
......
......@@ -116,6 +116,7 @@ public class UserFragment extends BackHandledFragment implements TransitionTarge
@Override
public void onResponse(Call<User> call, Response<User> response) {
if (response.isSuccessful()) {
if (getActivity() == null || getView() == null) return;
user = response.body();
populateViews();
getActivity().findViewById(R.id.loadingPanel).setVisibility(View.GONE);
......@@ -145,6 +146,8 @@ public class UserFragment extends BackHandledFragment implements TransitionTarge
}
private void populateViews() {
if (getActivity() == null || getView() == null) return;
userProfilePictureImageView = getActivity().findViewById(R.id.user_profile_picture_profile);
TextView userNameTextView = getActivity().findViewById(R.id.user_name_profile);
TextView userRollNumberTextView = getActivity().findViewById(R.id.user_rollno_profile);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment