public void appendData(PingInfo pi) { if (pi == null) { } else if (pi.getPingType() == PingInfo.ICMP_PING) { int minimum_size = (int) (60000.0 / icmpPingSettings.getRepeat()) + 1; IcmpInformationArray.add(pi); while (IcmpInformationArray.size() > minimum_size) IcmpInformationArray.remove(0); } else if (pi.getPingType() == PingInfo.HTTP_REQUEST) { int minimum_size = (int) (60000.0 / httpPingSettings.getRepeat()) + 1; HttpInformationArray.add(pi); while (HttpInformationArray.size() > minimum_size) HttpInformationArray.remove(0); } else if (pi.getPingType() == PingInfo.HTTP_SECURE) { int minimum_size = (int) (60000.0 / httpsPingSettings.getRepeat()) + 1; HttpsInformationArray.add(pi); while (HttpsInformationArray.size() > minimum_size) HttpsInformationArray.remove(0); } }
@Override protected void onCreate(Bundle savedInstanceState) { Log.i(LOG_TAG, "---New Session---"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); icmpPingSettings = new PingSettings(); icmpPingSettings.setTimeout(1000); icmpPingSettings.setRepeat(3000); icmpPingSettings.setDomain("www.google.com"); icmpPingSettings.setSlow(300); httpPingSettings = new PingSettings(); httpPingSettings.setTimeout(1500); httpPingSettings.setRepeat(3000); httpPingSettings.setDomain("www.google.com"); httpPingSettings.setSlow(500); httpsPingSettings = new PingSettings(); httpsPingSettings.setTimeout(2000); httpsPingSettings.setRepeat(3000); httpsPingSettings.setDomain("www.google.com"); httpsPingSettings.setSlow(1000); pingReceiver = new PingReceiver(); gv = (GraphView) findViewById(R.id.graph_view); gv.setTitle("Ping Times"); gv.getGridLabelRenderer().setHighlightZeroLines(true); gv.getGridLabelRenderer().setPadding(36); icmpLineSeries = new PointsGraphSeries<DataPoint>(); icmpLineSeries.setColor(Color.parseColor("#A00000")); icmpLineSeries.setSize(10); icmpLineSeries.setTitle("ICMP"); gv.addSeries(icmpLineSeries); httpLineSeries = new PointsGraphSeries<DataPoint>(); httpLineSeries.setColor(Color.parseColor("#00A000")); httpLineSeries.setSize(10); httpLineSeries.setTitle("HTTP"); gv.addSeries(httpLineSeries); httpsLineSeries = new PointsGraphSeries<DataPoint>(); httpsLineSeries.setColor(Color.parseColor("#0000A0")); httpsLineSeries.setSize(10); httpsLineSeries.setTitle("HTTPS"); gv.addSeries(httpsLineSeries); gv.getLegendRenderer().setVisible(true); gv.getLegendRenderer().setAlign(LegendRenderer.LegendAlign.MIDDLE); gv.getViewport().setXAxisBoundsManual(true); gv.getViewport().setMinX(0); gv.getViewport().setMaxX(60); // gv.getViewport().setYAxisBoundsManual(true); // gv.getViewport().setMinY(0); // gv.getViewport().setMaxY(1); alertToggle = (CheckBox) findViewById(R.id.alert_toggle); alertThresh = (EditText) findViewById(R.id.alert_input); alertToggle.setOnClickListener(this); icmp_set_btn = (Button) findViewById(R.id.icmp_settings); icmp_start_btn = (Button) findViewById(R.id.icmp_start); icmp_end_btn = (Button) findViewById(R.id.icmp_end); icmp_information = (TextView) findViewById(R.id.icmp_information); icmp_result = (TextView) findViewById(R.id.icmp_result); icmp_icon = (ImageView) findViewById(R.id.icmp_icon); icmp_start_btn.setOnClickListener(this); icmp_end_btn.setOnClickListener(this); icmp_set_btn.setOnClickListener(this); http_set_btn = (Button) findViewById(R.id.http_settings); http_start_btn = (Button) findViewById(R.id.http_start); http_end_btn = (Button) findViewById(R.id.http_end); http_information = (TextView) findViewById(R.id.http_information); http_result = (TextView) findViewById(R.id.http_result); http_icon = (ImageView) findViewById(R.id.http_icon); http_set_btn.setOnClickListener(this); http_start_btn.setOnClickListener(this); http_end_btn.setOnClickListener(this); https_set_btn = (Button) findViewById(R.id.https_settings); https_start_btn = (Button) findViewById(R.id.https_start); https_end_btn = (Button) findViewById(R.id.https_end); https_information = (TextView) findViewById(R.id.https_information); https_result = (TextView) findViewById(R.id.https_result); https_icon = (ImageView) findViewById(R.id.https_icon); https_set_btn.setOnClickListener(this); https_start_btn.setOnClickListener(this); https_end_btn.setOnClickListener(this); endHTTP(); endHTTPS(); endICMP(); updateInformation(); }
public void updateInformation() { https_information.setText(httpsPingSettings.informationString()); http_information.setText(httpPingSettings.informationString()); icmp_information.setText(icmpPingSettings.informationString()); }