package com.geodatadesign;

import com.geodatadesign.domain.TimeSeriesSite;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TextView;

public class DetailsActivity extends Activity {
    
    @Override
    public void onCreate(Bundle saveInstanceState) {
        super.onCreate(saveInstanceState);
        setContentView(R.layout.detail_list);
        
        // Deserialize the bundle
        TimeSeriesSite site = getIntent().getExtras().getParcelable("sitedata");
        int variableIndex = getIntent().getExtras().getInt("variableindex");
        setHeaders(variableIndex, site);
        
        ListView view = (ListView) findViewById(R.id.detail_listview);
        DetailViewAdapter adapter = new DetailViewAdapter(this, variableIndex, site);
       
        view.setAdapter(adapter);
    }
    
    private void setHeaders(int variableIndex, TimeSeriesSite site) {
        TextView siteName = (TextView) findViewById(R.id.sitename);
        TextView siteDesc = (TextView) findViewById(R.id.sitedescription);
        TextView columnHeader1 = (TextView) findViewById(R.id.column_header1);
        TextView columnHeader2 = (TextView) findViewById(R.id.column_header2);
     
        siteName.setText("Site name: "+site.getSiteName());
        siteDesc.setText("Site Desc: "+site.getSiteDescription());
        columnHeader1.setText("Date");
        columnHeader2.setText(site.getTimeSeriesVariableList().get(variableIndex).getVariableDescription());
    }
}
