master.flame.danmaku.danmaku.model.DanmakuTimer Java Examples

The following examples show how to use master.flame.danmaku.danmaku.model.DanmakuTimer. 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: DanmakuFilters.java    From letv with Apache License 2.0 6 votes vote down vote up
public synchronized boolean needFilter(BaseDanmaku danmaku, int index, int totalsizeInScreen, DanmakuTimer timer, boolean fromCachingTask) {
    boolean z = true;
    synchronized (this) {
        removeTimeoutDanmakus(this.blockedDanmakus, 2);
        removeTimeoutDanmakus(this.passedDanmakus, 2);
        removeTimeoutDanmakus(this.currentDanmakus, 3);
        if (!this.blockedDanmakus.contains(danmaku) || danmaku.isOutside()) {
            if (this.passedDanmakus.contains(danmaku)) {
                z = false;
            } else if (this.currentDanmakus.containsKey(danmaku.text)) {
                this.currentDanmakus.put(String.valueOf(danmaku.text), danmaku);
                this.blockedDanmakus.removeItem(danmaku);
                this.blockedDanmakus.addItem(danmaku);
            } else {
                this.currentDanmakus.put(String.valueOf(danmaku.text), danmaku);
                this.passedDanmakus.addItem(danmaku);
                z = false;
            }
        }
    }
    return z;
}
 
Example #2
Source File: DanmakuFilters.java    From letv with Apache License 2.0 6 votes vote down vote up
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: DanmakuFilters.java    From letv with Apache License 2.0 5 votes vote down vote up
public boolean filter(BaseDanmaku danmaku, int index, int totalsizeInScreen, DanmakuTimer timer, boolean willHit, DanmakuContext config) {
    boolean filtered = false;
    if (this.mEnabledPairs != null) {
        Boolean enabledValue = (Boolean) this.mEnabledPairs.get(Integer.valueOf(danmaku.getType()));
        filtered = enabledValue != null && enabledValue.booleanValue() && willHit;
        if (filtered) {
            danmaku.mFilterParam |= 512;
        }
    }
    return filtered;
}
 
Example #4
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 #5
Source File: CacheManagingDrawTask.java    From letv with Apache License 2.0 5 votes vote down vote up
public CacheManagingDrawTask(DanmakuTimer timer, DanmakuContext config, TaskListener taskListener, int maxCacheSize) {
    super(timer, config, taskListener);
    NativeBitmapFactory.loadLibs();
    this.mMaxCacheSize = maxCacheSize;
    if (NativeBitmapFactory.isInNativeAlloc()) {
        this.mMaxCacheSize = maxCacheSize * 2;
    }
    this.mCacheManager = new CacheManager(maxCacheSize, 3);
    this.mRenderer.setCacheManager(this.mCacheManager);
}
 
Example #6
Source File: DanmakuFilters.java    From letv with Apache License 2.0 5 votes vote down vote up
public boolean filterSecondary(BaseDanmaku danmaku, int lines, int totalsizeInScreen, DanmakuTimer timer, boolean willHit, DanmakuContext context) {
    for (IDanmakuFilter<?> f : this.mFilterArraySecondary) {
        if (f != null) {
            boolean filtered = f.filter(danmaku, lines, totalsizeInScreen, timer, willHit, context);
            danmaku.filterResetFlag = context.mGlobalFlagValues.FILTER_RESET_FLAG;
            if (filtered) {
                return true;
            }
        }
    }
    return false;
}
 
Example #7
Source File: DanmakuFilters.java    From letv with Apache License 2.0 5 votes vote down vote up
public void filter(BaseDanmaku danmaku, int index, int totalsizeInScreen, DanmakuTimer timer, boolean fromCachingTask, DanmakuContext context) {
    for (IDanmakuFilter<?> f : this.mFilterArray) {
        if (f != null) {
            boolean filtered = f.filter(danmaku, index, totalsizeInScreen, timer, fromCachingTask, context);
            danmaku.filterResetFlag = context.mGlobalFlagValues.FILTER_RESET_FLAG;
            if (filtered) {
                return;
            }
        }
    }
}
 
