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

fix PAGViewListener callback unexpected not called #2504

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
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
23 changes: 9 additions & 14 deletions ohos/libpag/src/main/ets/PAGView.ets
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//
/////////////////////////////////////////////////////////////////////////////////////////////////

import { JPAGView } from 'libpag.so'
import { JPAGView } from 'libpag.so';
import { PAGComposition } from './PAGComposition';
import { PAGScaleMode } from './PAGScaleMode';
import { PAGLayer } from './PAGLayer';
Expand Down Expand Up @@ -350,14 +350,14 @@ export class PAGViewController {
* Adds a listener to the set of listeners that are sent events through the life of an
* animation, such as start, repeat, and end.
*/
addListener(listener: WeakRef<PAGViewListener>) {
addListener(listener: PAGViewListener) {
this.listeners.push(listener);
}

/**
* Removes a listener from the set listening to this animation.
*/
removeListener(listener: WeakRef<PAGViewListener>) {
removeListener(listener: PAGViewListener) {
let index = this.listeners.indexOf(listener);
if (index != -1) {
this.listeners.splice(index);
Expand Down Expand Up @@ -389,35 +389,31 @@ export class PAGViewController {
}

private onAnimationStart() {
for (const weakListener of this.listeners) {
const listener = weakListener.deref();
for (const listener of this.listeners) {
if (listener && listener.onAnimationStart) {
listener.onAnimationStart(this);
}
}
}

private onAnimationEnd() {
for (const weakListener of this.listeners) {
const listener = weakListener.deref();
for (const listener of this.listeners) {
if (listener && listener.onAnimationEnd) {
listener.onAnimationEnd(this);
}
}
}

private onAnimationCancel() {
for (const weakListener of this.listeners) {
const listener = weakListener.deref();
for (const listener of this.listeners) {
if (listener && listener.onAnimationCancel) {
listener.onAnimationCancel(this);
}
}
}

private onAnimationRepeat() {
for (const weakListener of this.listeners) {
const listener = weakListener.deref();
for (const listener of this.listeners) {
if (listener && listener.onAnimationRepeat) {
listener.onAnimationRepeat(this);
}
Expand All @@ -437,16 +433,15 @@ export class PAGViewController {
}
}
private onAnimatorProgressUpdate = (): void => {
for (const weakListener of this.listeners) {
const listener = weakListener.deref();
for (const listener of this.listeners) {
if (listener && listener.onAnimationUpdate) {
listener.onAnimationUpdate(this);
}
}
}
private composition: PAGComposition | null = null;
private filePath: string | null = null;
private listeners: Array<WeakRef<PAGViewListener>> = [];
private listeners: Array<PAGViewListener> = [];
private jView: JPAGView = new JPAGView();
private view: WeakRef<PAGView> | null = null;
}
Expand Down