mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-12-02 12:17:46 +08:00
fix a crash caused by drawablecontainer
This commit is contained in:
parent
64cb5cfce3
commit
29527883f9
@ -111,15 +111,15 @@ bool AnimatedStateListDrawable::selectTransition(int toIndex){
|
|||||||
|
|
||||||
Transition* transition = nullptr;
|
Transition* transition = nullptr;
|
||||||
Drawable* d = getCurrent();
|
Drawable* d = getCurrent();
|
||||||
/*if (dynamic_cast<AnimationDrawable*>(d)) {
|
if (dynamic_cast<AnimationDrawable*>(d)) {
|
||||||
bool reversed = mState->isTransitionReversed(fromId, toId);
|
bool reversed = mState->isTransitionReversed(fromId, toId);
|
||||||
transition = new AnimationDrawableTransition((AnimationDrawable*) d,reversed, hasReversibleFlag);
|
transition = new AnimationDrawableTransition((AnimationDrawable*) d,reversed, hasReversibleFlag);
|
||||||
} else if (dynamic_cast<AnimatedVectorDrawable*>(d)) {
|
}/* else if (dynamic_cast<AnimatedVectorDrawable*>(d)) {
|
||||||
bool reversed = mState->isTransitionReversed(fromId, toId);
|
bool reversed = mState->isTransitionReversed(fromId, toId);
|
||||||
transition = new AnimatedVectorDrawableTransition((AnimatedVectorDrawable*) d, reversed, hasReversibleFlag);
|
transition = new AnimatedVectorDrawableTransition((AnimatedVectorDrawable*) d, reversed, hasReversibleFlag);
|
||||||
} else if (dynamic_cast<Animatable*>(d)) {
|
}*/ else if (dynamic_cast<Animatable*>(d)) {
|
||||||
transition = new AnimatableTransition((Animatable*) d);
|
transition = new AnimatableTransition((Animatable*) d);
|
||||||
} else*/ {
|
} else {
|
||||||
// We don't know how to animate this transition.
|
// We don't know how to animate this transition.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -170,6 +170,12 @@ void AnimatedStateListDrawable::setConstantState(std::shared_ptr<DrawableContain
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void AnimatedStateListDrawable::Transition::reverse(){
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AnimatedStateListDrawable::Transition::canReverse(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
AnimatedStateListDrawable::AnimatedStateListState::AnimatedStateListState(const AnimatedStateListDrawable::AnimatedStateListState* orig,AnimatedStateListDrawable* owner)
|
AnimatedStateListDrawable::AnimatedStateListState::AnimatedStateListState(const AnimatedStateListDrawable::AnimatedStateListState* orig,AnimatedStateListDrawable* owner)
|
||||||
:StateListState(orig,owner){
|
:StateListState(orig,owner){
|
||||||
@ -287,4 +293,78 @@ float AnimatedStateListDrawable::FrameInterpolator::getInterpolation(float input
|
|||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------
|
||||||
|
AnimatedStateListDrawable::AnimatableTransition::AnimatableTransition(Animatable* a) {
|
||||||
|
mA = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnimatedStateListDrawable::AnimatableTransition::start() {
|
||||||
|
mA->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnimatedStateListDrawable::AnimatableTransition::stop() {
|
||||||
|
mA->stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************/
|
||||||
|
AnimatedStateListDrawable::AnimationDrawableTransition::AnimationDrawableTransition(AnimationDrawable* ad, bool reversed, bool hasReversibleFlag){
|
||||||
|
const int frameCount = ad->getNumberOfFrames();
|
||||||
|
const int fromFrame = reversed ? frameCount - 1 : 0;
|
||||||
|
const int toFrame = reversed ? 0 : frameCount - 1;
|
||||||
|
FrameInterpolator* interp = new FrameInterpolator(ad, reversed);
|
||||||
|
ObjectAnimator* anim = ObjectAnimator::ofInt(ad, "currentIndex",{fromFrame, toFrame});
|
||||||
|
anim->setAutoCancel(true);
|
||||||
|
anim->setDuration(interp->getTotalDuration());
|
||||||
|
anim->setInterpolator(interp);
|
||||||
|
mHasReversibleFlag = hasReversibleFlag;
|
||||||
|
mAnim = anim;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AnimatedStateListDrawable::AnimationDrawableTransition::canReverse() {
|
||||||
|
return mHasReversibleFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnimatedStateListDrawable::AnimationDrawableTransition::start() {
|
||||||
|
mAnim->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnimatedStateListDrawable::AnimationDrawableTransition::reverse() {
|
||||||
|
mAnim->reverse();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnimatedStateListDrawable::AnimationDrawableTransition::stop() {
|
||||||
|
mAnim->cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************/
|
||||||
|
AnimatedStateListDrawable::AnimatedVectorDrawableTransition::AnimatedVectorDrawableTransition(AnimatedVectorDrawable* avd,bool reversed, bool hasReversibleFlag){
|
||||||
|
mAvd = avd;
|
||||||
|
mReversed = reversed;
|
||||||
|
mHasReversibleFlag = hasReversibleFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AnimatedStateListDrawable::AnimatedVectorDrawableTransition::canReverse(){
|
||||||
|
return mHasReversibleFlag;// && mAvd->canReverse();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnimatedStateListDrawable::AnimatedVectorDrawableTransition::start(){
|
||||||
|
if (mReversed) {
|
||||||
|
reverse();
|
||||||
|
} else {
|
||||||
|
//mAvd->start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnimatedStateListDrawable::AnimatedVectorDrawableTransition::reverse(){
|
||||||
|
if (canReverse()) {
|
||||||
|
//mAvd->reverse();
|
||||||
|
} else {
|
||||||
|
LOGW("Can't reverse, either the reversible is set to false,"
|
||||||
|
" or the AnimatedVectorDrawable can't reverse");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnimatedStateListDrawable::AnimatedVectorDrawableTransition::stop(){
|
||||||
|
//mAvd->stop();
|
||||||
|
}
|
||||||
|
|
||||||
}//endof namespace
|
}//endof namespace
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <drawables/statelistdrawable.h>
|
#include <drawables/statelistdrawable.h>
|
||||||
#include <drawables/animationdrawable.h>
|
#include <drawables/animationdrawable.h>
|
||||||
#include <animation/interpolators.h>
|
#include <animation/interpolators.h>
|
||||||
|
#include <animation/objectanimator.h>
|
||||||
#include <core/sparsearray.h>
|
#include <core/sparsearray.h>
|
||||||
namespace cdroid{
|
namespace cdroid{
|
||||||
|
|
||||||
@ -45,11 +46,54 @@ protected:
|
|||||||
virtual void start()=0;
|
virtual void start()=0;
|
||||||
virtual void stop()=0;
|
virtual void stop()=0;
|
||||||
|
|
||||||
virtual void reverse()=0;
|
virtual void reverse();
|
||||||
// Not supported by default.
|
// Not supported by default.
|
||||||
virtual bool canReverse() {
|
virtual bool canReverse();
|
||||||
return false;
|
};
|
||||||
}
|
class AnimatableTransition:public Transition {
|
||||||
|
private:
|
||||||
|
Animatable* mA;
|
||||||
|
public:
|
||||||
|
AnimatableTransition(Animatable* a);
|
||||||
|
void start()override;
|
||||||
|
void stop()override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class AnimationDrawableTransition:public Transition {
|
||||||
|
private:
|
||||||
|
ObjectAnimator* mAnim;
|
||||||
|
|
||||||
|
// Even AnimationDrawable is always reversible technically, but
|
||||||
|
// we should obey the XML's android:reversible flag.
|
||||||
|
bool mHasReversibleFlag;
|
||||||
|
public:
|
||||||
|
AnimationDrawableTransition(AnimationDrawable* ad,
|
||||||
|
bool reversed, bool hasReversibleFlag);
|
||||||
|
bool canReverse()override;
|
||||||
|
void start()override;
|
||||||
|
void reverse()override;
|
||||||
|
void stop()override;
|
||||||
|
};
|
||||||
|
typedef Drawable AnimatedVectorDrawable;
|
||||||
|
class AnimatedVectorDrawableTransition:public Transition {
|
||||||
|
private:
|
||||||
|
AnimatedVectorDrawable* mAvd;
|
||||||
|
|
||||||
|
// mReversed is indicating the current transition's direction.
|
||||||
|
bool mReversed;
|
||||||
|
|
||||||
|
// mHasReversibleFlag is indicating whether the whole transition has
|
||||||
|
// reversible flag set to true.
|
||||||
|
// If mHasReversibleFlag is false, then mReversed is always false.
|
||||||
|
bool mHasReversibleFlag;
|
||||||
|
public:
|
||||||
|
AnimatedVectorDrawableTransition(AnimatedVectorDrawable* avd,
|
||||||
|
bool reversed, bool hasReversibleFlag);
|
||||||
|
bool canReverse()override;
|
||||||
|
void start()override;
|
||||||
|
void reverse()override;
|
||||||
|
|
||||||
|
void stop()override;
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<AnimatedStateListState> mState;
|
std::shared_ptr<AnimatedStateListState> mState;
|
||||||
|
@ -44,6 +44,10 @@ BitmapDrawable::BitmapState::BitmapState(const BitmapState&bitmapState){
|
|||||||
mAutoMirrored = bitmapState.mAutoMirrored;
|
mAutoMirrored = bitmapState.mAutoMirrored;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BitmapDrawable::BitmapState::~BitmapState(){
|
||||||
|
delete mTint;
|
||||||
|
}
|
||||||
|
|
||||||
Drawable* BitmapDrawable::BitmapState::newDrawable(){
|
Drawable* BitmapDrawable::BitmapState::newDrawable(){
|
||||||
return new BitmapDrawable(shared_from_this());
|
return new BitmapDrawable(shared_from_this());
|
||||||
}
|
}
|
||||||
@ -211,6 +215,7 @@ void BitmapDrawable::setTintMode(int tintMode) {
|
|||||||
invalidateSelf();
|
invalidateSelf();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Drawable::ConstantState>BitmapDrawable::getConstantState(){
|
std::shared_ptr<Drawable::ConstantState>BitmapDrawable::getConstantState(){
|
||||||
return mBitmapState;
|
return mBitmapState;
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ private:
|
|||||||
BitmapState();
|
BitmapState();
|
||||||
BitmapState(RefPtr<ImageSurface>bitmap);
|
BitmapState(RefPtr<ImageSurface>bitmap);
|
||||||
BitmapState(const BitmapState&bitmapState);
|
BitmapState(const BitmapState&bitmapState);
|
||||||
|
~BitmapState()override;
|
||||||
Drawable* newDrawable()override;
|
Drawable* newDrawable()override;
|
||||||
int getChangingConfigurations()const override;
|
int getChangingConfigurations()const override;
|
||||||
};
|
};
|
||||||
|
@ -9,6 +9,9 @@
|
|||||||
|
|
||||||
namespace cdroid{
|
namespace cdroid{
|
||||||
|
|
||||||
|
Drawable::ConstantState::~ConstantState(){
|
||||||
|
}
|
||||||
|
|
||||||
Drawable::Drawable(){
|
Drawable::Drawable(){
|
||||||
mLevel=0;
|
mLevel=0;
|
||||||
mChangingConfigurations=0;
|
mChangingConfigurations=0;
|
||||||
|
@ -52,6 +52,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
virtual Drawable* newDrawable()=0;
|
virtual Drawable* newDrawable()=0;
|
||||||
virtual int getChangingConfigurations()const=0;
|
virtual int getChangingConfigurations()const=0;
|
||||||
|
virtual ~ConstantState();
|
||||||
};
|
};
|
||||||
enum{
|
enum{
|
||||||
DEFAULT_TINT_MODE=SRC_IN
|
DEFAULT_TINT_MODE=SRC_IN
|
||||||
|
@ -47,6 +47,7 @@ DrawableContainer::DrawableContainerState::DrawableContainerState(const Drawable
|
|||||||
mAutoMirrored = false;
|
mAutoMirrored = false;
|
||||||
mMutated = false;
|
mMutated = false;
|
||||||
mDither = false;
|
mDither = false;
|
||||||
|
mCheckedStateful = false;
|
||||||
mLayoutDirection = LayoutDirection::LTR;
|
mLayoutDirection = LayoutDirection::LTR;
|
||||||
mEnterFadeDuration= 0;
|
mEnterFadeDuration= 0;
|
||||||
mExitFadeDuration = 0;
|
mExitFadeDuration = 0;
|
||||||
@ -113,6 +114,7 @@ DrawableContainer::DrawableContainerState::DrawableContainerState(const Drawable
|
|||||||
mDrawables[i]=d;
|
mDrawables[i]=d;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawableContainer::DrawableContainerState::~DrawableContainerState(){
|
DrawableContainer::DrawableContainerState::~DrawableContainerState(){
|
||||||
for_each( mDrawables.begin(), mDrawables.end(),[](Drawable*d){delete d;});
|
for_each( mDrawables.begin(), mDrawables.end(),[](Drawable*d){delete d;});
|
||||||
mDrawables.clear();
|
mDrawables.clear();
|
||||||
@ -136,7 +138,6 @@ Drawable*DrawableContainer::DrawableContainerState::getChild(int index){
|
|||||||
Drawable* prepared = prepareDrawable(cs->newDrawable());
|
Drawable* prepared = prepareDrawable(cs->newDrawable());
|
||||||
mDrawables[index] = prepared;
|
mDrawables[index] = prepared;
|
||||||
LOGV("getChild(%d)=%p",index,prepared);
|
LOGV("getChild(%d)=%p",index,prepared);
|
||||||
mDrawableFutures.erase(it);
|
|
||||||
return prepared;
|
return prepared;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -269,10 +270,12 @@ int DrawableContainer::DrawableContainerState::getConstantWidth() {
|
|||||||
if (!mCheckedConstantSize) computeConstantSize();
|
if (!mCheckedConstantSize) computeConstantSize();
|
||||||
return mConstantWidth;
|
return mConstantWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DrawableContainer::DrawableContainerState::getConstantHeight() {
|
int DrawableContainer::DrawableContainerState::getConstantHeight() {
|
||||||
if (!mCheckedConstantSize) computeConstantSize();
|
if (!mCheckedConstantSize) computeConstantSize();
|
||||||
return mConstantHeight;
|
return mConstantHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DrawableContainer::DrawableContainerState::getConstantMinimumWidth() {
|
int DrawableContainer::DrawableContainerState::getConstantMinimumWidth() {
|
||||||
if (!mCheckedConstantSize)computeConstantSize();
|
if (!mCheckedConstantSize)computeConstantSize();
|
||||||
return mConstantMinimumWidth;
|
return mConstantMinimumWidth;
|
||||||
@ -291,13 +294,10 @@ Drawable* DrawableContainer::DrawableContainerState::prepareDrawable(Drawable* c
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DrawableContainer::DrawableContainerState::createAllFutures(){
|
void DrawableContainer::DrawableContainerState::createAllFutures(){
|
||||||
if (mDrawableFutures.size()) {
|
const int futureCount = mDrawableFutures.size();
|
||||||
int futureCount = mDrawableFutures.size();
|
for (int keyIndex = 0; keyIndex < futureCount; keyIndex++) {
|
||||||
for (int keyIndex = 0; keyIndex < futureCount; keyIndex++) {
|
auto cs = mDrawableFutures[keyIndex];
|
||||||
auto cs = mDrawableFutures[keyIndex];
|
mDrawables[keyIndex] = prepareDrawable(cs->newDrawable());
|
||||||
mDrawables[keyIndex] = prepareDrawable(cs->newDrawable());
|
|
||||||
}
|
|
||||||
mDrawableFutures.clear();//=nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
29
src/gui/drawables/levellistdrawable.cc
Normal file → Executable file
29
src/gui/drawables/levellistdrawable.cc
Normal file → Executable file
@ -6,16 +6,27 @@ namespace cdroid{
|
|||||||
|
|
||||||
LevelListDrawable::LevelListState::LevelListState(const LevelListState*orig,LevelListDrawable*own)
|
LevelListDrawable::LevelListState::LevelListState(const LevelListState*orig,LevelListDrawable*own)
|
||||||
:DrawableContainerState(orig,own){
|
:DrawableContainerState(orig,own){
|
||||||
if(orig!=nullptr){
|
if(orig!=nullptr){
|
||||||
mLows = orig->mLows;
|
mLows = orig->mLows;
|
||||||
mHighs= orig->mHighs;
|
mHighs= orig->mHighs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LevelListDrawable::LevelListState::mutate(){
|
void LevelListDrawable::LevelListState::mutate(){
|
||||||
//mLows = mLows.clone();
|
//mLows = mLows.clone();
|
||||||
// mHighs = mHighs.clone();
|
// mHighs = mHighs.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int LevelListDrawable::LevelListState::indexOfLevel(int level)const{
|
||||||
|
const int N = getChildCount();
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
if (level >= mLows[i] && level <= mHighs[i]) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
Drawable*LevelListDrawable::LevelListState::newDrawable(){
|
Drawable*LevelListDrawable::LevelListState::newDrawable(){
|
||||||
return new LevelListDrawable(std::dynamic_pointer_cast<LevelListState>(shared_from_this()));
|
return new LevelListDrawable(std::dynamic_pointer_cast<LevelListState>(shared_from_this()));
|
||||||
}
|
}
|
||||||
@ -34,7 +45,7 @@ LevelListDrawable::LevelListDrawable(std::shared_ptr<LevelListState>state){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool LevelListDrawable::onLevelChange(int level){
|
bool LevelListDrawable::onLevelChange(int level){
|
||||||
int idx =indexOfLevel(level);
|
int idx = mLevelListState->indexOfLevel(level);
|
||||||
if (selectDrawable(idx)) {
|
if (selectDrawable(idx)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -72,16 +83,6 @@ void LevelListDrawable::addLevel(int low,int high,Drawable* drawable) {
|
|||||||
onLevelChange(getLevel());
|
onLevelChange(getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
int LevelListDrawable::indexOfLevel(int level){
|
|
||||||
const int N = getChildCount();
|
|
||||||
for (int i = 0; i < N; i++) {
|
|
||||||
if (level >= mLevelListState->mLows[i] && level <= mLevelListState->mHighs[i]) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Drawable*LevelListDrawable::inflate(Context*ctx,const AttributeSet&atts){
|
Drawable*LevelListDrawable::inflate(Context*ctx,const AttributeSet&atts){
|
||||||
return new LevelListDrawable();
|
return new LevelListDrawable();
|
||||||
}
|
}
|
||||||
|
2
src/gui/drawables/levellistdrawable.h
Normal file → Executable file
2
src/gui/drawables/levellistdrawable.h
Normal file → Executable file
@ -11,11 +11,11 @@ private:
|
|||||||
LevelListState(const LevelListState*orig,LevelListDrawable*own);
|
LevelListState(const LevelListState*orig,LevelListDrawable*own);
|
||||||
LevelListState(const LevelListState&state);
|
LevelListState(const LevelListState&state);
|
||||||
void mutate();
|
void mutate();
|
||||||
|
int indexOfLevel(int level)const;
|
||||||
Drawable*newDrawable()override;
|
Drawable*newDrawable()override;
|
||||||
};
|
};
|
||||||
bool mMutated;
|
bool mMutated;
|
||||||
std::shared_ptr<LevelListState>mLevelListState;
|
std::shared_ptr<LevelListState>mLevelListState;
|
||||||
int indexOfLevel(int level);
|
|
||||||
LevelListDrawable(std::shared_ptr<LevelListState>state);
|
LevelListDrawable(std::shared_ptr<LevelListState>state);
|
||||||
protected:
|
protected:
|
||||||
bool onLevelChange(int level)override;
|
bool onLevelChange(int level)override;
|
||||||
|
@ -8,6 +8,7 @@ namespace cdroid{
|
|||||||
NinePatchDrawable::NinePatchDrawable(std::shared_ptr<NinePatchState>state){
|
NinePatchDrawable::NinePatchDrawable(std::shared_ptr<NinePatchState>state){
|
||||||
mNinePatchState=state;
|
mNinePatchState=state;
|
||||||
mAlpha=255;
|
mAlpha=255;
|
||||||
|
mMutated =false;
|
||||||
mTintFilter=nullptr;
|
mTintFilter=nullptr;
|
||||||
computeBitmapSize();
|
computeBitmapSize();
|
||||||
}
|
}
|
||||||
@ -15,6 +16,7 @@ NinePatchDrawable::NinePatchDrawable(std::shared_ptr<NinePatchState>state){
|
|||||||
NinePatchDrawable::NinePatchDrawable(Context*ctx,const std::string&resid){
|
NinePatchDrawable::NinePatchDrawable(Context*ctx,const std::string&resid){
|
||||||
mNinePatchState=std::make_shared<NinePatchState>(ctx->getImage(resid));
|
mNinePatchState=std::make_shared<NinePatchState>(ctx->getImage(resid));
|
||||||
mAlpha=255;
|
mAlpha=255;
|
||||||
|
mMutated =false;
|
||||||
mTintFilter=nullptr;
|
mTintFilter=nullptr;
|
||||||
computeBitmapSize();
|
computeBitmapSize();
|
||||||
}
|
}
|
||||||
@ -23,6 +25,7 @@ NinePatchDrawable::NinePatchDrawable(RefPtr<ImageSurface>bmp){
|
|||||||
mNinePatchState=std::make_shared<NinePatchState>(bmp);
|
mNinePatchState=std::make_shared<NinePatchState>(bmp);
|
||||||
mAlpha=255;
|
mAlpha=255;
|
||||||
mTintFilter=nullptr;
|
mTintFilter=nullptr;
|
||||||
|
mMutated =false;
|
||||||
computeBitmapSize();
|
computeBitmapSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
8
src/gui/res/color/textview.xml
Normal file → Executable file
8
src/gui/res/color/textview.xml
Normal file → Executable file
@ -1,5 +1,5 @@
|
|||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
<selector xmlns:cdroid="http://schemas.android.com/apk/res/android">
|
||||||
<item state_focused="false" alpha="#ff" color="#ffff0000"/>
|
<item cdroid:state_focused="false" cdroid:alpha="#ff" cdroid:color="#ffff0000"/>
|
||||||
<item state_focused="true" alpha="#ff" color="#ff00ff00"/>
|
<item cdroid:state_focused="true" cdroid:alpha="#ff" cdroid:color="#ff00ff00"/>
|
||||||
<item alpha="#ff" color="#ff0000ff"/>
|
<item cdroid:alpha="#ff" cdroid:color="#ff0000ff"/>
|
||||||
</selector>
|
</selector>
|
||||||
|
@ -27,6 +27,7 @@ void AbsListView::FLY_start(int initialVelocity) {
|
|||||||
mFlingStrictSpan = StrictMode.enterCriticalSpan("AbsListView-fling");
|
mFlingStrictSpan = StrictMode.enterCriticalSpan("AbsListView-fling");
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbsListView::FLY_startSpringback() {
|
void AbsListView::FLY_startSpringback() {
|
||||||
mSuppressIdleStateChangeCall = false;
|
mSuppressIdleStateChangeCall = false;
|
||||||
if (mScroller->springBack(0, mScrollY, 0, 0, 0, 0)) {
|
if (mScroller->springBack(0, mScrollY, 0, 0, 0, 0)) {
|
||||||
@ -38,6 +39,7 @@ void AbsListView::FLY_startSpringback() {
|
|||||||
reportScrollStateChange(OnScrollListener::SCROLL_STATE_IDLE);
|
reportScrollStateChange(OnScrollListener::SCROLL_STATE_IDLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbsListView::FLY_startOverfling(int initialVelocity) {
|
void AbsListView::FLY_startOverfling(int initialVelocity) {
|
||||||
mScroller->setInterpolator(nullptr);
|
mScroller->setInterpolator(nullptr);
|
||||||
mScroller->fling(0, mScrollY, 0, initialVelocity, 0, 0,INT_MIN,INT_MAX, 0, getHeight());
|
mScroller->fling(0, mScrollY, 0, initialVelocity, 0, 0,INT_MIN,INT_MAX, 0, getHeight());
|
||||||
@ -46,6 +48,7 @@ void AbsListView::FLY_startOverfling(int initialVelocity) {
|
|||||||
invalidate();
|
invalidate();
|
||||||
postOnAnimation(mFlingRunnable);
|
postOnAnimation(mFlingRunnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbsListView::FLY_edgeReached(int delta) {
|
void AbsListView::FLY_edgeReached(int delta) {
|
||||||
mScroller->notifyVerticalEdgeReached(mScrollY, 0, mOverflingDistance);
|
mScroller->notifyVerticalEdgeReached(mScrollY, 0, mOverflingDistance);
|
||||||
int overscrollMode = getOverScrollMode();
|
int overscrollMode = getOverScrollMode();
|
||||||
@ -71,6 +74,7 @@ void AbsListView::FLY_startScroll(int distance, int duration, bool linear, bool
|
|||||||
mSuppressIdleStateChangeCall = suppressEndFlingStateChangeCall;
|
mSuppressIdleStateChangeCall = suppressEndFlingStateChangeCall;
|
||||||
postOnAnimation(mFlingRunnable);
|
postOnAnimation(mFlingRunnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbsListView::FLY_endFling() {
|
void AbsListView::FLY_endFling() {
|
||||||
mTouchMode = TOUCH_MODE_REST;
|
mTouchMode = TOUCH_MODE_REST;
|
||||||
|
|
||||||
@ -245,7 +249,7 @@ void AbsListView::initAbsListView() {
|
|||||||
mIsChildViewEnabled =false;
|
mIsChildViewEnabled =false;
|
||||||
mIsDetaching =false;
|
mIsDetaching =false;
|
||||||
mSuppressIdleStateChangeCall =false;
|
mSuppressIdleStateChangeCall =false;
|
||||||
mVelocityScale =1.0f;
|
mVelocityScale = 1.0f;
|
||||||
mLastScrollState = OnScrollListener::SCROLL_STATE_IDLE;
|
mLastScrollState = OnScrollListener::SCROLL_STATE_IDLE;
|
||||||
mOnScrollListener.onScroll = nullptr;
|
mOnScrollListener.onScroll = nullptr;
|
||||||
mOnScrollListener.onScrollStateChanged = nullptr;
|
mOnScrollListener.onScrollStateChanged = nullptr;
|
||||||
@ -257,12 +261,14 @@ void AbsListView::initAbsListView() {
|
|||||||
mFlingRunnable = std::bind(&AbsListView::FLY_Proc,this);
|
mFlingRunnable = std::bind(&AbsListView::FLY_Proc,this);
|
||||||
mCheckFlywheel = std::bind(&AbsListView::FLY_CheckFlyWheelProc,this);
|
mCheckFlywheel = std::bind(&AbsListView::FLY_CheckFlyWheelProc,this);
|
||||||
mWidthMeasureSpec=0;
|
mWidthMeasureSpec=0;
|
||||||
mSelector =nullptr;
|
mSelector = nullptr;
|
||||||
mDataSetObserver =nullptr;
|
mDataSetObserver =nullptr;
|
||||||
mLayoutMode=LAYOUT_FORCE_TOP;
|
mCacheColorHint = 0;
|
||||||
mTouchMode =TOUCH_MODE_REST ;
|
mResurrectToPosition = INVALID_POSITION;
|
||||||
mDrawSelectorOnTop=true;
|
mLayoutMode = LAYOUT_FORCE_TOP;
|
||||||
mSmoothScrollbarEnabled =true;
|
mTouchMode = TOUCH_MODE_REST ;
|
||||||
|
mDrawSelectorOnTop = true;
|
||||||
|
mSmoothScrollbarEnabled = true;
|
||||||
ViewConfiguration& configuration = ViewConfiguration::get(mContext);
|
ViewConfiguration& configuration = ViewConfiguration::get(mContext);
|
||||||
mTouchSlop = configuration.getScaledTouchSlop();
|
mTouchSlop = configuration.getScaledTouchSlop();
|
||||||
mVerticalScrollFactor = configuration.getScaledVerticalScrollFactor();
|
mVerticalScrollFactor = configuration.getScaledVerticalScrollFactor();
|
||||||
|
@ -21,6 +21,7 @@ void GridView::initGridView(){
|
|||||||
mRequestedColumnWidth=0;
|
mRequestedColumnWidth=0;
|
||||||
mHorizontalSpacing=0;
|
mHorizontalSpacing=0;
|
||||||
mVerticalSpacing=0;
|
mVerticalSpacing=0;
|
||||||
|
mRequestedHorizontalSpacing = 0;
|
||||||
mStretchMode = STRETCH_COLUMN_WIDTH;
|
mStretchMode = STRETCH_COLUMN_WIDTH;
|
||||||
mReferenceView=nullptr;
|
mReferenceView=nullptr;
|
||||||
mReferenceViewInSelectedRow=nullptr;
|
mReferenceViewInSelectedRow=nullptr;
|
||||||
|
@ -836,6 +836,7 @@ RelativeLayout::LayoutParams::LayoutParams(Context*ctx,const AttributeSet&atts):
|
|||||||
mRules[ALIGN_PARENT_START] = atts.getBoolean("layout_alignParentStart", false) ? LTRUE : 0;
|
mRules[ALIGN_PARENT_START] = atts.getBoolean("layout_alignParentStart", false) ? LTRUE : 0;
|
||||||
mRules[ALIGN_PARENT_END] = atts.getBoolean("layout_alignParentEnd" , false) ? LTRUE : 0;
|
mRules[ALIGN_PARENT_END] = atts.getBoolean("layout_alignParentEnd" , false) ? LTRUE : 0;
|
||||||
mRulesChanged = true;
|
mRulesChanged = true;
|
||||||
|
mNeedsLayoutResolution = false;
|
||||||
memcpy(mInitialRules,mRules,sizeof(mRules));
|
memcpy(mInitialRules,mRules,sizeof(mRules));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,6 +66,7 @@ void TabLayout::initTabLayout(){
|
|||||||
mScrollAnimator = nullptr;
|
mScrollAnimator = nullptr;
|
||||||
mViewPager = nullptr;
|
mViewPager = nullptr;
|
||||||
mPagerAdapter = nullptr;
|
mPagerAdapter = nullptr;
|
||||||
|
mTabIndicatorGravity = Gravity::BOTTOM;
|
||||||
mAdapterChangeListener= nullptr;
|
mAdapterChangeListener= nullptr;
|
||||||
mTabSelectedIndicator = nullptr;
|
mTabSelectedIndicator = nullptr;
|
||||||
mRequestedTabMinWidth = INVALID_WIDTH;
|
mRequestedTabMinWidth = INVALID_WIDTH;
|
||||||
|
@ -238,9 +238,10 @@ bool ViewGroup::dispatchTransformedTouchEvent(MotionEvent& event, bool cancel,
|
|||||||
float offsetX = mScrollX - child->mLeft;
|
float offsetX = mScrollX - child->mLeft;
|
||||||
float offsetY = mScrollY - child->mTop;
|
float offsetY = mScrollY - child->mTop;
|
||||||
transformedEvent->offsetLocation(offsetX, offsetY);
|
transformedEvent->offsetLocation(offsetX, offsetY);
|
||||||
/*if (! child->hasIdentityMatrix()) {
|
if (! child->hasIdentityMatrix()) {
|
||||||
transformedEvent.transform(child.getInverseMatrix());
|
Matrix mtx=child->getInverseMatrix();
|
||||||
}*/
|
transformedEvent->transform((const float*)&mtx);
|
||||||
|
}
|
||||||
|
|
||||||
handled = child->dispatchTouchEvent(*transformedEvent);
|
handled = child->dispatchTouchEvent(*transformedEvent);
|
||||||
}
|
}
|
||||||
@ -382,11 +383,11 @@ bool ViewGroup::dispatchGenericFocusedEvent(MotionEvent&event){
|
|||||||
|
|
||||||
bool ViewGroup::dispatchTransformedGenericPointerEvent(MotionEvent& event, View* child) {
|
bool ViewGroup::dispatchTransformedGenericPointerEvent(MotionEvent& event, View* child) {
|
||||||
bool handled;
|
bool handled;
|
||||||
/*if (!child->hasIdentityMatrix()) {
|
if (!child->hasIdentityMatrix()) {
|
||||||
MotionEvent transformedEvent = getTransformedMotionEvent(event, child);
|
MotionEvent* transformedEvent = getTransformedMotionEvent(event, child);
|
||||||
handled = child.dispatchGenericMotionEvent(transformedEvent);
|
handled = child->dispatchGenericMotionEvent(*transformedEvent);
|
||||||
transformedEvent.recycle();
|
transformedEvent->recycle();
|
||||||
} else */{
|
} else {
|
||||||
float offsetX = mScrollX - child->mLeft;
|
float offsetX = mScrollX - child->mLeft;
|
||||||
float offsetY = mScrollY - child->mTop;
|
float offsetY = mScrollY - child->mTop;
|
||||||
event.offsetLocation(offsetX, offsetY);
|
event.offsetLocation(offsetX, offsetY);
|
||||||
@ -2260,6 +2261,18 @@ bool ViewGroup::dispatchKeyEvent(KeyEvent&event){
|
|||||||
return View::dispatchKeyEvent(event);
|
return View::dispatchKeyEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MotionEvent* ViewGroup::getTransformedMotionEvent(MotionEvent& event, View* child) {
|
||||||
|
const float offsetX = mScrollX - child->mLeft;
|
||||||
|
const float offsetY = mScrollY - child->mTop;
|
||||||
|
MotionEvent* transformedEvent = MotionEvent::obtain(event);
|
||||||
|
transformedEvent->offsetLocation(offsetX, offsetY);
|
||||||
|
if (!child->hasIdentityMatrix()) {
|
||||||
|
Matrix mtx=child->getInverseMatrix();
|
||||||
|
transformedEvent->transform((const float*)&mtx);
|
||||||
|
}
|
||||||
|
return transformedEvent;
|
||||||
|
}
|
||||||
|
|
||||||
bool ViewGroup::dispatchTouchEvent(MotionEvent&ev){
|
bool ViewGroup::dispatchTouchEvent(MotionEvent&ev){
|
||||||
const int action = ev.getAction();
|
const int action = ev.getAction();
|
||||||
const int actionMasked=ev.getActionMasked();
|
const int actionMasked=ev.getActionMasked();
|
||||||
|
@ -131,7 +131,7 @@ private:
|
|||||||
void removePointersFromTouchTargets(int pointerIdBits);
|
void removePointersFromTouchTargets(int pointerIdBits);
|
||||||
void cancelTouchTarget(View* view);
|
void cancelTouchTarget(View* view);
|
||||||
void cancelHoverTarget(View*view);
|
void cancelHoverTarget(View*view);
|
||||||
|
MotionEvent* getTransformedMotionEvent(MotionEvent& event, View* child);
|
||||||
bool dispatchTransformedTouchEvent(MotionEvent& event, bool cancel,
|
bool dispatchTransformedTouchEvent(MotionEvent& event, bool cancel,
|
||||||
View* child, int desiredPointerIdBits);
|
View* child, int desiredPointerIdBits);
|
||||||
bool dispatchTransformedGenericPointerEvent(MotionEvent& event, View* child);
|
bool dispatchTransformedGenericPointerEvent(MotionEvent& event, View* child);
|
||||||
|
Loading…
Reference in New Issue
Block a user