Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions app/src/main/java/io/neurolab/fragments/MemoryGraphFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
import static io.neurolab.utilities.FilePathUtil.LOG_FILE_KEY;

public class MemoryGraphFragment extends Fragment implements OnChartValueSelectedListener {

private boolean checkForStoppedGraph=false;
private int countForFirstExecution=0;
private LineChart memGraph;
private View view;
private Thread thread;
Expand Down Expand Up @@ -365,13 +366,16 @@ private void importLoggedData(String path) {
private void toggleMenuItem(Menu menu, boolean isPlaying) {
MenuItem play = menu.findItem(R.id.play_graph);
MenuItem stop = menu.findItem(R.id.stop_data);

boolean updatedIsPlaying;
if(checkForStoppedGraph && countForFirstExecution==1)
updatedIsPlaying=false;
else updatedIsPlaying=isPlaying;
if (getArguments().getString(LOG_FILE_KEY) == null) {
play.setVisible(false);
stop.setVisible(false);
} else {
play.setVisible(!isPlaying);
stop.setVisible(isPlaying);
play.setVisible(!updatedIsPlaying);
stop.setVisible(updatedIsPlaying);
}
}

Expand Down Expand Up @@ -442,10 +446,14 @@ public boolean onOptionsItemSelected(MenuItem item) {

} else if (id == R.id.stop_data) {
parsedData = null;
checkForStoppedGraph=true;
countForFirstExecution=1;
Toast.makeText(getContext(), "Stopped", Toast.LENGTH_SHORT).show();
isPlaying = true;
toggleMenuItem(globalMenu, !isPlaying);
} else if (id == R.id.play_graph && (parsedData == null && StatisticsFragment.parsedData != null)) {
checkForStoppedGraph=false;
countForFirstExecution=0;
parsedData = StatisticsFragment.parsedData;
plotGraph();
toggleMenuItem(globalMenu, isPlaying);
Expand Down Expand Up @@ -540,6 +548,10 @@ protected void onPostExecute(String[] strings) {
StatisticsFragment.parsedData = parsedData = strings;
progressDialog.dismiss();
plotGraph();
if(checkForStoppedGraph){
parsedData=null;
toggleMenuItem(globalMenu,false);
}
}
}
}