Skip to content

Instantly share code, notes, and snippets.

View MrCrambo's full-sized avatar
🏓
Win the world

mrcrambo MrCrambo

🏓
Win the world
  • Russia
View GitHub Profile
class GestureListener implements GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener
{
@Override
public boolean onSingleTapConfirmed(MotionEvent e)
{
// Do smth with single tap
}
@Override
public boolean onDoubleTapEvent(MotionEvent e)
package com.navigine.navigine;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
int top;
if (state == STATE_COLLAPSED)
top = mMinOffset;
else if (state == STATE_EXPANDED
top = mMaxOffset;
else if (mHideable && state == STATE_HIDDEN)
top = -child.getHeight();
int currentTop = child.getTop();
int newTop = currentTop - dy;
if (dy > 0) {
if (!ViewCompat.canScrollVertically(target, 1)) {
if (newTop >= mMinOffset || mHideable) {
consumed[1] = dy;
ViewCompat.offsetTopAndBottom(child, -dy);
setStateInternal(STATE_DRAGGING);
} else {
consumed[1] = currentTop - mMinOffset;
@Override
public boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection) {
if (ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(child))
ViewCompat.setFitsSystemWindows(child, true);
int savedTop = child.getTop();
// First let the parent lay it out
parent.onLayoutChild(child, layoutDirection);
ConstraintLayout logsTopSheet = findViewById(R.id.navigine__logcat_sheet);
TopSheetBehavior topSheetBehavior = TopSheetBehavior.from(logsTopSheet);
topSheetBehavior.setState(TopSheetBehavior.STATE_HIDDEN);
JNIEXPORT void JNICALL
Java_com_navigine_view_internal_GLRenderer_onEventHandled(JNIEnv * env, jobject self, jobject motionEvent)
{
// getting motion event class
jclass motionEventClass=env->GetObjectClass(motionEvent);
// getting functions id
jmethodID pointersCountMethodId = env->GetMethodID(motionEventClass, "getPointerCount", "()I");
jmethodID pointerIndexMethodId = env->GetMethodID(motionEventClass, "findPointerIndex", "(I)I");
jmethodID getActionMethodId = env->GetMethodID(motionEventClass, "getActionMasked", "()I");
case MotionEvent.ACTION_POINTER_UP:
int index = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
// ..
// Do something here ..
// ..
break;
/**
* A pressed gesture has started, the
* motion contains the initial starting location.
*/
public static final int ACTION_DOWN = 0;
/**
* A pressed gesture has finished, the
* motion contains the final release location as well as any intermediate
* points since the last down or move event.
...
bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(View view, int i) {
// ..
// your code is here
}
@Override