-
-
Save realdm/4adc202ac459d0257a51 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LoadPrevisao extends AsyncTask<String, Void, String> | |
{ | |
@Override | |
protected String doInBackground(String... params) { | |
return carregarDadosDeTemperatura(params[0]); | |
} | |
@Override | |
protected void onPostExecute(String s) { | |
//comeca a descodificar o JSON e no fim faz set ao adapter da lista | |
final String LIST="list"; | |
final String TEMP="temp"; | |
final String MIN="min"; | |
final String MAX="max"; | |
String[] previsaoDacloud; | |
Log.e("TempListaFragment", s); | |
JSONObject previsaoJson; | |
//comecar a processar JSON | |
try { | |
previsaoJson = new JSONObject(s); | |
JSONArray lista = previsaoJson.getJSONArray(LIST); | |
previsaoDacloud = new String[lista.length()]; | |
for(int i=0;i<lista.length();i++) | |
{ | |
JSONObject dia = lista.getJSONObject(i); | |
JSONObject temp = dia.getJSONObject(TEMP); | |
String min = temp.getString(MIN); | |
String max = temp.getString(MAX); | |
previsaoDacloud[i]="Dia "+i+" "+max+"/"+min; | |
} | |
adapter = new ListaAdapter(getActivity().getApplicationContext()); | |
adapter.setData(previsaoDacloud); | |
mLista.setAdapter(adapter); | |
} catch (JSONException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment