mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-12-04 05:10:06 +08:00
rdelete samples/expandablelayout.cc samples/exapandablelistview.cc
This commit is contained in:
parent
52a139e06f
commit
2a2a9a2b5f
@ -1,97 +0,0 @@
|
||||
#include <cdroid.h>
|
||||
#include <widget/expandablelistview.h>
|
||||
using namespace cdroid;
|
||||
class MyBaseExpandableListAdapter:public BaseExpandableListAdapter {
|
||||
private:
|
||||
std::vector<std::string> gData;
|
||||
std::vector<std::vector<std::string>> iData;
|
||||
Context* mContext;
|
||||
public:
|
||||
MyBaseExpandableListAdapter(Context*ctx) {
|
||||
this->mContext = ctx;
|
||||
}
|
||||
void addGroupData(const std::string&gname,const std::vector<std::string>&data){
|
||||
gData.push_back(gname);
|
||||
iData.push_back(data);
|
||||
}
|
||||
int getGroupCount()override{
|
||||
LOGD("groupCount=%d",gData.size());
|
||||
return gData.size();
|
||||
}
|
||||
|
||||
int getChildrenCount(int groupPosition)override{
|
||||
int count = iData.at(groupPosition).size();
|
||||
LOGD("group %d has %d children",groupPosition,count);
|
||||
return count;
|
||||
}
|
||||
|
||||
void* getGroup(int groupPosition)override{
|
||||
return &gData.at(groupPosition);
|
||||
}
|
||||
|
||||
void* getChild(int groupPosition, int childPosition)override {
|
||||
return &iData.at(groupPosition).at(childPosition);
|
||||
}
|
||||
|
||||
long getGroupId(int groupPosition)override{
|
||||
return groupPosition;
|
||||
}
|
||||
|
||||
long getChildId(int groupPosition, int childPosition)override{
|
||||
return childPosition;
|
||||
}
|
||||
|
||||
bool hasStableIds()override{
|
||||
return false;
|
||||
}
|
||||
|
||||
//取得用于显示给定分组的视图. 这个方法仅返回分组的视图对象
|
||||
View* getGroupView(int groupPosition, bool isExpanded, View* convertView, ViewGroup* parent)override{
|
||||
TextView*tv = (TextView*)convertView;
|
||||
if(convertView == nullptr){
|
||||
convertView = tv = new TextView(0,0);
|
||||
}
|
||||
LOGD("groupPosition=%d",groupPosition);
|
||||
tv->setText(gData.at(groupPosition));
|
||||
tv->setBackgroundColor(0xFF112233);
|
||||
return convertView;
|
||||
}
|
||||
|
||||
//取得显示给定分组给定子位置的数据用的视图
|
||||
View* getChildView(int groupPosition, int childPosition, bool isLastChild, View* convertView, ViewGroup* parent)override{
|
||||
TextView*tv = (TextView*)convertView;
|
||||
if(convertView == nullptr){
|
||||
convertView = tv = new TextView(0,0);
|
||||
}
|
||||
LOGD("groupPosition=%d childPosition=%d",groupPosition,childPosition);
|
||||
tv->setText(iData.at(groupPosition).at(childPosition));
|
||||
return convertView;
|
||||
}
|
||||
|
||||
//设置子列表是否可选中
|
||||
bool isChildSelectable(int groupPosition, int childPosition)override{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc,const char*argv[]){
|
||||
App app(argc,argv);
|
||||
Window*w =new Window(0,0,-1,-1);
|
||||
ExpandableListView*expLV = new ExpandableListView(0,0);
|
||||
MyBaseExpandableListAdapter*adapter=new MyBaseExpandableListAdapter(&app);
|
||||
std::vector<std::string>data;
|
||||
for(int i=0;i<8;i++)data.push_back(std::string("subitem")+std::to_string(i));
|
||||
for(int j=0;j<30;j++)
|
||||
adapter->addGroupData(std::to_string(j),data);
|
||||
|
||||
expLV->setVerticalScrollBarEnabled(true);
|
||||
expLV->setOverScrollMode(View::OVER_SCROLL_ALWAYS);
|
||||
|
||||
expLV->setAdapter(adapter);
|
||||
w->addView(expLV);
|
||||
expLV->setOnChildClickListener([](ExpandableListView& parent, View& v, int groupPosition, int childPosition, long id){
|
||||
LOGD("groupPosition=%d childPosition=%d",groupPosition,childPosition);
|
||||
return true;
|
||||
});
|
||||
return app.exec();
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
#include <cdroid.h>
|
||||
#include <widget/expandablelayout.h>
|
||||
using namespace cdroid;
|
||||
|
||||
int main(int argc,const char*argv[]){
|
||||
App app(argc,argv);
|
||||
Window*w =new Window(0,0,-1,-1);
|
||||
LinearLayout*ll=new LinearLayout(-1,-1);
|
||||
ll->setOrientation(1);
|
||||
Button *btn=new Button("Expand",200,40);
|
||||
ll->addView(btn);
|
||||
ExpandableLayout* el= new ExpandableLayout(-1,-1);
|
||||
el->setBackgroundColor(0xFF112233);
|
||||
TextView*tv=new TextView("line1\nline2\nline3\nline4\nline5\nline6\nline7\nline8\nline9",-1,400);
|
||||
tv->setBackgroundColor(0xFF332211);
|
||||
tv->setSingleLine(false);
|
||||
el->addView(tv);
|
||||
ll->addView(el);
|
||||
ll->addView(new Button("Bottom",200,40));
|
||||
w->addView(ll);
|
||||
btn->setOnClickListener([&el](View&){
|
||||
if(el->isExpanded())el->collapse(true);
|
||||
else el->expand(true);
|
||||
});
|
||||
return app.exec();
|
||||
}
|
@ -259,8 +259,7 @@ int KeyDevice::putRawEvent(const struct timeval&tv,int type,int code,int value){
|
||||
mEvent.initialize(getId(),getSources(),(value?KeyEvent::ACTION_DOWN:KeyEvent::ACTION_UP)/*action*/,flags,
|
||||
keycode,code/*scancode*/,0/*metaState*/,mRepeatCount, mDownTime,SystemClock::uptimeMicros()/*eventtime*/);
|
||||
LOGV("fd[%d] keycode:%08x->%04x[%s] action=%d flags=%d",getId(),code,keycode, mEvent.getLabel(),value,flags);
|
||||
//if(listener)listener(mEvent);
|
||||
mEvents.push_back(KeyEvent::obtain(mEvent));
|
||||
mEvents.push_back(KeyEvent::obtain(mEvent));
|
||||
break;
|
||||
case EV_SYN:
|
||||
LOGV("fd[%d].SYN value=%d code=%d",getId(),value,code);
|
||||
@ -394,7 +393,7 @@ int TouchDevice::putRawEvent(const struct timeval&tv,int type,int code,int value
|
||||
mEvent.setActionButton(MotionEvent::BUTTON_PRIMARY);
|
||||
mEvent.setAction(value ? MotionEvent::ACTION_DOWN : MotionEvent::ACTION_UP);
|
||||
if(value){
|
||||
mMoveTime = mDownTime = tv.tv_sec * 1000LL + tv.tv_usec/1000;
|
||||
mMoveTime = mDownTime = tv.tv_sec * 1000 + tv.tv_usec/1000;
|
||||
mEvent.setButtonState(MotionEvent::BUTTON_PRIMARY);
|
||||
}else{
|
||||
mMoveTime = tv.tv_sec * 1000 + tv.tv_usec/1000;
|
||||
@ -441,8 +440,8 @@ int TouchDevice::putRawEvent(const struct timeval&tv,int type,int code,int value
|
||||
case SYN_REPORT:
|
||||
mMoveTime =(tv.tv_sec * 1000 + tv.tv_usec/1000);
|
||||
mEvent.initialize(getId(),getSources(),mEvent.getAction(),mEvent.getActionButton()
|
||||
, 0/*flags*/ , 0/*edgeFlags*/, 0/*metaState*/, mEvent.getButtonState() ,0,0/*x/yOffset*/
|
||||
, 0 ,0 /*x/yPrecision*/ , mDownTime , mMoveTime , 0 , nullptr , nullptr);
|
||||
, 0/*flags*/ , 0/*edgeFlags*/, 0/*metaState*/, mEvent.getButtonState() ,0,0/*x/yOffset*/
|
||||
, 0 ,0 /*x/yPrecision*/ , mDownTime , mMoveTime , 0 , nullptr , nullptr);
|
||||
for(auto p:mPointMAP){
|
||||
mEvent.addSample(mMoveTime,p.second.prop,p.second.coord);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user