make variant compatibale with C++17

This commit is contained in:
houzh 2023-10-05 11:45:53 +08:00
parent 2ba4b2d314
commit 94e7908fa6
13 changed files with 424 additions and 29 deletions

View File

@ -1,7 +1,5 @@
project(cdroid C CXX)
set(CMAKE_CXX_STANDARD 11)
option( GUI_STATIC "UI is static link" ON)
if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")

View File

@ -39,17 +39,17 @@ void PropertyValuesHolder::evaluate(AnimateValue& out, const AnimateValue& from,
float fraction) const{
switch(from.index()){
case 0:
out = (int)((1.f - fraction)*from.get<int>() + fraction * to.get<int>());
out = (int)((1.f - fraction)*GET_VARIANT(from,int) + fraction * GET_VARIANT(to,int));
break;
case 1:{
float a=lerp((from.get<uint32_t>()>>24)/255.f,(to.get<uint32_t>()>>24)/255.f,fraction);
float r=lerp(((from.get<uint32_t>()>>16)&0xFF)/255.f,((to.get<uint32_t>()>>16)&0xFF)/255.f,fraction);
float g=lerp(((from.get<uint32_t>()>>8)&0xFF)/255.f,((to.get<uint32_t>()>>8)&0xFF)/255.f,fraction);
float b=lerp((from.get<uint32_t>()&0xFF)/255.f,(to.get<uint32_t>()&0xFF)/255.f,fraction);
float a=lerp((GET_VARIANT(from,uint32_t)>>24)/255.f,(GET_VARIANT(to,uint32_t)>>24)/255.f,fraction);
float r=lerp(((GET_VARIANT(from,uint32_t)>>16)&0xFF)/255.f,((GET_VARIANT(to,uint32_t)>>16)&0xFF)/255.f,fraction);
float g=lerp(((GET_VARIANT(from,uint32_t)>>8)&0xFF)/255.f,((GET_VARIANT(to,uint32_t)>>8)&0xFF)/255.f,fraction);
float b=lerp((GET_VARIANT(from,uint32_t)&0xFF)/255.f,(GET_VARIANT(to,uint32_t)&0xFF)/255.f,fraction);
out=((uint32_t)(a*255.f)<<24)|((uint32_t)(r*255)<<16)|((uint32_t)(g*255)<<8)|((uint32_t)(b*255));
}break;
case 2:
out = from.get<float>() * (1.f - fraction) + to.get<float>() * fraction;
out = GET_VARIANT(from,float) * (1.f - fraction) + GET_VARIANT(to,float) * fraction;
break;
}
}

View File

