package org.ntlab.radishforandroidstudio.framework.RWT;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;


import org.ntlab.radishforandroidstudio.R;
import org.ntlab.radishforandroidstudio.cactusClient.views.PlayerFragment;
import org.ntlab.radishforandroidstudio.framework.event.PadEvent;
import org.ntlab.radishforandroidstudio.framework.listener.PadListener;

import static android.view.View.*;

public class RWTUIFragment extends Fragment implements OnTouchListener,PadListener {
    PlayerFragment listener = null;
    View v = null;
    public RWTUIFragment() {}

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        v = inflater.inflate(R.layout.ui_fragment, container, false);
        RWTPad pad = v.findViewById(R.id.pad);
        pad.addListener(this);

        if (listener != null) {
            listener.onCreateFragmentEvent(this);
        }
        return inflater.inflate(R.layout.ui_fragment, null);
    }

    @Override
    public boolean onTouch(View v, MotionEvent event) {
        System.out.println("RWTUIFragment touch");
        return false;
    }

    @Override
    public boolean onEvent(PadEvent event) {
        return false;
    }

    public View findViewById(int id) {
        return v.findViewById(id);
    }

    public void setListener(PlayerFragment playerFragment) {
        listener = playerFragment;
    }
}
