xmuSistone / CardSlidePanel

enable users to slide card to the left or right smoothly and continuously
2.39k stars 516 forks source link

港真,发现一个问题 #36

Closed hidetag closed 8 years ago

hidetag commented 8 years ago

“无耻一点

如果我能不要脸一些,我会说这个项目有以下优点:

快。真的流畅,滑动的手速再快也赶不上代码刷新view的速度快。 高效。仅仅四个卡片view轻松搞定任意多的数据。 灵活。自定义ViewGroup对卡片view的高度实现了自适应。 细节。卡片之间联动的视觉效果,是像素级的精确。 不信,你下载下来look看看。”

最后这句话“不信,你下载下来look看看。”是个病句哇,如果翻译的话:不信,你下载下来看看看看。。。这个很显然不符合本项目的文风呐。。所以是不是可以考虑改成“不信,你下载下来look look”。。。

hidetag commented 8 years ago

运行Demo数组越界啦 E/AndroidRuntime: FATAL EXCEPTION: main Process: com.stone.card, PID: 11854 java.lang.IndexOutOfBoundsException: Invalid index 4, size is 4 at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255) at java.util.ArrayList.get(ArrayList.java:308) at com.stone.card.CardSlidePanel.ajustLinkageViewItem(CardSlidePanel.java:331) at com.stone.card.CardSlidePanel.processLinkageView(CardSlidePanel.java:313) at com.stone.card.CardSlidePanel.onViewPosChanged(CardSlidePanel.java:227) at com.stone.card.CardItemView$1.onSpringUpdate(CardItemView.java:66) at com.facebook.rebound.Spring.advance(Spring.java:441) at com.facebook.rebound.BaseSpringSystem.advance(BaseSpringSystem.java:129) at com.facebook.rebound.BaseSpringSystem.loop(BaseSpringSystem.java:143) at com.facebook.rebound.AndroidSpringLooperFactory$ChoreographerAndroidSpringLooper$1.doFrame(AndroidSpringLooperFactory.java:118) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:792) at android.view.Choreographer.doCallbacks(Choreographer.java:607) at android.view.Choreographer.doFrame(Choreographer.java:574) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:780) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5290) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:911) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:706)

xmuSistone commented 8 years ago

理论上不该出现这个问题的,你改了代码么?这个问题是怎么出现的?

hidetag commented 8 years ago

最直接跑demo哈,主要是先左滑右滑上滑下滑什么的,然后点叉叉或者喜欢,然后crash

xmuSistone commented 8 years ago

这个是没问题的啊。我这边十几个手机都没crash

sephyioth commented 8 years ago

Dear Friends: 话说,代码规范真的不咋地,通用性适配也比较差,今天在改你的问题,发现很多坑都需要填,不过给了不少好的参考。可以快些弄出来。还有,多加判空吧。如果datelist为空,就会nullpoint

   Yours.
   Genesis.Ling

Q Q :286680608 Phone:18758363081 Department: Embedded Software Engineer Send By Mac OS X

在 2016年9月28日,10:43,stone notifications@github.com 写道:

理论上不该出现这个问题的,你改了代码么?这个问题是怎么出现的?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/xmuSistone/android-card-slide-panel/issues/36#issuecomment-250057419, or mute the thread https://github.com/notifications/unsubscribe-auth/AGkijhcmH60xGrTsKa53YG8psQUqWjrKks5qudRGgaJpZM4KIWjv.

xmuSistone commented 8 years ago

@sephyioth 只是针对左右滑动这样特定的一种场景。如果你觉着不好改了,只能是你妹吃透代码了

xmuSistone commented 8 years ago

@sephyioth 通用性适配,你给讲讲为啥???xml文件是自己写的,特定的场景是满屏下的效果。

xmuSistone commented 8 years ago

@sephyioth 如果你自己的xml满屏适配时都出问题的话,也别指望这个这个仓库帮你解决什么。毕竟,使用这个仓库的大前提,就是你xml得自己适配好。

xmuSistone commented 8 years ago

@sephyioth dataList为空,为何让你改那么久?能有多久?有问题的话,请一并在issue里面列出来

sephyioth commented 8 years ago

Dear Friends: 就是不像adapter一样,直接继承就可以变不同的业务视图,要改你的布局,也挺麻烦的,打算做成类似adapter这类的效果吧,继承一下就可以使用,而且XML布局也有一定麻烦点,我在改写的时候发现了一些问题。可能我们公司的规范流程不同吧,感觉这份代码可以写的更好一些,在使用和封装上,还是希望能尽量的考虑多一点问题。毕竟开源的东西,给人用起来舒服,问题少,才好。很多在git上混的都是伸手党,你用起来是可以。并不是吐槽,只是一点建议,写好一个控件还是挺麻烦的。

   Yours.
   Genesis.Ling

Q Q :286680608 Phone:18758363081 Department: Embedded Software Engineer Send By Mac OS X

在 2016年9月28日,13:09,stone notifications@github.com 写道:

@sephyioth https://github.com/sephyioth dataList为空,为何让你改那么久?能有多久?有问题的话,请一并在issue里面列出来

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/xmuSistone/android-card-slide-panel/issues/36#issuecomment-250072998, or mute the thread https://github.com/notifications/unsubscribe-auth/AGkijjHAC_B4QCao8Mt7-MKmcudb-OB5ks5qufaHgaJpZM4KIWjv.

xmuSistone commented 8 years ago

@sephyioth 如果有坑,要列个一二三四五六七,这样我才好改。说有坑,也不列出来,这有什么意义???Adapter我不去做,因为我觉着这个仓库已经足够简单明了了。很简单,你只需要修改card_item.xml文件就好,可滑动的区域在CardItemView里面设定一下,绑定数据也在CardItemView,这样就可以了!!!

xmuSistone commented 8 years ago

@sephyioth 只是,我少了在readme里面做一下说明。所以你们改乱了,还来指责仓库~我这就加上

Nstd commented 8 years ago

:joy:看你们闹的这么欢,要不要试试我封装的https://github.com/Nstd/android-card-slide-panel/

xmuSistone commented 8 years ago

@Nstd 别闹

xmuSistone commented 8 years ago

只是dataList传入为null,我也是醉了。屏幕适配有问题,是xml文件没写好,可笑~~

sephyioth commented 8 years ago

Dear Friends: 我知道,现在我在改,感觉看懂代码还是挺麻烦的,所以要费点事。回头有问题问你好了。大致上坑没有发现,只是用的略操蛋,不喜欢这种用法。

   Yours.
   Genesis.Ling

Q Q :286680608 Phone:18758363081 Department: Embedded Software Engineer Send By Mac OS X

在 2016年9月28日,14:47,stone notifications@github.com 写道:

@sephyioth https://github.com/sephyioth 如果有坑,要列个一二三四五六七,这样我才好改。说有坑,也不列出来,这有什么意义???Adapter我不去做,因为我觉着这个仓库已经足够简单明了了。很简单,你只需要修改card_item.xml文件就好,可滑动的区域在CardItemView里面设定一下,绑定数据也在CardItemView,这样就可以了!!!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/xmuSistone/android-card-slide-panel/issues/36#issuecomment-250085669, or mute the thread https://github.com/notifications/unsubscribe-auth/AGkijpdXpedTAhtUqCnT-Cu-ho-uIgfDks5qug2fgaJpZM4KIWjv.

xmuSistone commented 8 years ago

不写代码更省事。

sephyioth commented 8 years ago

Dear Friends: 感谢,这个库比较好用,省的自己改了,已经改了一点点。

   Yours.
   Genesis.Ling

Q Q :286680608 Phone:18758363081 Department: Embedded Software Engineer Send By Mac OS X

在 2016年9月28日,15:01,Nstd notifications@github.com 写道:

😂看你们闹的这么欢,要不要试试我封装的https://github.com/Nstd/android-card-slide-panel/ https://github.com/Nstd/android-card-slide-panel/ — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/xmuSistone/android-card-slide-panel/issues/36#issuecomment-250087868, or mute the thread https://github.com/notifications/unsubscribe-auth/AGkijoDF6gSNiNLSAafMIPpv-PpbiNaLks5quhDlgaJpZM4KIWjv.

xmuSistone commented 8 years ago

如果要卡片居中的效果,就试着改一下onLayout函数吧。那里我写死了,是顶部对齐的~其它的布局问题,改xml文件就足够了

sephyioth commented 8 years ago

Dear Friends: 问一下,我在测试的时候发现一个比较有趣的问题,就是如果我放到自定义的一个linearlayout中,会出现以下情况。就是会调用onfinishinflate两次,其中又一次是空,找不到资源。具体代码如下:请问你有遇到过么?

   Yours.
   Genesis.Ling

Q Q :286680608 Phone:18758363081 Department: Embedded Software Engineer Send By Mac OS X

在 2016年9月28日,15:01,Nstd notifications@github.com 写道:

😂看你们闹的这么欢,要不要试试我封装的https://github.com/Nstd/android-card-slide-panel/ https://github.com/Nstd/android-card-slide-panel/ — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/xmuSistone/android-card-slide-panel/issues/36#issuecomment-250087868, or mute the thread https://github.com/notifications/unsubscribe-auth/AGkijoDF6gSNiNLSAafMIPpv-PpbiNaLks5quhDlgaJpZM4KIWjv.

Nstd commented 8 years ago

@sephyioth 你用的是哪个版本?Readme的gradle版本我忘改了,最新的是1.1.3

sephyioth commented 8 years ago

Dear Friends:

Grade我改过了,已经在我的project中运行了,如果直接加Gradle引用,好像BottomLayout的ID是没有的。

只是不是很理解,为什么会调用onfinishInflate两次,而且第一次视图没有被引用。 Yours. Genesis.Ling


Q Q :286680608 Phone:18758363081 Department: Embedded Software Engineer Send By Mac OS X

在 2016年9月29日,14:27,Nstd notifications@github.com 写道:

@sephyioth https://github.com/sephyioth 你用的是哪个版本?Readme的gradle版本我忘改了,最新的是1.1.3

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/xmuSistone/android-card-slide-panel/issues/36#issuecomment-250381470, or mute the thread https://github.com/notifications/unsubscribe-auth/AGkijh5SlvkI_DLqHDC3wuSgCDetCh0eks5qu1pqgaJpZM4KIWjv.

Nstd commented 8 years ago

@sephyioth 能看下代码吗?前面的代码好像没有贴成功

sephyioth commented 8 years ago

Dear Friends:

public class CardItemDetailView extends LinearLayout {

private CircleImageView   mImageView;
private CircleImageView   mImageUser;
private TextView          mTextAddr;
private TextView          mTextName;
private TextView          mTextTime;
private TextView          mTextPrice;
private TextView          mTextHolder;
private TextView          mTextAction;
private View              mLeftBtn;
private View              mRightBtn;
private ProperRatingBar   mProperRatingBar;
private CardSlidePanel    mSlidePanel;
private CardDetailAdapter mAdapter;

public CardItemDetailView(Context context) {
    super(context);
}

public CardItemDetailView(Context context, AttributeSet attrs) {
    super(context, attrs);
}

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    mImageView = (CircleImageView) findViewById(R.id.image_card);
    mImageUser = (CircleImageView) findViewById(R.id.image_user);
    mTextAddr = (TextView) findViewById(R.id.tv_local);
    mTextName = (TextView) findViewById(R.id.tv_cardname);
    mTextTime = (TextView) findViewById(R.id.tv_cardtime);
    mTextPrice = (TextView) findViewById(R.id.tv_price);
    mTextHolder = (TextView) findViewById(R.id.tv_carduser);
    mTextAction = (TextView) findViewById(R.id.btn_action);
    mProperRatingBar = (ProperRatingBar) findViewById(R.id.properRatingBar_user);
    mSlidePanel = (CardSlidePanel) findViewById(R.id.image_slide_panel);
    mAdapter = new CardDetailAdapter(getContext(), null);
    mLeftBtn = findViewById(R.id.card_left_btn);
    mRightBtn = findViewById(R.id.card_right_btn);
    mTextAction.setVisibility(GONE);
    mImageUser.setVisibility(GONE);
    mTextHolder.setVisibility(GONE);
    if (mSlidePanel != null) {
        mSlidePanel.setAdapter(mAdapter);
        mLeftBtn.setOnClickListener(btnClickListener);
        mRightBtn.setOnClickListener(btnClickListener);
    }
}

