11
11
import android .view .ViewGroup ;
12
12
import android .view .ViewParent ;
13
13
import android .widget .AdapterView ;
14
+ import android .widget .FrameLayout ;
14
15
15
16
import java .util .ArrayList ;
16
17
import java .util .HashMap ;
17
18
import java .util .List ;
18
19
import java .util .Map ;
19
20
20
- public class SwipeLayout extends ViewGroup {
21
+ public class SwipeLayout extends FrameLayout {
21
22
22
23
private ViewDragHelper mDragHelper ;
23
24
@@ -588,57 +589,12 @@ void layoutLayDown(){
588
589
589
590
@ Override
590
591
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
+
607
594
if (mDragEdge == DragEdge .Left || mDragEdge == DragEdge .Right )
608
595
mDragDistance = getBottomView ().getMeasuredWidth ();
609
596
else
610
597
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
-
642
598
}
643
599
644
600
@ Override
@@ -1058,4 +1014,4 @@ private Rect computeBottomLayDown(DragEdge dragEdge){
1058
1014
private int dp2px (float dp ){
1059
1015
return (int ) (dp * getContext ().getResources ().getDisplayMetrics ().density + 0.5f );
1060
1016
}
1061
- }
1017
+ }
0 commit comments