Example #8
Source File: DanmakuFilters.java    From letv with Apache License 2.0 5 votes vote down vote up
public boolean filter(BaseDanmaku danmaku, int index, int totalsizeInScreen, DanmakuTimer timer, boolean fromCachingTask, DanmakuContext config) {
    boolean filtered = danmaku != null && this.mBlackList.contains(Integer.valueOf(danmaku.userId));
    if (filtered) {
        danmaku.mFilterParam |= 16;
    }
    return filtered;
}
 
Example #9
Source File: DanmakuFilters.java    From letv with Apache License 2.0 5 votes vote down vote up
public boolean filter(BaseDanmaku danmaku, int index, int totalsizeInScreen, DanmakuTimer timer, boolean fromCachingTask, DanmakuContext config) {
    boolean filtered = danmaku != null && this.mBlackList.contains(danmaku.userHash);
    if (filtered) {
        danmaku.mFilterParam |= 32;
    }
    return filtered;
}
 
Example #10
Source File: DanmakuFilters.java    From letv with Apache License 2.0 5 votes vote down vote up
public boolean filter(BaseDanmaku danmaku, int orderInScreen, int totalsizeInScreen, DanmakuTimer timer, boolean fromCachingTask, DanmakuContext config) {
    boolean filtered = danmaku != null && this.mFilterTypes.contains(Integer.valueOf(danmaku.getType()));
    if (filtered) {
        danmaku.mFilterParam |= 1;
        danmaku.isDanmakuTypeFiltered = true;
    }
    return filtered;
}
 
Example #11
Source File: DanmakuFilters.java    From letv with Apache License 2.0 5 votes vote down vote up
public boolean filter(BaseDanmaku danmaku, int index, int totalsizeInScreen, DanmakuTimer timer, boolean fromCachingTask, DanmakuContext config) {
    boolean filtered = (danmaku == null || this.mWhiteList.contains(Integer.valueOf(danmaku.textColor))) ? false : true;
    if (filtered) {
        danmaku.mFilterParam |= 8;
    }
    return filtered;
}
 
Example #12
Source File: DanmakuFilters.java    From letv with Apache License 2.0 5 votes vote down vote up
public synchronized boolean filter(BaseDanmaku danmaku, int orderInScreen, int totalsizeInScreen, DanmakuTimer timer, boolean fromCachingTask, DanmakuContext config) {
    boolean filtered;
    filtered = needFilter(danmaku, orderInScreen, totalsizeInScreen, timer, fromCachingTask, config);
    if (filtered) {
        danmaku.mFilterParam |= 2;
    }
    return filtered;
}
 
Example #13
Source File: DanmakuFilters.java    From letv with Apache License 2.0 5 votes vote down vote up
public boolean filter(BaseDanmaku danmaku, int lines, int totalsizeInScreen, DanmakuTimer timer, boolean willHit, DanmakuContext config) {
    boolean filtered = false;
    if (this.mMaximumLinesPairs != null) {
        Integer maxLines = (Integer) this.mMaximumLinesPairs.get(Integer.valueOf(danmaku.getType()));
        filtered = maxLines != null && lines >= maxLines.intValue();
        if (filtered) {
            danmaku.mFilterParam |= 256;
        }
    }
    return filtered;
}
 
Example #14
Source File: DanmakuFilters.java    From letv with Apache License 2.0 5 votes vote down vote up
public boolean filter(BaseDanmaku danmaku, int index, int totalsizeInScreen, DanmakuTimer timer, boolean fromCachingTask, DanmakuContext config) {
    boolean filtered = this.mBlock.booleanValue() && danmaku.isGuest;
    if (filtered) {
        danmaku.mFilterParam |= 64;
    }
    return filtered;
}
 
