Last active
March 31, 2019 14:24
-
-
Save gavingt/658a517c217c0899e7671eafdcfd7e34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package appinventor.ai_GavinGT.DeliveryTipTrackerPro_ready_for_market.custom_classes; | |
import android.content.Context; | |
import android.util.AttributeSet; | |
import android.util.Log; | |
import android.view.GestureDetector; | |
import android.view.MotionEvent; | |
import android.widget.LinearLayout; | |
import androidx.annotation.Nullable; | |
public class MyLinearLayout extends LinearLayout { | |
GestureDetector mDetector; | |
public MyLinearLayout(Context context) { | |
super(context); | |
mDetector = new GestureDetector(context, new MyGestureListener()); | |
} | |
public MyLinearLayout(Context context, @Nullable AttributeSet attrs) { | |
super(context, attrs); | |
mDetector = new GestureDetector(context, new MyGestureListener()); | |
} | |
public MyLinearLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { | |
super(context, attrs, defStyleAttr); | |
mDetector = new GestureDetector(context, new MyGestureListener()); | |
} | |
@Override | |
public boolean onInterceptTouchEvent(MotionEvent ev) { | |
return mDetector.onTouchEvent(ev); | |
} | |
@Override | |
public boolean onTouchEvent(MotionEvent ev) { | |
mDetector.onTouchEvent(ev); | |
return true; | |
} | |
} | |
// In the SimpleOnGestureListener subclass you should override | |
// onDown and any other gesture that you want to detect. | |
class MyGestureListener extends GestureDetector.SimpleOnGestureListener { | |
@Override | |
public boolean onDown(MotionEvent event) { | |
Log.d("TAG","onDown: "); | |
return false; | |
} | |
@Override | |
public boolean onScroll(MotionEvent e1, MotionEvent e2, | |
float distanceX, float distanceY) { | |
Log.i("TAG", "onScroll: "); | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment