fix some prototypes of recyclerview.adapter

This commit is contained in:
侯歌 2024-05-05 15:55:29 +08:00
parent e8ccf6b9ed
commit 43db51fb58
3 changed files with 23 additions and 25 deletions

View File

@ -403,7 +403,7 @@ void TouchDevice::setAxisValue(int raw_axis,int value,bool isRelative){
switch(raw_axis){
case ABS_X ... ABS_Z :
mSlotID = 0 ; mTrackID = 0;
mProp.id = 0;
mProp.id = 0;
mDeviceClasses &= ~INPUT_DEVICE_CLASS_TOUCH_MT;
break;
case ABS_MT_POSITION_X...ABS_MT_POSITION_Y:
@ -527,7 +527,7 @@ int TouchDevice::putRawEvent(const struct timeval&tv,int type,int code,int value
pointerCount =(mDeviceClasses&INPUT_DEVICE_CLASS_TOUCH_MT)?std::max(mLastBits.count(),mCurrBits.count()):1;
if(lastEvent&&(lastEvent->getActionMasked()==MotionEvent::ACTION_MOVE)&&(mMoveTime-lastEvent->getEventTime()<5000)){
lastEvent->addSample(mMoveTime,mPointerCoords.data());
LOGD("%s",printEvent(mEvent).c_str());
LOGV("%s",printEvent(lastEvent).c_str());
goto CLEAR_END;
}else {
const bool useBackupProps = ((action==MotionEvent::ACTION_UP)||(action==MotionEvent::ACTION_POINTER_UP))&&(mDeviceClasses&INPUT_DEVICE_CLASS_TOUCH_MT);
@ -535,14 +535,14 @@ int TouchDevice::putRawEvent(const struct timeval&tv,int type,int code,int value
const PointerProperties*props= useBackupProps ? mPointerPropsBak.data() : mPointerProps.data();
mEvent = MotionEvent::obtain(mMoveTime , mMoveTime , action , pointerCount,props,coords, 0/*metaState*/,mButtonState,
0,0/*x/yPrecision*/,getId()/*deviceId*/, 0/*edgeFlags*/, getSources(), 0/*flags*/);
LOGD_IF(action!=MotionEvent::ACTION_MOVE,"mask=%08x,%08x\n%s",mLastBits.value,mCurrBits.value,printEvent(mEvent).c_str());
LOGV_IF(action!=MotionEvent::ACTION_MOVE,"mask=%08x,%08x\n%s",mLastBits.value,mCurrBits.value,printEvent(mEvent).c_str());
mEvent->setActionButton(mActionButton);
mEvent->setAction(action|(pointerIndex<<MotionEvent::ACTION_POINTER_INDEX_SHIFT));
}
if( mLastBits.count() > mCurrBits.count() ){
const uint32_t pointerIndex = BitSet32::firstMarkedBit(mLastBits.value^mCurrBits.value);
LOGD("clearbits %d %08x,%08x trackslot.size=%d",pointerIndex,mLastBits.value,mCurrBits.value, mTrack2Slot.size());
LOGV("clearbits %d %08x,%08x trackslot.size=%d",pointerIndex,mLastBits.value,mCurrBits.value, mTrack2Slot.size());
if(mDeviceClasses&INPUT_DEVICE_CLASS_TOUCH_MT) mCurrBits.clearBit(pointerIndex);
if( pointerIndex<mTrack2Slot.size())
mTrack2Slot.removeAt(pointerIndex);

View File

@ -248,20 +248,31 @@ public:
nsecs_t getHistoricalEventTime(size_t historicalIndex) const;
nsecs_t getHistoricalEventTimeNanos(size_t historicalIndex) const;
void getPointerCoords(int pointerIndex, PointerCoords& outPointerCoords){
getHistoricalRawPointerCoords(pointerIndex,HISTORY_CURRENT,outPointerCoords);
}
/*Raw AXIS Properties*/
////////////////////////////////// Raw AXIS Properties ///////////////////////////////////
const PointerCoords& getRawPointerCoords(size_t pointerIndex) const;
void getHistoricalRawPointerCoords(size_t pointerIndex, size_t historicalIndex,PointerCoords& outPointerCoords) const;
float getHistoricalRawAxisValue(int32_t axis, size_t pointerIndex,size_t historicalIndex) const;
float getHistoricalRawX(size_t pointerIndex, size_t historicalIndex) const;
float getHistoricalRawY(size_t pointerIndex, size_t historicalIndex) const;
float getRawAxisValue(int32_t axis, size_t pointerIndex) const;
inline float getRawX(size_t pointerIndex) const { return getRawAxisValue(AXIS_X, pointerIndex); }
inline float getRawY(size_t pointerIndex) const { return getRawAxisValue(AXIS_Y, pointerIndex); }
/*AXIS Properties has been transformed*/
/////////////////////// AXIS Properties has been transformed //////////////////////////////
void getPointerCoords(int pointerIndex, PointerCoords& outPointerCoords)const{
getHistoricalRawPointerCoords(pointerIndex,HISTORY_CURRENT,outPointerCoords);
}
void getHistoricalPointerCoords(size_t pointerIndex, size_t historicalIndex,PointerCoords& outPointerCoords) const;
float getHistoricalAxisValue(int axis, size_t pointerIndex,size_t historicalIndex) const;
float getHistoricalX(size_t pointerIndex, size_t historicalIndex) const;
float getHistoricalY(size_t pointerIndex, size_t historicalIndex) const;
float getAxisValue(int32_t axis)const;
float getAxisValue(int32_t axis, size_t pointerIndex)const;
float getX(size_t pointerIndex=0) const { return getAxisValue(AXIS_X,pointerIndex); }
float getY(size_t pointerIndex=0) const { return getAxisValue(AXIS_Y,pointerIndex); }
//////////////////////////////////////////////////////////////////////////////////////////
inline const PointerProperties& getPointerProperties(size_t pointerIndex) const {
return mPointerProperties[pointerIndex];
}
@ -283,19 +294,6 @@ public:
return mPointerProperties[pointerIndex].toolType;
}
inline nsecs_t getEventTime() const override{ return mSampleEventTimes[getHistorySize()]; }
const PointerCoords& getRawPointerCoords(size_t pointerIndex) const;
float getRawAxisValue(int32_t axis, size_t pointerIndex) const;
inline float getRawX(size_t pointerIndex) const {
return getRawAxisValue(AXIS_X, pointerIndex);
}
inline float getRawY(size_t pointerIndex) const {
return getRawAxisValue(AXIS_Y, pointerIndex);
}
float getAxisValue(int32_t axis)const;
float getAxisValue(int32_t axis, size_t pointerIndex)const;
float getX(size_t pointer=0)const{return getAxisValue(AXIS_X,pointer);}
float getY(size_t pointer=0)const{return getAxisValue(AXIS_Y,pointer);}
inline float getPressure(size_t pointerIndex) const {
return getAxisValue(AXIS_PRESSURE, pointerIndex);
}

View File

@ -209,11 +209,11 @@ public:/*public classes*/
virtual bool onFailedToRecycleView(ViewHolder& holder);
virtual void onViewAttachedToWindow(ViewHolder& holder);
virtual void onViewDetachedFromWindow(ViewHolder& holder);
virtual bool hasObservers()const final;
bool hasObservers()const final;
void registerAdapterDataObserver(AdapterDataObserver* observer);
void unregisterAdapterDataObserver(AdapterDataObserver* observer);
void onAttachedToRecyclerView(RecyclerView& recyclerView);
void onDetachedFromRecyclerView(RecyclerView& recyclerView);
virtual void onAttachedToRecyclerView(RecyclerView& recyclerView);
virtual void onDetachedFromRecyclerView(RecyclerView& recyclerView);
virtual void notifyDataSetChanged()final;
virtual void notifyItemChanged(int position)final;
virtual void notifyItemChanged(int position,Object* payload)final;