package com.domandtom.bitcoinchart;

import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.google.android.glass.app.Card;

public class MainActivity extends Activity {
	
	private class JSONBitcoinChartTask extends AsyncTask<String, Void, SpotRate> {
		private MainActivity context;
		protected SpotRate spotRate;
		
		public JSONBitcoinChartTask(final MainActivity context) {
            super();

            this.context = context;
        }
		
		@Override
		protected SpotRate doInBackground(String... params) {
			spotRate = new SpotRate();
			
		    String data = ( (new CoinbaseHttpClient()).getSpotRate());
		    spotRate = JSONCoinbaseParser.getSpotRate(data);
			
			Log.d("doInBackground", "data: " + data);
			
		    return spotRate;
		}
		
		@Override
		protected void onPostExecute(SpotRate result) {
			/* Create output */
			Card card = new Card(context);
			String cardText = "*** Bitcoin Price ***\n" + spotRate.getAmount() + "\n" + spotRate.getCurrency();
			card.setText(cardText);
			View cardView = card.toView();
			setContentView(cardView);
			
			Log.d("onPostExecute", "cardText: " + cardText);
		}
	}
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.activity_main);
	    
	   	JSONBitcoinChartTask task = new JSONBitcoinChartTask(this);
	    task.execute();
	}
	
	@Override
	protected void onStop()
	{
	    super.onStop();
	}
}

@@ -30,16 +30,40 @@
 chart;%0A%0A
+import java.util.Date;%0A%0A
 import a
@@ -138,16 +138,55 @@
 Bundle;%0A
+import android.text.format.DateFormat;%0A
 import a
@@ -963,16 +963,181 @@
 sult) %7B%0A
+%09%09%09long timeStamp = System.currentTimeMillis();%0A%09%09%09Date date = new Date(timeStamp);%0A%09%09%09String displayDate = DateFormat.format(%22MM/dd/yyyy hh:mm%22, date).toString();%0A%0A
 %09%09%09/* Cr
@@ -1315,16 +1315,90 @@
 dText);%0A
+%09%09%09card.setInfo(%22Built by Dom & Tom%22);%0A%09%09%09card.setTimestamp(displayDate);%0A
 %09%09%09View 

update to display info and timestamp