package org.ntlab.radishforandroidstudio.cactusClient.views;

import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.support.v4.app.Fragment;
import android.widget.Button;
import android.widget.Toast;


import org.ntlab.radishforandroidstudio.R;

public class CharactersFragment extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        String test = getArguments().getString("test");
        Toast.makeText(getActivity(), test, Toast.LENGTH_SHORT).show();
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.characters_fragment, container, false);
    }

    public void onStart() {
        super.onStart();

        Button button = (Button) getActivity().findViewById(R.id.chooseInstances);
        //↓↓↓↓↓↓↓↓画面遷移↓↓↓↓↓↓↓↓
        button.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                //Toast.makeText(getActivity(), "hoge!", Toast.LENGTH_SHORT).show();

                FragmentManager manager = getFragmentManager();
                FragmentTransaction transaction = manager.beginTransaction();

                transaction.replace(R.id.fragment_place, new InstancesFragment());

                transaction.commit();
            }
        });

        Button Nobita = (Button) getActivity().findViewById(R.id.NOBITA);
        //↓↓↓↓↓↓↓↓画面遷移↓↓↓↓↓↓↓↓
        Nobita.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                //Toast.makeText(getActivity(), "hoge!", Toast.LENGTH_SHORT).show();

                FragmentManager manager = getFragmentManager();
                FragmentTransaction transaction = manager.beginTransaction();
                transaction.replace(R.id.fragment_place, new PlayerFragment());
                transaction.addToBackStack(null);
                transaction.commit();
            }
        });

    }
}