public List<StrikeAbstract> getStrikesGrid( int intervalDuration, int intervalOffset, int rasterSize, int countThreshold, int region) { List<StrikeAbstract> strikes = new ArrayList<StrikeAbstract>(); nextId = 0; incrementalResult = false; try { JSONObject response = client.call( "get_strikes_grid", intervalDuration, rasterSize, intervalOffset, region, countThreshold); readRasterData(response, strikes); rasterParameters.setInfo(String.format("%.0f km", rasterSize / 1000f)); readHistogramData(response); } catch (Exception e) { skipServer(); throw new RuntimeException(e); } Log.v( Main.LOG_TAG, String.format( "JsonRpcDataProvider: read %d bytes (%d raster positions, region %d)", client.getLastNumberOfTransferredBytes(), strikes.size(), region)); return strikes; }
public List<StrikeAbstract> getStrikes(int timeInterval, int intervalOffset, int region) { List<StrikeAbstract> strikes = new ArrayList<StrikeAbstract>(); rasterParameters = null; if (intervalOffset < 0) { nextId = 0; } incrementalResult = nextId != 0; try { JSONObject response = client.call("get_strikes", timeInterval, intervalOffset < 0 ? intervalOffset : nextId); readStrikes(response, strikes); readHistogramData(response); } catch (Exception e) { skipServer(); throw new RuntimeException(e); } Log.v( Main.LOG_TAG, String.format( "JsonRpcDataProvider: read %d bytes (%d new strikes, region %d)", client.getLastNumberOfTransferredBytes(), strikes.size(), region)); return strikes; }
@Override public void setUp() { String agentSuffix = pInfo != null ? "-" + Integer.toString(pInfo.versionCode) : ""; client = new JsonRpcClient(getServer(), agentSuffix); client.setConnectionTimeout(40000); client.setSocketTimeout(40000); }
@Override public List<Station> getStations(int region) { List<Station> stations = new ArrayList<Station>(); try { JSONObject response = client.call("get_stations"); JSONArray stations_array = (JSONArray) response.get("stations"); for (int i = 0; i < stations_array.length(); i++) { stations.add(stationBuilder.fromJson(stations_array.getJSONArray(i))); } } catch (Exception e) { skipServer(); throw new RuntimeException(e); } return stations; }
@Override public void shutDown() { client.shutdown(); client = null; }