mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-12-06 06:08:24 +08:00
fix Assets::getDrawable for url not exists
This commit is contained in:
parent
dd1e122345
commit
c3491d4197
@ -365,7 +365,7 @@ Drawable* Assets::getDrawable(const std::string&fullresid) {
|
||||
}
|
||||
}
|
||||
//wrap png to drawable,make app develop simply
|
||||
if(resname[0]=='#'||resname[1]=='x'|| resname[1]=='X'||resname.find('/')==std::string::npos) {
|
||||
if(resname[0]=='#'||resname[1]=='x'|| resname[1]=='X'){
|
||||
LOGV("color %s",fullresid.c_str());
|
||||
return new ColorDrawable(Color::parseColor(resname));
|
||||
}
|
||||
@ -390,7 +390,7 @@ Drawable* Assets::getDrawable(const std::string&fullresid) {
|
||||
std::ifstream fs(fullresid);
|
||||
d = Drawable::fromStream(nullptr,fs,resname,package);
|
||||
}
|
||||
LOGD_IF(zfile==nullptr,"drawable %s load failed",fullresid.c_str());
|
||||
LOGD_IF(zfile==nullptr&&fullresid.find("/")!=std::string::npos,"drawable %s load failed",fullresid.c_str());
|
||||
}
|
||||
if(d) {
|
||||
mDrawables.insert({fullresid,std::weak_ptr<Drawable::ConstantState>(d->getConstantState())});
|
||||
|
@ -617,13 +617,14 @@ Drawable*Drawable::fromStream(Context*ctx,std::istream&stream,const std::string&
|
||||
XML_SetUserData(parser,&pd);
|
||||
pd.items.clear();
|
||||
XML_SetElementHandler(parser, startElement, endElement);
|
||||
LOGE_IF(!stream.good(),"%s open failed",resname.c_str());
|
||||
const bool isResURL = strpbrk(resname.c_str(),"@/:")!=nullptr;
|
||||
LOGE_IF((stream.good()==false)&&isResURL,"%s open failed",resname.c_str());
|
||||
do {
|
||||
stream.read(buf,sizeof(buf));
|
||||
rdlen=stream.gcount();
|
||||
if (XML_Parse(parser, buf,rdlen,!rdlen) == XML_STATUS_ERROR) {
|
||||
const char*es=XML_ErrorString(XML_GetErrorCode(parser));
|
||||
LOGE("%s at %s:line %ld",es, resname.c_str(),XML_GetCurrentLineNumber(parser));
|
||||
LOGE_IF(isResURL,"%s at %s:line %ld",es, resname.c_str(),XML_GetCurrentLineNumber(parser));
|
||||
XML_ParserFree(parser);
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -1106,9 +1106,10 @@ void NumberPicker::onDraw(Canvas&canvas){
|
||||
}
|
||||
}
|
||||
}
|
||||
Drawable*dr = mContext->getDrawable(scrollSelectorValue);
|
||||
if(dr){
|
||||
const bool isResURL = strpbrk(scrollSelectorValue.c_str(),"@:/")!=nullptr;
|
||||
if(isResURL){
|
||||
Rect outRect;
|
||||
Drawable*dr = mContext->getDrawable(scrollSelectorValue);
|
||||
Gravity::apply(textGravity,dr->getIntrinsicWidth(),dr->getIntrinsicHeight(),recText,outRect,getLayoutDirection());
|
||||
dr->setBounds(outRect);
|
||||
dr->draw(canvas);
|
||||
|
Loading…
Reference in New Issue
Block a user