From 7b13ca79855b9d87d73e3a319faaf697eff81304 Mon Sep 17 00:00:00 2001 From: Spectre-ak <62694340+Spectre-ak@users.noreply.github.com> Date: Wed, 4 Nov 2020 19:16:00 +0530 Subject: [PATCH 1/3] Update MemoryGraphFragment.java Unintentional resume of plotting of graph #628 Fixed: Graph plotting resumes once the menu bar's option is clicked after plotting of the graph was stopped. --- .../io/neurolab/fragments/MemoryGraphFragment.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/neurolab/fragments/MemoryGraphFragment.java b/app/src/main/java/io/neurolab/fragments/MemoryGraphFragment.java index e5f2ebd4..7e508b55 100644 --- a/app/src/main/java/io/neurolab/fragments/MemoryGraphFragment.java +++ b/app/src/main/java/io/neurolab/fragments/MemoryGraphFragment.java @@ -58,7 +58,8 @@ import static io.neurolab.utilities.FilePathUtil.LOG_FILE_KEY; public class MemoryGraphFragment extends Fragment implements OnChartValueSelectedListener { - + private boolean check_for_stopped_graph=false; + private int count_for_first_execution=0; private LineChart memGraph; private View view; private Thread thread; @@ -363,6 +364,8 @@ private void importLoggedData(String path) { * @param isPlaying */ private void toggleMenuItem(Menu menu, boolean isPlaying) { + if(check_for_stopped_graph=true && count_for_first_execution==1) + isPlaying=false; MenuItem play = menu.findItem(R.id.play_graph); MenuItem stop = menu.findItem(R.id.stop_data); @@ -441,11 +444,12 @@ public boolean onOptionsItemSelected(MenuItem item) { infoDialog.show(); } else if (id == R.id.stop_data) { - parsedData = null; + parsedData = null;check_for_stopped_graph=true;count_for_first_execution=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)) { + check_for_stopped_graph=false;count_for_first_execution=0; parsedData = StatisticsFragment.parsedData; plotGraph(); toggleMenuItem(globalMenu, isPlaying); @@ -540,6 +544,10 @@ protected void onPostExecute(String[] strings) { StatisticsFragment.parsedData = parsedData = strings; progressDialog.dismiss(); plotGraph(); + if(check_for_stopped_graph==true){ + parsedData=null; + toggleMenuItem(globalMenu,false); + } } } } From 8964a6e30ac682d3700926b092a07ca004f5b33b Mon Sep 17 00:00:00 2001 From: Spectre-ak <62694340+Spectre-ak@users.noreply.github.com> Date: Wed, 4 Nov 2020 20:47:39 +0530 Subject: [PATCH 2/3] Update MemoryGraphFragment.java --- .../io/neurolab/fragments/MemoryGraphFragment.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/neurolab/fragments/MemoryGraphFragment.java b/app/src/main/java/io/neurolab/fragments/MemoryGraphFragment.java index 7e508b55..abc50503 100644 --- a/app/src/main/java/io/neurolab/fragments/MemoryGraphFragment.java +++ b/app/src/main/java/io/neurolab/fragments/MemoryGraphFragment.java @@ -364,17 +364,18 @@ private void importLoggedData(String path) { * @param isPlaying */ private void toggleMenuItem(Menu menu, boolean isPlaying) { - if(check_for_stopped_graph=true && count_for_first_execution==1) - isPlaying=false; MenuItem play = menu.findItem(R.id.play_graph); MenuItem stop = menu.findItem(R.id.stop_data); - + boolean var; + if(check_for_stopped_graph && count_for_first_execution==1) + var=false; + else var=isPlaying; if (getArguments().getString(LOG_FILE_KEY) == null) { play.setVisible(false); stop.setVisible(false); } else { - play.setVisible(!isPlaying); - stop.setVisible(isPlaying); + play.setVisible(!var); + stop.setVisible(var); } } @@ -544,7 +545,7 @@ protected void onPostExecute(String[] strings) { StatisticsFragment.parsedData = parsedData = strings; progressDialog.dismiss(); plotGraph(); - if(check_for_stopped_graph==true){ + if(check_for_stopped_graph){ parsedData=null; toggleMenuItem(globalMenu,false); } From 40d298420c2e163636175c1b5247f2f936b112af Mon Sep 17 00:00:00 2001 From: Spectre-ak <62694340+Spectre-ak@users.noreply.github.com> Date: Sun, 8 Nov 2020 00:17:29 +0530 Subject: [PATCH 3/3] Update MemoryGraphFragment.java --- .../fragments/MemoryGraphFragment.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/io/neurolab/fragments/MemoryGraphFragment.java b/app/src/main/java/io/neurolab/fragments/MemoryGraphFragment.java index abc50503..7ac55427 100644 --- a/app/src/main/java/io/neurolab/fragments/MemoryGraphFragment.java +++ b/app/src/main/java/io/neurolab/fragments/MemoryGraphFragment.java @@ -58,8 +58,8 @@ import static io.neurolab.utilities.FilePathUtil.LOG_FILE_KEY; public class MemoryGraphFragment extends Fragment implements OnChartValueSelectedListener { - private boolean check_for_stopped_graph=false; - private int count_for_first_execution=0; + private boolean checkForStoppedGraph=false; + private int countForFirstExecution=0; private LineChart memGraph; private View view; private Thread thread; @@ -366,16 +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 var; - if(check_for_stopped_graph && count_for_first_execution==1) - var=false; - else var=isPlaying; + 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(!var); - stop.setVisible(var); + play.setVisible(!updatedIsPlaying); + stop.setVisible(updatedIsPlaying); } } @@ -445,12 +445,15 @@ public boolean onOptionsItemSelected(MenuItem item) { infoDialog.show(); } else if (id == R.id.stop_data) { - parsedData = null;check_for_stopped_graph=true;count_for_first_execution=1; + 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)) { - check_for_stopped_graph=false;count_for_first_execution=0; + checkForStoppedGraph=false; + countForFirstExecution=0; parsedData = StatisticsFragment.parsedData; plotGraph(); toggleMenuItem(globalMenu, isPlaying); @@ -545,7 +548,7 @@ protected void onPostExecute(String[] strings) { StatisticsFragment.parsedData = parsedData = strings; progressDialog.dismiss(); plotGraph(); - if(check_for_stopped_graph){ + if(checkForStoppedGraph){ parsedData=null; toggleMenuItem(globalMenu,false); }