mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-12-02 12:17:46 +08:00
fix drawable's loading issue (some crash will occured without resources),fix graph_rfb's includes
This commit is contained in:
parent
c9a3987edd
commit
a3b6465f11
@ -79,7 +79,7 @@ void AbsListView::FLY_endFling() {
|
||||
|
||||
if (!mSuppressIdleStateChangeCall) reportScrollStateChange(OnScrollListener::SCROLL_STATE_IDLE);
|
||||
|
||||
//clearScrollingCache();
|
||||
clearScrollingCache();
|
||||
mScroller->abortAnimation();
|
||||
|
||||
/*if (mFlingStrictSpan != nullptr) {
|
||||
@ -236,7 +236,7 @@ void AbsListView::initAbsListView() {
|
||||
setFocusableInTouchMode(true);
|
||||
setWillNotDraw(false);
|
||||
//setAlwaysDrawnWithCacheEnabled(false);
|
||||
//setScrollingCacheEnabled(true);
|
||||
setScrollingCacheEnabled(true);
|
||||
mListPadding.set(0,0,0,0);
|
||||
mVelocityTracker = nullptr;
|
||||
mPositionScroller= nullptr;
|
||||
@ -362,6 +362,17 @@ void AbsListView::setOnScrollListener(OnScrollListener l) {
|
||||
invokeOnItemScrollListener();
|
||||
}
|
||||
|
||||
bool AbsListView::isScrollingCacheEnabled()const{
|
||||
return mScrollingCacheEnabled;
|
||||
}
|
||||
|
||||
void AbsListView::setScrollingCacheEnabled(bool enabled){
|
||||
if (mScrollingCacheEnabled && !enabled) {
|
||||
clearScrollingCache();
|
||||
}
|
||||
mScrollingCacheEnabled = enabled;
|
||||
}
|
||||
|
||||
int AbsListView::getListPaddingTop()const {
|
||||
return mListPadding.y;
|
||||
}
|
||||
@ -1062,7 +1073,7 @@ bool AbsListView::resurrectSelection() {
|
||||
if (mPositionScroller) mPositionScroller->stop();
|
||||
|
||||
mTouchMode = TOUCH_MODE_REST;
|
||||
//clearScrollingCache();
|
||||
clearScrollingCache();
|
||||
mSpecificTop = selectedTop;
|
||||
selectedPos = lookForSelectablePosition(selectedPos, down);
|
||||
if (selectedPos >= firstPosition && selectedPos <= getLastVisiblePosition()) {
|
||||
@ -1602,9 +1613,9 @@ bool AbsListView::trackMotionScroll(int deltaY, int incrementalDeltaY) {
|
||||
}
|
||||
|
||||
bool cannotScrollDown = (firstPosition == 0 &&
|
||||
firstTop >= listPadding.y && incrementalDeltaY >= 0);
|
||||
firstTop >= listPadding.y && incrementalDeltaY >= 0);
|
||||
bool cannotScrollUp = (firstPosition + childCount == mItemCount &&
|
||||
lastBottom <= getHeight() - listPadding.height && incrementalDeltaY <= 0);
|
||||
lastBottom <= getHeight() - listPadding.height && incrementalDeltaY <= 0);
|
||||
if (cannotScrollDown || cannotScrollUp) {
|
||||
return incrementalDeltaY != 0;
|
||||
}
|
||||
@ -1828,9 +1839,8 @@ bool AbsListView::onKeyDown(int keyCode, KeyEvent& event) {
|
||||
|
||||
bool AbsListView::onKeyUp(int keyCode, KeyEvent& event) {
|
||||
if (KeyEvent::isConfirmKey(keyCode)) {
|
||||
if (!isEnabled()) {
|
||||
return true;
|
||||
}LOGD("isClickable=%d pressed=%d mSelectedPosition=%d",isClickable(),isPressed(),mSelectedPosition);
|
||||
LOGD("isClickable=%d pressed=%d mSelectedPosition=%d",isClickable(),isPressed(),mSelectedPosition);
|
||||
if (!isEnabled()) return true;
|
||||
if (isClickable() && isPressed() && (mSelectedPosition >= 0)
|
||||
&& mAdapter && (mSelectedPosition < mAdapter->getCount()) ) {
|
||||
View* view = getChildAt(mSelectedPosition - mFirstPosition);
|
||||
@ -1917,7 +1927,7 @@ bool AbsListView::onInterceptTouchEvent(MotionEvent& ev) {
|
||||
mMotionY = y;
|
||||
mMotionPosition = motionPosition;
|
||||
mTouchMode = TOUCH_MODE_DOWN;
|
||||
//clearScrollingCache();
|
||||
clearScrollingCache();
|
||||
}
|
||||
mLastY = INT_MIN;
|
||||
initOrResetVelocityTracker();
|
||||
@ -2003,7 +2013,7 @@ void AbsListView::onTouchModeChanged(bool isInTouchMode){
|
||||
|
||||
if (mScrollY != 0) {
|
||||
mScrollY = 0;
|
||||
//invalidateParentCaches();
|
||||
invalidateParentCaches();
|
||||
finishGlows();
|
||||
invalidate();
|
||||
}
|
||||
@ -2043,17 +2053,13 @@ bool AbsListView::onTouchEvent(MotionEvent& ev) {
|
||||
vtev->offsetLocation(0, mNestedYOffset);
|
||||
switch (actionMasked) {
|
||||
case MotionEvent::ACTION_DOWN:
|
||||
onTouchDown(ev);
|
||||
break;
|
||||
onTouchDown(ev); break;
|
||||
case MotionEvent::ACTION_MOVE:
|
||||
onTouchMove(ev, *vtev);
|
||||
break;
|
||||
onTouchMove(ev, *vtev); break;
|
||||
case MotionEvent::ACTION_UP:
|
||||
onTouchUp(ev);
|
||||
break;
|
||||
onTouchUp(ev); break;
|
||||
case MotionEvent::ACTION_CANCEL:
|
||||
onTouchCancel();
|
||||
break;
|
||||
onTouchCancel(); break;
|
||||
case MotionEvent::ACTION_POINTER_UP: {
|
||||
onSecondaryPointerUp(ev);
|
||||
int motionPosition = pointToPosition(mMotionX, mMotionY);
|
||||
@ -2141,7 +2147,7 @@ bool AbsListView::startScrollIfNeeded(int x, int y, MotionEvent* vtev) {
|
||||
bool overscroll = mScrollY != 0;
|
||||
if ((overscroll || distance > mTouchSlop) &&
|
||||
(getNestedScrollAxes() & SCROLL_AXIS_VERTICAL) == 0) {
|
||||
//createScrollingCache();
|
||||
createScrollingCache();
|
||||
if (overscroll) {
|
||||
mTouchMode = TOUCH_MODE_OVERSCROLL;
|
||||
mMotionCorrection = 0;
|
||||
@ -2328,7 +2334,7 @@ void AbsListView::scrollIfNeeded(int x, int y, MotionEvent* vtev) {
|
||||
// Coming back to 'real' list scrolling
|
||||
if (mScrollY != 0) {
|
||||
mScrollY = 0;
|
||||
//invalidateParentIfNeeded();
|
||||
invalidateParentIfNeeded();
|
||||
}
|
||||
|
||||
trackMotionScroll(incrementalDeltaY, incrementalDeltaY);
|
||||
@ -2403,7 +2409,7 @@ void AbsListView::onTouchDown(MotionEvent& ev) {
|
||||
if (!mDataChanged) {
|
||||
if (mTouchMode == TOUCH_MODE_FLING) {
|
||||
// Stopped a fling. It is a scroll.
|
||||
//createScrollingCache();
|
||||
createScrollingCache();
|
||||
mTouchMode = TOUCH_MODE_SCROLL;
|
||||
mMotionCorrection = 0;
|
||||
motionPosition = findMotionRow(y);
|
||||
@ -2663,7 +2669,7 @@ void AbsListView::onTouchCancel() {
|
||||
if (motionView != nullptr) {
|
||||
motionView->setPressed(false);
|
||||
}
|
||||
//clearScrollingCache();
|
||||
clearScrollingCache();
|
||||
removeCallbacks(mPendingCheckForLongPress);
|
||||
recycleVelocityTracker();
|
||||
}
|
||||
@ -2725,6 +2731,7 @@ void AbsListView::smoothScrollToPosition(int position, int boundPosition){
|
||||
void AbsListView::smoothScrollBy(int distance, int duration){
|
||||
smoothScrollBy(distance, duration, false, false);
|
||||
}
|
||||
|
||||
void AbsListView::smoothScrollBy(int distance, int duration, bool linear,bool suppressEndFlingStateChangeCall){
|
||||
// No sense starting to scroll if we're not going anywhere
|
||||
int firstPos = mFirstPosition;
|
||||
@ -2780,6 +2787,32 @@ void AbsListView::smoothScrollByOffset(int position){
|
||||
}*/
|
||||
}
|
||||
|
||||
void AbsListView::createScrollingCache(){
|
||||
if (mScrollingCacheEnabled && !mCachingStarted /*&& !isHardwareAccelerated()*/) {
|
||||
//setChildrenDrawnWithCacheEnabled(true);
|
||||
//setChildrenDrawingCacheEnabled(true);
|
||||
mCachingStarted = mCachingActive = true;
|
||||
}
|
||||
}
|
||||
|
||||
void AbsListView::clearScrollingCache(){
|
||||
if (mClearScrollingCache == nullptr) {
|
||||
mClearScrollingCache =[this]() {
|
||||
if (mCachingStarted) {
|
||||
mCachingStarted = mCachingActive = false;
|
||||
/*setChildrenDrawnWithCacheEnabled(false);
|
||||
if ((mPersistentDrawingCache & PERSISTENT_SCROLLING_CACHE) == 0) {
|
||||
setChildrenDrawingCacheEnabled(false);
|
||||
}*/
|
||||
if (true){//!isAlwaysDrawnWithCacheEnabled()) {
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
post(mClearScrollingCache);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
AbsListView::PositionScroller::PositionScroller(AbsListView*lv) {
|
||||
|
@ -140,6 +140,7 @@ private:
|
||||
bool mIsChildViewEnabled;
|
||||
bool mForceTranscriptScroll;
|
||||
Runnable mTouchModeReset;
|
||||
Runnable mClearScrollingCache;
|
||||
bool mHasPerformedLongPress;
|
||||
static const bool PROFILE_SCROLLING = false;
|
||||
bool mScrollProfilingStarted = false;
|
||||
@ -169,12 +170,15 @@ private:
|
||||
void invalidateTopGlow();
|
||||
void invalidateBottomGlow();
|
||||
void finishGlows();
|
||||
void createScrollingCache();
|
||||
void clearScrollingCache();
|
||||
protected:
|
||||
int mChoiceMode;
|
||||
int mCheckedItemCount;
|
||||
int mTouchSlop;
|
||||
int mSelectedTop;
|
||||
int mStackFromBottom;
|
||||
bool mScrollingCacheEnabled;
|
||||
int mSelectorPosition;
|
||||
int mResurrectToPosition;
|
||||
int mMinimumVelocity;
|
||||
@ -184,6 +188,8 @@ protected:
|
||||
int mOverflingDistance;
|
||||
View * mScrollUp ;
|
||||
View * mScrollDown;
|
||||
bool mCachingStarted;
|
||||
bool mCachingActive;
|
||||
EdgeEffect* mEdgeGlowTop;
|
||||
EdgeEffect* mEdgeGlowBottom;
|
||||
AbsPositionScroller* mPositionScroller;
|
||||
@ -291,6 +297,8 @@ public:
|
||||
void setChoiceMode(int choiceMode);
|
||||
void setMultiChoiceModeListener(MultiChoiceModeListener listener);
|
||||
void setOnScrollListener(OnScrollListener);
|
||||
bool isScrollingCacheEnabled()const;
|
||||
void setScrollingCacheEnabled(bool enabled);
|
||||
void clearChoices();
|
||||
void setDrawSelectorOnTop(bool onTop);
|
||||
Drawable*getSelector();
|
||||
|
@ -56,7 +56,7 @@ bool CompoundButton::performClick(){
|
||||
}
|
||||
|
||||
void CompoundButton::setButtonDrawable(const std::string&resid){
|
||||
Drawable* d= Drawable::inflate(getContext(),resid);
|
||||
Drawable* d= getContext()->getDrawable(resid);
|
||||
setButtonDrawable(d);
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,6 @@ bool EdgeEffect::draw(Canvas& canvas){
|
||||
|
||||
canvas.rectangle(mBounds);
|
||||
canvas.clip();
|
||||
//mPaint.setAlpha((int) (0xff * mGlowAlpha));
|
||||
canvas.set_color(mColor);
|
||||
canvas.curve_to(mBounds.x,mBounds.y,mBounds.width/2+translateX,mBounds.height*mGlowScaleY,mBounds.width,0);
|
||||
canvas.fill();
|
||||
|
@ -1316,6 +1316,7 @@ void ListView::drawOverscrollFooter(Canvas&canvas, Drawable* drawable,RECT& boun
|
||||
bool ListView::recycleOnMeasure() {
|
||||
return true;
|
||||
}
|
||||
|
||||
int ListView::measureHeightOfChildren(int widthMeasureSpec, int startPosition, int endPosition,
|
||||
int maxHeight, int disallowPartialChildPosition) {
|
||||
if (mAdapter == nullptr) {
|
||||
@ -1688,6 +1689,7 @@ ListView::ArrowScrollFocusResult* ListView::arrowScrollFocused(int direction){
|
||||
int ListView::getArrowScrollPreviewLength(){
|
||||
return std::max(MIN_SCROLL_PREVIEW_PIXELS, getVerticalFadingEdgeLength());
|
||||
}
|
||||
|
||||
int ListView::lookForSelectablePositionOnScreen(int direction){
|
||||
int firstPosition = mFirstPosition;
|
||||
if (direction == View::FOCUS_DOWN) {
|
||||
@ -1976,6 +1978,7 @@ int ListView::nextSelectedPositionForDirection(View* selectedView, int selectedP
|
||||
static int constrain(int amount, int low, int high) {//get the
|
||||
return amount < low ? low : (amount > high ? high : amount);
|
||||
}
|
||||
|
||||
int ListView::lookForSelectablePositionAfter(int current, int position, bool lookDown){
|
||||
Adapter* adapter = mAdapter;
|
||||
if (adapter == nullptr || isInTouchMode()) {
|
||||
@ -2007,6 +2010,13 @@ int ListView::lookForSelectablePositionAfter(int current, int position, bool loo
|
||||
return position;
|
||||
}
|
||||
|
||||
/**
|
||||
* To avoid horizontal focus searches changing the selected item, we
|
||||
* manually focus search within the selected item (as applicable), and
|
||||
* prevent focus from jumping to something within another item.
|
||||
* @param direction one of {View.FOCUS_LEFT, View.FOCUS_RIGHT}
|
||||
* @return Whether this consumes the key event.
|
||||
*/
|
||||
bool ListView::handleHorizontalFocusWithinListItem(int direction){
|
||||
if (direction != View::FOCUS_LEFT && direction != View::FOCUS_RIGHT) {
|
||||
LOGD("direction must be one of{View.FOCUS_LEFT, View.FOCUS_RIGHT}");
|
||||
|
@ -488,7 +488,7 @@ void ScrollView::onOverScrolled(int scrollX, int scrollY, bool clampedX, bool cl
|
||||
int oldY = mScrollY;
|
||||
mScrollX = scrollX;
|
||||
mScrollY = scrollY;
|
||||
//invalidateParentIfNeeded();
|
||||
invalidateParentIfNeeded();
|
||||
onScrollChanged(mScrollX, mScrollY, oldX, oldY);
|
||||
if (clampedY) {
|
||||
mScroller->springBack(mScrollX, mScrollY, 0, 0, 0, getScrollRange());
|
||||
|
@ -142,14 +142,14 @@ View::View(Context*ctx,const AttributeSet&attrs){
|
||||
setScrollBarSize(attrs.getDimensionPixelSize("scrollBarSize",10));
|
||||
|
||||
mScrollCache->scrollBar->setHorizontalThumbDrawable(
|
||||
Drawable::inflate(mContext,attrs.getString("scrollbarThumbHorizontal")));
|
||||
mContext->getDrawable(attrs.getString("scrollbarThumbHorizontal")));
|
||||
mScrollCache->scrollBar->setHorizontalTrackDrawable(
|
||||
Drawable::inflate(mContext,attrs.getString("scrollbarTrackHorizontal")));
|
||||
mContext->getDrawable(attrs.getString("scrollbarTrackHorizontal")));
|
||||
|
||||
mScrollCache->scrollBar->setVerticalThumbDrawable(
|
||||
Drawable::inflate(mContext,attrs.getString("scrollbarThumbVertical")));
|
||||
mContext->getDrawable(attrs.getString("scrollbarThumbVertical")));
|
||||
mScrollCache->scrollBar->setVerticalTrackDrawable(
|
||||
Drawable::inflate(mContext,attrs.getString("scrollbarTrackVertical")));
|
||||
mContext->getDrawable(attrs.getString("scrollbarTrackVertical")));
|
||||
}
|
||||
}
|
||||
|
||||
@ -339,7 +339,7 @@ void View::clearAnimation() {
|
||||
mCurrentAnimation->detach();
|
||||
}
|
||||
mCurrentAnimation = nullptr;
|
||||
//invalidateParentIfNeeded();
|
||||
invalidateParentIfNeeded();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@ -3062,6 +3062,10 @@ void View::invalidateParentCaches(){
|
||||
if(mParent)mParent->mPrivateFlags |= PFLAG_INVALIDATED;
|
||||
}
|
||||
|
||||
void View::invalidateParentIfNeeded(){
|
||||
if(mParent)mParent->invalidate(true);
|
||||
}
|
||||
|
||||
void View::invalidateInternal(int l, int t, int w, int h, bool invalidateCache,bool fullInvalidate){
|
||||
|
||||
if (skipInvalidate()) return;
|
||||
|
@ -344,6 +344,7 @@ protected:
|
||||
int getFadeHeight(bool offsetRequired);
|
||||
|
||||
void invalidateParentCaches();
|
||||
void invalidateParentIfNeeded();
|
||||
void destroyDrawingCache();
|
||||
RefPtr<ImageSurface>getDrawingCache(bool autoScale);
|
||||
|
||||
|
@ -771,7 +771,6 @@ void ViewGroup::removeView(View* view){
|
||||
}
|
||||
}
|
||||
View&ViewGroup::addView(View* child, int index,LayoutParams* params){
|
||||
//requestLayout();
|
||||
return addViewInner(child, index, params, false);
|
||||
}
|
||||
void ViewGroup::addInArray(View* child, int index){
|
||||
|
@ -164,7 +164,7 @@ int Window::processKeyEvent(KeyEvent&event){
|
||||
int handled = FINISH_NOT_HANDLED;
|
||||
int groupNavigationDirection = 0;
|
||||
const int action=event.getAction();
|
||||
LOGD_IF(action==KeyEvent::ACTION_DOWN,"key:0x%x %s %x",event.getKeyCode(),KeyEvent::getLabel(event.getKeyCode()),KEY_DPAD_DOWN);
|
||||
LOGV_IF(action==KeyEvent::ACTION_DOWN,"key:0x%x %s %x",event.getKeyCode(),KeyEvent::getLabel(event.getKeyCode()),KEY_DPAD_DOWN);
|
||||
if(dispatchKeyEvent(event))
|
||||
return FINISH_HANDLED;
|
||||
if (action == KeyEvent::ACTION_DOWN && event.getKeyCode() == KEY_TAB) {
|
||||
@ -317,25 +317,25 @@ void Window::requestLayout(){
|
||||
LOGV("requestLayout(%dx%d)child.count=%d HAS_BOUNDS=%x",getWidth(),getHeight(),
|
||||
getChildCount(),(mPrivateFlags&PFLAG_HAS_BOUNDS));
|
||||
for(auto c:mChildren){
|
||||
int x=0,y=0;
|
||||
int widthSpec,heightSpec;
|
||||
int x=0,y=0;
|
||||
int widthSpec,heightSpec;
|
||||
ViewGroup*vg=dynamic_cast<ViewGroup*>(c);
|
||||
if(vg==nullptr)continue;
|
||||
LayoutParams*lp=vg->getLayoutParams();
|
||||
LOGV("lp=%p layoutsize=%d,%d",lp,lp->width,lp->height);
|
||||
if(vg==nullptr)continue;
|
||||
LayoutParams*lp=vg->getLayoutParams();
|
||||
LOGV("lp=%p layoutsize=%d,%d",lp,lp->width,lp->height);
|
||||
|
||||
if(vg->getWidth()>0) widthSpec =MeasureSpec::makeMeasureSpec(vg->getWidth(),MeasureSpec::EXACTLY);
|
||||
else if(vg->getWidth()<0)widthSpec=MeasureSpec::makeMeasureSpec(lp->width,MeasureSpec::AT_MOST);
|
||||
else if(vg->getWidth()<0)widthSpec=MeasureSpec::makeMeasureSpec(lp->width,MeasureSpec::AT_MOST);
|
||||
else widthSpec=MeasureSpec::makeMeasureSpec(mWidth,MeasureSpec::EXACTLY);
|
||||
|
||||
|
||||
if(vg->getHeight()>0) heightSpec =MeasureSpec::makeMeasureSpec(vg->getHeight(),MeasureSpec::EXACTLY);
|
||||
else if(vg->getHeight()<0)heightSpec=MeasureSpec::makeMeasureSpec(lp->height,MeasureSpec::AT_MOST);
|
||||
else if(vg->getHeight()<0)heightSpec=MeasureSpec::makeMeasureSpec(lp->height,MeasureSpec::AT_MOST);
|
||||
else heightSpec=MeasureSpec::makeMeasureSpec(mHeight,MeasureSpec::EXACTLY);
|
||||
|
||||
if(vg->getHeight()>0&&vg->getWidth()>0){
|
||||
x=vg->getLeft();
|
||||
y=vg->getTop();
|
||||
}
|
||||
if(vg->getHeight()>0&&vg->getWidth()>0){
|
||||
x=vg->getLeft();
|
||||
y=vg->getTop();
|
||||
}
|
||||
vg->measure(widthSpec, heightSpec);
|
||||
vg->layout(x,y,vg->getMeasuredWidth(),vg->getMeasuredHeight());
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <cdtypes.h>
|
||||
#include <ngl_os.h>
|
||||
#include <ngl_graph.h>
|
||||
#include <cdgraph.h>
|
||||
#include <cdlog.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h> /* getenv(), etc. */
|
||||
@ -9,8 +9,7 @@
|
||||
#include <rfb/rfb.h>
|
||||
#include <rfb/keysym.h>
|
||||
#include <rfb/rfbproto.h>
|
||||
#include <ngl_input.h>
|
||||
NGL_MODULE(GRAPH);
|
||||
#include <cdinput.h>
|
||||
|
||||
typedef struct{
|
||||
unsigned int width;
|
||||
|
Loading…
Reference in New Issue
Block a user