Skip to content

Commit

Permalink
added check for not null value
Browse files Browse the repository at this point in the history
  • Loading branch information
sephiroth74 committed Mar 18, 2013
1 parent 16ccac1 commit c537364
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ public boolean canScroll( int direction ) {
updateRect( bitmapRect, mScrollRect );
Rect imageViewRect = new Rect();
getGlobalVisibleRect( imageViewRect );

if( null == bitmapRect ) {
return false;
}

if ( bitmapRect.right >= imageViewRect.right ) {
if ( direction < 0 ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,16 +786,13 @@ protected void panBy( double dx, double dy ) {
protected void updateRect( RectF bitmapRect, RectF scrollRect ) {
if ( bitmapRect == null ) return;

float width = mThisWidth;
float height = mThisHeight;

if ( bitmapRect.top >= 0 && bitmapRect.bottom <= height ) scrollRect.top = 0;
if ( bitmapRect.left >= 0 && bitmapRect.right <= width ) scrollRect.left = 0;
if ( bitmapRect.top + scrollRect.top >= 0 && bitmapRect.bottom > height ) scrollRect.top = (int) ( 0 - bitmapRect.top );
if ( bitmapRect.bottom + scrollRect.top <= ( height - 0 ) && bitmapRect.top < 0 )
scrollRect.top = (int) ( ( height - 0 ) - bitmapRect.bottom );
if ( bitmapRect.top >= 0 && bitmapRect.bottom <= mThisHeight ) scrollRect.top = 0;
if ( bitmapRect.left >= 0 && bitmapRect.right <= mThisWidth ) scrollRect.left = 0;
if ( bitmapRect.top + scrollRect.top >= 0 && bitmapRect.bottom > mThisHeight ) scrollRect.top = (int) ( 0 - bitmapRect.top );
if ( bitmapRect.bottom + scrollRect.top <= ( mThisHeight - 0 ) && bitmapRect.top < 0 )
scrollRect.top = (int) ( ( mThisHeight - 0 ) - bitmapRect.bottom );
if ( bitmapRect.left + scrollRect.left >= 0 ) scrollRect.left = (int) ( 0 - bitmapRect.left );
if ( bitmapRect.right + scrollRect.left <= ( width - 0 ) ) scrollRect.left = (int) ( ( width - 0 ) - bitmapRect.right );
if ( bitmapRect.right + scrollRect.left <= ( mThisWidth - 0 ) ) scrollRect.left = (int) ( ( mThisWidth - 0 ) - bitmapRect.right );
}

protected void scrollBy( float distanceX, float distanceY, final double durationMs ) {
Expand Down

0 comments on commit c537364

Please sign in to comment.