Skip to main content
.java relacionando .xml
Fonte Link
@BindView(R.id.oi) TextView dataHora;

@Override
public void onCreate(Bundle bundle) {
    LayoutInflater inflater = (LayoutInflater)getLayoutInflater();
    View v = inflater.inflate(R.layout.activity_mapa, null);
    super.onCreate(bundle);
    getMapAsync(this);
    ButterKnife.bind((Activity) getContext());
}
    @Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    centralizaImagem(googleMap);

    circuloNoMapa();

    Call<List<AppSync>> calldata = (Call<List<AppSync>>) new RetrofitInicializador().getServices().lista();
    calldata.enqueue(new Callback<List<AppSync>>() {
        @Override
        public void onResponse(Call<List<AppSync>> call, Response<List<AppSync>> response) {
            AppSync objeto = response.body().get(0);

            String url = objeto.getUrl();
            String fileDate = objeto.getFileDate();
            String fileTime = objeto.getFileTime();

            dataHora.setText(fileDate + " - " + fileTime + " GTM") ;

            convertido = new ImageView(getContext());

            Picasso.with(getContext())
                    .load(url)
                    .into(convertido);

           convertido.setDrawingCacheEnabled(true);
           convertido.buildDrawingCache();
           Bitmap bitmap= Bitmap.createBitmap(convertido.getDrawingCache());
            
            configuraBmpMapa();

        }

        @Override
        public void onFailure(Call<List<AppSync>> call, Throwable t) {
            Log.e("ERRO RETROFIT", t.getMessage() );
        }
    });

}

private void configuraBmpMapa() {
    LatLngBounds newarkBounds = new LatLngBounds(
            new LatLng(LATITUDE_MINIMA, LONGITUDE_MINIMA),       // South west corner
            new LatLng(LATITUDE_MAXIMA, LONGITUDE_MAXIMA));      // North east corner

    GroundOverlayOptions newarkMap = new GroundOverlayOptions()
            .image(BitmapDescriptorFactory.fromResource(R.drawable.oi))
            .positionFromBounds(newarkBounds);

    GroundOverlay imageOverlay = mMap.addGroundOverlay(newarkMap);
}
    @Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    centralizaImagem(googleMap);

    circuloNoMapa();

    Call<List<AppSync>> calldata = (Call<List<AppSync>>) new RetrofitInicializador().getServices().lista();
    calldata.enqueue(new Callback<List<AppSync>>() {
        @Override
        public void onResponse(Call<List<AppSync>> call, Response<List<AppSync>> response) {
            AppSync objeto = response.body().get(0);

            String url = objeto.getUrl();
            String fileDate = objeto.getFileDate();
            String fileTime = objeto.getFileTime();

            dataHora.setText(fileDate + " - " + fileTime + " GTM") ;

            convertido = new ImageView(getContext());

            Picasso.with(getContext())
                    .load(url)
                    .into(convertido);

           convertido.setDrawingCacheEnabled(true);
           convertido.buildDrawingCache();
           Bitmap bitmap= Bitmap.createBitmap(convertido.getDrawingCache());
            
            configuraBmpMapa();

        }

        @Override
        public void onFailure(Call<List<AppSync>> call, Throwable t) {
            Log.e("ERRO RETROFIT", t.getMessage() );
        }
    });

}

private void configuraBmpMapa() {
    LatLngBounds newarkBounds = new LatLngBounds(
            new LatLng(LATITUDE_MINIMA, LONGITUDE_MINIMA),       // South west corner
            new LatLng(LATITUDE_MAXIMA, LONGITUDE_MAXIMA));      // North east corner

    GroundOverlayOptions newarkMap = new GroundOverlayOptions()
            .image(BitmapDescriptorFactory.fromResource(R.drawable.oi))
            .positionFromBounds(newarkBounds);

    GroundOverlay imageOverlay = mMap.addGroundOverlay(newarkMap);
}
@BindView(R.id.oi) TextView dataHora;

