From 192e1bd7776d01f8df7a65db91e452478e5139a9 Mon Sep 17 00:00:00 2001 From: huxq17 Date: Fri, 27 May 2016 19:22:37 +0800 Subject: [PATCH] =?UTF-8?q?debug=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 4 +-- .../huxq17/example/adapter/MeiziAdapter.java | 2 ++ .../example/fragment/MeiziFragment.java | 3 +- .../huxq17/swipecardsview/SwipeCardsView.java | 29 ++++++++++++------- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 4ca96b7..85a5555 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -33,8 +33,8 @@ dependencies { compile 'com.android.support:cardview-v7:23.0.1' compile 'io.realm:realm-android:0.81.1' compile 'org.jsoup:jsoup:1.8.2' - compile 'com.huxq17.android:SwipeCardsView:1.0.0' +// compile 'com.huxq17.android:SwipeCardsView:1.0.0' compile 'com.android.support:appcompat-v7:23.0.1' -// compile project(':library') + compile project(':library') compile project(':okhttp') } diff --git a/app/src/main/java/com/huxq17/example/adapter/MeiziAdapter.java b/app/src/main/java/com/huxq17/example/adapter/MeiziAdapter.java index 9f24f22..fa9c92a 100644 --- a/app/src/main/java/com/huxq17/example/adapter/MeiziAdapter.java +++ b/app/src/main/java/com/huxq17/example/adapter/MeiziAdapter.java @@ -8,6 +8,7 @@ import com.huxq17.example.R; import com.huxq17.example.bean.ContentBean; import com.huxq17.swipecardsview.BaseCardAdapter; +import com.huxq17.swipecardsview.LogUtil; import com.squareup.picasso.Picasso; import java.util.List; @@ -43,6 +44,7 @@ public void onBindData(int position, View cardview) { if (datas == null || datas.size() == 0) { return; } + LogUtil.d("onBindData position="+position); ImageView imageView = (ImageView) cardview.findViewById(R.id.iv_meizi); ContentBean meizi = datas.get(position); String url = meizi.getUrl(); diff --git a/app/src/main/java/com/huxq17/example/fragment/MeiziFragment.java b/app/src/main/java/com/huxq17/example/fragment/MeiziFragment.java index cf0b50c..14cb5ea 100644 --- a/app/src/main/java/com/huxq17/example/fragment/MeiziFragment.java +++ b/app/src/main/java/com/huxq17/example/fragment/MeiziFragment.java @@ -8,7 +8,6 @@ import android.view.View; import android.view.ViewGroup; -import com.andbase.tractor.utils.LogUtils; import com.huxq17.example.MainActivity; import com.huxq17.example.R; import com.huxq17.example.adapter.MeiziAdapter; @@ -81,7 +80,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa @Override public void onShow(int index) { curIndex = index; - LogUtils.i("test showing index = " + index); +// LogUtils.i("test showing index = " + index); } @Override diff --git a/library/src/main/java/com/huxq17/swipecardsview/SwipeCardsView.java b/library/src/main/java/com/huxq17/swipecardsview/SwipeCardsView.java index a939843..5294dac 100644 --- a/library/src/main/java/com/huxq17/swipecardsview/SwipeCardsView.java +++ b/library/src/main/java/com/huxq17/swipecardsview/SwipeCardsView.java @@ -90,7 +90,6 @@ public void onClick(View view) { mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); mMaxVelocity = ViewConfiguration.get(getContext()).getScaledMaximumFlingVelocity(); mMinVelocity = ViewConfiguration.get(getContext()).getScaledMinimumFlingVelocity(); - } /** @@ -133,8 +132,10 @@ private void bindCardData(int position, View cardview) { */ public void notifyDatasetChanged(int index) { if (canResetView()) { + LogUtil.d("test notifyDatasetChanged canResetView="+index); refreshUI(index); } else { + LogUtil.d("test notifyDatasetChanged can not Reset View="+index); mWaitRefresh = true; tempShowingIndex = index; } @@ -281,10 +282,12 @@ public boolean dispatchTouchEventSupper(MotionEvent e) { } private void releaseTopView(float xvel, float yvel) { - View TopView = getTopView(); - if (TopView != null) { - onTopViewReleased(TopView, xvel, yvel); - } + View topView = getTopView(); + LogUtil.i("test start releaseTopView topView="+topView); + if (topView != null) { + onTopViewReleased(topView, xvel, yvel); + } LogUtil.i("test end releaseTopView topView="+topView); + } /** @@ -402,7 +405,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - if (hasTouchTopView) { + if (hasTouchTopView||mScroller.computeScrollOffset()) { return; } int size = viewList.size(); @@ -417,6 +420,8 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto initLeft = viewList.get(0).getLeft(); initTop = viewList.get(0).getTop(); mCardWidth = viewList.get(0).getMeasuredWidth(); + View topView = getTopView(); + LogUtil.i("test onLayout initLeft="+initLeft+"; topView="+topView); } @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) @@ -474,6 +479,7 @@ private void layoutChild(View child, int index) { @Override public void computeScroll() { + LogUtil.d("test computeScroll mScroller.computeScrollOffset()="+mScroller.computeScrollOffset()); if (mScroller.computeScrollOffset()) { View topView = getTopView(); if (topView == null) { @@ -522,10 +528,11 @@ private void resetViewGroup() { } } else { View changedView = releasedViewList.get(0); -// if (changedView.getLeft() == initLeft) { -// releasedViewList.remove(0); -// return; -// } + if (changedView.getLeft() == initLeft) { + LogUtil.i("test changedView="+changedView+";changedView.getLeft() == initLeft left="+initLeft+";scalex="+changedView.getScaleX()); + releasedViewList.remove(0); + return; + } int viewSize = viewList.size(); removeViewInLayout(changedView); addViewInLayout(changedView, 0, changedView.getLayoutParams(), true); @@ -622,10 +629,12 @@ private void onTopViewReleased(View changedView, float xvel, float yvel) { finalX = mWidth; finalY = dy * (mCardWidth + initLeft) / dx + initTop; flyType = SlideType.RIGHT; + LogUtil.i("test 向右边滑出"); } else if (dx < -X_DISTANCE_THRESHOLD || (xvel < -X_VEL_THRESHOLD && dx < 0)) {//向左边滑出 finalX = -mCardWidth; finalY = dy * (mCardWidth + initLeft) / (-dx) + dy + initTop; flyType = SlideType.LEFT; + LogUtil.i("test 向左边滑出"); } if (finalY > mHeight) {