package com.example.mobapp_23_gestures;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.ScaleGestureDetector.OnScaleGestureListener;
import android.widget.TextView;

public class Act2 extends Activity implements OnScaleGestureListener {

	private ScaleGestureDetector Detector;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_act2);
		
		Detector = new ScaleGestureDetector(this,this);
	}

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

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

	@Override
	public boolean onScale(ScaleGestureDetector detector) {
		TextView text = (TextView)findViewById(R.id.textView3);
		text.setText("scale");
		return true;
	}

	@Override
	public boolean onScaleBegin(ScaleGestureDetector detector) {
		TextView text = (TextView)findViewById(R.id.textView3);
		text.setText("begin");
		return true;
	}

	@Override
	public void onScaleEnd(ScaleGestureDetector detector) {
		TextView text = (TextView)findViewById(R.id.textView3);
		text.setText("end "+detector.getCurrentSpan());
	}

}
