package com.openxc.enabler;

import java.util.TimerTask;

import android.app.Activity;

import com.openxc.VehicleManager;
import android.widget.ListView;
import android.widget.ArrayAdapter;

public class PipelineStatusUpdateTask extends TimerTask {
    private VehicleManager mVehicleManager;
    private Activity mActivity;
    private ListView mSourceListView;
    private ListView mSinkListView;

    public PipelineStatusUpdateTask(VehicleManager vehicleService,
            Activity activity, ListView sourceListView, ListView sinkListView) {
        mVehicleManager = vehicleService;
        mActivity = activity;
        mSourceListView = sourceListView;
        mSinkListView = sinkListView;
    }

    public void run() {
        mActivity.runOnUiThread(new Runnable() {
            public void run() {
                mSourceListView.setAdapter(new ArrayAdapter<Object>(mActivity,
                            android.R.layout.simple_list_item_1,
                            mVehicleManager.getSourceSummaries().toArray()));
                mSinkListView.setAdapter(new ArrayAdapter<Object>(mActivity,
                            android.R.layout.simple_list_item_1,
                            mVehicleManager.getSinkSummaries().toArray()));
            }
        });
    }
}

@@ -391,16 +391,120 @@
 istView;
+%0A    private ArrayAdapter%3CObject%3E mSourceListAdapter;%0A    private ArrayAdapter%3CObject%3E mSinkListAdapter;
 %0A%0A    pu
@@ -801,163 +801,212 @@
 ew;%0A
+%0A
     
-%7D%0A%0A
     
-public void run() %7B%0A        mActivity.runOnUiThread(new Runnable() %7B%0A            public void run() %7B%0A                mSourceListView.setAdapter(
+mSourceListAdapter = new ArrayAdapter%3CObject%3E(mActivity,%0A                android.R.layout.simple_list_item_1);%0A        mSourceListView.setAdapter(mSourceListAdapter);%0A%0A        mSinkListAdapter = 
 new 
@@ -1049,36 +1049,24 @@
             
-         
-   
 android.R.la
@@ -1084,34 +1084,278 @@
 _list_item_1
-,%0A        
+);%0A        mSinkListView.setAdapter(mSinkListAdapter);%0A    %7D%0A%0A    public void run() %7B%0A        mActivity.runOnUiThread(new Runnable() %7B%0A            public void run() %7B%0A                mSourceListAdapter.clear();%0A                mSourceListAdapter.addAll(%0A
             
@@ -1401,33 +1401,32 @@
 ies().toArray())
-)
 ;%0A              
@@ -1433,140 +1433,133 @@
   mS
-inkListView.setAdapter(new ArrayAdapter%3CObject%3E(mActivity,%0A                            android.R.layout.simple_list_item_1,%0A        
+ourceListAdapter.notifyDataSetChanged();%0A%0A                mSinkListAdapter.clear();%0A                mSinkListAdapter.addAll(%0A
     
@@ -1619,16 +1619,72 @@
 Array())
+;%0A                mSinkListAdapter.notifyDataSetChanged(
 );%0A     

Maintain scroll position in data source/sink list in Enabler.