drawablecontainer.s fading in/out tested OK

This commit is contained in:
houzh 2023-12-30 23:49:35 +08:00
parent 8f9c352a51
commit e9f4043673
3 changed files with 12 additions and 9 deletions

View File

@ -43,6 +43,7 @@ BitmapDrawable::BitmapState::BitmapState(const BitmapState&bitmapState){
mTransparency = bitmapState.mTransparency; mTransparency = bitmapState.mTransparency;
//mRebuildShader = bitmapState.mRebuildShader; //mRebuildShader = bitmapState.mRebuildShader;
mAutoMirrored = bitmapState.mAutoMirrored; mAutoMirrored = bitmapState.mAutoMirrored;
mResource = bitmapState.mResource;
} }
BitmapDrawable::BitmapState::~BitmapState(){ BitmapDrawable::BitmapState::~BitmapState(){

View File

@ -489,21 +489,23 @@ static void startElement(void *userData, const XML_Char *name, const XML_Char **
if(it!=drawableParsers.end()) { if(it!=drawableParsers.end()) {
auto item = pd->items.back(); auto item = pd->items.back();
if(strcmp(name,"shape")||((strcmp(name,"item")==0)&&atts.hasAttribute("drawable"))){ if( strcmp(name,"shape")||(((strcmp(name,"item")==0)||(strcmp(name,"transition")==0))&&atts.hasAttribute("drawable"))){
Drawable* d = it->second(pd->ctx,atts); Drawable* d = it->second(pd->ctx,atts);
if(d){ if(d){
auto cs = d->getConstantState(); auto cs = d->getConstantState();
if(cs)cs->mResource =pd->resourceFile; if(cs){
cs->mResource = atts.getString("drawable");
LOGD_IF(atts.hasAttribute("drawable"),"%p.res=%s",cs->mResource.c_str());
}
} }
item->drawable = d; item->drawable = d;
}else if(strcmp(name,"transition")==0){
LOGD("");
} }
LOGV("created drawable %s:%p props:%d",name,item->drawable,item->props.size()); LOGV("created drawable %s:%p props:%d",name,item->drawable,item->props.size());
} }
} }
static Drawable*parseShapeDrawable(Context*ctx,const AttributeSet&atts,const std::vector<AttributeSet>&props,const std::vector<std::string>&names) { static Drawable*parseShapeDrawable(Context*ctx,const AttributeSet&atts,
const std::vector<AttributeSet>&props,const std::vector<std::string>&names) {
const AttributeSet* corners = nullptr,*gradient = nullptr,*padding = nullptr; const AttributeSet* corners = nullptr,*gradient = nullptr,*padding = nullptr;
const AttributeSet* size = nullptr, *stroke = nullptr,*solid = nullptr; const AttributeSet* size = nullptr, *stroke = nullptr,*solid = nullptr;

View File

@ -430,7 +430,7 @@ int DrawableContainer::getChangingConfigurations()const{
} }
void DrawableContainer::setAlpha(int alpha) { void DrawableContainer::setAlpha(int alpha) {
if (!mHasAlpha || mAlpha != alpha) { if (!mHasAlpha || (mAlpha != alpha)) {
mHasAlpha = true; mHasAlpha = true;
mAlpha = alpha; mAlpha = alpha;
if (mCurrDrawable != nullptr) { if (mCurrDrawable != nullptr) {
@ -645,9 +645,9 @@ void DrawableContainer::animate(bool schedule) {
} else { } else {
mExitAnimationEnd = 0; mExitAnimationEnd = 0;
} }
LOGV_IF(mCurrDrawable&&mLastDrawable,"%p Cur %d:%p alpha=%d ; Last %d:%p alpha=%d",this, LOGD_IF(mCurrDrawable&&mLastDrawable,"%p \nCur %d:%p[%s] alpha=%d\nLast %d:%p[%s] alpha=%d",this,
mCurIndex,mCurrDrawable,mCurrDrawable->getAlpha(), mCurIndex,mCurrDrawable,mCurrDrawable->getConstantState()->mResource.c_str(),mCurrDrawable->getAlpha(),
mLastIndex,mLastDrawable,mLastDrawable->getAlpha()); mLastIndex,mLastDrawable,mLastDrawable->getConstantState()->mResource.c_str(),mLastDrawable->getAlpha());
if (schedule && animating) { if (schedule && animating) {
scheduleSelf(mAnimationRunnable, now + 1000 / 60); scheduleSelf(mAnimationRunnable, now + 1000 / 60);
} }