Skip to content

Commit 20a2b12

Browse files
committed
Code Sync
1 parent 3df4085 commit 20a2b12

6 files changed

Lines changed: 654 additions & 0 deletions

File tree

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package com.xapps.media.xmusic.widget;
2+
3+
import android.content.Context;
4+
import android.os.Trace;
5+
import android.util.AttributeSet;
6+
import android.view.View;
7+
import android.widget.LinearLayout;
8+
9+
public class RemainingHeightLinearLayout extends LinearLayout {
10+
11+
public RemainingHeightLinearLayout(Context context) {
12+
super(context);
13+
init();
14+
}
15+
16+
public RemainingHeightLinearLayout(Context context, AttributeSet attrs) {
17+
super(context, attrs);
18+
init();
19+
}
20+
21+
public RemainingHeightLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) {
22+
super(context, attrs, defStyleAttr);
23+
init();
24+
}
25+
26+
private void init() {
27+
setOrientation(VERTICAL);
28+
}
29+
30+
@Override
31+
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
32+
Trace.beginSection("RHLL:onMeasure");
33+
try {
34+
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
35+
36+
int childCount = getChildCount();
37+
if (childCount == 0) {
38+
return;
39+
}
40+
41+
View lastChild = getChildAt(childCount - 1);
42+
if (lastChild.getVisibility() == GONE) {
43+
return;
44+
}
45+
46+
int usedHeight = getPaddingTop() + getPaddingBottom();
47+
48+
for (int i = 0; i < childCount - 1; i++) {
49+
View child = getChildAt(i);
50+
51+
if (child.getVisibility() == GONE) {
52+
continue;
53+
}
54+
55+
MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();
56+
usedHeight += child.getMeasuredHeight();
57+
usedHeight += lp.topMargin + lp.bottomMargin;
58+
}
59+
60+
MarginLayoutParams lp = (MarginLayoutParams) lastChild.getLayoutParams();
61+
62+
int remainingHeight = getMeasuredHeight()
63+
- usedHeight
64+
- lp.topMargin
65+
- lp.bottomMargin;
66+
67+
if (remainingHeight < 0) {
68+
remainingHeight = 0;
69+
}
70+
71+
int childWidthSpec = getChildMeasureSpec(
72+
widthMeasureSpec,
73+
getPaddingLeft()
74+
+ getPaddingRight()
75+
+ lp.leftMargin
76+
+ lp.rightMargin,
77+
lp.width);
78+
79+
int childHeightSpec = MeasureSpec.makeMeasureSpec(
80+
remainingHeight,
81+
MeasureSpec.EXACTLY);
82+
83+
lastChild.measure(childWidthSpec, childHeightSpec);
84+
} finally {
85+
Trace.endSection();
86+
}
87+
}
88+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:width="24dp"
4+
android:height="24dp"
5+
android:viewportWidth="24"
6+
android:viewportHeight="24"
7+
android:tint="#FFE6E0E9">
8+
<path
9+
android:fillColor="@android:color/white"
10+
android:pathData="M11.01 3.05C6.51 3.54 3 7.36 3 12a9 9 0 0 0 9 9c4.63 0 8.45-3.5 8.95-8c.09-.79-.78-1.42-1.54-.95A5.403 5.403 0 0 1 11.1 7.5c0-1.06.31-2.06.84-2.89c.45-.67-.04-1.63-.93-1.56z" />
11+
</vector>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:width="24dp"
4+
android:height="24dp"
5+
android:viewportWidth="24"
6+
android:viewportHeight="24"
7+
android:tint="#FFE6E0E9">
8+
<path
9+
android:fillColor="@android:color/white"
10+
android:pathData="M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5s5-2.24 5-5s-2.24-5-5-5zM2 13h2c.55 0 1-.45 1-1s-.45-1-1-1H2c-.55 0-1 .45-1 1s.45 1 1 1zm18 0h2c.55 0 1-.45 1-1s-.45-1-1-1h-2c-.55 0-1 .45-1 1s.45 1 1 1zM11 2v2c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1s-1 .45-1 1zm0 18v2c0 .55.45 1 1 1s1-.45 1-1v-2c0-.55-.45-1-1-1s-1 .45-1 1zM5.99 4.58a.996.996 0 0 0-1.41 0a.996.996 0 0 0 0 1.41l1.06 1.06c.39.39 1.03.39 1.41 0s.39-1.03 0-1.41L5.99 4.58zm12.37 12.37a.996.996 0 0 0-1.41 0a.996.996 0 0 0 0 1.41l1.06 1.06c.39.39 1.03.39 1.41 0a.996.996 0 0 0 0-1.41l-1.06-1.06zm1.06-10.96a.996.996 0 0 0 0-1.41a.996.996 0 0 0-1.41 0l-1.06 1.06c-.39.39-.39 1.03 0 1.41s1.03.39 1.41 0l1.06-1.06zM7.05 18.36a.996.996 0 0 0 0-1.41a.996.996 0 0 0-1.41 0l-1.06 1.06c-.39.39-.39 1.03 0 1.41s1.03.39 1.41 0l1.06-1.06z" />
11+
</vector>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:width="24dp"
4+
android:height="24dp"
5+
android:viewportWidth="24"
6+
android:viewportHeight="24"
7+
android:tint="#FFE6E0E9">
8+
<path
9+
android:fillColor="@android:color/white"
10+
android:pathData="M7.5,2C5.71,3.15 4.5,5.18 4.5,7.5C4.5,9.82 5.71,11.85 7.53,13C4.46,13 2,10.54 2,7.5A5.5,5.5 0 0,1 7.5,2M19.07,3.5L20.5,4.93L4.93,20.5L3.5,19.07L19.07,3.5M12.89,5.93L11.41,5L9.97,6L10.39,4.3L9,3.24L10.75,3.12L11.33,1.47L12,3.1L13.73,3.13L12.38,4.26L12.89,5.93M9.59,9.54L8.43,8.81L7.31,9.59L7.65,8.27L6.56,7.44L7.92,7.35L8.37,6.06L8.88,7.33L10.24,7.36L9.19,8.23L9.59,9.54M19,13.5A5.5,5.5 0 0,1 13.5,19C12.28,19 11.15,18.6 10.24,17.93L17.93,10.24C18.6,11.15 19,12.28 19,13.5M14.6,20.08L17.37,18.93L17.13,22.28L14.6,20.08M18.93,17.38L20.08,14.61L22.28,17.15L18.93,17.38M20.08,12.42L18.94,9.64L22.28,9.88L20.08,12.42M9.63,18.93L12.4,20.08L9.87,22.27L9.63,18.93Z" />
11+
</vector>

0 commit comments

Comments
 (0)