Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Little fix with content size. Now the padding of the popover should b…

…e taked in account
  • Loading branch information...
commit ea1ec599ac3bd82100e3a0322ce3d2e544dccce7 1 parent 8271e6c
@lupidan authored
Showing with 25 additions and 16 deletions.
  1. +25 −16 src/com/daniel/lupianez/casares/PopoverView.java
View
41 src/com/daniel/lupianez/casares/PopoverView.java
@@ -165,6 +165,10 @@ public static Rect getFrameForView(View v){
*/
private Point contentSizeForViewInPopover = new Point(0, 0);
/**
+ * The real content size we will use (it considers the padding)
+ */
+ private Point realContentSize = new Point(0, 0);
+ /**
* A hash containing
*/
private Map<Integer, Rect> possibleRects;
@@ -397,11 +401,11 @@ private Rect getRectForArrowUp(Rect originRect){
//Get final width and height
int finalX = xAvailable;
- if ((contentSizeForViewInPopover.x > 0) && (contentSizeForViewInPopover.x < finalX))
- finalX = contentSizeForViewInPopover.x;
+ if ((realContentSize.x > 0) && (realContentSize.x < finalX))
+ finalX = realContentSize.x;
int finalY = yAvailable;
- if ((contentSizeForViewInPopover.y > 0) && (contentSizeForViewInPopover.y < finalY))
- finalY = contentSizeForViewInPopover.y;
+ if ((realContentSize.y > 0) && (realContentSize.y < finalY))
+ finalY = realContentSize.y;
//Get final origin X and Y
int originX = (originRect.centerX()-popoverLayoutRect.left) - (finalX/2) ;
@@ -435,11 +439,11 @@ private Rect getRectForArrowDown(Rect originRect){
//Get final width and height
int finalX = xAvailable;
- if ((contentSizeForViewInPopover.x > 0) && (contentSizeForViewInPopover.x < finalX))
- finalX = contentSizeForViewInPopover.x;
+ if ((realContentSize.x > 0) && (realContentSize.x < finalX))
+ finalX = realContentSize.x;
int finalY = yAvailable;
- if ((contentSizeForViewInPopover.y > 0) && (contentSizeForViewInPopover.y < finalY))
- finalY = contentSizeForViewInPopover.y;
+ if ((realContentSize.y > 0) && (realContentSize.y < finalY))
+ finalY = realContentSize.y;
//Get final origin X and Y
int originX = (originRect.centerX()-popoverLayoutRect.left) - (finalX/2) ;
@@ -473,11 +477,11 @@ private Rect getRectForArrowRight(Rect originRect){
//Get final width and height
int finalX = xAvailable;
- if ((contentSizeForViewInPopover.x > 0) && (contentSizeForViewInPopover.x < finalX))
- finalX = contentSizeForViewInPopover.x;
+ if ((realContentSize.x > 0) && (realContentSize.x < finalX))
+ finalX = realContentSize.x;
int finalY = yAvailable;
- if ((contentSizeForViewInPopover.y > 0) && (contentSizeForViewInPopover.y < finalY))
- finalY = contentSizeForViewInPopover.y;
+ if ((realContentSize.y > 0) && (realContentSize.y < finalY))
+ finalY = realContentSize.y;
//Get final origin X and Y
int originX = (originRect.left - popoverLayoutRect.left) - finalX;
@@ -509,11 +513,11 @@ private Rect getRectForArrowLeft(Rect originRect){
//Get final width and height
int finalX = xAvailable;
- if ((contentSizeForViewInPopover.x > 0) && (contentSizeForViewInPopover.x < finalX))
- finalX = contentSizeForViewInPopover.x;
+ if ((realContentSize.x > 0) && (realContentSize.x < finalX))
+ finalX = realContentSize.x;
int finalY = yAvailable;
- if ((contentSizeForViewInPopover.y > 0) && (contentSizeForViewInPopover.y < finalY))
- finalY = contentSizeForViewInPopover.y;
+ if ((realContentSize.y > 0) && (realContentSize.y < finalY))
+ finalY = realContentSize.y;
//Get final origin X and Y
int originX = (originRect.right - popoverLayoutRect.left);
@@ -617,6 +621,11 @@ public Point getContentSizeForViewInPopover() {
*/
public void setContentSizeForViewInPopover(Point contentSizeForViewInPopover) {
this.contentSizeForViewInPopover = contentSizeForViewInPopover;
+ //Save the real content size
+ realContentSize = new Point(contentSizeForViewInPopover);
+ realContentSize.x += popoverView.getPaddingLeft()+popoverView.getPaddingRight();
+ realContentSize.y += popoverView.getPaddingTop()+popoverView.getPaddingBottom();
+
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.