master.flame.danmaku.danmaku.model.IDanmakus Java Examples

The following examples show how to use master.flame.danmaku.danmaku.model.IDanmakus. 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: DanmakuTouchHelper.java    From letv with Apache License 2.0 6 votes vote down vote up
public boolean onTouchEvent(MotionEvent event) {
    switch (event.getAction()) {
        case 1:
            IDanmakus clickDanmakus = touchHitDanmaku(event.getX(), event.getY());
            BaseDanmaku newestDanmaku = null;
            if (!(clickDanmakus == null || clickDanmakus.isEmpty())) {
                performClick(clickDanmakus);
                newestDanmaku = fetchLatestOne(clickDanmakus);
            }
            if (newestDanmaku != null) {
                performClickWithlatest(newestDanmaku);
                break;
            }
            break;
    }
    return false;
}
 
Example #2
Source File: DanmakuTouchHelper.java    From letv with Apache License 2.0 6 votes vote down vote up
public IDanmakus touchHitDanmaku(float x, float y) {
    IDanmakus hitDanmakus = new Danmakus();
    this.mDanmakuBounds.setEmpty();
    IDanmakus danmakus = this.danmakuView.getCurrentVisibleDanmakus();
    if (danmakus != null && !danmakus.isEmpty()) {
        IDanmakuIterator iterator = danmakus.iterator();
        while (iterator.hasNext()) {
            BaseDanmaku danmaku = iterator.next();
            if (danmaku != null) {
                this.mDanmakuBounds.set(danmaku.getLeft(), danmaku.getTop() - 30.0f, danmaku.getRight(), danmaku.getBottom() + 30.0f);
                if (this.mDanmakuBounds.contains(x, y)) {
                    danmaku.clickX = x;
                    danmaku.clickY = y;
                    danmaku.setRectF(this.mDanmakuBounds);
                    hitDanmakus.addItem(danmaku);
                    break;
                }
            }
        }
    }
    return hitDanmakus;
}
 
Example #3
Source File: DanmakuFilters.java    From letv with Apache License 2.0 6 votes vote down vote up
private final void removeTimeoutDanmakus(IDanmakus danmakus, long limitTime) {
    IDanmakuIterator it = danmakus.iterator();
    long startTime = SystemClock.uptimeMillis();
    while (it.hasNext()) {
        try {
            if (it.next().isTimeOut()) {
                it.remove();
                if (SystemClock.uptimeMillis() - startTime > limitTime) {
                    return;
                }
            }
            return;
        } catch (Exception e) {
            return;
        }
    }
}
 
Example #4
Source File: DanmakuSurfaceView.java    From BlueBoard with Apache License 2.0 5 votes vote down vote up
@Override
public IDanmakus getCurrentVisibleDanmakus() {
    if (handler != null) {
        return handler.getCurrentVisibleDanmakus();
    }

    return null;
}
 
Example #5
Source File: Danmakus.java    From letv with Apache License 2.0 5 votes vote down vote up
public IDanmakus sub(long startTime, long endTime) {
    if (this.items == null || this.items.size() == 0) {
        return null;
    }
    if (this.subItems == null) {
        if (this.mSortType == 4) {
            this.subItems = new Danmakus(4);
            this.subItems.setItems(this.items);
        } else {
            this.subItems = new Danmakus(this.mDuplicateMergingEnabled);
        }
    }
    if (this.mSortType == 4) {
        return this.subItems;
    }
    if (this.startItem == null) {
        this.startItem = createItem(JarConstant.PLUGIN_WINDOW_PLAYER_STATIC_METHOD_NAME_START);
    }
    if (this.endItem == null) {
        this.endItem = createItem("end");
    }
    if (this.subItems != null && startTime - this.startItem.time >= 0 && endTime <= this.endItem.time) {
        return this.subItems;
    }
    this.startItem.time = startTime;
    this.endItem.time = endTime;
    this.subItems.setItems(((SortedSet) this.items).subSet(this.startItem, this.endItem));
    return this.subItems;
}
 
