From 70483c09a997b2db6e01f01eebcef4595fcce03d Mon Sep 17 00:00:00 2001 From: Joachim Fritzsch Date: Sat, 18 May 2013 12:50:24 +0200 Subject: [PATCH] android: bug fixes for tickets #1248, #1251, #1244 --- android/BOINC/res/values/strings.xml | 2 +- .../src/edu/berkeley/boinc/TasksActivity.java | 21 ++++++++++++++++--- .../boinc/adapter/TasksListAdapter.java | 5 ++++- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/android/BOINC/res/values/strings.xml b/android/BOINC/res/values/strings.xml index f0a7e2b113..40010746e7 100644 --- a/android/BOINC/res/values/strings.xml +++ b/android/BOINC/res/values/strings.xml @@ -205,7 +205,7 @@ stopping paused paused - reporting… + ready to report Abort task diff --git a/android/BOINC/src/edu/berkeley/boinc/TasksActivity.java b/android/BOINC/src/edu/berkeley/boinc/TasksActivity.java index a26349f172..b252e6f9fc 100644 --- a/android/BOINC/src/edu/berkeley/boinc/TasksActivity.java +++ b/android/BOINC/src/edu/berkeley/boinc/TasksActivity.java @@ -19,6 +19,7 @@ package edu.berkeley.boinc; import java.util.ArrayList; +import java.util.Iterator; import edu.berkeley.boinc.adapter.TasksListAdapter; import edu.berkeley.boinc.client.ClientStatus; @@ -150,9 +151,8 @@ public class TasksActivity extends FragmentActivity { } private void updateData(ArrayList newData) { - //loop through all received Result items + //loop through all received Result items to add new results for(Result rpcResult: newData) { - //check whether this Result is new Integer index = null; for(int x = 0; x < data.size(); x++) { @@ -168,6 +168,21 @@ public class TasksActivity extends FragmentActivity { data.get(index).updateResultData(rpcResult); } } + + //loop through the list adapter to find removed (ready/aborted) Results + // use iterator to safely remove while iterating + Iterator iData = data.iterator(); + while(iData.hasNext()) { + Boolean found = false; + TaskData listItem = iData.next(); + for(Result rpcResult: newData) { + if(listItem.id.equals(rpcResult.name)) { + found = true; + continue; + } + } + if(!found) iData.remove(); + } } public class TaskData { @@ -252,7 +267,7 @@ public class TasksActivity extends FragmentActivity { public int determineState() { if(result.suspended_via_gui) return BOINCDefs.RESULT_SUSPENDED_VIA_GUI; if(result.project_suspended_via_gui) return BOINCDefs.RESULT_PROJECT_SUSPENDED; - if(result.ready_to_report) return BOINCDefs.RESULT_READY_TO_REPORT; + if(result.ready_to_report && result.state != BOINCDefs.RESULT_ABORTED && result.state != BOINCDefs.RESULT_COMPUTE_ERROR) return BOINCDefs.RESULT_READY_TO_REPORT; if(result.active_task){ return result.active_task_state; } else { diff --git a/android/BOINC/src/edu/berkeley/boinc/adapter/TasksListAdapter.java b/android/BOINC/src/edu/berkeley/boinc/adapter/TasksListAdapter.java index 484745cc43..9819b2ffb8 100644 --- a/android/BOINC/src/edu/berkeley/boinc/adapter/TasksListAdapter.java +++ b/android/BOINC/src/edu/berkeley/boinc/adapter/TasksListAdapter.java @@ -89,7 +89,10 @@ public class TasksListAdapter extends ArrayAdapter{ String statusT = determineStatusText(listItem); status.setText(statusT); - int elapsedTime = (int)listItem.result.elapsed_time; + int elapsedTime; + // show time depending whether task is active or not + if(listItem.result.active_task) elapsedTime = (int)listItem.result.elapsed_time; //is 0 when task finished + else elapsedTime = (int) listItem.result.final_elapsed_time; time.setText(String.format("%02d:%02d:%02d", elapsedTime/3600, (elapsedTime/60)%60, elapsedTime%60)); RelativeLayout ll = (RelativeLayout) v.findViewById(R.id.expansion);