A video to further elucidate how the app works: link
So, I'd like that ImageView where that GTA V image (used just to exemplify) would come from a URL obtained from a JSON file, as well as the data cited above. The JSON file in question is this: link
(In the following codes, you can see my failed attempt to mimic the codes that correctly retrieve the data (such as name, description, and coordinates) in the source code I used as the basis, but I could not and I could not identify the correct cause of the problem, much less fix it ...)
RESULTS OBTAINED BY DEBUGAR APPLICATION:
Afterseeingtheaboveimages,noticethatinthecodeofthePoints.javafile,"receiveImage" is the only one that returns nothing when a breakpoint is added to it and run in debugging, until the "application" itself returns the URL that is there in JSON, but I noticed something strange in that which can be seen in the images above, after the "application" line in Points.java, the breakpoint returns at the end the warning "image: null", which is strange, already which does not appear on other lines which I added breakpoints to debug.
After all, I do not really know what the problem is.
OBS. It includes relevant parts of the code below, along with links to such complete Java readable files in PasteBin.
OtherActivity.java (The Activity where the image should appear in ImageView "ImagePlace"): (AnotherActivity.java complete: link )
private ImageView ImagemLugar;
...
public static ArrayList<Pontos> iwantimage = new ArrayList<>();
...
ImagemLugar = (ImageView) v.findViewById(R.id.imageem);
setHasOptionsMenu(true);
for (int i = 0; i < iwantimage.size(); i++) {
Pontos pontos = iwantimage.get(i);
Picasso.get().load(pontos.recebeImagem()).into(ImagemLugar);
}
return v;
}
Activity where data is fetched from JSON: (the complete file: link )
String url = "https://api.myjson.com/bins/ox334";
...
@Override
protected String doInBackground(String... params) {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url(url).build();
...
JSONObject objectp = new JSONObject(s);
JSONArray jArrPoints = objectp.getJSONArray("pontos");
for (int i =0 ;i<jArrPoints.length();i++) {
pontos = new Pontos();
pontos.aplicaNome(jArrPoints.getJSONObject(i).getString("nome"));
pontos.aplicaPosx(jArrPoints.getJSONObject(i).getString("posx"));
pontos.aplicaPosy(jArrPoints.getJSONObject(i).getString("posy"));
pontos.aplicaDescricao( jArrPoints.getJSONObject(i).getString("descricao"));
pontos.aplicaTipo( jArrPoints.getJSONObject(i).getString("tipo"));
pontos.aplicaImagem( jArrPoints.getJSONObject(i).getString("imagem"));
listaitensPontos.add(pontos);
}
AbaMapa.listaitens = listaitensPontos;
The "Points.java" File, an ArrayList: (Full.java Points: link ) / p>
public class Pontos {
private String nome;
private String posx;
private String posy;
private String descricao;
private String tipo;
private String imagem;
public Pontos(){}
public Pontos(String nome, String posx, String posy, String descricao, String tipo){
this.nome = nome;
this.posx = posx;
this.posy = posy;
this.descricao = descricao;
this.tipo = tipo;
this.imagem = imagem;
}
public String recebeNome() {
return nome;
}
public void aplicaNome(String nome) {
this.nome = nome;
}
public String recebePosx() {
return posx;
}
public void aplicaPosx (String posx) {
this.posx = posx;
}
public String recebePosy() {
return posy;
}
public void aplicaPosy (String posy) {
this.posy = posy;
}
public String recebeDescricao() {
return descricao;
}
public void aplicaDescricao (String descricao) {
this.descricao = descricao;
}
public String recebeTipo() {
return tipo;
}
public void aplicaTipo (String tipo) {
this.tipo = tipo;
}
public String recebeImagem() {
return imagem;
}
public void aplicaImagem (String imagem) {
this.imagem = imagem;
}
}