Example #15
Source File: DanmakuFilters.java    From letv with Apache License 2.0 5 votes vote down vote up
public boolean filter(BaseDanmaku danmaku, int orderInScreen, int totalsizeInScreen, DanmakuTimer timer, boolean fromCachingTask, DanmakuContext config) {
    boolean filtered = needFilter(danmaku, orderInScreen, totalsizeInScreen, timer, fromCachingTask);
    if (filtered) {
        danmaku.mFilterParam |= 4;
    }
    return filtered;
}
 
Example #16
Source File: DanmakuFilters.java    From letv with Apache License 2.0 5 votes vote down vote up
private synchronized boolean needFilter(BaseDanmaku danmaku, int orderInScreen, int totalsizeInScreen, DanmakuTimer timer, boolean fromCachingTask) {
    boolean z = false;
    synchronized (this) {
        if (timer != null) {
            if (danmaku.isOutside()) {
                if (SystemClock.uptimeMillis() - timer.currMillisecond >= this.mMaxTime) {
                    z = true;
                }
            }
        }
    }
    return z;
}
 
Example #17
Source File: DanmakuFilters.java    From letv with Apache License 2.0 5 votes vote down vote up
public boolean filter(BaseDanmaku danmaku, int index, int totalsizeInScreen, DanmakuTimer timer, boolean fromCachingTask, DanmakuContext config) {
    boolean filtered = needFilter(danmaku, index, totalsizeInScreen, timer, fromCachingTask);
    if (filtered) {
        danmaku.mFilterParam |= 128;
    }
    return filtered;
}
 
Example #18
Source File: DrawTask.java    From letv with Apache License 2.0 5 votes vote down vote up
public DrawTask(DanmakuTimer timer, DanmakuContext context, TaskListener taskListener) {
    boolean z = false;
    if (context == null) {
        throw new IllegalArgumentException("context is null");
    }
    this.mContext = context;
    this.mDisp = context.getDisplayer();
    this.mTaskListener = taskListener;
    this.mRenderer = new DanmakuRenderer(context);
    this.mRenderer.setOnDanmakuShownListener(new OnDanmakuShownListener() {
        public void onDanmakuShown(BaseDanmaku danmaku) {
            if (DrawTask.this.mTaskListener != null) {
                DrawTask.this.mTaskListener.onDanmakuShown(danmaku);
            }
        }
    });
    IRenderer iRenderer = this.mRenderer;
    if (this.mContext.isPreventOverlappingEnabled() || this.mContext.isMaxLinesLimited()) {
        z = true;
    }
    iRenderer.setVerifierEnabled(z);
    initTimer(timer);
    Boolean enable = Boolean.valueOf(this.mContext.isDuplicateMergingEnabled());
    if (enable == null) {
        return;
    }
    if (enable.booleanValue()) {
        this.mContext.mDanmakuFilters.registerFilter(DanmakuFilters.TAG_DUPLICATE_FILTER);
    } else {
        this.mContext.mDanmakuFilters.unregisterFilter(DanmakuFilters.TAG_DUPLICATE_FILTER);
    }
}
 
Example #19
Source File: DrawHandler.java    From letv with Apache License 2.0 5 votes vote down vote up
private IDrawTask createDrawTask(boolean useDrwaingCache, DanmakuTimer timer, Context context, int width, int height, boolean isHardwareAccelerated, TaskListener taskListener) {
    this.mDisp = this.mContext.getDisplayer();
    this.mDisp.setSize(width, height);
    DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
    this.mDisp.setDensities(displayMetrics.density, displayMetrics.densityDpi, displayMetrics.scaledDensity);
    this.mDisp.resetSlopPixel(this.mContext.scaleTextSize);
    this.mDisp.setHardwareAccelerated(isHardwareAccelerated);
    IDrawTask task = useDrwaingCache ? new CacheManagingDrawTask(timer, this.mContext, taskListener, (1048576 * AndroidUtils.getMemoryClass(context)) / 3) : new DrawTask(timer, this.mContext, taskListener);
    task.setParser(this.mParser);
    task.prepare();
    obtainMessage(10, Boolean.valueOf(false)).sendToTarget();
    return task;
}
 
