android: bug fixes for tickets #1248, #1251, #1244

This commit is contained in:
Joachim Fritzsch 2013-05-18 12:50:24 +02:00
parent a54607dd4f
commit 70483c09a9
3 changed files with 23 additions and 5 deletions

View File

@ -205,7 +205,7 @@
<string name="tasks_active_quit_pending">stopping</string>
<string name="tasks_custom_suspended_via_gui">paused</string>
<string name="tasks_custom_project_suspended_via_gui">paused</string>
<string name="tasks_custom_ready_to_report">reporting&#8230;</string>
<string name="tasks_custom_ready_to_report">ready to report</string>
<!-- confirmation dialog -->
<string name="confirm_abort_task_title">Abort task</string>

View File

@ -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<Result> 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<TaskData> 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 {

View File

@ -89,7 +89,10 @@ public class TasksListAdapter extends ArrayAdapter<TaskData>{
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);