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;
}
}
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);
}
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);
}
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);
}
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);
}
}
Aggregations