package com.ocelotworks.weedsim.fragments;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.ocelotworks.weedsim.R;
import com.ocelotworks.weedsim.WeedService;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class StartFragment extends Fragment {

	View view;

	public StartFragment() {
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View rootView = inflater.inflate(R.layout.fragment_start, container,
				false);
		view = rootView;
		return rootView;
	}

	@Override
	public void onStart() {
		super.onStart();
		if (WeedService.isAds) {
				AdView mAdView = (AdView) view.findViewById(R.id.adView);
				AdRequest adRequest = new AdRequest.Builder().build();
				mAdView.loadAd(adRequest);
		}
		((TextView) view.findViewById(R.id.textView2)).setText("Money: £"
				+ WeedService.wr.getMoney());
		((TextView) view.findViewById(R.id.textView3)).setText("Cuttings: "
				+ WeedService.wr.getCuttings());

	}
	
	@Override
	public void onPause(){
		super.onPause();
		((AdView) view.findViewById(R.id.adView)).destroy();
	}
	
	@Override
	public void onResume(){
		super.onResume();
		AdView mAdView = (AdView) view.findViewById(R.id.adView);
		AdRequest adRequest = new AdRequest.Builder().build();
		mAdView.loadAd(adRequest);
	}

}
