package com.example.siddieboyy.myapplication;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.view.MotionEvent;
import android.view.GestureDetector;
import android.support.v4.view.GestureDetectorCompat;


public class MainActivity extends ActionBarActivity implements GestureDetector.OnDoubleTapListener,
GestureDetector.OnGestureListener {

private TextView changetext;
private GestureDetectorCompat gestureDetector;


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

TextView sidstext = (TextView)findViewById(R.id.changetext);
this.gestureDetector = new GestureDetectorCompat(this,this);
gestureDetector.setOnDoubleTapListener(this);

Button sidsbutton = (Button)findViewById(R.id.changebutton);
sidsbutton.setOnClickListener(
new Button.OnClickListener()
{
public void onClick(View v)
{
TextView sidstext = (TextView)findViewById(R.id.changetext);
sidstext.setText("I got Changed");
}
}
);
sidsbutton.setOnLongClickListener(
new Button.OnLongClickListener()
{
public boolean onLongClick(View v)
{
TextView sidstext = (TextView)findViewById(R.id.changetext);
sidstext.setText("I already got Changed Bruh!!");
return true;
}
}
);
}

@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
changetext.setText("Getting Scrolled");
return true;
}

@Override
public boolean onTouchEvent(MotionEvent event) {
this.gestureDetector.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.menu_main, menu);
return true;
}


@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}

return super.onOptionsItemSelected(item);
}
}