Exemplo n.º 1
0
 @Override
 public void removeAllDanmakus() {
   if (danmakuList == null || danmakuList.isEmpty()) return;
   synchronized (danmakuList) {
     danmakuList.clear();
   }
 }
Exemplo n.º 2
0
 @Override
 public void removeAllLiveDanmakus() {
   if (danmakuList == null || danmakuList.isEmpty()) return;
   synchronized (danmakuList) {
     IDanmakuIterator it = danmakuList.iterator();
     while (it.hasNext()) {
       if (it.next().isLive) {
         it.remove();
       }
     }
   }
 }
Exemplo n.º 3
0
 @Override
 public synchronized void removeAllLiveDanmakus() {
   if (danmakus == null || danmakus.isEmpty()) return;
   synchronized (danmakus) {
     IDanmakuIterator it = danmakus.iterator();
     while (it.hasNext()) {
       BaseDanmaku danmaku = it.next();
       if (danmaku.isLive) {
         it.remove();
         onDanmakuRemoved(danmaku);
       }
     }
   }
 }
Exemplo n.º 4
0
 protected void removeUnusedLiveDanmakusIn(int msec) {
   if (danmakuList == null || danmakuList.isEmpty()) return;
   long startTime = System.currentTimeMillis();
   IDanmakuIterator it = danmakuList.iterator();
   while (it.hasNext()) {
     BaseDanmaku danmaku = it.next();
     if (danmaku.isLive && danmaku.isTimeOut()) {
       it.remove();
     }
     if (System.currentTimeMillis() - startTime > msec) {
       break;
     }
   }
 }
Exemplo n.º 5
0
 protected synchronized void removeUnusedLiveDanmakusIn(int msec) {
   if (danmakuList == null || danmakuList.isEmpty()) return;
   long startTime = System.currentTimeMillis();
   IDanmakuIterator it = danmakuList.iterator();
   while (it.hasNext()) {
     BaseDanmaku danmaku = it.next();
     boolean isTimeout = danmaku.isTimeOut();
     if (isTimeout && danmaku.isLive) {
       it.remove();
       onDanmakuRemoved(danmaku);
     }
     if (!isTimeout || System.currentTimeMillis() - startTime > msec) {
       break;
     }
   }
 }
Exemplo n.º 6
0
 protected RenderingState drawDanmakus(AbsDisplayer<?> disp, DanmakuTimer timer) {
   if (clearRetainerFlag) {
     DanmakusRetainer.clear();
     clearRetainerFlag = false;
   }
   if (danmakuList != null) {
     Canvas canvas = (Canvas) disp.getExtraData();
     DrawHelper.clearCanvas(canvas);
     if (mIsHidden) {
       return mRenderingState;
     }
     long beginMills = timer.currMillisecond - DanmakuFactory.MAX_DANMAKU_DURATION - 100;
     long endMills = timer.currMillisecond + DanmakuFactory.MAX_DANMAKU_DURATION;
     if (mLastBeginMills > beginMills || timer.currMillisecond > mLastEndMills) {
       IDanmakus subDanmakus = danmakuList.sub(beginMills, endMills);
       if (subDanmakus != null) {
         danmakus = subDanmakus;
       } else {
         danmakus.clear();
       }
       mLastBeginMills = beginMills;
       mLastEndMills = endMills;
     } else {
       beginMills = mLastBeginMills;
       endMills = mLastEndMills;
     }
     if (danmakus != null && !danmakus.isEmpty()) {
       RenderingState renderingState =
           mRenderingState = mRenderer.draw(mDisp, danmakus, mStartRenderTime);
       if (renderingState.nothingRendered) {
         if (renderingState.beginTime == RenderingState.UNKNOWN_TIME) {
           renderingState.beginTime = beginMills;
         }
         if (renderingState.endTime == RenderingState.UNKNOWN_TIME) {
           renderingState.endTime = endMills;
         }
       }
       return renderingState;
     } else {
       mRenderingState.nothingRendered = true;
       mRenderingState.beginTime = beginMills;
       mRenderingState.endTime = endMills;
       return mRenderingState;
     }
   }
   return null;
 }