public void actualizar_registros() { mVisitas = new Visitas_model(db); Cursor c = mVisitas.getNuevos(); if (c.getCount() > 0) { while (c.moveToNext()) { JsonSetTask task = new JsonSetTask( c.getString(2), c.getString(3), c.getString(4), c.getString(5), c.getString(6), c.getString(7)); String url2 = config.getIp(db) + "/actualizaciones/setVisita/"; task.execute(new String[] {url2}); } } else { Toast.makeText(mContext, config.msjNoRegistros("visitas"), Toast.LENGTH_SHORT).show(); } JsonReadTask taskVisitas = new JsonReadTask(); String url = config.getIp(db) + "/actualizaciones/getVisitas/"; taskVisitas.execute(new String[] {url}); }
// build hash set for list view public void CargarVisitas() { String subjet; subjet = "visitas"; try { JSONObject jsonResponse = new JSONObject(jsonResult); JSONArray jsonMainNode = jsonResponse.optJSONArray(subjet); if (jsonMainNode != null) { if (jsonMainNode.length() > 0) { mVisitas.truncate(); } for (int i = 0; i < jsonMainNode.length(); i++) { JSONObject jsonChildNode = jsonMainNode.getJSONObject(i); mVisitas.insert( jsonChildNode.optString("id_visita"), jsonChildNode.optString("id_vendedor"), jsonChildNode.optString("id_cliente"), jsonChildNode.optString("descripcion"), jsonChildNode.optString("id_epoca_visita"), jsonChildNode.optString("valoracion"), jsonChildNode.optString("fecha"), jsonChildNode.optString("id_origen"), jsonChildNode.optString("visto"), jsonChildNode.optString("date_add"), jsonChildNode.optString("date_upd"), jsonChildNode.optString("eliminado"), jsonChildNode.optString("user_add"), jsonChildNode.optString("user_upd")); } Toast.makeText( mContext, config.msjRegistrosActualizados(subjet + " " + jsonMainNode.length()), Toast.LENGTH_SHORT) .show(); } } catch (JSONException e) { Toast.makeText(mContext, config.msjError(e.toString()), Toast.LENGTH_SHORT).show(); } }