In my android app, I'm getting some locations when I choose the first element(anyone of the list) from RecyclerView it works and it gives location normally, but when I go back to choose another one it gives me NPE.
First example:
- I choose the second element (it works).
- I go back to choose another one.
- I choose the first element(gives NPE).
Second example:
- I choose the first element (it works). 
- I go back to choose another one. 
- I choose the second element(gives NPE). 
My code:
private SupportMapFragment mapFragment;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    view = inflater.inflate(R.layout.fragment_sales_item, container, false);
    if(getArguments()!=null)
    {
        saleID = getArguments().getString("saleID");
    }
    initIDs();
   retroFit();
    maps();
    return view;
}
public void retroFit(){
    Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(ServiceConstants.URL)
            .addConverterFactory(GsonConverterFactory.create())
            .build();
    RoyalAPI royalAPI = retrofit.create(RoyalAPI.class);
    Call<SaleItemResponse> connection = royalAPI.getSaleItem(saleID);
    connection.enqueue(new Callback<SaleItemResponse>() {
        @Override
        public void onResponse(Call<SaleItemResponse> call, Response<SaleItemResponse> response) {
            List<SaleItem> posts = response.body().getData();
            latitude = posts.get(0).getLatitude();
            longitude = posts.get(0).getLongitude();
        }
        @Override
        public void onFailure(Call<SaleItemResponse> call, Throwable t) {
        }
    });
}
private void map(){
    if (mapFragment == null) {
        mapFragment = SupportMapFragment.newInstance();
        mapFragment.getMapAsync(new OnMapReadyCallback() {
            @Override
            public void onMapReady(GoogleMap googleMap) {
                LatLng latLng = new LatLng(Double.parseDouble(latitude), Double.parseDouble(longitude));
                googleMap.addMarker(new MarkerOptions().position(latLng)
                        .title(""));
                googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
            }
        });
    }
    // R.id.map is a FrameLayout, not a Fragment
    getChildFragmentManager().beginTransaction().replace(R.id.map_sales, mapFragment).commit();
}
.
public class SaleItemResponse {
@SerializedName("data")
private List<SaleItem> mData;
@SerializedName("state")
private Long mState;
public List<SaleItem> getData() {
    return mData;
}
public void setData(List<SaleItem> data) {
    mData = data;
}
public Long getState() {
    return mState;
}
public void setState(Long state) {
    mState = state;
}
}
.
public class SaleItem {
@SerializedName("latitude")
private String mLatitude;
@SerializedName("longitude")
public String getLatitude() {
    return mLatitude;
}
public void setLatitude(String latitude) {
    mLatitude = latitude;
}
public String getLongitude() {
    return mLongitude;
}
public void setLongitude(String longitude) {
    mLongitude = longitude;
}
}
 
    