diff options
author | Chih-Chung Chang <chihchung@google.com> | 2009-05-13 16:42:57 +0800 |
---|---|---|
committer | Chih-Chung Chang <chihchung@google.com> | 2009-05-13 16:43:13 +0800 |
commit | 56a8643a84a829ba9de36e6b4fb2137f42da5a32 (patch) | |
tree | 2552371ee1978fb3f78ce24c7925d10967244395 /src/com/android/camera/GridViewSpecial.java | |
parent | dfedc5bad4632e3128af96933883257ea0718d6b (diff) | |
download | LegacyCamera-56a8643a84a829ba9de36e6b4fb2137f42da5a32.zip LegacyCamera-56a8643a84a829ba9de36e6b4fb2137f42da5a32.tar.gz LegacyCamera-56a8643a84a829ba9de36e6b4fb2137f42da5a32.tar.bz2 |
Put scrolling position in the valid range.
Diffstat (limited to 'src/com/android/camera/GridViewSpecial.java')
-rw-r--r-- | src/com/android/camera/GridViewSpecial.java | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/com/android/camera/GridViewSpecial.java b/src/com/android/camera/GridViewSpecial.java index 87751b3..142110d 100644 --- a/src/com/android/camera/GridViewSpecial.java +++ b/src/com/android/camera/GridViewSpecial.java @@ -205,6 +205,10 @@ class GridViewSpecial extends View { mMaxScrollY = mSpec.mCellSpacing + (mRows * mBlockHeight) - (bottom - top); + // Put mScrollY in the valid range. This matters if mMaxScrollY is + // changed. For example, orientation changed from portrait to landscape. + mScrollY = Math.max(0, Math.min(mMaxScrollY, mScrollY)); + generateOutlineBitmap(); if (mImageBlockManager != null) { @@ -215,10 +219,10 @@ class GridViewSpecial extends View { mAllImages, mLoader, mDrawAdapter, mSpec, mColumns, width, mOutline[OUTLINE_EMPTY]); - moveDataWindow(); - mListener.onLayoutComplete(changed); + moveDataWindow(); + mLayoutComplete = true; } @@ -275,11 +279,12 @@ class GridViewSpecial extends View { // Calculate visible region according to scroll position. int startRow = (mScrollY - mSpec.mCellSpacing) / mBlockHeight; int endRow = (mScrollY + getHeight() - mSpec.mCellSpacing - 1) - / mBlockHeight + 1; + / mBlockHeight; - startRow = Math.max(0, startRow); - endRow = Math.min(mRows, endRow); - mImageBlockManager.setVisibleRows(startRow, endRow); + // Limit startRow and endRow to the valid range. + startRow = Math.min(Math.max(startRow, 0), mRows - 1); + endRow = Math.min(Math.max(endRow, 0), mRows - 1); + mImageBlockManager.setVisibleRows(startRow, endRow + 1); } private class MyGestureDetector extends SimpleOnGestureListener { |