mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-12-11 00:53:59 +08:00
add RecyclerView::SavedState
This commit is contained in:
parent
c57256f4f0
commit
5df3a226d7
@ -573,7 +573,7 @@ int TouchDevice::putRawEvent(const struct timeval&tv,int type,int code,int value
|
|||||||
slot = mTrack2Slot.indexOfKey(mProp.id);
|
slot = mTrack2Slot.indexOfKey(mProp.id);
|
||||||
#else
|
#else
|
||||||
slot = mProp.id;
|
slot = mProp.id;
|
||||||
if( (mProp.id==-1) && ((mDeviceClasses&INPUT_DEVICE_CLASS_TOUCH_MT)==0) )
|
if( (mProp.id==-1) && ((mCorrectedDeviceClasses&INPUT_DEVICE_CLASS_TOUCH_MT)==0) )
|
||||||
mProp.id = 0;
|
mProp.id = 0;
|
||||||
#endif
|
#endif
|
||||||
slot = slot>=0?slot:0;
|
slot = slot>=0?slot:0;
|
||||||
|
@ -576,19 +576,13 @@ void Layout::relayout(bool force){
|
|||||||
|
|
||||||
static const std::string processBidi(const std::wstring&logstr){
|
static const std::string processBidi(const std::wstring&logstr){
|
||||||
#ifdef ENABLE_FRIBIDI
|
#ifdef ENABLE_FRIBIDI
|
||||||
size_t wsize=logstr.length()+1;
|
const size_t wsize = logstr.length()+1;
|
||||||
FriBidiCharType base_dir=FRIBIDI_TYPE_ON;
|
FriBidiCharType base_dir = FRIBIDI_TYPE_ON;
|
||||||
FriBidiChar * visstr= new FriBidiChar[wsize] ;
|
FriBidiChar * visstr = new FriBidiChar[wsize] ;
|
||||||
FriBidiLevel* level = new FriBidiLevel[wsize];
|
|
||||||
FriBidiStrIndex *posLV= new FriBidiStrIndex[wsize];
|
|
||||||
FriBidiStrIndex *posVL= new FriBidiStrIndex[wsize];
|
|
||||||
|
|
||||||
fribidi_log2vis((const FriBidiChar*)logstr.c_str(),logstr.length(),&base_dir,visstr,posLV,posVL,level);
|
fribidi_log2vis((const FriBidiChar*)logstr.c_str(),logstr.length(),&base_dir,visstr,nullptr,nullptr,nullptr);
|
||||||
std::wstring biditxt((const wchar_t*)visstr,wsize-1);
|
std::wstring biditxt((const wchar_t*)visstr,wsize-1);
|
||||||
delete [] visstr;
|
delete [] visstr;
|
||||||
delete [] posLV;
|
|
||||||
delete [] posVL;
|
|
||||||
delete [] level;
|
|
||||||
return TextUtils::unicode2utf8(biditxt);
|
return TextUtils::unicode2utf8(biditxt);
|
||||||
#else
|
#else
|
||||||
return TextUtils::unicode2utf8(logstr);
|
return TextUtils::unicode2utf8(logstr);
|
||||||
@ -621,7 +615,7 @@ void Layout::drawText(Canvas&canvas,int firstLine,int lastLine){
|
|||||||
line.size(),lw,int(te.x_advance));
|
line.size(),lw,int(te.x_advance));
|
||||||
canvas.move_to(x,y);
|
canvas.move_to(x,y);
|
||||||
canvas.show_text(processBidi(line));
|
canvas.show_text(processBidi(line));
|
||||||
if(mCaretPos>=lineStart&&mCaretPos<lineEnd){
|
if( (mCaretPos>=lineStart) && (mCaretPos<lineEnd) ){
|
||||||
measureSize(line.substr(0,mCaretPos-lineStart),te,nullptr);
|
measureSize(line.substr(0,mCaretPos-lineStart),te,nullptr);
|
||||||
mCaretRect.left= x + te.x_advance;
|
mCaretRect.left= x + te.x_advance;
|
||||||
mCaretRect.top = lineNum * mLineHeight;
|
mCaretRect.top = lineNum * mLineHeight;
|
||||||
|
@ -17,6 +17,7 @@ LinearLayoutManager::LinearLayoutManager(Context* context,int orientation,bool r
|
|||||||
mStackFromEnd = false;
|
mStackFromEnd = false;
|
||||||
mShouldReverseLayout = false;
|
mShouldReverseLayout = false;
|
||||||
mRecycleChildrenOnDetach = true;
|
mRecycleChildrenOnDetach = true;
|
||||||
|
mInitialPrefetchItemCount = 2;
|
||||||
mAnchorInfo = new AnchorInfo();
|
mAnchorInfo = new AnchorInfo();
|
||||||
mLayoutChunkResult = new LayoutChunkResult();
|
mLayoutChunkResult = new LayoutChunkResult();
|
||||||
setOrientation(orientation);
|
setOrientation(orientation);
|
||||||
@ -98,6 +99,7 @@ Parcelable* LinearLayoutManager::onSaveInstanceState() {
|
|||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinearLayoutManager::onRestoreInstanceState(Parcelable& state) {
|
void LinearLayoutManager::onRestoreInstanceState(Parcelable& state) {
|
||||||
if (dynamic_cast<SavedState*>(&state)) {
|
if (dynamic_cast<SavedState*>(&state)) {
|
||||||
mPendingSavedState = (SavedState*)&state;
|
mPendingSavedState = (SavedState*)&state;
|
||||||
|
@ -26,8 +26,8 @@ private:
|
|||||||
bool mStackFromEnd = false;
|
bool mStackFromEnd = false;
|
||||||
bool mSmoothScrollbarEnabled = true;
|
bool mSmoothScrollbarEnabled = true;
|
||||||
bool mRecycleChildrenOnDetach;
|
bool mRecycleChildrenOnDetach;
|
||||||
LayoutChunkResult* mLayoutChunkResult;// = new LayoutChunkResult();
|
LayoutChunkResult* mLayoutChunkResult;;
|
||||||
int mInitialPrefetchItemCount = 2;
|
int mInitialPrefetchItemCount;
|
||||||
int mReusableIntPair[2];
|
int mReusableIntPair[2];
|
||||||
private:
|
private:
|
||||||
void resolveShouldLayoutReverse();
|
void resolveShouldLayoutReverse();
|
||||||
|
@ -124,6 +124,7 @@ RecyclerView::~RecyclerView(){
|
|||||||
delete mBottomGlow;
|
delete mBottomGlow;
|
||||||
delete mEdgeEffectFactory;
|
delete mEdgeEffectFactory;
|
||||||
delete mScrollingChildHelper;
|
delete mScrollingChildHelper;
|
||||||
|
delete mPendingSavedState;
|
||||||
delete (ViewInfoStore::ProcessCallback*)mViewInfoProcessCallback;
|
delete (ViewInfoStore::ProcessCallback*)mViewInfoProcessCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,6 +146,7 @@ void RecyclerView::initRecyclerView(){
|
|||||||
mViewFlinger = new ViewFlinger(this);
|
mViewFlinger = new ViewFlinger(this);
|
||||||
mItemAnimator= nullptr;
|
mItemAnimator= nullptr;
|
||||||
mRecycler = new Recycler(this);
|
mRecycler = new Recycler(this);
|
||||||
|
mPendingSavedState = nullptr;
|
||||||
mObserver = new RecyclerViewDataObserver(this);
|
mObserver = new RecyclerViewDataObserver(this);
|
||||||
mLeftGlow = mTopGlow = nullptr;
|
mLeftGlow = mTopGlow = nullptr;
|
||||||
mRightGlow = mBottomGlow = nullptr;
|
mRightGlow = mBottomGlow = nullptr;
|
||||||
@ -616,34 +618,28 @@ RecyclerView::OnFlingListener RecyclerView::getOnFlingListener() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Parcelable* RecyclerView::onSaveInstanceState() {
|
Parcelable* RecyclerView::onSaveInstanceState() {
|
||||||
#if 0
|
SavedState* state = new SavedState(ViewGroup::onSaveInstanceState());
|
||||||
SavedState* state = new SavedState(super.onSaveInstanceState());;
|
|
||||||
if (mPendingSavedState != nullptr) {
|
if (mPendingSavedState != nullptr) {
|
||||||
state->copyFrom(mPendingSavedState);
|
state->copyFrom(*mPendingSavedState);
|
||||||
} else if (mLayout != nullptr) {
|
} else if (mLayout != nullptr) {
|
||||||
state->mLayoutState = mLayout->onSaveInstanceState();
|
state->mLayoutState = mLayout->onSaveInstanceState();
|
||||||
} else {
|
} else {
|
||||||
state->mLayoutState = nullptr;
|
state->mLayoutState = nullptr;
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
#else
|
|
||||||
return nullptr;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecyclerView::onRestoreInstanceState(Parcelable& state) {
|
void RecyclerView::onRestoreInstanceState(Parcelable& state) {
|
||||||
#if 0
|
if (dynamic_cast<SavedState*>(&state)==nullptr) {
|
||||||
if (!(dynamic_cast<SavedState*>(&state)) {
|
|
||||||
ViewGroup::onRestoreInstanceState(state);
|
ViewGroup::onRestoreInstanceState(state);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mPendingSavedState = (SavedState*)& state;
|
mPendingSavedState = (SavedState*)& state;
|
||||||
ViewGroup::onRestoreInstanceState(mPendingSavedState.getSuperState());
|
ViewGroup::onRestoreInstanceState(*mPendingSavedState->getSuperState());
|
||||||
if (mLayout != null && mPendingSavedState.mLayoutState != null) {
|
if (mLayout != nullptr && mPendingSavedState->mLayoutState != nullptr) {
|
||||||
mLayout->onRestoreInstanceState(mPendingSavedState.mLayoutState);
|
mLayout->onRestoreInstanceState(*mPendingSavedState->mLayoutState);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecyclerView::dispatchSaveInstanceState(SparseArray<Parcelable*>& container) {
|
void RecyclerView::dispatchSaveInstanceState(SparseArray<Parcelable*>& container) {
|
||||||
@ -6801,47 +6797,25 @@ void RecyclerView::SmoothScroller::Action::update(int dx,int dy,int duration,Int
|
|||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
#if 0
|
/** called by CREATOR */
|
||||||
public static class SavedState extends AbsSavedState {
|
RecyclerView::SavedState::SavedState(Parcel& in):AbsSavedState(in){
|
||||||
|
//super(in, loader);
|
||||||
|
//mLayoutState = in.readParcelable(loader != null ? loader : LayoutManager.class.getClassLoader());
|
||||||
|
}
|
||||||
|
|
||||||
Parcelable mLayoutState;
|
/**Called by onSaveInstanceState */
|
||||||
|
RecyclerView::SavedState::SavedState(Parcelable* superState):AbsSavedState(superState){
|
||||||
|
}
|
||||||
|
|
||||||
/** called by CREATOR */
|
void RecyclerView::SavedState::writeToParcel(Parcel& dest, int flags) {
|
||||||
SavedState(Parcel in, ClassLoader loader) {
|
AbsSavedState::writeToParcel(dest, flags);
|
||||||
super(in, loader);
|
//dest.writeParcelable(mLayoutState, 0);
|
||||||
mLayoutState = in.readParcelable(
|
}
|
||||||
loader != null ? loader : LayoutManager.class.getClassLoader());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**Called by onSaveInstanceState */
|
void RecyclerView::SavedState::copyFrom(SavedState& other) {
|
||||||
SavedState(Parcelable superState) {
|
|
||||||
super(superState);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
|
||||||
super.writeToParcel(dest, flags);
|
|
||||||
dest.writeParcelable(mLayoutState, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void copyFrom(SavedState other) {
|
|
||||||
mLayoutState = other.mLayoutState;
|
mLayoutState = other.mLayoutState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<SavedState> CREATOR = new ClassLoaderCreator<SavedState>() {
|
|
||||||
public SavedState createFromParcel(Parcel in, ClassLoader loader) {
|
|
||||||
return new SavedState(in, loader);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SavedState createFromParcel(Parcel in) {
|
|
||||||
return new SavedState(in, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SavedState[] newArray(int size) {
|
|
||||||
return new SavedState[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool RecyclerView::AdapterDataObservable::hasObservers() const{
|
bool RecyclerView::AdapterDataObservable::hasObservers() const{
|
||||||
return !mObservers.empty();
|
return !mObservers.empty();
|
||||||
|
@ -25,6 +25,7 @@ public:
|
|||||||
class ViewHolder;
|
class ViewHolder;
|
||||||
class Recycler;
|
class Recycler;
|
||||||
class State;
|
class State;
|
||||||
|
class SavedState;
|
||||||
class LayoutManager;
|
class LayoutManager;
|
||||||
class AdapterDataObservable;
|
class AdapterDataObservable;
|
||||||
class RecycledViewPool;
|
class RecycledViewPool;
|
||||||
@ -448,6 +449,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
RecyclerViewDataObserver* mObserver;
|
RecyclerViewDataObserver* mObserver;
|
||||||
Recycler* mRecycler;
|
Recycler* mRecycler;
|
||||||
|
SavedState* mPendingSavedState;
|
||||||
AdapterHelper* mAdapterHelper;
|
AdapterHelper* mAdapterHelper;
|
||||||
ChildHelper* mChildHelper;
|
ChildHelper* mChildHelper;
|
||||||
ViewInfoStore* mViewInfoStore;
|
ViewInfoStore* mViewInfoStore;
|
||||||
@ -811,6 +813,7 @@ public:
|
|||||||
int getViewLayoutPosition();
|
int getViewLayoutPosition();
|
||||||
int getViewAdapterPosition();
|
int getViewAdapterPosition();
|
||||||
};
|
};
|
||||||
|
|
||||||
class RecyclerView::EdgeEffectFactory {
|
class RecyclerView::EdgeEffectFactory {
|
||||||
public:
|
public:
|
||||||
friend RecyclerView;
|
friend RecyclerView;
|
||||||
@ -1088,6 +1091,18 @@ public:
|
|||||||
void notifyItemRangeRemoved(int positionStart, int itemCount);
|
void notifyItemRangeRemoved(int positionStart, int itemCount);
|
||||||
void notifyItemMoved(int fromPosition, int toPosition);
|
void notifyItemMoved(int fromPosition, int toPosition);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class RecyclerView::SavedState:public AbsSavedState{
|
||||||
|
protected:
|
||||||
|
Parcelable*mLayoutState;
|
||||||
|
friend RecyclerView;
|
||||||
|
public:
|
||||||
|
SavedState(Parcel&in);
|
||||||
|
SavedState(Parcelable*superState);
|
||||||
|
void writeToParcel(Parcel&dest,int flags)override;
|
||||||
|
void copyFrom(SavedState&other);
|
||||||
|
};
|
||||||
|
|
||||||
class RecyclerView::State{
|
class RecyclerView::State{
|
||||||
protected:
|
protected:
|
||||||
friend RecyclerView;
|
friend RecyclerView;
|
||||||
|
Loading…
Reference in New Issue
Block a user