Example #20
Source File: GameBaseActivity.java    From kcanotify_h5-master with GNU General Public License v3.0 4 votes vote down vote up
/**
 * danmuku init
 */
public void initDanMuKu(){
    //弹幕
    // 设置最大显示行数
    HashMap<Integer, Integer> maxLinesPair = new HashMap<Integer, Integer>();
    maxLinesPair.put(BaseDanmaku.TYPE_SCROLL_RL, 10); // 滚动弹幕最大显示10行
    // 设置是否禁止重叠
    HashMap<Integer, Boolean> overlappingEnablePair = new HashMap<Integer, Boolean>();
    overlappingEnablePair.put(BaseDanmaku.TYPE_SCROLL_RL, true);
    overlappingEnablePair.put(BaseDanmaku.TYPE_FIX_TOP, true);

    danmakuContext = DanmakuContext.create();
    danmakuContext.setDanmakuStyle(IDisplayer.DANMAKU_STYLE_STROKEN, 5).setDuplicateMergingEnabled(false)
            .setMaximumLines(maxLinesPair)
            .preventOverlapping(overlappingEnablePair).setDanmakuMargin(20);
    danmakuView = findViewById(R.id.danmaku_view);
    danmakuView.enableDanmakuDrawingCache(true);
    danmakuView.setCallback(new DrawHandler.Callback() {
        @Override
        public void prepared() {
            showDanmaku = true;
            danmakuView.start();
        }

        @Override
        public void updateTimer(DanmakuTimer timer) {

        }

        @Override
        public void danmakuShown(BaseDanmaku danmaku) {

        }

        @Override
        public void drawingFinished() {

        }
    });
    danmakuView.prepare(parser, danmakuContext);
}
 
Example #21
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 #22
Source File: DrawTask.java    From letv with Apache License 2.0 4 votes vote down vote up
protected void initTimer(DanmakuTimer timer) {
    this.mTimer = timer;
}
 
Example #23
Source File: CacheManagingDrawTask.java    From letv with Apache License 2.0 4 votes vote down vote up
protected void initTimer(DanmakuTimer timer) {
    this.mTimer = timer;
    this.mCacheTimer = new DanmakuTimer();
    this.mCacheTimer.update(timer.currMillisecond);
}
 
Example #24
Source File: BaseDanmakuParser.java    From letv with Apache License 2.0 4 votes vote down vote up
public BaseDanmakuParser setTimer(DanmakuTimer timer) {
    this.mTimer = timer;
    return this;
}
 
Example #25
Source File: BaseDanmakuParser.java    From letv with Apache License 2.0 4 votes vote down vote up
public DanmakuTimer getTimer() {
    return this.mTimer;
}
 
Example #26
Source File: MyDanmakuView.java    From DKVideoPlayer with Apache License 2.0 2 votes vote down vote up
@Override
public void updateTimer(DanmakuTimer timer) {

}
 
Example #27
Source File: DanmakuFilters.java    From letv with Apache License 2.0 votes vote down vote up
boolean filter(BaseDanmaku baseDanmaku, int i, int i2, DanmakuTimer danmakuTimer, boolean z, DanmakuContext danmakuContext); 
Example #28
Source File: DanmakuFilters.java    From letv with Apache License 2.0 votes vote down vote up
public abstract boolean filter(BaseDanmaku baseDanmaku, int i, int i2, DanmakuTimer danmakuTimer, boolean z, DanmakuContext danmakuContext); 
Example #29
Source File: DrawHandler.java    From letv with Apache License 2.0 votes vote down vote up
void updateTimer(DanmakuTimer danmakuTimer);