Search in sources :

Example 66 with Point

use of android.graphics.Point in project AdvancedMaterialDrawer by madcyph3r.

the class MaterialRippleLayout method onTouchEvent.

@Override
public boolean onTouchEvent(MotionEvent event) {
    boolean superOnTouchEvent = super.onTouchEvent(event);
    if (!isEnabled() || !childView.isEnabled())
        return superOnTouchEvent;
    boolean isEventInBounds = bounds.contains((int) event.getX(), (int) event.getY());
    if (isEventInBounds) {
        previousCoords.set(currentCoords.x, currentCoords.y);
        currentCoords.set((int) event.getX(), (int) event.getY());
    }
    boolean gestureResult = gestureDetector.onTouchEvent(event);
    if (gestureResult || mHasPerformedLongPress) {
        return true;
    } else {
        int action = event.getActionMasked();
        switch(action) {
            case MotionEvent.ACTION_UP:
                pendingClickEvent = new PerformClickEvent();
                if (prepressed) {
                    childView.setPressed(true);
                    postDelayed(new Runnable() {

                        @Override
                        public void run() {
                            childView.setPressed(false);
                        }
                    }, ViewConfiguration.getPressedStateDuration());
                }
                if (isEventInBounds) {
                    startRipple(pendingClickEvent);
                } else if (!rippleHover) {
                    setRadius(0);
                }
                if (!rippleDelayClick && isEventInBounds) {
                    pendingClickEvent.run();
                }
                cancelPressedEvent();
                break;
            case MotionEvent.ACTION_DOWN:
                setPositionInAdapter();
                eventCancelled = false;
                pendingPressEvent = new PressedEvent(event);
                if (isInScrollingContainer()) {
                    cancelPressedEvent();
                    prepressed = true;
                    postDelayed(pendingPressEvent, ViewConfiguration.getTapTimeout());
                } else {
                    pendingPressEvent.run();
                }
                break;
            case MotionEvent.ACTION_CANCEL:
                if (rippleInAdapter) {
                    // dont use current coords in adapter since they tend to jump drastically on scroll
                    currentCoords.set(previousCoords.x, previousCoords.y);
                    previousCoords = new Point();
                }
                childView.onTouchEvent(event);
                if (rippleHover) {
                    if (!prepressed) {
                        startRipple(null);
                    }
                } else {
                    childView.setPressed(false);
                }
                cancelPressedEvent();
                break;
            case MotionEvent.ACTION_MOVE:
                if (rippleHover) {
                    if (isEventInBounds && !eventCancelled) {
                        invalidate();
                    } else if (!isEventInBounds) {
                        startRipple(null);
                    }
                }
                if (!isEventInBounds) {
                    cancelPressedEvent();
                    if (hoverAnimator != null) {
                        hoverAnimator.cancel();
                    }
                    childView.onTouchEvent(event);
                    eventCancelled = true;
                }
                break;
        }
        return true;
    }
}
Also used : Point(android.graphics.Point) Point(android.graphics.Point) Paint(android.graphics.Paint)

Example 67 with Point

use of android.graphics.Point in project robolectric by robolectric.

the class ShadowDisplay method getCurrentSizeRange.

@Implementation
public void getCurrentSizeRange(Point outSmallestSize, Point outLargestSize) {
    int minimum = Math.min(width, height);
    int maximum = Math.max(width, height);
    outSmallestSize.set(minimum, minimum);
    outLargestSize.set(maximum, maximum);
}
Also used : Point(android.graphics.Point) Implementation(org.robolectric.annotation.Implementation)

Example 68 with Point

use of android.graphics.Point in project robolectric by robolectric.

the class ShadowView method scrollTo.

@Implementation
public void scrollTo(int x, int y) {
    try {
        Method method = View.class.getDeclaredMethod("onScrollChanged", new Class[] { int.class, int.class, int.class, int.class });
        method.setAccessible(true);
        method.invoke(realView, x, y, scrollToCoordinates.x, scrollToCoordinates.y);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    scrollToCoordinates = new Point(x, y);
}
Also used : Method(java.lang.reflect.Method) Point(android.graphics.Point) RemoteException(android.os.RemoteException)

Example 69 with Point

use of android.graphics.Point in project robolectric by robolectric.

the class ShadowBitmapFactoryTest method createShouldSetSizeToValueFromMapAsFirstPriority.

@Test
public void createShouldSetSizeToValueFromMapAsFirstPriority() {
    ShadowBitmapFactory.provideWidthAndHeightHints("image.png", 111, 222);
    final Bitmap bitmap = ShadowBitmapFactory.create("file:image.png", null, new Point(50, 60));
    assertThat(bitmap.getWidth()).isEqualTo(111);
    assertThat(bitmap.getHeight()).isEqualTo(222);
}
Also used : Bitmap(android.graphics.Bitmap) Point(android.graphics.Point) Test(org.junit.Test)

Example 70 with Point

use of android.graphics.Point in project PagerSlidingTabStrip by astuetz.

the class QuickContactFragment method onStart.

@SuppressWarnings("deprecation")
@Override
public void onStart() {
    super.onStart();
    // change dialog width
    if (getDialog() != null) {
        int fullWidth = getDialog().getWindow().getAttributes().width;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
            Display display = getActivity().getWindowManager().getDefaultDisplay();
            Point size = new Point();
            display.getSize(size);
            fullWidth = size.x;
        } else {
            Display display = getActivity().getWindowManager().getDefaultDisplay();
            fullWidth = display.getWidth();
        }
        final int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24, getResources().getDisplayMetrics());
        int w = fullWidth - padding;
        int h = getDialog().getWindow().getAttributes().height;
        getDialog().getWindow().setLayout(w, h);
    }
}
Also used : Point(android.graphics.Point) Point(android.graphics.Point) Display(android.view.Display)

Aggregations

Point (android.graphics.Point)1151 Display (android.view.Display)217 Rect (android.graphics.Rect)194 Paint (android.graphics.Paint)170 WindowManager (android.view.WindowManager)138 RemoteException (android.os.RemoteException)76 RectF (android.graphics.RectF)62 Bitmap (android.graphics.Bitmap)54 Resources (android.content.res.Resources)41 View (android.view.View)41 ArrayList (java.util.ArrayList)40 ImageView (android.widget.ImageView)37 Camera (android.hardware.Camera)36 Canvas (android.graphics.Canvas)31 Matrix (android.graphics.Matrix)29 Animator (android.animation.Animator)27 SuppressLint (android.annotation.SuppressLint)27 Configuration (android.content.res.Configuration)26 IOException (java.io.IOException)24 Message (android.os.Message)22