Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.example.pppp.onex.InfoWindowData.getTitle()' on a null object reference
  2. at com.example.pppp.onex.CustomInfoWindowAdapter.getInfoContents(CustomInfoWindowAdapter.java:49)
  3.  
  4. mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
  5. @Override
  6. public boolean onMarkerClick(final Marker marker) {
  7.  
  8. db.collection("marcadores")
  9. .get()
  10. .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
  11. @Override
  12. public void onComplete(@NonNull Task<QuerySnapshot> task) {
  13. if (task.isSuccessful()) {
  14. for (final QueryDocumentSnapshot document : task.getResult()) {
  15.  
  16.  
  17. Log.d(TAG,String.valueOf(marker.getPosition().latitude));
  18.  
  19. if(String.valueOf(marker.getPosition().latitude).equals(String.valueOf(document.getData().get("latitude"))) && String.valueOf(marker.getPosition().longitude).equals(String.valueOf(document.getData().get("longitude")))){
  20.  
  21. InfoWindowData info = new InfoWindowData();
  22.  
  23. info.setTitle(marker.getId());
  24. CustomInfoWindowAdapter customInfoWindow = new CustomInfoWindowAdapter(MapsActivity.this);
  25. mMap.setInfoWindowAdapter(customInfoWindow);
  26.  
  27. marker.setTag(info);
  28. marker.showInfoWindow();
  29.  
  30. break;
  31. }
  32.  
  33. }
  34. } else {
  35. Log.w(TAG, "Error getting documents.", task.getException());
  36. }
  37. }
  38. });
  39.  
  40. return false;
  41. }
  42. });
  43.  
  44. public CustomInfoWindowAdapter(Context context){
  45. this.context = context;
  46. }
  47. @Override
  48. public View getInfoContents(final Marker m) {
  49. //Carga layout personalizado.
  50. //View v = inflater.inflate(R.layout.infowindow_layout, null);
  51. View v = ((Activity)context).getLayoutInflater()
  52. .inflate(R.layout.infowindow_layout, null);
  53. InfoWindowData infoWindowData = (InfoWindowData) m.getTag();
  54. TextView title = ((TextView)v.findViewById(R.id.infoWindowAdapterTextView));
  55. title.setText(infoWindowData.getTitle());
  56. return v;
  57. }
  58.  
  59. public class InfoWindowData {
  60. private String title;
  61.  
  62. public String getTitle() {
  63. return title;
  64. }
  65.  
  66. public void setTitle(String title) {
  67. this.title = title;
  68. }
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement