package kimiko.coreen.app.data.ui;

import kimiko.coreen.app.HanjaActivity;
import kimiko.coreen.app.R;
import kimiko.coreen.app.view.Fragment.HanjaFragment;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.View.OnClickListener;

public class HanjaDetailListener implements OnClickListener {
	private Context context;
	private Bundle valeur;

	public HanjaDetailListener(Context context, Bundle bundle) {
		this.context = context;
		this.valeur = bundle;
	}
	@Override
	public void onClick(View v) {
		Object viewer = ((Activity) context).findViewById(R.id.detailContainer);
		if (viewer == null) {
			Intent myIntent = new Intent(context, HanjaActivity.class);
			myIntent.putExtras(valeur);
			context.startActivity(myIntent);
		} else {
			HanjaFragment fra = new HanjaFragment();
			fra.setArguments(valeur);
			((FragmentActivity) context).getSupportFragmentManager().beginTransaction().replace(R.id.detailContainer, fra).commit();
		}
	}
}