package com.example.mobapp_23_gestures;

import android.os.Bundle;
import android.app.Activity;
import android.support.v4.view.GestureDetectorCompat;
import android.view.GestureDetector.OnDoubleTapListener;
import android.view.Menu;
import android.view.GestureDetector.OnGestureListener;
import android.view.MotionEvent;
import android.widget.TextView;

public class Act1 extends Activity implements OnGestureListener, OnDoubleTapListener
{
	private GestureDetectorCompat Detector; 

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_act1);

		Detector = new GestureDetectorCompat(this,this); // context und gesture listener
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.act1, menu);
		return true;
	}

	// needed!!!
	@Override
	public boolean onTouchEvent(MotionEvent event){ 
        this.Detector.onTouchEvent(event);
        return super.onTouchEvent(event);
	}

	// OnGestureListener
	@Override
	public boolean onDown(MotionEvent e) {
    		TextView text = (TextView)findViewById(R.id.textView3);
    		text.setText("down");
        return true;
	}

	@Override
	public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
			float velocityY) {
		TextView text = (TextView)findViewById(R.id.textView3);
		text.setText("fling");
		return true;
	}

	@Override
	public void onLongPress(MotionEvent e) {
		TextView text = (TextView)findViewById(R.id.textView3);
		text.setText("longpress");
	}

	@Override
	public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
			float distanceY) {
		TextView text = (TextView)findViewById(R.id.textView3);
		text.setText("scroll");
		return true;
	}

	@Override
	public void onShowPress(MotionEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public boolean onSingleTapUp(MotionEvent e) {
		TextView text = (TextView)findViewById(R.id.textView3);
		text.setText("singletapup");
		return true;
	}

	// OnDoubleTapListener
	
	@Override
	public boolean onDoubleTap(MotionEvent e) {
		TextView text = (TextView)findViewById(R.id.textView3);
		text.setText("doubletap");
		return true;
	}

	@Override
	public boolean onDoubleTapEvent(MotionEvent e) {
		TextView text = (TextView)findViewById(R.id.textView3);
		text.setText("doubletapevent");
		return true;
	}

	@Override
	public boolean onSingleTapConfirmed(MotionEvent e) {
		TextView text = (TextView)findViewById(R.id.textView3);
		text.setText("singletapconfirm");
		return true;
	}

}
