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 { ...@@ -230,6 +230,8 @@ public class CalendarFragment extends BaseFragment {
@Override @Override
public void onResponse(Call<NewsFeedResponse> call, Response<NewsFeedResponse> response) { public void onResponse(Call<NewsFeedResponse> call, Response<NewsFeedResponse> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
if (getActivity() == null || getView() == null) return;
// Concatenate the response // Concatenate the response
NewsFeedResponse newsFeedResponse = response.body(); NewsFeedResponse newsFeedResponse = response.body();
List<Event> eventList = newsFeedResponse.getEvents(); List<Event> eventList = newsFeedResponse.getEvents();
......
...@@ -231,7 +231,7 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -231,7 +231,7 @@ public class MapFragment extends Fragment implements TextWatcher,
@Override @Override
public void onResponse(Call<List<Venue>> call, Response<List<Venue>> response) { public void onResponse(Call<List<Venue>> call, Response<List<Venue>> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
if (getActivity() == null || getView() == null) return; if (getActivity() == null || getView() == null || getContext() == null) return;
// Setup fade animation for background // Setup fade animation for background
int colorFrom = Utils.getAttrColor(getContext(), R.attr.themeColor); int colorFrom = Utils.getAttrColor(getContext(), R.attr.themeColor);
...@@ -241,6 +241,7 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -241,6 +241,7 @@ public class MapFragment extends Fragment implements TextWatcher,
colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override @Override
public void onAnimationUpdate(ValueAnimator animator) { public void onAnimationUpdate(ValueAnimator animator) {
if (getActivity() == null || getView() == null) return;
getView().findViewById(R.id.main_container).setBackgroundColor( getView().findViewById(R.id.main_container).setBackgroundColor(
(int) animator.getAnimatedValue() (int) animator.getAnimatedValue()
); );
...@@ -249,6 +250,7 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -249,6 +250,7 @@ public class MapFragment extends Fragment implements TextWatcher,
colorAnimation.start(); colorAnimation.start();
// Show the location fab // Show the location fab
if (getView() == null) return;
((FloatingActionButton) getView().findViewById(R.id.locate_fab)).show(); ((FloatingActionButton) getView().findViewById(R.id.locate_fab)).show();
// Show the map and data // Show the map and data
......
...@@ -116,6 +116,7 @@ public class UserFragment extends BackHandledFragment implements TransitionTarge ...@@ -116,6 +116,7 @@ public class UserFragment extends BackHandledFragment implements TransitionTarge
@Override @Override
public void onResponse(Call<User> call, Response<User> response) { public void onResponse(Call<User> call, Response<User> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
if (getActivity() == null || getView() == null) return;
user = response.body(); user = response.body();
populateViews(); populateViews();
getActivity().findViewById(R.id.loadingPanel).setVisibility(View.GONE); getActivity().findViewById(R.id.loadingPanel).setVisibility(View.GONE);
...@@ -145,6 +146,8 @@ public class UserFragment extends BackHandledFragment implements TransitionTarge ...@@ -145,6 +146,8 @@ public class UserFragment extends BackHandledFragment implements TransitionTarge
} }
private void populateViews() { private void populateViews() {
if (getActivity() == null || getView() == null) return;
userProfilePictureImageView = getActivity().findViewById(R.id.user_profile_picture_profile); userProfilePictureImageView = getActivity().findViewById(R.id.user_profile_picture_profile);
TextView userNameTextView = getActivity().findViewById(R.id.user_name_profile); TextView userNameTextView = getActivity().findViewById(R.id.user_name_profile);
TextView userRollNumberTextView = getActivity().findViewById(R.id.user_rollno_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