Skip to content

Commit

Permalink
fix the bug about the adapter's LayoutParams and optimize part codes
Browse files Browse the repository at this point in the history
  • Loading branch information
xyczero committed Mar 24, 2015
1 parent cf456f2 commit 1ed2e6a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.AnimationUtils;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
Expand Down Expand Up @@ -221,7 +220,7 @@ private View newView(Context context, int position, ViewGroup parent) {
// itemLayout indicates the outermost layout of the new view.
RelativeLayout itemLayout = new RelativeLayout(context);
itemLayout.setLayoutParams(new AbsListView.LayoutParams(
LayoutParams.MATCH_PARENT, itemView.getLayoutParams().height));
itemView.getLayoutParams().width, itemView.getLayoutParams().height));
itemLayout.addView(itemView);

// get a new swipeLeftView and init it.
Expand All @@ -236,7 +235,7 @@ private View newView(Context context, int position, ViewGroup parent) {
// itemSwipeLeftLayout indicates the layout of the swipeLeftView.
RelativeLayout itemSwipeLeftLayout = new RelativeLayout(context);
itemSwipeLeftLayout.setLayoutParams(new AbsListView.LayoutParams(
LayoutParams.MATCH_PARENT, itemView.getLayoutParams().height));
itemView.getLayoutParams().width, itemView.getLayoutParams().height));
itemSwipeLeftLayout.setHorizontalGravity(Gravity.END);
itemSwipeLeftLayout.setBackgroundColor(mContext.getResources()
.getColor(android.R.color.transparent));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,13 +475,13 @@ private boolean isInSwipePosition(int x, int y) {
frame = mTouchFrame;
}
// The premise is that the itemswipeview is visible.
if (isItemSwipeViewVisible && mCurItemSwipeView == mLastItemSwipeView) {
if (isItemSwipeViewVisible) {
frame.set(
mCurItemSwipeView.getLeft(),
getChildAt(mCurSelectedPosition - getFirstVisiblePosition())
mLastItemSwipeView.getLeft(),
getChildAt(mLastSelectedPosition - getFirstVisiblePosition())
.getTop(),
mCurItemSwipeView.getRight(),
getChildAt(mCurSelectedPosition - getFirstVisiblePosition())
mLastItemSwipeView.getRight(),
getChildAt(mLastSelectedPosition - getFirstVisiblePosition())
.getBottom());
if (frame.contains(x, y)) {
return true;
Expand Down

0 comments on commit 1ed2e6a

Please sign in to comment.