Example #6
Source File: Danmakus.java    From letv with Apache License 2.0 5 votes vote down vote up
public IDanmakus subnew(long startTime, long endTime) {
    Collection<BaseDanmaku> subset = subset(startTime, endTime);
    if (subset == null || subset.isEmpty()) {
        return null;
    }
    return new Danmakus(new ArrayList(subset));
}
 
Example #7
Source File: BaseDanmakuParser.java    From letv with Apache License 2.0 5 votes vote down vote up
public IDanmakus getDanmakus() {
    if (this.mDanmakus != null) {
        return this.mDanmakus;
    }
    this.mContext.mDanmakuFactory.resetDurationsData();
    this.mDanmakus = parse();
    releaseDataSource();
    this.mContext.mDanmakuFactory.updateMaxDanmakuDuration();
    return this.mDanmakus;
}
 
Example #8
Source File: DrawTask.java    From letv with Apache License 2.0 5 votes vote down vote up
public IDanmakus getVisibleDanmakusOnTime(long time) {
    IDanmakus subDanmakus = this.danmakuList.subnew((time - this.mContext.mDanmakuFactory.MAX_DANMAKU_DURATION) - 100, time + this.mContext.mDanmakuFactory.MAX_DANMAKU_DURATION);
    IDanmakus visibleDanmakus = new Danmakus();
    if (!(subDanmakus == null || subDanmakus.isEmpty())) {
        IDanmakuIterator iterator = subDanmakus.iterator();
        while (iterator.hasNext()) {
            BaseDanmaku danmaku = iterator.next();
            if (danmaku.isShown() && !danmaku.isOutside()) {
                visibleDanmakus.addItem(danmaku);
            }
        }
    }
    return visibleDanmakus;
}
 
Example #9
Source File: VideoPlayActivity.java    From BlueBoard with Apache License 2.0 5 votes vote down vote up
private void danmuku(InputStream inputStream) {
        if (mDanmakuView != null) {
            mParser = DanmakuHelper.createParser(inputStream);
            mDanmakuView.setCallback(new DrawHandler.Callback() {
                @Override
                public void updateTimer(DanmakuTimer timer) {
                }

                @Override
                public void danmakuShown(BaseDanmaku danmaku) {

                }

                @Override
                public void drawingFinished() {

                }

                @Override
                public void prepared() {
                    mIsDanmakuReday = true;
                }
            });
            mDanmakuView.setOnDanmakuClickListener(new IDanmakuView.OnDanmakuClickListener() {
                @Override
                public void onDanmakuClick(BaseDanmaku latest) {
//                    Log.d("DFM", "onDanmakuClick text:" + latest.text);
                }

                @Override
                public void onDanmakuClick(IDanmakus danmakus) {
//                    Log.d("DFM", "onDanmakuClick danmakus size:" + danmakus.size());
                }
            });
            mDanmakuView.prepare(mParser, mDanmakuContext);
            mDanmakuView.enableDanmakuDrawingCache(true);
//            mDanmakuView.showFPS(true);
        }
    }
 
Example #10
Source File: DanmakuTouchHelper.java    From letv with Apache License 2.0 4 votes vote down vote up
private BaseDanmaku fetchLatestOne(IDanmakus danmakus) {
    if (danmakus.isEmpty()) {
        return null;
    }
    return danmakus.last();
}
 
Example #11
Source File: DanmakuView.java    From letv with Apache License 2.0 4 votes vote down vote up
public IDanmakus getCurrentVisibleDanmakus() {
    if (this.handler != null) {
        return this.handler.getCurrentVisibleDanmakus();
    }
    return null;
}
 
Example #12
Source File: DanmakuView.java    From letv with Apache License 2.0 4 votes vote down vote up
public boolean isClickDanmukuRange(MotionEvent event) {
    IDanmakus clickDanmakus = this.mTouchHelper.touchHitDanmaku(event.getX(), event.getY());
    return (clickDanmakus == null || clickDanmakus.isEmpty()) ? false : true;
}
 
Example #13
Source File: DanmakuTouchHelper.java    From letv with Apache License 2.0 4 votes vote down vote up
private void performClick(IDanmakus danmakus) {
    if (this.danmakuView.getOnDanmakuClickListener() != null) {
        this.danmakuView.getOnDanmakuClickListener().onDanmakuClick(danmakus);
    }
}
 
