Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): add stopAnimation() to View #10130

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0c9f35e
Android: stop animation
m1ga Jun 24, 2018
cc3f8d8
Android: stop animation
m1ga Jun 24, 2018
56d8cae
Merge branch 'master' into anistop
m1ga Jun 24, 2018
20d94b1
docs
m1ga Jun 24, 2018
09a7082
cancel event
m1ga Sep 22, 2018
aefae44
Merge branch 'master' into anistop
m1ga Sep 22, 2018
138ec43
Merge branch 'master' into anistop
m1ga Nov 16, 2018
605f64c
add animate() to stop the animation
m1ga Nov 21, 2018
fe3b4cb
Merge branch 'anistop' of https://github.com/m1ga/titanium_mobile int…
m1ga Nov 21, 2018
179a443
Merge branch 'master' into anistop
m1ga Nov 21, 2018
b284a54
Merge branch 'master' into anistop
m1ga Dec 20, 2018
8a52a3d
Merge branch 'master' into anistop
sgtcoolguy Jan 14, 2019
0766c04
Merge branch 'master' into anistop
sgtcoolguy Jan 15, 2019
3ff9214
Merge branch 'master' into anistop
m1ga May 4, 2019
dbe6797
Merge branch 'master' into anistop
sgtcoolguy Sep 9, 2019
3004dd7
Merge branch 'master' into anistop
m1ga Nov 21, 2019
9334d7a
Merge branch 'master' into anistop
m1ga Dec 31, 2019
4a2d882
Merge branch 'master' into anistop
m1ga Mar 18, 2020
4b68de3
Merge branch 'master' into anistop
m1ga Apr 25, 2020
ee3334c
Merge branch 'master' into anistop
m1ga May 28, 2020
f3d0bc2
Merge branch 'master' into anistop
m1ga Aug 16, 2020
73f325b
Merge branch 'master' into anistop
m1ga Oct 25, 2020
2a807c6
Merge branch 'master' into anistop
m1ga Jan 22, 2021
f902a2e
Merge branch 'master' into anistop
m1ga Jul 8, 2021
daeba00
Merge branch 'master' into anistop
m1ga Jan 4, 2022
fefcf74
Merge branch 'master' into anistop
m1ga Mar 20, 2022
03bf0cc
fix: issue templates
m1ga Mar 26, 2022
6ce8409
Revert "fix(tests): move to getter/setter (#12441)"
m1ga Mar 26, 2022
6bffbc4
Merge branch 'master' of https://github.com/appcelerator/titanium_mobile
m1ga Mar 27, 2022
4e7b649
Merge branch 'master' into anistop
m1ga Mar 27, 2022
51e9bcc
tests, bugfixes, doc update
m1ga Mar 27, 2022
578dc26
Merge branch 'anistop' of https://github.com/m1ga/titanium_mobile int…
m1ga Mar 27, 2022
2fad1a8
Merge branch 'tidev:master' into master
m1ga Mar 27, 2022
ae8a987
Merge branch 'master' of https://github.com/m1ga/titanium_mobile
m1ga Mar 27, 2022
4458f33
Merge branch 'master' into anistop
m1ga Mar 27, 2022
182d439
fix tests again
m1ga Mar 27, 2022
f9df876
Merge branch 'master' into anistop
m1ga Jul 2, 2022
e3ca791
Merge branch 'master' into anistop
m1ga Feb 10, 2023
43e39f4
docs
m1ga Feb 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,16 @@ public void animate(Object arg, @Kroll.argument(optional = true) KrollFunction c
}
}

@Kroll.method
public void stopAnimation()
{
TiUIView tiv = peekView();

if (tiv != null) {
tiv.stopAnimation();
}
}

public void handlePendingAnimation(boolean forceQueue)
{
if (pendingAnimation != null && peekView() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public class TiAnimationBuilder
protected View view;
protected AnimatorHelper animatorHelper;
protected TiViewProxy viewProxy;
protected AnimatorSet animatorSet;

public TiAnimationBuilder()
{
Expand Down Expand Up @@ -628,7 +629,7 @@ private AnimatorSet buildPropertyAnimators(int x, int y, int w, int h, int paren
if (delay != null) {
as.setStartDelay(delay.longValue());
}

animatorSet = as;
return as;
}

Expand Down Expand Up @@ -1416,6 +1417,17 @@ public void start(TiViewProxy viewProxy, View view)
}
}

public void stop(View view)
{
if (animatorSet != null) {
animatorSet.removeAllListeners();
animatorSet.cancel();
animatorSet = null;
}
view.clearAnimation();
setAnimationRunningFor(view, false);
}

private void setAnchor(int width, int height)
{
setAnchor(width, height, anchorX, anchorY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public abstract class TiUIView implements KrollProxyListener, OnFocusChangeListe
private AtomicBoolean bLayoutPending = new AtomicBoolean();
private AtomicBoolean bTransformPending = new AtomicBoolean();

private TiAnimationBuilder tiBuilder;
/**
* Constructs a TiUIView object with the associated proxy.
* @param proxy the associated proxy.
Expand Down Expand Up @@ -377,12 +378,12 @@ public void animate()
}
}

TiAnimationBuilder builder = proxy.getPendingAnimation();
if (builder == null) {
tiBuilder = proxy.getPendingAnimation();
if (tiBuilder == null) {
return;
}

proxy.clearAnimation(builder);
proxy.clearAnimation(tiBuilder);

// If a view is "visible" but not currently seen (such as because it's covered or
// its position is currently set to be fully outside its parent's region),
Expand Down Expand Up @@ -410,14 +411,22 @@ public void animate()
if (Log.isDebugModeEnabled()) {
Log.d(TAG, "starting animation", Log.DEBUG_MODE);
}

builder.start(proxy, outerView);
tiBuilder.start(proxy, outerView);

if (invalidateParent) {
((View) viewParent).postInvalidate();
}
}

public void stopAnimation()
{
View outerView = getOuterView();
if (outerView == null || bTransformPending.get() || tiBuilder == null) {
return;
}
tiBuilder.stop(outerView);
}

public void listenerAdded(String type, int count, KrollProxy proxy)
{
}
Expand Down
7 changes: 7 additions & 0 deletions apidoc/Titanium/UI/View.yml
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,13 @@ methods:
since: "3.0.0"
notes: Use the <Titanium.Proxy.applyProperties> method to batch-update layout properties.

- name: stopAnimation
summary: Stops a running animation.
description: |
Stops a running view [Animation](Titanium.UI.Animation).
platforms: [android]
since: { android: "7.4.0" }

- name: toImage
summary: Returns an image of the rendered view, as a Blob.
description: |
Expand Down