Java Code Examples for master.flame.danmaku.danmaku.model.BaseDanmaku#isTimeOut()
The following examples show how to use
master.flame.danmaku.danmaku.model.BaseDanmaku#isTimeOut() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DrawTask.java From letv with Apache License 2.0 | 6 votes |
protected synchronized void removeUnusedLiveDanmakusIn(int msec) { if (this.danmakuList != null && !this.danmakuList.isEmpty()) { long startTime = SystemClock.uptimeMillis(); IDanmakuIterator it = this.danmakuList.iterator(); while (it.hasNext()) { BaseDanmaku danmaku = it.next(); boolean isTimeout = danmaku.isTimeOut(); if (isTimeout && danmaku.isLive) { it.remove(); onDanmakuRemoved(danmaku); } if (isTimeout) { if (SystemClock.uptimeMillis() - startTime > ((long) msec)) { break; } } break; } } }
Example 2
Source File: DanmakuFilters.java From letv with Apache License 2.0 | 6 votes |
private boolean needFilter(BaseDanmaku danmaku, int orderInScreen, int totalSizeInScreen, DanmakuTimer timer, boolean fromCachingTask, DanmakuContext context) { Log.v("XX", "QuantityDanmakuFilter needFilter mMaximumSize : " + this.mMaximumSize + " totalSizeInScreen : " + totalSizeInScreen + " orderInScreen : " + orderInScreen + " danmaku.isTimeOut() " + danmaku.isTimeOut() + " mMaximumSize : " + this.mMaximumSize + " isShown :" + danmaku.isShown()); if (this.mMaximumSize == 0) { return true; } if (totalSizeInScreen < this.mMaximumSize || (this.mLastSkipped != null && danmaku.time - this.mLastSkipped.time > context.mDanmakuFactory.MAX_DANMAKU_DURATION / 4)) { Log.v("xx", " QuantityDanmakuFilter not guolv2222 >>>>>>>>"); this.mLastSkipped = danmaku; return false; } else if (orderInScreen <= this.mMaximumSize || danmaku.isTimeOut()) { this.mLastSkipped = danmaku; Log.v("xx", " QuantityDanmakuFilter not guolv11111 >>>>>>>>"); return false; } else { Log.v("xx", " QuantityDanmakuFilter guolv >>>>>>>>"); return true; } }
Example 3
Source File: CacheManagingDrawTask.java From letv with Apache License 2.0 | 6 votes |
private void clearTimeOutCaches(long time) { IDanmakuIterator it = this.mCaches.iterator(); while (it.hasNext() && !this.mEndFlag) { BaseDanmaku val = it.next(); if (val.isTimeOut()) { synchronized (CacheManagingDrawTask.this.mDrawingNotify) { try { CacheManagingDrawTask.this.mDrawingNotify.wait(30); } catch (InterruptedException e) { e.printStackTrace(); return; } } entryRemoved(false, val, null); it.remove(); } else { return; } } }
Example 4
Source File: DanmakuUtils.java From letv with Apache License 2.0 | 6 votes |
public static boolean willHitInDuration(IDisplayer disp, BaseDanmaku d1, BaseDanmaku d2, long duration, long currTime) { int type1 = d1.getType(); if (type1 != d2.getType()) { return false; } if (d1.isOutside()) { return false; } long dTime = d2.time - d1.time; if (dTime < 0) { return true; } if (Math.abs(dTime) >= duration || d1.isTimeOut() || d2.isTimeOut()) { return false; } if (type1 == 5 || type1 == 4) { return true; } return checkHitAtTime(disp, d1, d2, currTime) || checkHitAtTime(disp, d1, d2, d1.time + d1.getDuration()); }
Example 5
Source File: CacheManagingDrawTask.java From letv with Apache License 2.0 | 5 votes |
private final void addDanmakuAndBuildCache(BaseDanmaku danmaku) { if (!danmaku.isTimeOut() && danmaku.time <= CacheManagingDrawTask.this.mCacheTimer.currMillisecond + CacheManagingDrawTask.this.mContext.mDanmakuFactory.MAX_DANMAKU_DURATION) { if (danmaku.priority != (byte) 0 || !danmaku.isFiltered()) { if (!danmaku.isDanmakuTypeFiltered || !danmaku.isFiltered()) { if (!danmaku.hasDrawingCache()) { buildCache(danmaku, true); } if (danmaku.isLive) { CacheManagingDrawTask.this.mCacheTimer.update(CacheManagingDrawTask.this.mTimer.currMillisecond + (CacheManagingDrawTask.this.mContext.mDanmakuFactory.MAX_DANMAKU_DURATION * ((long) CacheManager.this.mScreenSize))); } } } } }
Example 6
Source File: CacheManagingDrawTask.java From letv with Apache License 2.0 | 5 votes |
public void addDanmaku(BaseDanmaku danmaku) { if (this.mHandler == null) { return; } if (!danmaku.isLive) { this.mHandler.obtainMessage(2, danmaku).sendToTarget(); } else if (!danmaku.isTimeOut()) { this.mHandler.createCache(danmaku); } }
Example 7
Source File: CacheManagingDrawTask.java From letv with Apache License 2.0 | 5 votes |
private boolean push(BaseDanmaku item, int itemSize, boolean forcePush) { int size = itemSize; while (this.mRealSize + size > this.mMaxSize && this.mCaches.size() > 0) { BaseDanmaku oldValue = this.mCaches.first(); if (oldValue.isTimeOut()) { entryRemoved(false, oldValue, item); this.mCaches.removeItem(oldValue); } else if (!forcePush) { return false; } } this.mCaches.addItem(item); this.mRealSize += size; return true; }
Example 8
Source File: CacheManagingDrawTask.java From letv with Apache License 2.0 | 4 votes |
private long prepareCaches(boolean repositioned) { long curr = CacheManagingDrawTask.this.mCacheTimer.currMillisecond; long end = curr + (CacheManagingDrawTask.this.mContext.mDanmakuFactory.MAX_DANMAKU_DURATION * ((long) CacheManager.this.mScreenSize)); if (end < CacheManagingDrawTask.this.mTimer.currMillisecond) { return 0; } long startTime = SystemClock.uptimeMillis(); IDanmakus danmakus = null; int tryCount = 0; boolean hasException = false; do { BaseDanmaku first; try { danmakus = CacheManagingDrawTask.this.danmakuList.subnew(curr, end); } catch (Exception e) { hasException = true; SystemClock.sleep(10); } tryCount++; if (tryCount >= 3 || danmakus != null) { if (danmakus != null) { CacheManagingDrawTask.this.mCacheTimer.update(end); return 0; } first = danmakus.first(); BaseDanmaku last = danmakus.last(); if (first != null || last == null) { CacheManagingDrawTask.this.mCacheTimer.update(end); return 0; } long sleepTime = Math.min(100, 30 + ((10 * (first.time - CacheManagingDrawTask.this.mTimer.currMillisecond)) / CacheManagingDrawTask.this.mContext.mDanmakuFactory.MAX_DANMAKU_DURATION)); if (repositioned) { sleepTime = 0; } IDanmakuIterator itr = danmakus.iterator(); BaseDanmaku item = null; int orderInScreen = 0; int currScreenIndex = 0; int sizeInScreen = danmakus.size(); while (!this.mPause && !this.mCancelFlag && itr.hasNext()) { item = itr.next(); if (last.time >= CacheManagingDrawTask.this.mTimer.currMillisecond) { if (!item.hasDrawingCache() && (repositioned || (!item.isTimeOut() && item.isOutside()))) { if (!item.hasPassedFilter()) { CacheManagingDrawTask.this.mContext.mDanmakuFilters.filter(item, orderInScreen, sizeInScreen, null, true, CacheManagingDrawTask.this.mContext); } if (!((item.priority == (byte) 0 && item.isFiltered()) || (item.isDanmakuTypeFiltered && item.isFiltered()))) { int screenIndex = (int) ((item.time - curr) / CacheManagingDrawTask.this.mContext.mDanmakuFactory.MAX_DANMAKU_DURATION); if (currScreenIndex == screenIndex) { orderInScreen++; } else { orderInScreen = 0; currScreenIndex = screenIndex; } if (!repositioned) { try { synchronized (CacheManagingDrawTask.this.mDrawingNotify) { CacheManagingDrawTask.this.mDrawingNotify.wait(sleepTime); } } catch (InterruptedException e2) { e2.printStackTrace(); } } if (buildCache(item, false) != (byte) 1) { if (!repositioned && SystemClock.uptimeMillis() - startTime >= DanmakuFactory.COMMON_DANMAKU_DURATION * ((long) CacheManager.this.mScreenSize)) { break; } } break; } } } break; } long consumingTime = SystemClock.uptimeMillis() - startTime; if (item != null) { CacheManagingDrawTask.this.mCacheTimer.update(item.time); return consumingTime; } CacheManagingDrawTask.this.mCacheTimer.update(end); return consumingTime; } } while (hasException); if (danmakus != null) { first = danmakus.first(); BaseDanmaku last2 = danmakus.last(); if (first != null) { } CacheManagingDrawTask.this.mCacheTimer.update(end); return 0; } CacheManagingDrawTask.this.mCacheTimer.update(end); return 0; }