Example #14
Source File: DanmakuTextureView.java    From letv with Apache License 2.0 4 votes vote down vote up
public IDanmakus getCurrentVisibleDanmakus() {
    if (this.handler != null) {
        return this.handler.getCurrentVisibleDanmakus();
    }
    return null;
}
 
Example #15
Source File: LivePlayActivity.java    From C9MJ with Apache License 2.0 4 votes vote down vote up
@Override
protected IDanmakus parse() {
    return new Danmakus();
}
 
Example #16
Source File: DanmakuSurfaceView.java    From letv with Apache License 2.0 4 votes vote down vote up
public IDanmakus getCurrentVisibleDanmakus() {
    if (this.handler != null) {
        return this.handler.getCurrentVisibleDanmakus();
    }
    return null;
}
 
Example #17
Source File: DanmakuRenderer.java    From letv with Apache License 2.0 4 votes vote down vote up
public RenderingState draw(IDisplayer disp, IDanmakus danmakus, long startRenderTime) {
    int lastTotalDanmakuCount = this.mRenderingState.totalDanmakuCount;
    this.mRenderingState.reset();
    IDanmakuIterator itr = danmakus.iterator();
    int orderInScreen = 0;
    this.mStartTimer.update(SystemClock.uptimeMillis());
    int sizeInScreen = danmakus.size();
    BaseDanmaku drawItem = null;
    while (itr.hasNext()) {
        drawItem = itr.next();
        if (!drawItem.hasPassedFilter()) {
            this.mContext.mDanmakuFilters.filter(drawItem, orderInScreen, sizeInScreen, this.mStartTimer, false, this.mContext);
        }
        if (drawItem.time >= startRenderTime && (!(drawItem.priority == (byte) 0 && drawItem.isFiltered()) && drawItem.time >= startRenderTime)) {
            if (!drawItem.isDanmakuTypeFiltered || !drawItem.isFiltered()) {
                if (drawItem.isLate()) {
                    if (this.mCacheManager == null || drawItem.hasDrawingCache()) {
                        break;
                    }
                    this.mCacheManager.addDanmaku(drawItem);
                } else {
                    orderInScreen++;
                    if (!drawItem.isMeasured()) {
                        drawItem.measure(disp, false);
                    }
                    this.mDanmakusRetainer.fix(drawItem, disp, this.mVerifier);
                    if (!drawItem.isOutside() && drawItem.isShown()) {
                        if (drawItem.lines != null || drawItem.getBottom() <= ((float) disp.getHeight())) {
                            int renderingType = drawItem.draw(disp);
                            RenderingState renderingState;
                            if (renderingType == 1) {
                                renderingState = this.mRenderingState;
                                renderingState.cacheHitCount++;
                            } else if (renderingType == 2) {
                                renderingState = this.mRenderingState;
                                renderingState.cacheMissCount++;
                                if (this.mCacheManager != null) {
                                    this.mCacheManager.addDanmaku(drawItem);
                                }
                            }
                            this.mRenderingState.addCount(drawItem.getType(), 1);
                            this.mRenderingState.addTotalCount(1);
                            if (!(this.mOnDanmakuShownListener == null || drawItem.firstShownFlag == this.mContext.mGlobalFlagValues.FIRST_SHOWN_RESET_FLAG)) {
                                drawItem.firstShownFlag = this.mContext.mGlobalFlagValues.FIRST_SHOWN_RESET_FLAG;
                                this.mOnDanmakuShownListener.onDanmakuShown(drawItem);
                            }
                        }
                    }
                }
            }
        }
    }
    this.mRenderingState.nothingRendered = this.mRenderingState.totalDanmakuCount == 0;
    this.mRenderingState.endTime = drawItem != null ? drawItem.time : -1;
    if (this.mRenderingState.nothingRendered) {
        this.mRenderingState.beginTime = -1;
    }
    this.mRenderingState.incrementCount = this.mRenderingState.totalDanmakuCount - lastTotalDanmakuCount;
    this.mRenderingState.consumingTime = this.mStartTimer.update(SystemClock.uptimeMillis());
    return this.mRenderingState;
}
 
