package fishrungames.bashgid;

import fishrungames.bashgid.core.LinkContentStorage;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class LinkContentFragment extends Fragment {

	
	String [] titleArray = { 
			"Предприятия Башкортостана", "Статистика", "Помощь инвестору", "Транспорт",
			};
	
	public int contentId = 0;
	
	View rootView;
	TextView titleTextView;
	ImageView imageView;
	TextView textView;
	Button button;
	
	public LinkContentFragment(int contentId)
	{
		this.contentId = contentId;
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		rootView = inflater.inflate(R.layout.fragment_link_content_page, container, false);
		
		titleTextView = (TextView) rootView.findViewById(R.id.titleTextView);
		imageView = (ImageView) rootView.findViewById(R.id.imageView);
		textView = (TextView) rootView.findViewById(R.id.textView);
		button = (Button) rootView.findViewById(R.id.button);
		
		titleTextView.setText(LinkContentStorage.titleArray[contentId]);
		imageView.setImageResource(LinkContentStorage.imgIdArray[contentId]);
		
		textView.setText(LinkContentStorage.textArray[contentId]);
		
		
		button.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				Uri uri = Uri.parse(LinkContentStorage.webLinkArray[contentId]);
				Intent intent = new Intent(Intent.ACTION_VIEW, uri);
				startActivity(intent);
			}
			
		});
		
		
		
		return rootView;
	}
	
	@Override
    public void onResume()
    {
    	super.onResume();
    	
    }
}