@Override
public void onCreate(Bundle bundle) {
    LayoutInflater inflater = (LayoutInflater)getLayoutInflater();
    View v = inflater.inflate(R.layout.activity_mapa, null);
    super.onCreate(bundle);
    getMapAsync(this);
    ButterKnife.bind((Activity) getContext());
}
    @Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    centralizaImagem(googleMap);

    circuloNoMapa();

    Call<List<AppSync>> calldata = (Call<List<AppSync>>) new RetrofitInicializador().getServices().lista();
    calldata.enqueue(new Callback<List<AppSync>>() {
        @Override
        public void onResponse(Call<List<AppSync>> call, Response<List<AppSync>> response) {
            AppSync objeto = response.body().get(0);

            String url = objeto.getUrl();
            String fileDate = objeto.getFileDate();
            String fileTime = objeto.getFileTime();

            dataHora.setText(fileDate + " - " + fileTime + " GTM") ;

            convertido = new ImageView(getContext());

            Picasso.with(getContext())
                    .load(url)
                    .into(convertido);

           convertido.setDrawingCacheEnabled(true);
           convertido.buildDrawingCache();
           Bitmap bitmap= Bitmap.createBitmap(convertido.getDrawingCache());
            
            configuraBmpMapa();

        }

        @Override
        public void onFailure(Call<List<AppSync>> call, Throwable t) {
            Log.e("ERRO RETROFIT", t.getMessage() );
        }
    });

}

private void configuraBmpMapa() {
    LatLngBounds newarkBounds = new LatLngBounds(
            new LatLng(LATITUDE_MINIMA, LONGITUDE_MINIMA),       // South west corner
            new LatLng(LATITUDE_MAXIMA, LONGITUDE_MAXIMA));      // North east corner

    GroundOverlayOptions newarkMap = new GroundOverlayOptions()
            .image(BitmapDescriptorFactory.fromResource(R.drawable.oi))
            .positionFromBounds(newarkBounds);

    GroundOverlay imageOverlay = mMap.addGroundOverlay(newarkMap);
}
trecho xml
Fonte Link

Esse é o .xml para o texto:

<FrameLayout
    android:id="@+id/frame_datahora"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.1">
<TextView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/oi"
    tools:text="02/09/99 - 11:00 GTM"
    android:textAlignment="center"
    android:textSize="16sp"/>
</FrameLayout>

Agradeço desde já a ajuda!

Agradeço desde já a ajuda!

Esse é o .xml para o texto:

<FrameLayout
    android:id="@+id/frame_datahora"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.1">
<TextView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/oi"
    tools:text="02/09/99 - 11:00 GTM"
    android:textAlignment="center"
    android:textSize="16sp"/>
</FrameLayout>

Agradeço desde já a ajuda!

correções
Fonte Link

Essa é a mensagem de erro:

FATAL EXCEPTION: main
Process: com.tabatabaesso.exercicio2, PID: 9585
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
     at com.tabatabaesso.exercicio2.MapaFragment$1.onResponse(MapaFragment.java:102)
     at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:70)
     at android.os.Handler.handleCallback(Handler.java:789)
     at android.os.Handler.dispatchMessage(Handler.java:98)
     at android.os.Looper.loop(Looper.java:164)
     at android.app.ActivityThread.main(ActivityThread.java:6541)
     at java.lang.reflect.Method.invoke(Native Method)
     at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

Agradeço desde já a ajuda!

Agradeço desde já a ajuda!

Essa é a mensagem de erro:

FATAL EXCEPTION: main
Process: com.tabatabaesso.exercicio2, PID: 9585
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
     at com.tabatabaesso.exercicio2.MapaFragment$1.onResponse(MapaFragment.java:102)
     at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:70)
     at android.os.Handler.handleCallback(Handler.java:789)
     at android.os.Handler.dispatchMessage(Handler.java:98)
     at android.os.Looper.loop(Looper.java:164)
     at android.app.ActivityThread.main(ActivityThread.java:6541)
     at java.lang.reflect.Method.invoke(Native Method)
     at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

Agradeço desde já a ajuda!

tags editadas
Link
ramaral
  • 44,7mil
  • 14
  • 60
  • 110
Carregando
Fonte Link
Carregando