package com.example.mobapp_23_gestures;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;

public class MainActivity extends Activity {

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

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

	@Override
	public boolean onTouchEvent(MotionEvent event) 
	{ 
		// optional: VelocityTracker
		
		TextView text = (TextView)findViewById(R.id.textView3);
		int action = event.getAction();
		
	    switch(action) {
	        case (MotionEvent.ACTION_DOWN) :
	        		text.setText("down");
	            return true;
	        case (MotionEvent.ACTION_MOVE) :
	        		float x = event.getX();
	        		float y = event.getY();
	        		text.setText("move x:"+x+" y:"+y);
	            return true;
	        case (MotionEvent.ACTION_UP) :
	        		text.setText("up");
	            return true;
	        default : 
	            return super.onTouchEvent(event);
	    }   
	}

	public void openact1(View view)
	{
		Intent intent = new Intent(this, Act1.class);
		startActivity(intent);
	}


}
