Reset button is now resetting graph and throughput texts

This commit is contained in:
Ziver Koc 2014-08-11 13:56:32 +02:00
parent 77fe316f14
commit 97798ababa
4 changed files with 31 additions and 9 deletions

View file

@ -168,7 +168,10 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
return true;
}
else if (id == R.id.action_reset) {
currentExecutor.reset();
if(currentExecutor != null)
currentExecutor.reset();
if(statusFragment != null)
statusFragment.reset();
updateExecutionState();
}
else if (id == R.id.action_edit) {

View file

@ -62,11 +62,12 @@ public class StatusFragment extends Fragment {
rat_type = (TextView) view.findViewById(R.id.rat_type);
// Init the graph
GraphViewData[] zeroPoint = new GraphViewData[]{new GraphViewData(0, 0)};
if(downGraph == null)
downGraph = new GraphViewSeries("Download Throughput", new GraphViewSeriesStyle(Color.GREEN, 3), zeroPoint);
downGraph = new GraphViewSeries("Download Throughput", new GraphViewSeriesStyle(Color.GREEN, 3),
new GraphViewData[]{new GraphViewData(0, 0)});
if(upGraph == null)
upGraph = new GraphViewSeries("Upload Throughput", new GraphViewSeriesStyle(Color.RED, 3), zeroPoint);
upGraph = new GraphViewSeries("Upload Throughput", new GraphViewSeriesStyle(Color.RED, 3),
new GraphViewData[]{new GraphViewData(0, 0)});
LineGraphView graphView = new LineGraphView(this.getActivity(), "GraphViewDemo");
graphView.addSeries(downGraph);
@ -130,6 +131,20 @@ public class StatusFragment extends Fragment {
}
}
public void reset(){
if(downGraph != null)
downGraph.resetData(new GraphViewData[]{new GraphViewData(0, 0)});
if(upGraph != null)
upGraph.resetData(new GraphViewData[]{new GraphViewData(0, 0)});
x = 0;
down_speed.post(new Runnable() {
@Override
public void run() {
down_speed.setText(ThroughputCalculator.getBitThroughputString(0));
up_speed.setText(ThroughputCalculator.getBitThroughputString(0));
}
});
}
}