Skip to content

Commit

Permalink
add call back when the danmaku drawing has been finished
Browse files Browse the repository at this point in the history
  • Loading branch information
xyczero committed Nov 10, 2015
1 parent b66b416 commit eb6fdc7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public interface Callback {
public void prepared();

public void updateTimer(DanmakuTimer timer);

public void drawingFinished();

}

public static final int START = 1;
Expand Down Expand Up @@ -474,6 +477,13 @@ public void onDanmakuAdd(BaseDanmaku danmaku) {
obtainMessage(NOTIFY_RENDERING).sendToTarget();
}

@Override
public void onDanmakusDrawingFinished() {
if (mCallback != null) {
mCallback.drawingFinished();
}
}

@Override
public void onDanmakuConfigChanged() {
if (quitFlag && mDanmakusVisible) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public class DrawTask implements IDrawTask {
private long mLastEndMills;

private boolean mIsHidden;

private BaseDanmaku mLastDanmaku;

private ConfigChangedCallback mConfigChangedCallback = new ConfigChangedCallback() {
@Override
public boolean onDanmakuConfigChanged(DanmakuContext config, DanmakuConfigTag tag, Object... values) {
Expand Down Expand Up @@ -117,6 +120,10 @@ public synchronized void addDanmaku(BaseDanmaku item) {
if (added && mTaskListener != null) {
mTaskListener.onDanmakuAdd(item);
}

if (mLastDanmaku == null || (item != null && mLastDanmaku != null && item.time > mLastDanmaku.time)) {
mLastDanmaku = item;
}
}

@Override
Expand Down Expand Up @@ -246,6 +253,10 @@ protected void loadDanmakus(BaseDanmakuParser parser) {
}
}
mContext.mGlobalFlagValues.resetAll();

if(danmakuList != null) {
mLastDanmaku = danmakuList.last();
}
}

public void setParser(BaseDanmakuParser parser) {
Expand Down Expand Up @@ -282,6 +293,9 @@ protected RenderingState drawDanmakus(AbsDisplayer disp, DanmakuTimer timer) {
if (danmakus != null && !danmakus.isEmpty()) {
RenderingState renderingState = mRenderingState = mRenderer.draw(mDisp, danmakus, mStartRenderTime);
if (renderingState.nothingRendered) {
if(mTaskListener != null && mLastDanmaku != null && mLastDanmaku.isTimeOut()) {
mTaskListener.onDanmakusDrawingFinished();
}
if (renderingState.beginTime == RenderingState.UNKNOWN_TIME) {
renderingState.beginTime = beginMills;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public interface TaskListener {
public void onDanmakuAdd(BaseDanmaku danmaku);

public void onDanmakuConfigChanged();

public void onDanmakusDrawingFinished();
}

public void requestHide();
Expand Down

0 comments on commit eb6fdc7

Please sign in to comment.