Skip to content

Commit aaca3a0

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 13dfd5b + dc59849 commit aaca3a0

File tree

6 files changed

+131
-9
lines changed

6 files changed

+131
-9
lines changed

.idea/misc.xml

Lines changed: 7 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
package com.heyanle.eplayer_standard.component
2+
3+
import android.content.Context
4+
import android.util.AttributeSet
5+
import android.view.LayoutInflater
6+
import android.view.View
7+
import android.widget.FrameLayout
8+
import android.widget.RelativeLayout
9+
import com.heyanle.eplayer_core.constant.EasyPlayStatus
10+
import com.heyanle.eplayer_core.controller.ComponentContainer
11+
import com.heyanle.eplayer_core.controller.IComponent
12+
import com.heyanle.eplayer_standard.databinding.ComponentErrorBinding
13+
14+
/**
15+
* Create by heyanlin on 2022/11/10
16+
*/
17+
class ErrorComponent: FrameLayout, IComponent {
18+
19+
private val binding: ComponentErrorBinding = ComponentErrorBinding.inflate(LayoutInflater.from(context), this, true)
20+
21+
private var container: ComponentContainer? = null
22+
23+
init {
24+
visibility = View.GONE
25+
binding.btRetry.setOnClickListener {
26+
visibility = View.GONE
27+
runWithContainer {
28+
replay(false)
29+
}
30+
}
31+
}
32+
33+
override fun getView(): View {
34+
return this
35+
}
36+
37+
override fun getLayoutParam(): RelativeLayout.LayoutParams {
38+
return RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)
39+
}
40+
41+
private fun requireContainer(): ComponentContainer {
42+
return container ?: throw NullPointerException()
43+
}
44+
45+
private inline fun runWithContainer(block: ComponentContainer.()->Unit){
46+
container?.block()
47+
}
48+
49+
override fun onAttachToContainer(container: ComponentContainer) {
50+
this.container = container
51+
}
52+
53+
override fun onDetachToContainer(container: ComponentContainer) {
54+
this.container = null
55+
}
56+
57+
override fun onPlayStateChanged(playState: Int) {
58+
super.onPlayStateChanged(playState)
59+
if(playState == EasyPlayStatus.STATE_ERROR) {
60+
visibility = View.VISIBLE
61+
}else if(playState == EasyPlayStatus.STATE_IDLE) {
62+
visibility = View.GONE
63+
}
64+
}
65+
66+
67+
68+
constructor(context: Context) : super(context)
69+
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
70+
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
71+
context,
72+
attrs,
73+
defStyleAttr
74+
)
75+
76+
constructor(
77+
context: Context,
78+
attrs: AttributeSet?,
79+
defStyleAttr: Int,
80+
defStyleRes: Int
81+
) : super(context, attrs, defStyleAttr, defStyleRes)
82+
83+
84+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:app="http://schemas.android.com/apk/res-auto"
5+
xmlns:tools="http://schemas.android.com/tools"
6+
android:visibility="gone"
7+
tools:visibility="visible"
8+
android:id="@+id/center_container"
9+
android:layout_width="match_parent"
10+
android:layout_height="match_parent"
11+
android:layout_gravity="center"
12+
android:background="#96000000"
13+
android:gravity="center"
14+
android:orientation="vertical">
15+
16+
<TextView
17+
android:textSize="24sp"
18+
android:textColor="@android:color/white"
19+
android:text="@string/play_error"
20+
android:layout_width="wrap_content"
21+
android:layout_height="wrap_content"/>
22+
23+
<com.google.android.material.button.MaterialButton
24+
android:layout_marginTop="8dp"
25+
android:id="@+id/bt_retry"
26+
android:text="@string/retry"
27+
android:layout_width="wrap_content"
28+
android:layout_height="wrap_content"/>
29+
30+
</LinearLayout>

eplayer-standard/src/main/res/layout/component_long_press.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
android:layout_gravity="center_horizontal|top"
77
android:layout_width="160dp"
88
android:textColor="@android:color/white"
9-
android:text="加速播放中"
9+
android:text="@string/play_speeding_up"
1010
android:gravity="center"
1111
android:layout_height="32dp"
1212
android:background="#96000000"

eplayer-standard/src/main/res/layout/component_volume_brightness.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
xmlns:app="http://schemas.android.com/apk/res-auto"
55
xmlns:tools="http://schemas.android.com/tools"
66
android:visibility="gone"
7+
tools:visibility="visible"
78
android:id="@+id/center_container"
89
android:layout_width="160dp"
910
android:layout_height="120dp"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<resources>
2+
<string name="app_name">EasyPlayer</string>
3+
4+
<string name="play_error">出了点小问题,请点击重试</string>
5+
<string name="retry">重试</string>
6+
7+
<string name="play_speeding_up">两倍速播放中</string>
8+
</resources>

0 commit comments

Comments
 (0)