Skip to content

Commit 0ec9c71

Browse files
committed
Merge branch 'master' of github.com:daimajia/AndroidSwipeLayout
2 parents 6472d75 + ae54ad3 commit 0ec9c71

File tree

2 files changed

+6
-50
lines changed

2 files changed

+6
-50
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Time passed, finally...as you see right now.
1414

1515
![](http://ww2.sinaimg.cn/mw690/610dc034jw1ejoplapwtqg208n0e74dx.gif)
1616

17-
[Download Demo](https://github.com/daimajia/AndroidSwipeLayout/releases/download/v1.0.0/AndroidSwipeLayout-Demo-1.0.0.apk)
17+
[Download Demo](https://github.com/daimajia/AndroidSwipeLayout/releases/download/v1.0.0/AndroidSwipeLayout-Demo-1.0.1-snapshot.apk)
1818

1919
Before I made this, I actually found some libraries (eg.[SwipeListView](https://github.com/47deg/android-swipelistview)) that helps developers to integrate swiping with your UI component. But they have too much limitation, only in ListView, or some other limitations.
2020

library/src/main/java/com/daimajia/swipe/SwipeLayout.java

Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
import android.view.ViewGroup;
1212
import android.view.ViewParent;
1313
import android.widget.AdapterView;
14+
import android.widget.FrameLayout;
1415

1516
import java.util.ArrayList;
1617
import java.util.HashMap;
1718
import java.util.List;
1819
import java.util.Map;
1920

20-
public class SwipeLayout extends ViewGroup{
21+
public class SwipeLayout extends FrameLayout {
2122

2223
private ViewDragHelper mDragHelper;
2324

@@ -588,57 +589,12 @@ void layoutLayDown(){
588589

589590
@Override
590591
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
591-
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
592-
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
593-
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
594-
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
595-
596-
int width, height;
597-
598-
if(heightMode == MeasureSpec.UNSPECIFIED)
599-
heightSize = Integer.MAX_VALUE;
600-
601-
if(widthMode == MeasureSpec.UNSPECIFIED)
602-
widthSize = Integer.MAX_VALUE;
603-
604-
measure(getSurfaceView(), widthSize, heightSize);
605-
measure(getBottomView(), widthSize, heightSize);
606-
592+
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
593+
607594
if(mDragEdge == DragEdge.Left || mDragEdge == DragEdge.Right)
608595
mDragDistance = getBottomView().getMeasuredWidth();
609596
else
610597
mDragDistance = getBottomView().getMeasuredHeight();
611-
612-
width = Math.max(getSurfaceView().getMeasuredWidth(), getBottomView().getMeasuredWidth());
613-
height = Math.max(getBottomView().getMeasuredHeight(), getBottomView().getMeasuredHeight());
614-
615-
setMeasuredDimension(width, height);
616-
}
617-
618-
private void measure(View child, int maxWidth, int maxHeight){
619-
LayoutParams lp = child.getLayoutParams();
620-
int childWidthSpec, childHeightSpec;
621-
if(lp.width == LayoutParams.WRAP_CONTENT){
622-
childWidthSpec = MeasureSpec.makeMeasureSpec(maxWidth, MeasureSpec.AT_MOST);
623-
}else if(lp.width == LayoutParams.MATCH_PARENT){
624-
childWidthSpec = MeasureSpec.makeMeasureSpec(maxWidth, MeasureSpec.EXACTLY);
625-
}else{
626-
childWidthSpec = MeasureSpec.makeMeasureSpec(Math.min(maxWidth, lp.width), MeasureSpec.EXACTLY);
627-
}
628-
629-
if(lp.height == LayoutParams.WRAP_CONTENT){
630-
childHeightSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST);
631-
}else if(lp.height == LayoutParams.MATCH_PARENT) {
632-
if(maxHeight == Integer.MAX_VALUE){
633-
maxHeight = dp2px(80);
634-
}
635-
childHeightSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.EXACTLY);
636-
}else{
637-
childHeightSpec = MeasureSpec.makeMeasureSpec(Math.min(maxHeight, lp.height), MeasureSpec.EXACTLY);
638-
}
639-
640-
child.measure(childWidthSpec, childHeightSpec);
641-
642598
}
643599

644600
@Override
@@ -1058,4 +1014,4 @@ private Rect computeBottomLayDown(DragEdge dragEdge){
10581014
private int dp2px(float dp){
10591015
return (int) (dp * getContext().getResources().getDisplayMetrics().density + 0.5f);
10601016
}
1061-
}
1017+
}

0 commit comments

Comments
 (0)