Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
halo
packages_apps_Gallery2
Commits
fd695590
Commit
fd695590
authored
13 years ago
by
Chih-Chung Chang
Committed by
The Android Automerger
13 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Patch 2 for MR1.
Change-Id: I39cc780e0ef49c4e0863a1a83e585e16f0a32425
parent
1cdcda48
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
5 deletions
+54
-5
src/com/android/gallery3d/ui/PhotoView.java
src/com/android/gallery3d/ui/PhotoView.java
+31
-1
src/com/android/gallery3d/ui/PositionController.java
src/com/android/gallery3d/ui/PositionController.java
+23
-4
No files found.
src/com/android/gallery3d/ui/PhotoView.java
View file @
fd695590
...
...
@@ -43,6 +43,7 @@ public class PhotoView extends GLView {
private
static
final
int
MSG_TRANSITION_COMPLETE
=
1
;
private
static
final
int
MSG_SHOW_LOADING
=
2
;
private
static
final
int
MSG_CANCEL_EXTRA_SCALING
=
3
;
private
static
final
long
DELAY_SHOW_LOADING
=
250
;
// 250ms;
...
...
@@ -111,6 +112,7 @@ public class PhotoView extends GLView {
private
Path
mOpenedItemPath
;
private
GalleryActivity
mActivity
;
private
Point
mImageCenter
=
new
Point
();
private
boolean
mCancelExtraScalingPending
;
public
PhotoView
(
GalleryActivity
activity
)
{
mActivity
=
activity
;
...
...
@@ -146,6 +148,12 @@ public class PhotoView extends GLView {
}
break
;
}
case
MSG_CANCEL_EXTRA_SCALING:
{
cancelScaleGesture
();
mPositionController
.
setExtraScalingRange
(
false
);
mCancelExtraScalingPending
=
false
;
break
;
}
default
:
throw
new
AssertionError
(
message
.
what
);
}
}
...
...
@@ -585,8 +593,22 @@ public class PhotoView extends GLView {
float
scale
=
detector
.
getScaleFactor
();
if
(
Float
.
isNaN
(
scale
)
||
Float
.
isInfinite
(
scale
)
||
mTransitionMode
!=
TRANS_NONE
)
return
true
;
mPositionController
.
scaleBy
(
scale
,
boolean
outOfRange
=
mPositionController
.
scaleBy
(
scale
,
detector
.
getFocusX
(),
detector
.
getFocusY
());
if
(
outOfRange
)
{
if
(!
mCancelExtraScalingPending
)
{
mHandler
.
sendEmptyMessageDelayed
(
MSG_CANCEL_EXTRA_SCALING
,
700
);
mPositionController
.
setExtraScalingRange
(
true
);
mCancelExtraScalingPending
=
true
;
}
}
else
{
if
(
mCancelExtraScalingPending
)
{
mHandler
.
removeMessages
(
MSG_CANCEL_EXTRA_SCALING
);
mPositionController
.
setExtraScalingRange
(
false
);
mCancelExtraScalingPending
=
false
;
}
}
return
true
;
}
...
...
@@ -605,6 +627,14 @@ public class PhotoView extends GLView {
}
}
private
void
cancelScaleGesture
()
{
long
now
=
SystemClock
.
uptimeMillis
();
MotionEvent
cancelEvent
=
MotionEvent
.
obtain
(
now
,
now
,
MotionEvent
.
ACTION_CANCEL
,
0
,
0
,
0
);
mScaleDetector
.
onTouchEvent
(
cancelEvent
);
cancelEvent
.
recycle
();
}
public
boolean
jumpTo
(
int
index
)
{
if
(
mTransitionMode
!=
TRANS_NONE
)
return
false
;
mModel
.
jumpTo
(
index
);
...
...
This diff is collapsed.
Click to expand it.
src/com/android/gallery3d/ui/PositionController.java
View file @
fd695590
...
...
@@ -64,6 +64,9 @@ class PositionController {
private
static
final
float
SCALE_LIMIT
=
4
;
private
static
final
int
sHorizontalSlack
=
GalleryUtils
.
dpToPixel
(
12
);
private
static
final
float
SCALE_MIN_EXTRA
=
0.6f
;
private
static
final
float
SCALE_MAX_EXTRA
=
1.4f
;
private
PhotoView
mViewer
;
private
EdgeView
mEdgeView
;
private
int
mImageW
,
mImageH
;
...
...
@@ -83,6 +86,7 @@ class PositionController {
// The minimum and maximum scale we allow.
private
float
mScaleMin
,
mScaleMax
=
SCALE_LIMIT
;
private
boolean
mExtraScalingRange
=
false
;
// This is used by the fling animation
private
FlingScroller
mScroller
;
...
...
@@ -268,7 +272,8 @@ class PositionController {
(
focusY
-
mViewH
/
2
f
)
/
mCurrentScale
);
}
public
void
scaleBy
(
float
s
,
float
focusX
,
float
focusY
)
{
// Returns true if the result scale is outside the stable range.
public
boolean
scaleBy
(
float
s
,
float
focusX
,
float
focusY
)
{
// We want to keep the focus point (on the bitmap) the same as when
// we begin the scale guesture, that is,
...
...
@@ -280,6 +285,7 @@ class PositionController {
int
y
=
Math
.
round
(
mFocusBitmapY
-
(
focusY
-
mViewH
/
2
f
)
/
s
);
startAnimation
(
x
,
y
,
s
,
ANIM_KIND_SCALE
);
return
(
s
<
mScaleMin
||
s
>
mScaleMax
);
}
public
void
endScale
()
{
...
...
@@ -287,6 +293,13 @@ class PositionController {
startSnapbackIfNeeded
();
}
public
void
setExtraScalingRange
(
boolean
enabled
)
{
mExtraScalingRange
=
enabled
;
if
(!
enabled
)
{
startSnapbackIfNeeded
();
}
}
public
float
getCurrentScale
()
{
return
mCurrentScale
;
}
...
...
@@ -400,7 +413,8 @@ class PositionController {
mToX
=
targetX
;
mToY
=
targetY
;
mToScale
=
Utils
.
clamp
(
scale
,
0.6f
*
mScaleMin
,
1.4f
*
mScaleMax
);
mToScale
=
Utils
.
clamp
(
scale
,
SCALE_MIN_EXTRA
*
mScaleMin
,
SCALE_MAX_EXTRA
*
mScaleMax
);
// If the scaled height is smaller than the view height,
// force it to be in the center.
...
...
@@ -540,9 +554,14 @@ class PositionController {
boolean
needAnimation
=
false
;
float
scale
=
mCurrentScale
;
if
(
mCurrentScale
<
mScaleMin
||
mCurrentScale
>
mScaleMax
)
{
float
scaleMin
=
mExtraScalingRange
?
mScaleMin
*
SCALE_MIN_EXTRA
:
mScaleMin
;
float
scaleMax
=
mExtraScalingRange
?
mScaleMax
*
SCALE_MAX_EXTRA
:
mScaleMax
;
if
(
mCurrentScale
<
scaleMin
||
mCurrentScale
>
scaleMax
)
{
needAnimation
=
true
;
scale
=
Utils
.
clamp
(
mCurrentScale
,
mS
caleMin
,
mS
caleMax
);
scale
=
Utils
.
clamp
(
mCurrentScale
,
s
caleMin
,
s
caleMax
);
}
calculateStableBound
(
scale
,
sHorizontalSlack
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment