本文整理汇总了Java中master.flame.danmaku.danmaku.model.BaseDanmaku类的典型用法代码示例。如果您正苦于以下问题:Java BaseDanmaku类的具体用法?Java BaseDanmaku怎么用?Java BaseDanmaku使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BaseDanmaku类属于master.flame.danmaku.danmaku.model包,在下文中一共展示了BaseDanmaku类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initData
import master.flame.danmaku.danmaku.model.BaseDanmaku; //导入依赖的package包/类
/**
* 对弹幕的基础数据进行初始化
* @param data
* @param danmaku
*/
protected void initData(T data, BaseDanmaku danmaku) {
int danmakuType = TYPE_SCROLL_RL;
if (danmaku instanceof R2LDanmaku) {
danmakuType = BaseDanmaku.TYPE_SCROLL_RL;
} else if (danmaku instanceof FBDanmaku) {
danmakuType = BaseDanmaku.TYPE_FIX_BOTTOM;
} else if (danmaku instanceof FTDanmaku) {
danmakuType = BaseDanmaku.TYPE_FIX_TOP;
}
data.setType(danmakuType);
data.setContent(danmaku.text.toString());
data.setTime(danmaku.getTime());
data.setTextSize(danmaku.textSize);
data.setTextColor(danmaku.textColor);
}
示例2: seek
import master.flame.danmaku.danmaku.model.BaseDanmaku; //导入依赖的package包/类
@Override
public void seek(long mills) {
reset();
mContext.mGlobalFlagValues.updateVisibleFlag();
mContext.mGlobalFlagValues.updateFirstShownFlag();
mStartRenderTime = mills < 1000 ? 0 : mills;
if (mRenderingState != null) {
mRenderingState.reset();
mRenderingState.endTime = mStartRenderTime;
}
if (danmakuList != null) {
BaseDanmaku last = danmakuList.last();
if (last != null && !last.isTimeOut()) {
mLastDanmaku = last;
}
}
}
示例3: push
import master.flame.danmaku.danmaku.model.BaseDanmaku; //导入依赖的package包/类
private boolean push(BaseDanmaku item, int itemSize, boolean forcePush) {
int size = itemSize; //sizeOf(item);
while (mRealSize + size > mMaxSize && mCaches.size() > 0) {
BaseDanmaku oldValue = mCaches.first();
if (oldValue.isTimeOut()) {
entryRemoved(false, oldValue, item);
mCaches.removeItem(oldValue);
} else {
if (forcePush) {
break;
}
return false;
}
}
this.mCaches.addItem(item);
mRealSize += size;
//Log.e("CACHE", "realsize:"+mRealSize + ",size" + size);
return true;
}
示例4: needFilter
import master.flame.danmaku.danmaku.model.BaseDanmaku; //导入依赖的package包/类
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;
}
}
示例5: getPaint
import master.flame.danmaku.danmaku.model.BaseDanmaku; //导入依赖的package包/类
private synchronized TextPaint getPaint(BaseDanmaku danmaku, boolean fromWorkerThread) {
TextPaint paint;
if (fromWorkerThread) {
paint = PAINT;
} else {
paint = PAINT_DUPLICATE;
paint.set(PAINT);
}
paint.setTextSize(danmaku.textSize);
applyTextScaleConfig(danmaku, paint);
//ignore the transparent textShadowColor
if (!HAS_SHADOW || SHADOW_RADIUS <= 0 || danmaku.textShadowColor == 0) {
paint.clearShadowLayer();
} else {
paint.setShadowLayer(SHADOW_RADIUS, 0, 0, danmaku.textShadowColor);
}
paint.setAntiAlias(ANTI_ALIAS);
return paint;
}
示例6: subset
import master.flame.danmaku.danmaku.model.BaseDanmaku; //导入依赖的package包/类
private Collection<BaseDanmaku> subset(long startTime, long endTime) {
if (mSortType == ST_BY_LIST || items == null || items.size() == 0) {
return null;
}
if (subItems == null) {
subItems = new Danmakus(mDuplicateMergingEnabled);
}
if (startSubItem == null) {
startSubItem = createItem("start");
}
if (endSubItem == null) {
endSubItem = createItem("end");
}
startSubItem.time = startTime;
endSubItem.time = endTime;
return ((SortedSet<BaseDanmaku>) items).subSet(startSubItem, endSubItem);
}
示例7: createCache
import master.flame.danmaku.danmaku.model.BaseDanmaku; //导入依赖的package包/类
public boolean createCache(BaseDanmaku item) {
if (!item.isMeasured()) {
item.measure(CacheManagingDrawTask.this.mDisp, true);
}
DrawingCache cache = null;
try {
cache = DanmakuUtils.buildDanmakuDrawingCache(item, CacheManagingDrawTask.this.mDisp, (DrawingCache) CacheManager.this.mCachePool.acquire());
item.cache = cache;
return true;
} catch (OutOfMemoryError e) {
if (cache != null) {
CacheManager.this.mCachePool.release(cache);
}
item.cache = null;
return false;
} catch (Exception e2) {
if (cache != null) {
CacheManager.this.mCachePool.release(cache);
}
item.cache = null;
return false;
}
}
示例8: addDanmaku
import master.flame.danmaku.danmaku.model.BaseDanmaku; //导入依赖的package包/类
private void addDanmaku(boolean islive, String message, boolean isSelf) {
log.i("adddanmu", "add");
BaseDanmaku danmaku = mContext.mDanmakuFactory.createDanmaku(BaseDanmaku.TYPE_SCROLL_RL);
if (danmaku == null || mDanmakuView == null) {
return;
}
danmaku.text = message;
danmaku.padding = 5;
danmaku.priority = 2; // 可能会被各种过滤器过滤并隐藏显示
danmaku.isLive = islive;
danmaku.time = mDanmakuView.getCurrentTime() + 1500;
danmaku.textSize = IjkPlayer.mDanmuTextSize * (mParser.getDisplayer().getDensity() - 0.6f);
danmaku.textColor = (int) (Math.random() * (16777216) + (-16777216));
log.i("hex", "" + (int) (Math.random() * (16777216) + (-16777216)));
//透明度
log.i("curDanmuTrans123", IjkPlayer.curDanmuTrans + "," + 1.2f* IjkPlayer.curDanmuSpeed + "-----" + 25f * (mParser.getDisplayer().getDensity() - 0.6f) + "===" + mParser.getDisplayer().getDensity());
mContext.setDanmakuTransparency(IjkPlayer.curDanmuTrans);
//速度
mContext.setScrollSpeedFactor(1.2f* IjkPlayer.curDanmuSpeed);
// danmaku.underlineColor = Color.GREEN;
if (isSelf) {
danmaku.borderColor = Color.WHITE;
}
mDanmakuView.addDanmaku(danmaku);
}
示例9: addDanmaku
import master.flame.danmaku.danmaku.model.BaseDanmaku; //导入依赖的package包/类
@Override
public void addDanmaku(BaseDanmaku danmaku) {
if (mHandler != null) {
if (danmaku.isLive) {
if (danmaku.forceBuildCacheInSameThread) {
if (!danmaku.isTimeOut()) {
mHandler.createCache(danmaku);
}
} else {
mHandler.obtainMessage(CacheHandler.BIND_CACHE, danmaku).sendToTarget();
}
} else {
mHandler.obtainMessage(CacheHandler.ADD_DANMAKKU, danmaku).sendToTarget();
}
}
}
示例10: clearTimeOutCaches
import master.flame.danmaku.danmaku.model.BaseDanmaku; //导入依赖的package包/类
private void clearTimeOutCaches(long time) {
IDanmakuIterator it = mCaches.iterator();
while (it.hasNext() && !mEndFlag) {
BaseDanmaku val = it.next();
if (val.isTimeOut()) {
synchronized (mDrawingNotify) {
try {
mDrawingNotify.wait(30);
} catch (InterruptedException e) {
e.printStackTrace();
break;
}
}
entryRemoved(false, val, null);
it.remove();
} else {
break;
}
}
}
示例11: addCount
import master.flame.danmaku.danmaku.model.BaseDanmaku; //导入依赖的package包/类
public int addCount(int type, int count) {
switch (type) {
case BaseDanmaku.TYPE_SCROLL_RL:
r2lDanmakuCount += count;
return r2lDanmakuCount;
case BaseDanmaku.TYPE_SCROLL_LR:
l2rDanmakuCount += count;
return l2rDanmakuCount;
case BaseDanmaku.TYPE_FIX_TOP:
ftDanmakuCount += count;
return ftDanmakuCount;
case BaseDanmaku.TYPE_FIX_BOTTOM:
fbDanmakuCount += count;
return fbDanmakuCount;
case BaseDanmaku.TYPE_SPECIAL:
specialDanmakuCount += count;
return specialDanmakuCount;
}
return 0;
}
示例12: willHitInDuration
import master.flame.danmaku.danmaku.model.BaseDanmaku; //导入依赖的package包/类
/**
* 检测两个弹幕是否会碰撞
* 允许不同类型弹幕的碰撞
* @param d1
* @param d2
* @return
*/
public static boolean willHitInDuration(IDisplayer disp, BaseDanmaku d1, BaseDanmaku d2,
long duration, long currTime) {
final int type1 = d1.getType();
final int type2 = d2.getType();
// allow hit if different type
if(type1 != type2)
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 == BaseDanmaku.TYPE_FIX_TOP || type1 == BaseDanmaku.TYPE_FIX_BOTTOM) {
return true;
}
return checkHitAtTime(disp, d1, d2, currTime)
|| checkHitAtTime(disp, d1, d2, d1.time + d1.getDuration());
}
示例13: touchHitDanmaku
import master.flame.danmaku.danmaku.model.BaseDanmaku; //导入依赖的package包/类
private IDanmakus touchHitDanmaku(float x, float y) {
IDanmakus hitDanmakus = new Danmakus();
mDanmakuBounds.setEmpty();
IDanmakus danmakus = danmakuView.getCurrentVisibleDanmakus();
if (null != danmakus && !danmakus.isEmpty()) {
IDanmakuIterator iterator = danmakus.iterator();
while (iterator.hasNext()) {
BaseDanmaku danmaku = iterator.next();
if (null != danmaku) {
mDanmakuBounds.set(danmaku.getLeft(), danmaku.getTop(), danmaku.getRight(), danmaku.getBottom());
if (mDanmakuBounds.contains(x, y)) {
hitDanmakus.addItem(danmaku);
}
}
}
}
return hitDanmakus;
}
示例14: Danmakus
import master.flame.danmaku.danmaku.model.BaseDanmaku; //导入依赖的package包/类
public Danmakus(int sortType, boolean duplicateMergingEnabled) {
BaseComparator comparator = null;
if (sortType == ST_BY_TIME) {
comparator = new TimeComparator(duplicateMergingEnabled);
} else if (sortType == ST_BY_YPOS) {
comparator = new YPosComparator(duplicateMergingEnabled);
} else if (sortType == ST_BY_YPOS_DESC) {
comparator = new YPosDescComparator(duplicateMergingEnabled);
}
if(sortType == ST_BY_LIST) {
items = new ArrayList<BaseDanmaku>();
} else {
mDuplicateMergingEnabled = duplicateMergingEnabled;
comparator.setDuplicateMergingEnabled(duplicateMergingEnabled);
items = new TreeSet<BaseDanmaku>(comparator);
mComparator = comparator;
}
mSortType = sortType;
mSize = 0;
iterator = new DanmakuIterator(items);
}
示例15: sendDanmaku
import master.flame.danmaku.danmaku.model.BaseDanmaku; //导入依赖的package包/类
/**
* 发射弹幕
*
* @param text 内容
* @param isLive 是否直播
* @return 弹幕数据
*/
public void sendDanmaku(String text, boolean isLive) {
if (!mIsEnableDanmaku) {
throw new RuntimeException("Danmaku is disable, use enableDanmaku() first");
}
if (TextUtils.isEmpty(text)) {
Toast.makeText(mAttachActivity, "内容为空", Toast.LENGTH_SHORT).show();
return;
}
if (!mDanmakuView.isPrepared()) {
Toast.makeText(mAttachActivity, "弹幕还没准备好", Toast.LENGTH_SHORT).show();
return;
}
BaseDanmaku danmaku = mDanmakuContext.mDanmakuFactory.createDanmaku(mDanmakuType);
if (danmaku == null || mDanmakuView == null) {
return;
}
if (mDanmakuTextSize == INVALID_VALUE) {
mDanmakuTextSize = 25f * (mDanmakuParser.getDisplayer().getDensity() - 0.6f);
}
danmaku.text = text;
danmaku.padding = 5;
danmaku.isLive = isLive;
danmaku.priority = 0; // 可能会被各种过滤器过滤并隐藏显示
danmaku.textSize = mDanmakuTextSize;
danmaku.textColor = mDanmakuTextColor;
danmaku.underlineColor = Color.GREEN;
danmaku.setTime(mDanmakuView.getCurrentTime() + 500);
mDanmakuView.addDanmaku(danmaku);
if (mDanmakuListener != null) {
if (mDanmakuConverter != null) {
mDanmakuListener.onDataObtain(mDanmakuConverter.convertDanmaku(danmaku));
} else {
mDanmakuListener.onDataObtain(danmaku);
}
}
}