diff --git a/DanmakuFlameMaster/src/main/java/master/flame/danmaku/controller/DrawHandler.java b/DanmakuFlameMaster/src/main/java/master/flame/danmaku/controller/DrawHandler.java index 4031a160..c6cb85e1 100644 --- a/DanmakuFlameMaster/src/main/java/master/flame/danmaku/controller/DrawHandler.java +++ b/DanmakuFlameMaster/src/main/java/master/flame/danmaku/controller/DrawHandler.java @@ -46,6 +46,9 @@ public interface Callback { public void prepared(); public void updateTimer(DanmakuTimer timer); + + public void drawingFinished(); + } public static final int START = 1; @@ -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) { diff --git a/DanmakuFlameMaster/src/main/java/master/flame/danmaku/controller/DrawTask.java b/DanmakuFlameMaster/src/main/java/master/flame/danmaku/controller/DrawTask.java index a514e49b..358db891 100644 --- a/DanmakuFlameMaster/src/main/java/master/flame/danmaku/controller/DrawTask.java +++ b/DanmakuFlameMaster/src/main/java/master/flame/danmaku/controller/DrawTask.java @@ -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) { @@ -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 @@ -246,6 +253,10 @@ protected void loadDanmakus(BaseDanmakuParser parser) { } } mContext.mGlobalFlagValues.resetAll(); + + if(danmakuList != null) { + mLastDanmaku = danmakuList.last(); + } } public void setParser(BaseDanmakuParser parser) { @@ -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; } diff --git a/DanmakuFlameMaster/src/main/java/master/flame/danmaku/controller/IDrawTask.java b/DanmakuFlameMaster/src/main/java/master/flame/danmaku/controller/IDrawTask.java index dac21c1d..6be15dae 100644 --- a/DanmakuFlameMaster/src/main/java/master/flame/danmaku/controller/IDrawTask.java +++ b/DanmakuFlameMaster/src/main/java/master/flame/danmaku/controller/IDrawTask.java @@ -56,6 +56,8 @@ public interface TaskListener { public void onDanmakuAdd(BaseDanmaku danmaku); public void onDanmakuConfigChanged(); + + public void onDanmakusDrawingFinished(); } public void requestHide();