private View.OnClickListener btnClickListener = new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.card_left_btn) {
            mSlidePanel.vanishOnBtnClick(CardSlidePanel.VANISH_TYPE_LEFT);
        } else if (v.getId() == R.id.card_right_btn) {
            mSlidePanel.vanishOnBtnClick(CardSlidePanel.VANISH_TYPE_RIGHT);
        }
    }
};

public void setCardBean(CardBean bean) {
    if (bean != null) {
        LDImageLoader.getImageLoader().displayImage(bean.getCardPhotoUrl(), mImageView);
        LDImageLoader.getImageLoader().displayImage(bean.getCardPhotoUrl(), mImageUser);
        mTextName.setText(bean.getCardName());
        mTextPrice.setText(bean.getCardPrice());
        mTextTime.setText(bean.getCardTime());
        mTextHolder.setText(bean.getCardHolder());
        mProperRatingBar.setRating((int) bean.getCardStars());
    }
}

} 可以,其实可以过滤很多部分代码,就直接挑重点的,继承一个layout,然后在onfinishInflate中添加,以前在THS都是这样写的。便于维护视图。

   Yours.
   Genesis.Ling

Q Q :286680608 Phone:18758363081 Department: Embedded Software Engineer Send By Mac OS X

在 2016年9月29日,15:13,Nstd notifications@github.com 写道:

@sephyioth https://github.com/sephyioth 能看下代码吗?前面的代码好像没有贴成功

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/xmuSistone/android-card-slide-panel/issues/36#issuecomment-250388894, or mute the thread https://github.com/notifications/unsubscribe-auth/AGkijj7mpogWOghnq2EkTx3C8is4JYFFks5qu2UcgaJpZM4KIWjv.

sephyioth commented 8 years ago

Dear Friends:

哪个就是出问题的代码段,觉得很奇怪的问题,第一次遇到。

   Yours.
   Genesis.Ling

Q Q :286680608 Phone:18758363081 Department: Embedded Software Engineer Send By Mac OS X

在 2016年9月29日,15:13,Nstd notifications@github.com 写道:

@sephyioth https://github.com/sephyioth 能看下代码吗?前面的代码好像没有贴成功

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/xmuSistone/android-card-slide-panel/issues/36#issuecomment-250388894, or mute the thread https://github.com/notifications/unsubscribe-auth/AGkijj7mpogWOghnq2EkTx3C8is4JYFFks5qu2UcgaJpZM4KIWjv.

Nstd commented 8 years ago

@sephyioth card里的header和footer也是在onFinishInflat()之后才调用的,card本身是在添加了adapter之后才会添加的,所以不知道是不是这个原因导致的

sephyioth commented 8 years ago

Dear Friends: 有可能,我跟踪了一下,好像视图没被inflatable ,要首先加载adapter中的视图,然后才能被inflatable,写法我看了,学习了很多。不过感觉代码有的还是有一些可以改进的区间,懒得改了,凑活用就行了 多谢贡献啦 Yours. Genesis.Ling


Q Q :286680608 Phone:18758363081 Department: Embedded Software Engineer Send By Mac OS X

在 2016年9月30日,11:48,Nstd notifications@github.com 写道:

@sephyioth https://github.com/sephyioth card里的header和footer也是在onFinishInflat()之后才调用的,card本身是在添加了adapter之后才会添加的,所以不知道是不是这个原因导致的

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/xmuSistone/android-card-slide-panel/issues/36#issuecomment-250652231, or mute the thread https://github.com/notifications/unsubscribe-auth/AGkijlPC3bg3_oMKtT4qZy2ZUj7NpaXQks5qvIakgaJpZM4KIWjv.

Nstd commented 8 years ago

@sephyioth :joy:我现在也是需求驱动,够用就行,有需求再改吧

zhuchen1109 commented 8 years ago

之前的项目有这样需求,就参考大神们写了一个,优化了好几个版本,现在深度满足产品各种需求。有大神需要可以参考https://github.com/zhuchen1109/Swipe-cards 没写readme 见谅