本文整理汇总了Java中com.hookedonplay.decoviewlib.events.DecoEvent类的典型用法代码示例。如果您正苦于以下问题:Java DecoEvent类的具体用法?Java DecoEvent怎么用?Java DecoEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DecoEvent类属于com.hookedonplay.decoviewlib.events包,在下文中一共展示了DecoEvent类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processRevealEffect
import com.hookedonplay.decoviewlib.events.DecoEvent; //导入依赖的package包/类
/**
* Adjust the line width used when the hide animation is taking place. This will reduce the
* line width from the original width to nothing over time. At the same this the alpha of the
* line will be reduced to nothing
*/
protected void processRevealEffect() {
if ((mDrawMode != DecoEvent.EventType.EVENT_HIDE) &&
(mDrawMode != DecoEvent.EventType.EVENT_SHOW)) {
if (mSeriesItem.getLineWidth() != mPaint.getStrokeWidth()) {
mPaint.setStrokeWidth(mSeriesItem.getLineWidth());
}
return;
}
float lineWidth = mSeriesItem.getLineWidth();
if (mPercentComplete > 0) {
lineWidth *= (1.0f - mPercentComplete);
mPaint.setAlpha((int) (Color.alpha(mSeriesItem.getColor()) * (1.0f - mPercentComplete)));
} else {
mPaint.setAlpha(Color.alpha(mSeriesItem.getColor()));
}
mPaint.setStrokeWidth(lineWidth);
}
示例2: calcCurrentPosition
import com.hookedonplay.decoviewlib.events.DecoEvent; //导入依赖的package包/类
/**
* Calculates the current position of an series based on the progress of the animation
* being executed
*
* @return Current percentage to fill chart (0 .. 1.0f)
*/
protected float calcCurrentPosition(float start, float end, float min, float max, float percent) {
start -= min;
end -= min;
max -= min;
if (Math.abs(start - end) < 0.01) {
return start / max;
}
if ((mDrawMode == DecoEvent.EventType.EVENT_HIDE) ||
(mDrawMode == DecoEvent.EventType.EVENT_SHOW) ||
(mDrawMode == DecoEvent.EventType.EVENT_COLOR_CHANGE)) {
// When revealing we are not animating the movement, but animating the size and
// transparency, so treat this as if it is 100% complete already
percent = 1.0f;
}
if (Math.abs(end) < 0.01) {
return (start / max) * (start - (start * percent)) / start;
}
return (end / max) * (start + (percent * (end - start))) / end;
}
示例3: executeMove
import com.hookedonplay.decoviewlib.events.DecoEvent; //导入依赖的package包/类
/**
* Execute a move event
*
* @param event Event to execute
*/
private void executeMove(@NonNull DecoEvent event) {
if ((event.getEventType() != DecoEvent.EventType.EVENT_MOVE) &&
(event.getEventType() != DecoEvent.EventType.EVENT_COLOR_CHANGE)) {
return;
}
if (mChartSeries != null) {
if (mChartSeries.size() <= event.getIndexPosition()) {
throw new IllegalArgumentException("Invalid index: Position out of range (Index: " + event.getIndexPosition() + " Series Count: " + mChartSeries.size() + ")");
}
final int index = event.getIndexPosition();
if (index >= 0 && index < mChartSeries.size()) {
ChartSeries item = mChartSeries.get(event.getIndexPosition());
if (event.getEventType() == DecoEvent.EventType.EVENT_COLOR_CHANGE) {
item.startAnimateColorChange(event);
} else {
item.startAnimateMove(event);
}
} else {
Log.e(TAG, "Ignoring move request: Invalid array index. Index: " + index + " Size: " + mChartSeries.size());
}
}
}
示例4: executeReveal
import com.hookedonplay.decoviewlib.events.DecoEvent; //导入依赖的package包/类
/**
* Process event reveal as required
*
* @param event DecoEvent to process
* @return true if handled
*/
@SuppressWarnings("UnusedReturnValue")
private boolean executeReveal(@NonNull DecoEvent event) {
if ((event.getEventType() != DecoEvent.EventType.EVENT_SHOW) &&
(event.getEventType() != DecoEvent.EventType.EVENT_HIDE)) {
return false;
}
if (event.getEventType() == DecoEvent.EventType.EVENT_SHOW) {
setVisibility(View.VISIBLE);
}
if (mChartSeries != null) {
for (int i = 0; i < mChartSeries.size(); i++) {
if ((event.getIndexPosition() == i) || (event.getIndexPosition() < 0)) {
ChartSeries chartSeries = mChartSeries.get(i);
chartSeries.startAnimateHideShow(event, event.getEventType() == DecoEvent.EventType.EVENT_SHOW);
}
}
}
return true;
}
示例5: startAnimateHideShow
import com.hookedonplay.decoviewlib.events.DecoEvent; //导入依赖的package包/类
/**
* Kick off an animation to hide or show the arc. This results in an animation where
* both the width of the line used for the arc and the transparency of the arc is
* altered over the duration provided
*
* @param event Event to process
* @param showArc True to show the arc, false to hide
*/
public void startAnimateHideShow(@NonNull final DecoEvent event, final boolean showArc) {
cancelAnimation();
event.notifyStartListener();
mDrawMode = event.getEventType();
mPercentComplete = showArc ? 1.0f : 0f;
mVisible = true;
final float maxValue = 1.0f;
mValueAnimator = ValueAnimator.ofFloat(0, maxValue);
mValueAnimator.setDuration(event.getEffectDuration());
mValueAnimator.setInterpolator(new LinearInterpolator());
mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
float current = Float.valueOf(valueAnimator.getAnimatedValue().toString());
mPercentComplete = showArc ? (maxValue - current) : current;
for (SeriesItem.SeriesItemListener seriesItemListener : mSeriesItem.getListeners()) {
seriesItemListener.onSeriesItemDisplayProgress(mPercentComplete);
}
}
});
mValueAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (event.getEventType() != DecoEvent.EventType.EVENT_EFFECT) {
event.notifyEndListener();
}
}
});
mValueAnimator.start();
}
示例6: reset
import com.hookedonplay.decoviewlib.events.DecoEvent; //导入依赖的package包/类
/**
* Reset the arc back to the initial values and cancel any current animations
*/
public void reset() {
mDrawMode = DecoEvent.EventType.EVENT_MOVE;
mVisible = mSeriesItem.getInitialVisibility();
cancelAnimation();
mPositionStart = mSeriesItem.getMinValue();
mPositionEnd = mSeriesItem.getInitialValue();
mPositionCurrentEnd = mSeriesItem.getInitialValue();
mPercentComplete = 1.0f;
mPaint = new Paint();
mPaint.setColor(mSeriesItem.getColor());
mPaint.setStyle((mSeriesItem.getChartStyle() == SeriesItem.ChartStyle.STYLE_DONUT) ? Paint.Style.STROKE : Paint.Style.FILL);
mPaint.setStrokeWidth(mSeriesItem.getLineWidth());
mPaint.setStrokeCap(mSeriesItem.getRoundCap() ? Paint.Cap.ROUND : Paint.Cap.BUTT);
mPaint.setAntiAlias(true);
if (mSeriesItem.getShadowSize() > 0) {
mPaint.setShadowLayer(mSeriesItem.getShadowSize(), 0, 0, mSeriesItem.getShadowColor());
}
// We need to reset the bounds for the case we are drawing a gradient and need to recreate
// based on the bounds
mBounds = null;
for (SeriesItem.SeriesItemListener seriesItemListener : mSeriesItem.getListeners()) {
seriesItemListener.onSeriesItemAnimationProgress(mPercentComplete, mPositionCurrentEnd);
}
}
示例7: draw
import com.hookedonplay.decoviewlib.events.DecoEvent; //导入依赖的package包/类
/**
* Draw this series in the current position calculated by the ValueAnimator.
*
* @param canvas Canvas used to draw
* @param bounds Bounds to be used to draw the arc
* @return true if drawing has already been handled
*/
public boolean draw(Canvas canvas, RectF bounds) {
if (!mVisible) {
return true;
}
if (bounds == null || bounds.isEmpty()) {
throw new IllegalArgumentException("Drawing bounds can not be null or empty");
}
processBoundsChange(bounds);
if (mDrawMode == DecoEvent.EventType.EVENT_EFFECT) {
// Delegate the drawing to the ArcEffect as required
if (mEffect != null) {
mEffect.draw(canvas, mBoundsInset, mPercentComplete, mAngleStart, mAngleSweep);
}
return true;
}
processRevealEffect();
if (mColorAnimate != null) {
mPaint.setColor(mColorAnimate.getColorCurrent(mPercentComplete));
} else if (mPaint.getColor() != getSeriesItem().getColor()) {
mPaint.setColor(getSeriesItem().getColor());
}
return false;
}
示例8: onExecuteEventStart
import com.hookedonplay.decoviewlib.events.DecoEvent; //导入依赖的package包/类
/**
* Event Manager wants to start an event. It is this classes responsibility to execute the
* event
*
* @param event Event to be executed
*/
@Override
public void onExecuteEventStart(@NonNull DecoEvent event) {
executeMove(event);
executeReveal(event);
executeEffect(event);
}
示例9: animate
import com.hookedonplay.decoviewlib.events.DecoEvent; //导入依赖的package包/类
private void animate(){
if(mArcView == null || mDeployment == null){
return;
}
if(!Prefs.isAnimationEnabled()){
mArcView.addEvent(new DecoEvent.Builder(DecoEvent.EventType.EVENT_SHOW, true)
.setDelay(0)
.setDuration(0)
.build());
mArcView.addEvent(new DecoEvent.Builder(mDeployment.getCompleted())
.setIndex(mCompletedIndex)
.setDelay(0)
.setDuration(0)
.build());
setPercent(mDeployment.getPercentage());
return;
}
// Remove all animation events
mArcView.executeReset();
mArcView.addEvent(new DecoEvent.Builder(DecoEvent.EventType.EVENT_SHOW, true)
.setDelay(ANI_SHOW_DELAY)
.setDuration(ANI_SHOW_DURATION)
.build());
mArcView.addEvent(new DecoEvent.Builder(mDeployment.getCompleted())
.setIndex(mCompletedIndex)
.setDelay(ANI_SHOW_DELAY + ANI_SHOW_DURATION)
.setDuration(ANI_PERCENT_DURATION)
.build());
}
示例10: startAnimateColorChange
import com.hookedonplay.decoviewlib.events.DecoEvent; //导入依赖的package包/类
/**
* Animate change of color
*
* @param event Event to process
*/
public void startAnimateColorChange(@NonNull final DecoEvent event) {
cancelAnimation();
event.notifyStartListener();
mVisible = true;
mDrawMode = event.getEventType();
mPercentComplete = 0f;
final boolean changeColors = event.isColorSet();
if (changeColors) {
mColorAnimate = new ColorAnimate(mSeriesItem.getColor(), event.getColor());
mSeriesItem.setColor(event.getColor());
} else {
Log.w(TAG, "Must set new color to start CHANGE_COLOR event");
return;
}
final float maxValue = 1.0f;
mValueAnimator = ValueAnimator.ofFloat(0, maxValue);
mValueAnimator.setDuration(event.getEffectDuration());
if (event.getInterpolator() != null) {
mValueAnimator.setInterpolator(event.getInterpolator());
} else {
mValueAnimator.setInterpolator(new LinearInterpolator());
}
mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
mPercentComplete = Float.valueOf(valueAnimator.getAnimatedValue().toString());
for (SeriesItem.SeriesItemListener seriesItemListener : mSeriesItem.getListeners()) {
seriesItemListener.onSeriesItemDisplayProgress(mPercentComplete);
}
}
});
mValueAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
event.notifyEndListener();
}
});
mValueAnimator.start();
}
示例11: startAnimateEffect
import com.hookedonplay.decoviewlib.events.DecoEvent; //导入依赖的package包/类
/**
* Execute an Animation effect by starting the Value Animator
*
* @param event Event to process effect
* @throws IllegalStateException No effect set in event
*/
public void startAnimateEffect(@NonNull final DecoEvent event)
throws IllegalStateException {
if (event.getEffectType() == null) {
throw new IllegalStateException("Unable to execute null effect type");
}
// All effects run from 0.0 .. 1.0f in duration
final float maxValue = 1.0f;
cancelAnimation();
event.notifyStartListener();
mVisible = true;
mDrawMode = event.getEventType();
mEffect = new DecoDrawEffect(event.getEffectType(), mPaint, event.getDisplayText());
mEffect.setRotationCount(event.getEffectRotations());
mPercentComplete = 0f;
mValueAnimator = ValueAnimator.ofFloat(0, maxValue);
mValueAnimator.setDuration(event.getEffectDuration());
Interpolator interpolator = (event.getInterpolator() != null) ? event.getInterpolator() : new LinearInterpolator();
mValueAnimator.setInterpolator(interpolator);
mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
mPercentComplete = Float.valueOf(valueAnimator.getAnimatedValue().toString());
for (SeriesItem.SeriesItemListener seriesItemListener : mSeriesItem.getListeners()) {
seriesItemListener.onSeriesItemDisplayProgress(mPercentComplete);
}
}
});
mValueAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
event.notifyEndListener();
mDrawMode = DecoEvent.EventType.EVENT_MOVE;
mVisible = mEffect.postExecuteVisibility();
mEffect = null;
}
});
mValueAnimator.start();
}
示例12: moveTo
import com.hookedonplay.decoviewlib.events.DecoEvent; //导入依赖的package包/类
/**
* Basic wrapper function to create an event with all defaults for the arc and simply execute
* a move for the current position of the arc. If you want to customize the move (such as delay,
* speed, interpolator...) then you need to use create an {@link DecoEvent} and call
* {@link #addEvent(DecoEvent)}
* <p/>
* This function will not create a {@link DecoEvent} if you pass 0 as the duration
*
* @param index index of the arc series to apply the move
* @param position position of the arc
* @param duration duration of the move
*/
public void moveTo(int index, float position, int duration) {
if (duration == 0) {
getChartSeries(index).setPosition(position);
invalidate();
return;
}
addEvent(new DecoEvent.Builder(position).setIndex(index).setDuration(duration).build());
}
示例13: addEvent
import com.hookedonplay.decoviewlib.events.DecoEvent; //导入依赖的package包/类
/**
* Add an event to the DynamicArcViews {@link DecoEventManager} for processing. This can be
* executed immediately or if the event has a {@link DecoEvent#mDelay} set then it will be
* executed at a future time.
* <p/>
* When this event is to be executed the {@link DecoEventManager.ArcEventManagerListener#onExecuteEventStart(DecoEvent)}
* callback will be executed
* <p/>
* To create an event see {@link DecoEvent.Builder}
*
* @param event Event to be processed
*/
public void addEvent(@NonNull DecoEvent event) {
getEventManager().add(event);
}