Example #18
Source File: GameBaseActivity.java    From kcanotify_h5-master with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected IDanmakus parse() {
    return new Danmakus();
}
 
Example #19
Source File: CacheManagingDrawTask.java    From letv with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example #20
Source File: DrawTask.java    From letv with Apache License 2.0 4 votes vote down vote up
protected RenderingState drawDanmakus(AbsDisplayer disp, DanmakuTimer timer) {
    if (this.clearRetainerFlag) {
        this.mRenderer.clearRetainer();
        this.clearRetainerFlag = false;
    }
    if (this.danmakuList == null) {
        return null;
    }
    DrawHelper.clearCanvas((Canvas) disp.getExtraData());
    if (this.mIsHidden) {
        return this.mRenderingState;
    }
    long beginMills = (timer.currMillisecond - this.mContext.mDanmakuFactory.MAX_DANMAKU_DURATION) - 100;
    long endMills = timer.currMillisecond + this.mContext.mDanmakuFactory.MAX_DANMAKU_DURATION;
    if (this.mLastBeginMills > beginMills || timer.currMillisecond > this.mLastEndMills) {
        IDanmakus subDanmakus = this.danmakuList.sub(beginMills, endMills);
        if (subDanmakus != null) {
            this.danmakus = subDanmakus;
        } else {
            this.danmakus.clear();
        }
        this.mLastBeginMills = beginMills;
        this.mLastEndMills = endMills;
    } else {
        beginMills = this.mLastBeginMills;
        endMills = this.mLastEndMills;
    }
    if (this.danmakus == null || this.danmakus.isEmpty()) {
        this.mRenderingState.nothingRendered = true;
        this.mRenderingState.beginTime = beginMills;
        this.mRenderingState.endTime = endMills;
        return this.mRenderingState;
    }
    RenderingState renderingState = this.mRenderer.draw(this.mDisp, this.danmakus, this.mStartRenderTime);
    this.mRenderingState = renderingState;
    if (!renderingState.nothingRendered) {
        return renderingState;
    }
    if (!(this.mTaskListener == null || this.mLastDanmaku == null || !this.mLastDanmaku.isTimeOut())) {
        this.mTaskListener.onDanmakusDrawingFinished();
    }
    if (renderingState.beginTime == -1) {
        renderingState.beginTime = beginMills;
    }
    if (renderingState.endTime != -1) {
        return renderingState;
    }
    renderingState.endTime = endMills;
    return renderingState;
}
 
Example #21
Source File: DrawHandler.java    From letv with Apache License 2.0 4 votes vote down vote up
public IDanmakus getCurrentVisibleDanmakus() {
    if (this.drawTask != null) {
        return this.drawTask.getVisibleDanmakusOnTime(getCurrentTime());
    }
    return null;
}
 
Example #22
Source File: QSDanmakuParser.java    From QSVideoPlayer with Apache License 2.0 4 votes vote down vote up
@Override
protected IDanmakus parse() {
    if (result == null) result = preParse(mContext);
    return result;
}
 
Example #23
Source File: MyDanmakuView.java    From DKVideoPlayer with Apache License 2.0 4 votes vote down vote up
@Override
protected IDanmakus parse() {
    return new Danmakus();
}
 
Example #24
Source File: IRenderer.java    From letv with Apache License 2.0 votes vote down vote up
RenderingState draw(IDisplayer iDisplayer, IDanmakus iDanmakus, long j); 
Example #25
Source File: BaseDanmakuParser.java    From letv with Apache License 2.0 votes vote down vote up
protected abstract IDanmakus parse(); 
Example #26
Source File: IDrawTask.java    From letv with Apache License 2.0 votes vote down vote up
IDanmakus getVisibleDanmakusOnTime(long j); 
Example #27
Source File: IDanmakuView.java    From letv with Apache License 2.0 votes vote down vote up
IDanmakus getCurrentVisibleDanmakus(); 
Example #28
Source File: IDanmakuView.java    From letv with Apache License 2.0 votes vote down vote up
void onDanmakuClick(IDanmakus iDanmakus);