@ -11,6 +11,11 @@
#include <core/variant.h>
//reference:
//http://androidxref.com/9.0.0_r3/xref/frameworks/base/libs/hwui/PropertyValuesHolder.h
#if variant_CPP17_OR_GREATER
#define GET_VARIANT(vt,type) std::get<type>(vt)
#else
#define GET_VARIANT(vt,type) vt.get<type>()
#endif
namespace cdroid{
typedef nonstd::variant<int,uint32_t,float>AnimateValue;

View File

@ -91,8 +91,7 @@ void RippleBackground::onStateChanged(){
mAnimator->setInterpolator(new LinearInterpolator());//LINEAR_INTERPOLATOR);
mAnimator->addUpdateListener(ValueAnimator::AnimatorUpdateListener([this](ValueAnimator&anim){
PropertyValuesHolder*fp=anim.getValues(0);
LOGD("mOpacity=%f",fp->getAnimatedValue().get<float>());
mOpacity=fp->getAnimatedValue().get<float>();
mOpacity = GET_VARIANT(fp->getAnimatedValue(),float);
invalidateSelf();
}));

View File

@ -102,7 +102,7 @@ void RippleForeground::startSoftwareEnter() {
tweenRadius->setInterpolator(new DecelerateInterpolator());//DECELERATE_INTERPOLATOR);
tweenRadius->addUpdateListener(ValueAnimator::AnimatorUpdateListener([this](ValueAnimator&anim){
LOGV("mTweenRadius=%f [%f,%f,%f] opacity=%f",getCurrentRadius(),mStartRadius,mTargetRadius,mOpacity);
mTweenRadius=anim.getAnimatedValue().get<float>();
mTweenRadius = GET_VARIANT(anim.getAnimatedValue(),float);
onAnimationPropertyChanged();
}));
tweenRadius->start();
@ -112,7 +112,7 @@ void RippleForeground::startSoftwareEnter() {
tweenOrigin->setDuration(RIPPLE_ORIGIN_DURATION);
tweenOrigin->setInterpolator(new DecelerateInterpolator());//DECELERATE_INTERPOLATOR);
tweenOrigin->addUpdateListener(ValueAnimator::AnimatorUpdateListener([this](ValueAnimator&anim){
mTweenX=mTweenY=anim.getAnimatedValue().get<float>();
mTweenX=mTweenY=GET_VARIANT(anim.getAnimatedValue(),float);
onAnimationPropertyChanged();
}));
tweenOrigin->start();
@ -122,7 +122,7 @@ void RippleForeground::startSoftwareEnter() {
opacity->setDuration(OPACITY_ENTER_DURATION);
opacity->setInterpolator(new LinearInterpolator());//LINEAR_INTERPOLATOR);
opacity->addUpdateListener(ValueAnimator::AnimatorUpdateListener([this](ValueAnimator&anim){
mOpacity=anim.getAnimatedValue().get<float>();
mOpacity=GET_VARIANT(anim.getAnimatedValue(),float);
onAnimationPropertyChanged();
}));
opacity->start();
@ -136,7 +136,7 @@ void RippleForeground::startSoftwareExit() {
opacity->addListener(mAnimationListener);
opacity->setStartDelay(computeFadeOutDelay());
opacity->addUpdateListener(ValueAnimator::AnimatorUpdateListener([this](ValueAnimator&anim){
mOpacity=anim.getAnimatedValue().get<float>();
mOpacity=GET_VARIANT(anim.getAnimatedValue(),float);
}));
opacity->start();

View File

@ -18,7 +18,7 @@ SwipeHelper::SwipeHelper(Context*ctx) {
mPreContentViewAnimator = ValueAnimator::ofFloat({.0f, 1.f});
mPreContentViewAnimator->setInterpolator(new AccelerateDecelerateInterpolator());
mPreContentViewAnimator->addUpdateListener(ValueAnimator::AnimatorUpdateListener([this](ValueAnimator&anim){
const float value = anim.getAnimatedValue().get<float>();
const float value = GET_VARIANT(anim.getAnimatedValue(),float);
const int xx = mPrevStartX+(mPrevEndX-mPrevStartX)*value;
Window* prev = (Window*)getPreContentView();
LOGV("move PrevWindow(%p) to %d cancel=%d",prev,xx,mCancel);
@ -28,7 +28,7 @@ SwipeHelper::SwipeHelper(Context*ctx) {
mCurContentViewAnimator = ValueAnimator::ofFloat({.0f, 1.f});
mCurContentViewAnimator->setInterpolator(new AccelerateDecelerateInterpolator());
mCurContentViewAnimator->addUpdateListener(ValueAnimator::AnimatorUpdateListener([this](ValueAnimator&anim){
const float value = anim.getAnimatedValue().get<float>();
const float value = GET_VARIANT(anim.getAnimatedValue(),float);
const int xx = mCurrentStartX+(mCurrentEndX-mCurrentStartX)*value;
Window* cur = (Window*)getCurContentView();
LOGV("move CurrentWindow(%p) to %d cancel=%d",cur,xx,mCancel);

View File

@ -0,0 +1,363 @@
namespace cdroid{
DateTimeView::DateTimeView(Context context,const AttributeSet& attrs) {
:TextView(context, attrs);
setShowRelativeTime(attrs.getBoolean("showRelative",false);
}
void DateTimeView::onAttachedToWindow() {
TextView::onAttachedToWindow();
ReceiverInfo ri = sReceiverInfo.get();
if (ri == null) {
ri = new ReceiverInfo();
sReceiverInfo.set(ri);
}
ri.addView(this);
// The view may not be added to the view hierarchy immediately right after setTime()
// is called which means it won't get any update from intents before being added.
// In such case, the view might show the incorrect relative time after being added to the
// view hierarchy until the next update intent comes.
// So we update the time here if mShowRelativeTime is enabled to prevent this case.
if (mShowRelativeTime) {
update();
}
}
void DateTimeView::onDetachedFromWindow() {
TextView::onDetachedFromWindow();
final ReceiverInfo ri = sReceiverInfo.get();
if (ri != null) {
ri.removeView(this);
}
}
void DateTimeView::setTime(long timeMillis) {
mTimeMillis = timeMillis;
LocalDateTime dateTime = toLocalDateTime(timeMillis, ZoneId.systemDefault());
mLocalTime = dateTime.withSecond(0);
update();
}
void DateTimeView::setShowRelativeTime(bool showRelativeTime) {
mShowRelativeTime = showRelativeTime;
updateNowText();
update();
}
bool DateTimeView::isShowRelativeTime() const{
return mShowRelativeTime;
}
void DateTimeView::setVisibility(int visibility) {
bool gotVisible = visibility != GONE && getVisibility() == GONE;
TextView::setVisibility(visibility);
if (gotVisible) {
update();
}
}
void DateTimeView::update() {
if (mLocalTime == null || getVisibility() == GONE) {
return;
}
if (mShowRelativeTime) {
updateRelativeTime();
return;
}
int display;
ZoneId zoneId = ZoneId.systemDefault();
// localTime is the local time for mTimeMillis but at zero seconds past the minute.
LocalDateTime localTime = mLocalTime;
LocalDateTime localStartOfDay =
LocalDateTime.of(localTime.toLocalDate(), LocalTime.MIDNIGHT);
LocalDateTime localTomorrowStartOfDay = localStartOfDay.plusDays(1);
// now is current local time but at zero seconds past the minute.
LocalDateTime localNow = LocalDateTime.now(zoneId).withSecond(0);
long twelveHoursBefore = toEpochMillis(localTime.minusHours(12), zoneId);
long twelveHoursAfter = toEpochMillis(localTime.plusHours(12), zoneId);
long midnightBefore = toEpochMillis(localStartOfDay, zoneId);
long midnightAfter = toEpochMillis(localTomorrowStartOfDay, zoneId);
long time = toEpochMillis(localTime, zoneId);
long now = toEpochMillis(localNow, zoneId);
// Choose the display mode
choose_display: {
if ((now >= midnightBefore && now < midnightAfter)
|| (now >= twelveHoursBefore && now < twelveHoursAfter)) {
display = SHOW_TIME;
break choose_display;
}
// Else, show month day and year.
display = SHOW_MONTH_DAY_YEAR;
break choose_display;
}
// Choose the format
DateFormat format;
if (display == mLastDisplay && mLastFormat != null) {
// use cached format
format = mLastFormat;
} else {
switch (display) {
case SHOW_TIME:
format = getTimeFormat();
break;
case SHOW_MONTH_DAY_YEAR:
format = DateFormat.getDateInstance(DateFormat.SHORT);
break;
default:
throw new RuntimeException("unknown display value: " + display);
}
mLastFormat = format;
}
// Set the text
String text = format.format(new Date(time));
maybeSetText(text);
// Schedule the next update
if (display == SHOW_TIME) {
// Currently showing the time, update at the later of twelve hours after or midnight.
mUpdateTimeMillis = twelveHoursAfter > midnightAfter ? twelveHoursAfter : midnightAfter;
} else {
// Currently showing the date
if (mTimeMillis < now) {
// If the time is in the past, don't schedule an update
mUpdateTimeMillis = 0;
} else {
// If hte time is in the future, schedule one at the earlier of twelve hours
// before or midnight before.
mUpdateTimeMillis = twelveHoursBefore < midnightBefore
? twelveHoursBefore : midnightBefore;
}
}
}
void DateTimeView::updateRelativeTime() {
long now = System.currentTimeMillis();
long duration = Math.abs(now - mTimeMillis);
int count;
long millisIncrease;
boolean past = (now >= mTimeMillis);
String result;
if (duration < MINUTE_IN_MILLIS) {
maybeSetText(mNowText);
mUpdateTimeMillis = mTimeMillis + MINUTE_IN_MILLIS + 1;
return;
} else if (duration < HOUR_IN_MILLIS) {
count = (int)(duration / MINUTE_IN_MILLIS);
result = getContext().getResources().getString(past
? com.android.internal.R.string.duration_minutes_shortest
: com.android.internal.R.string.duration_minutes_shortest_future,
count);
millisIncrease = MINUTE_IN_MILLIS;
} else if (duration < DAY_IN_MILLIS) {
count = (int)(duration / HOUR_IN_MILLIS);
result = getContext().getResources().getString(past
? com.android.internal.R.string.duration_hours_shortest
: com.android.internal.R.string.duration_hours_shortest_future,
count);
millisIncrease = HOUR_IN_MILLIS;
} else if (duration < YEAR_IN_MILLIS) {
// In weird cases it can become 0 because of daylight savings
LocalDateTime localDateTime = mLocalTime;
ZoneId zoneId = ZoneId.systemDefault();
LocalDateTime localNow = toLocalDateTime(now, zoneId);
count = Math.max(Math.abs(dayDistance(localDateTime, localNow)), 1);
result = getContext().getResources().getString(past
? com.android.internal.R.string.duration_days_shortest
: com.android.internal.R.string.duration_days_shortest_future,
count);
if (past || count != 1) {
mUpdateTimeMillis = computeNextMidnight(localNow, zoneId);
millisIncrease = -1;
} else {
millisIncrease = DAY_IN_MILLIS;
}
} else {
count = (int)(duration / YEAR_IN_MILLIS);
result = getContext().getResources().getString(past
? com.android.internal.R.string.duration_years_shortest
: com.android.internal.R.string.duration_years_shortest_future,
count);
millisIncrease = YEAR_IN_MILLIS;
}
if (millisIncrease != -1) {
if (past) {
mUpdateTimeMillis = mTimeMillis + millisIncrease * (count + 1) + 1;
} else {
mUpdateTimeMillis = mTimeMillis - millisIncrease * count + 1;
}
}
maybeSetText(result);
}
void DateTimeView::maybeSetText(const std::string& text) {
if (TextUtils.equals(getText(), text)) {
return;
}
setText(text);
}
long DateTimeView::computeNextMidnight(LocalDateTime time, ZoneId zoneId) {
// This ignores the chance of overflow: it should never happen.
LocalDate tomorrow = time.toLocalDate().plusDays(1);
LocalDateTime nextMidnight = LocalDateTime.of(tomorrow, LocalTime.MIDNIGHT);
return toEpochMillis(nextMidnight, zoneId);
}
void DateTimeView::onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
updateNowText();
update();
}
void DateTimeView::updateNowText() {
if (!mShowRelativeTime) {
return;
}
mNowText = getContext().getResources().getString(
com.android.internal.R.string.now_string_shortest);
}
int DateTimeView::dayDistance(LocalDateTime start, LocalDateTime end) {
return (int) (end.getLong(JulianFields.JULIAN_DAY)
- start.getLong(JulianFields.JULIAN_DAY));
}
DateFormat DateTimeView::getTimeFormat() {
return android.text.format.DateFormat.getTimeFormat(getContext());
}
void DateTimeView::clearFormatAndUpdate() {
mLastFormat = null;
update();
}
void DateTimeView::setReceiverHandler(Handler handler) {
ReceiverInfo ri = sReceiverInfo.get();
if (ri == null) {
ri = new ReceiverInfo();
sReceiverInfo.set(ri);
}
ri.setHandler(handler);
}
LocalDateTime DateTimeView::toLocalDateTime(long timeMillis, ZoneId zoneId) {
// java.time types like LocalDateTime / Instant can support the full range of "long millis"
// with room to spare so we do not need to worry about overflow / underflow and the rsulting
// exceptions while the input to this class is a long.
Instant instant = Instant.ofEpochMilli(timeMillis);
return LocalDateTime.ofInstant(instant, zoneId);
}
long DateTimeView::toEpochMillis(LocalDateTime time, ZoneId zoneId) {
Instant instant = time.toInstant(zoneId.getRules().getOffset(time));
return instant.toEpochMilli();
}
private static class ReceiverInfo {
private final ArrayList<DateTimeView> mAttachedViews = new ArrayList<DateTimeView>();
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (Intent.ACTION_TIME_TICK.equals(action)) {
if (System.currentTimeMillis() < getSoonestUpdateTime()) {
// The update() function takes a few milliseconds to run because of
// all of the time conversions it needs to do, so we can't do that
// every minute.
return;
}
}
// ACTION_TIME_CHANGED can also signal a change of 12/24 hr. format.
updateAll();
}
};
ContentObserver mObserver = new ContentObserver(new Handler()) {
void onChange(boolean selfChange) {
updateAll();
}
};
Handler mHandler = new Handler();
void addView(DateTimeView v) {
synchronized (mAttachedViews) {
bool register = mAttachedViews.isEmpty();
mAttachedViews.add(v);
if (register) {
register(getApplicationContextIfAvailable(v.getContext()));
}
}
}
void removeView(DateTimeView v) {
synchronized (mAttachedViews) {
final bool removed = mAttachedViews.remove(v);
// Only unregister once when we remove the last view in the list otherwise we risk
// trying to unregister a receiver that is no longer registered.
if (removed && mAttachedViews.isEmpty()) {
unregister(getApplicationContextIfAvailable(v.getContext()));
}
}
}
void updateAll() {
synchronized (mAttachedViews) {
final int count = mAttachedViews.size();
for (int i = 0; i < count; i++) {
DateTimeView view = mAttachedViews.get(i);
view.post(() -> view.clearFormatAndUpdate());
}
}
}
long getSoonestUpdateTime() {
long result = Long.MAX_VALUE;
synchronized (mAttachedViews) {
final int count = mAttachedViews.size();
for (int i = 0; i < count; i++) {
final long time = mAttachedViews.get(i).mUpdateTimeMillis;
if (time < result) {
result = time;
}
}
}
return result;
}
static final Context getApplicationContextIfAvailable(Context context) {
final Context ac = context.getApplicationContext();
return ac != null ? ac : ActivityThread.currentApplication().getApplicationContext();
}
void register(Context context) {
final IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_TIME_TICK);
filter.addAction(Intent.ACTION_TIME_CHANGED);
filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
context.registerReceiver(mReceiver, filter, null, mHandler);
}
void unregister(Context context) {
context.unregisterReceiver(mReceiver);
}
public void setHandler(Handler handler) {
mHandler = handler;
synchronized (mAttachedViews) {
if (!mAttachedViews.isEmpty()) {
unregister(mAttachedViews.get(0).getContext());
register(mAttachedViews.get(0).getContext());
}
}
}
}
}/*endof namespace*/

View File

@ -0,0 +1,30 @@
#ifndef __DATE_TIME_VIEW_H__
#define __DATE_TIME_VIEW_H__
namespace cdroid{
class DateTimeView public:TextView{
private:
static constexpr int SHOW_TIME = 0;
static constexpr int SHOW_MONTH_DAY_YEAR = 1;
private:
long mTimeMillis;
// The LocalDateTime equivalent of mTimeMillis but truncated to minute, i.e. no seconds / nanos.
LocalDateTime mLocalTime;
int mLastDisplay = -1;
DateFormat mLastFormat;
long mUpdateTimeMillis;
//static final ThreadLocal<ReceiverInfo> sReceiverInfo = new ThreadLocal<ReceiverInfo>();
std::string mNowText;
bool mShowRelativeTime;
protected:
void onAttachedToWindow()override;
void onDetachedFromWindow()override;
public:
DateTimeView(Context context,const AttributeSet& attrs);
void setTime(long timeMillis);
};
}/*endof namespace*/
#endif

View File

@ -213,7 +213,7 @@ void ExpandableLayout::animateSize(int targetExpansion) {
mAnimator->setDuration(mDuration);
mAnimator->addUpdateListener(ValueAnimator::AnimatorUpdateListener([this](ValueAnimator&anim) {
setExpansion((float) anim.getAnimatedValue().get<float>());
setExpansion(GET_VARIANT(anim.getAnimatedValue(),float));
}));
Animator::AnimatorListener ls;

View File

@ -316,7 +316,7 @@ void ProgressBar::doRefreshProgress(int id, int progress, bool fromUser,bool cal
mAnimator->setDuration(PROGRESS_ANIM_DURATION);
mAnimator->setInterpolator(new DecelerateInterpolator());
mAnimator->addUpdateListener(ValueAnimator::AnimatorUpdateListener([this](ValueAnimator&anim){
setVisualProgress(R::id::progress,anim.getAnimatedValue().get<float>());
setVisualProgress(R::id::progress,GET_VARIANT(anim.getAnimatedValue(),float));
}));
mAnimator->addListener(mAnimtorListener);
}

View File

@ -564,7 +564,7 @@ void Switch::animateThumbToCheckedState(bool newCheckedState){
mPositionAnimator->setAutoCancel(true);
mPositionAnimator->start();
mPositionAnimator->addUpdateListener(ValueAnimator::AnimatorUpdateListener([this](ValueAnimator&anim){
setThumbPosition(anim.getAnimatedValue().get<float>());
setThumbPosition(GET_VARIANT(anim.getAnimatedValue(),float));
}));
}

View File

@ -618,7 +618,7 @@ void TabLayout::ensureScrollAnimator(){
mScrollAnimator->setDuration(ANIMATION_DURATION);
mScrollAnimator->addUpdateListener(ValueAnimator::AnimatorUpdateListener([this](ValueAnimator&anim) {
PropertyValuesHolder*ip=anim.getValues()[0];
scrollTo(ip->getAnimatedValue().get<float>(), 0);
scrollTo(GET_VARIANT(ip->getAnimatedValue(),float),0);
}));
}
}

View File

@ -25,7 +25,7 @@ TEST_F(ANIMATOR,callback){
TEST_F(ANIMATOR,ofInt1){
ValueAnimator*anim=ValueAnimator::ofInt({0,100});
anim->addUpdateListener(ValueAnimator::AnimatorUpdateListener([this](ValueAnimator&anim){
LOGD("value=%d",anim.getAnimatedValue().get<int>());
LOGD("value=%d",GET_VARIANT(anim.getAnimatedValue(),int));
}));
for(int i=0;i<=10;i++){
anim->setCurrentFraction((float)i/10.f);
@ -37,7 +37,7 @@ TEST_F(ANIMATOR,ofInt2){
iprop.setValues(std::vector<int>({0,100}));
ValueAnimator*anim=ValueAnimator::ofPropertyValuesHolder({&iprop});
anim->addUpdateListener(ValueAnimator::AnimatorUpdateListener([this](ValueAnimator&anim){
LOGD("value=%d",anim.getAnimatedValue().get<int>());
LOGD("value=%d",GET_VARIANT(anim.getAnimatedValue(),int));
}));
for(int i=0;i<=10;i++){
anim->setCurrentFraction((float)i/10.f);
@ -49,7 +49,7 @@ TEST_F(ANIMATOR,ofFloat){
fprop.setValues(std::vector<float>({0,100}));
ValueAnimator*anim=ValueAnimator::ofPropertyValuesHolder({&fprop});
anim->addUpdateListener(ValueAnimator::AnimatorUpdateListener([this](ValueAnimator&anim){
LOGD("value=%f",anim.getAnimatedValue().get<float>());
LOGD("value=%f",GET_VARIANT(anim.getAnimatedValue(),float));
}));
for(int i=0;i<=10;i++){
anim->setCurrentFraction((float)i/10.f);
@ -62,7 +62,7 @@ TEST_F(ANIMATOR,start){
fprop.setValues(std::vector<float>({0,100}));
ValueAnimator*anim=ValueAnimator::ofPropertyValuesHolder({&fprop});
anim->addUpdateListener(ValueAnimator::AnimatorUpdateListener([this](ValueAnimator&anim){
LOGD("value=%f",anim.getAnimatedValue().get<float>());
LOGD("value=%f",GET_VARIANT(anim.getAnimatedValue(),float));
}));
anim->setDuration(200);
anim->start();
@ -75,7 +75,7 @@ TEST_F(ANIMATOR,startDelay){
fprop.setValues(std::vector<float>({0,100}));
ValueAnimator*anim=ValueAnimator::ofPropertyValuesHolder({&fprop});
anim->addUpdateListener(ValueAnimator::AnimatorUpdateListener([this](ValueAnimator&anim){
LOGD("value=%f",anim.getAnimatedValue().get<float>());
LOGD("value=%f",GET_VARIANT(anim.getAnimatedValue(),float));
}));
anim->setDuration(200);
anim->setStartDelay(1000);
@ -107,7 +107,7 @@ TEST_F(ANIMATOR,loopdrivered){
ValueAnimator*anim=ValueAnimator::ofPropertyValuesHolder({&iprop});
anim->addUpdateListener(ValueAnimator::AnimatorUpdateListener([this](ValueAnimator&anim){
LOGD("value=%d",anim.getAnimatedValue().get<int>());
LOGD("value=%d",GET_VARIANT(anim.getAnimatedValue(),int));
}));
anim->setDuration(2000);
anim->start();
@ -137,8 +137,8 @@ TEST_F(ANIMATOR,translate){
PropertyValuesHolder*xp=anim.getValues(0);
PropertyValuesHolder*yp=anim.getValues(1);
PropertyValuesHolder*cp=anim.getValues(2);
tv->setPos(xp->getAnimatedValue().get<int>(),yp->getAnimatedValue().get<int>());
tv->setBackgroundColor(cp->getAnimatedValue().get<uint32_t>());
tv->setPos(GET_VARIANT(xp->getAnimatedValue(),int),GET_VARIANT(yp->getAnimatedValue(),int));
tv->setBackgroundColor(GET_VARIANT(cp->getAnimatedValue(),uint32_t));
}));
anim->setDuration(5000);
@ -158,7 +158,7 @@ TEST_F(ANIMATOR,scale){
ValueAnimator*anim=ValueAnimator::ofPropertyValuesHolder({&fprop});
anim->addUpdateListener(ValueAnimator::AnimatorUpdateListener([tv](ValueAnimator&anim){
const float scale=anim.getAnimatedValue().get<float>();
const float scale=GET_VARIANT(anim.getAnimatedValue(),float);
tv->setScaleX(scale);
tv->setScaleY(scale);
}));