Newer
Older
Cactus-CleanArchitecture / app / src / main / java / org / ntlab / radishforandroidstudio / framework / RWT / RWTUIFragment.java
n-konishi on 26 Jun 2018 4 KB 修正
//package org.ntlab.radishforandroidstudio.framework.RWT;
//
//import android.support.annotation.NonNull;
//import android.support.v4.app.Fragment;
//import android.os.Bundle;
//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.PlayerActivity;
//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 {
//    PlayerActivity 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(org.ntlab.radishforandroidstudio.R.id.button3);
//        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");
//        v.performClick();
//        return false;
//    }
//
//    public void setListener(PlayerActivity activity) {
//        listener = activity;
//    }
//
//    @Override
//    public boolean onEvent(PadEvent event) {
//        return false;
//    }
//    public View findViewById(int id) {
//        return v.findViewById(id);
//    }
//}
package org.ntlab.radishforandroidstudio.framework.RWT;

import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import org.ntlab.radishforandroidstudio.R;
import org.ntlab.radishforandroidstudio.cactusClient.PlayerActivity;
import org.ntlab.radishforandroidstudio.framework.event.PadEvent;
import org.ntlab.radishforandroidstudio.framework.listener.PadListener;
import org.ntlab.radishforandroidstudio.sample.SampleGameActivity;


//import android.support.annotation.NonNull;
//import android.support.v4.app.Fragment;
//import android.os.Bundle;
//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.PlayerActivity;
//import org.ntlab.radishforandroidstudio.framework.event.PadEvent;
//import org.ntlab.radishforandroidstudio.framework.listener.PadListener;
//
//import static android.view.View.*;

import static android.view.View.*;

public class RWTUIFragment extends Fragment implements OnTouchListener,PadListener {
    PlayerActivity 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(org.ntlab.radishforandroidstudio.R.id.button3);
        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 void setListener(PlayerActivity activity) {
        listener = activity;
    }

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

}