mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-12-05 13:48:02 +08:00
code style (format)
This commit is contained in:
parent
5339af05cb
commit
90f151e745
@ -90,8 +90,7 @@ void Assets::parseItem(const std::string&package,const std::vector<std::string>&
|
||||
const std::string name=atts[0].getString("name");
|
||||
uint32_t color = Color::parseColor(value);
|
||||
LOGV("%s:color/%s:%s",package.c_str(),name.c_str(),value.c_str());
|
||||
mColors.insert(std::pair<const std::string,uint32_t>
|
||||
(package+":color/"+name,color));
|
||||
mColors.insert(std::pair<const std::string,uint32_t>(package+":color/"+name,color));
|
||||
} else if(tag0.compare("string")==0) {
|
||||
const std::string name= atts[0].getString("name");
|
||||
const std::string key = package+":string/"+name;
|
||||
@ -368,20 +367,20 @@ Drawable* Assets::getDrawable(const std::string&fullresid) {
|
||||
if(resname[0]=='#'||resname[1]=='x'|| resname[1]=='X'){
|
||||
LOGV("color %s",fullresid.c_str());
|
||||
d = new ColorDrawable(Color::parseColor(resname));
|
||||
mDrawables.insert(std::pair<std::string,std::weak_ptr<Drawable::ConstantState>>(fullresid,d->getConstantState()));
|
||||
return d;
|
||||
mDrawables.insert(std::pair<std::string,std::weak_ptr<Drawable::ConstantState>>(fullresid,d->getConstantState()));
|
||||
return d;
|
||||
}
|
||||
if(resname.find("color/")!=std::string::npos){
|
||||
auto itc = mColors.find(fullresid);
|
||||
auto its = mStateColors.find(fullresid);
|
||||
if(itc!=mColors.end()){
|
||||
const uint32_t cc = (uint32_t)getColor(fullresid);
|
||||
LOGE("%s use colors as drawable",fullresid.c_str());
|
||||
LOGV("%s use colors as drawable",fullresid.c_str());
|
||||
d = new ColorDrawable(cc);
|
||||
mDrawables.insert(std::pair<std::string,std::weak_ptr<Drawable::ConstantState>>(fullresid,d->getConstantState()));
|
||||
return d;
|
||||
return d;
|
||||
} else if(its!=mStateColors.end()){
|
||||
LOGE("%s use colorstatelist as drawable",fullresid.c_str());
|
||||
LOGV("%s use colorstatelist as drawable",fullresid.c_str());
|
||||
d = new StateListDrawable(*its->second);
|
||||
mDrawables.insert(std::pair<std::string,std::weak_ptr<Drawable::ConstantState>>(fullresid,d->getConstantState()));
|
||||
return d;
|
||||
@ -450,27 +449,27 @@ ColorStateList* Assets::getColorStateList(const std::string&fullresid) {
|
||||
if( its!=mStateColors.end())
|
||||
return its->second;
|
||||
else if(itc != mColors.end()){
|
||||
ColorStateList* cls = ColorStateList::valueOf(itc->second);
|
||||
mStateColors.insert(std::pair<const std::string,ColorStateList*>(fullresid,cls));
|
||||
return cls;
|
||||
ColorStateList* cls = ColorStateList::valueOf(itc->second);
|
||||
mStateColors.insert(std::pair<const std::string,ColorStateList*>(fullresid,cls));
|
||||
return cls;
|
||||
}else if( (itc == mColors.end()) && (name.empty()==false) ) {
|
||||
size_t slashpos = fullresid.find("/");
|
||||
if( (fullresid[0]=='#') || (slashpos==std::string::npos) ) {/*digital colors*/
|
||||
const int color = Color::parseColor(fullresid);
|
||||
ColorStateList* cls = ColorStateList::valueOf(color);
|
||||
mStateColors.insert(std::pair<const std::string,ColorStateList*>(fullresid,cls));
|
||||
return cls;
|
||||
mStateColors.insert(std::pair<const std::string,ColorStateList*>(fullresid,cls));
|
||||
return cls;
|
||||
}
|
||||
if( slashpos==std::string::npos ) {/*for color wolrds*/
|
||||
std::string realName;
|
||||
parseResource(fullresid,&realName,nullptr);
|
||||
realName = mTheme.getString(realName);
|
||||
itc = mColors.find(realName);
|
||||
if(itc != mColors.end()){
|
||||
if(itc != mColors.end()){
|
||||
ColorStateList* cls = ColorStateList::valueOf(itc->second);
|
||||
mStateColors.insert(std::pair<const std::string,ColorStateList*>(fullresid,cls));
|
||||
return cls;
|
||||
}
|
||||
mStateColors.insert(std::pair<const std::string,ColorStateList*>(fullresid,cls));
|
||||
return cls;
|
||||
}
|
||||
}
|
||||
} else if(fullresid.find("attr")!=std::string::npos) {
|
||||
size_t slashpos=fullresid.find("/");
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <map>
|
||||
#include <cdtypes.h>
|
||||
#include <cdlog.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace cdroid{
|
||||
|
||||
@ -30,9 +29,6 @@ ColorStateList::ColorStateList(const std::vector<std::vector<int>>&states,const
|
||||
onColorsChanged();
|
||||
}
|
||||
|
||||
ColorStateList::~ColorStateList(){
|
||||
}
|
||||
|
||||
void ColorStateList::dump()const{
|
||||
std::ostringstream oss;
|
||||
for(int i=0;i<mColors.size();i++){
|
||||
@ -177,7 +173,7 @@ static void startElement(void *userData, const XML_Char *name, const XML_Char **
|
||||
std::vector<int>states;
|
||||
int color = cd->ctx->getColor(atts.getString("color"));
|
||||
StateSet::parseState(states,atts);
|
||||
if(cd->colors==nullptr)
|
||||
if(cd->colors==nullptr)
|
||||
cd->colors = new ColorStateList();
|
||||
cd->colors->addStateColor(states,color);
|
||||
}
|
||||
|
@ -26,10 +26,8 @@ public:
|
||||
ColorStateList();
|
||||
ColorStateList(const ColorStateList&other);
|
||||
ColorStateList(const std::vector<std::vector<int>>&states,const std::vector<int>&colors);
|
||||
~ColorStateList();
|
||||
int addStateColor(const std::vector<int>&stateSet,int color);
|
||||
int getDefaultColor()const override;
|
||||
const std::vector<std::vector<int>>& getStates()const;
|
||||
bool isOpaque()const;
|
||||
bool isStateful()const override;
|
||||
bool hasFocusStateSpecified()const;
|
||||
@ -39,7 +37,7 @@ public:
|
||||
bool operator==(const ColorStateList&other)const;
|
||||
int getChangingConfigurations()const;
|
||||
int getColorForState(const std::vector<int>&stateSet, int defaultColor)const;
|
||||
|
||||
const std::vector<std::vector<int>>& getStates()const;
|
||||
const std::vector<int>& getColors()const;
|
||||
bool hasState(int state)const ;
|
||||
void dump()const;
|
||||
|
@ -49,7 +49,7 @@ StateListDrawable::StateListDrawable(const ColorStateList&cls){
|
||||
const std::vector<int>&colors = cls.getColors();
|
||||
const std::vector<std::vector<int>>& states = cls.getStates();
|
||||
for(int i=0;i<states.size();i++){
|
||||
addState(states[i],new ColorDrawable(colors[i]));
|
||||
addState(states[i],new ColorDrawable(colors[i]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ public:
|
||||
};
|
||||
|
||||
bool View::DEBUG_DRAW = false;
|
||||
|
||||
static int mViewCount=0;
|
||||
View::View(int w,int h){
|
||||
initView();
|
||||
mContext=&App::getInstance();
|
||||
@ -440,6 +440,8 @@ View::View(Context*ctx,const AttributeSet&attrs){
|
||||
}
|
||||
|
||||
void View::initView(){
|
||||
mViewCount ++;
|
||||
LOGD("mViewCount=%d",mViewCount);
|
||||
mID = NO_ID;
|
||||
mAutofillViewId =NO_ID;
|
||||
mAccessibilityViewId = NO_ID;
|
||||
@ -516,6 +518,8 @@ void View::initView(){
|
||||
}
|
||||
|
||||
View::~View(){
|
||||
mViewCount --;
|
||||
LOGD("mViewCount=%d",mViewCount);
|
||||
if(mParent)
|
||||
mParent->removeViewInternal(this);
|
||||
if(isAttachedToWindow())onDetachedFromWindow();
|
||||
|
@ -376,7 +376,6 @@ View* RecycleBin::retrieveFromScrap(std::vector<View*>& scrapViews, int position
|
||||
|
||||
void RecycleBin::clearScrap(std::vector<View*>& scrap) {
|
||||
const int scrapCount = scrap.size();
|
||||
LOGD_IF(scrapCount,"%p:%d remove %d View",LV,LV->getId(),scrapCount);
|
||||
for (int j = 0; j < scrapCount; j++) {
|
||||
View*v=scrap[scrapCount - 1 - j];
|
||||
scrap.erase(scrap.begin()+scrapCount - 1 - j);
|
||||
|
Loading…
Reference in New Issue
Block a user