Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_vedio
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
android
android_vedio
Commits
d48b9df8
Commit
d48b9df8
authored
Aug 15, 2023
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码优化
parent
2d3ab50a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
11 deletions
+65
-11
build.gradle
video/app/build.gradle
+2
-0
MainActivity.kt
.../java/com/duben/happyplaylet/ui/activitys/MainActivity.kt
+54
-1
shape_phone_left.xml
video/app/src/main/res/drawable/shape_phone_left.xml
+1
-2
float_app.xml
video/app/src/main/res/layout/float_app.xml
+8
-8
No files found.
video/app/build.gradle
View file @
d48b9df8
...
@@ -220,6 +220,8 @@ dependencies {
...
@@ -220,6 +220,8 @@ dependencies {
implementation
'com.airbnb.android:lottie:3.4.0'
implementation
'com.airbnb.android:lottie:3.4.0'
// 跑马灯
// 跑马灯
implementation
'com.sunfusheng:MarqueeView:1.4.1'
implementation
'com.sunfusheng:MarqueeView:1.4.1'
// 悬浮窗
implementation
'com.github.princekin-f:EasyFloat:1.3.4'
// 工具类
// 工具类
// BASE64Decoder接入
// BASE64Decoder接入
// 兼容奔溃问题-Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
// 兼容奔溃问题-Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
...
...
video/app/src/main/java/com/duben/happyplaylet/ui/activitys/MainActivity.kt
View file @
d48b9df8
...
@@ -5,6 +5,7 @@ import android.content.Intent
...
@@ -5,6 +5,7 @@ import android.content.Intent
import
android.media.AudioManager
import
android.media.AudioManager
import
android.net.Uri
import
android.net.Uri
import
android.os.Bundle
import
android.os.Bundle
import
android.view.Gravity
import
android.view.KeyEvent
import
android.view.KeyEvent
import
android.view.View
import
android.view.View
import
android.widget.TextView
import
android.widget.TextView
...
@@ -22,6 +23,10 @@ import com.duben.happyplaylet.ui.fragment.RecommendFragment
...
@@ -22,6 +23,10 @@ import com.duben.happyplaylet.ui.fragment.RecommendFragment
import
com.duben.happyplaylet.ui.widgets.DialogListener
import
com.duben.happyplaylet.ui.widgets.DialogListener
import
com.duben.happyplaylet.ui.widgets.PhoneDialog
import
com.duben.happyplaylet.ui.widgets.PhoneDialog
import
com.duben.happyplaylet.video.csj.DPHolderManager
import
com.duben.happyplaylet.video.csj.DPHolderManager
import
com.lzf.easyfloat.EasyFloat
import
com.lzf.easyfloat.anim.AppFloatDefaultAnimator
import
com.lzf.easyfloat.anim.DefaultAnimator
import
com.lzf.easyfloat.enums.SidePattern
import
kotlinx.android.synthetic.main.activity_main.*
import
kotlinx.android.synthetic.main.activity_main.*
/**
/**
...
@@ -79,7 +84,7 @@ class MainActivity : BaseActivity(), View.OnClickListener {
...
@@ -79,7 +84,7 @@ class MainActivity : BaseActivity(), View.OnClickListener {
initEditView
()
initEditView
()
initEasyFloat
()
}
}
override
fun
isApplyKitKatTranslucency
():
Boolean
{
override
fun
isApplyKitKatTranslucency
():
Boolean
{
...
@@ -286,4 +291,52 @@ class MainActivity : BaseActivity(), View.OnClickListener {
...
@@ -286,4 +291,52 @@ class MainActivity : BaseActivity(), View.OnClickListener {
ll_bottom_tab
.
background
=
ContextCompat
.
getDrawable
(
context
,
R
.
color
.
white
)
ll_bottom_tab
.
background
=
ContextCompat
.
getDrawable
(
context
,
R
.
color
.
white
)
}
}
}
}
private
fun
initEasyFloat
()
{
EasyFloat
.
with
(
this
)
// 设置浮窗xml布局文件,并可设置详细信息
.
setLayout
(
R
.
layout
.
float_app
)
{
it
.
findViewById
<
TextView
>(
R
.
id
.
tv_float
).
setOnClickListener
{
backPhoneDialog
()
}
}
// 设置吸附方式,共15种模式,详情参考SidePattern
.
setSidePattern
(
SidePattern
.
RESULT_HORIZONTAL
)
// 设置浮窗是否可拖拽,默认可拖拽
.
setDragEnable
(
false
)
// 系统浮窗是否包含EditText,仅针对系统浮窗,默认不包含
.
hasEditText
(
false
)
// 设置浮窗的对齐方式和坐标偏移量
.
setGravity
(
Gravity
.
CENTER_VERTICAL
,
0
,
200
)
// 设置宽高是否充满父布局,直接在xml设置match_parent属性无效
.
setMatchParent
(
widthMatch
=
false
,
heightMatch
=
false
)
// 设置Activity浮窗的出入动画,可自定义,实现相应接口即可(策略模式),无需动画直接设置为null
.
setAnimator
(
DefaultAnimator
())
// 设置系统浮窗的出入动画,使用同上
.
setAppFloatAnimator
(
AppFloatDefaultAnimator
())
// 设置系统浮窗的不需要显示的页面
// 浮窗的一些状态回调,如:创建结果、显示、隐藏、销毁、touchEvent、拖拽过程、拖拽结束。
// ps:通过Kotlin DSL实现的回调,可以按需复写方法,用到哪个写哪个
.
registerCallback
{
createResult
{
isCreated
,
msg
,
view
->
}
show
{
}
hide
{
}
dismiss
{
}
touchEvent
{
view
,
motionEvent
->
}
// drag { view, motionEvent ->
// view.findViewById<TextView>(R.id.tv_float).apply {
// text = "我被拖拽..."
// setBackgroundResource(R.drawable.shape_banner_write)
// }
// }
dragEnd
{
it
.
findViewById
<
TextView
>(
R
.
id
.
tv_float
).
apply
{
text
=
"联系\n客服"
val
location
=
IntArray
(
2
)
getLocationOnScreen
(
location
)
setBackgroundResource
(
if
(
location
[
0
]
>
10
)
R
.
drawable
.
shape_phone_left
else
R
.
drawable
.
shape_phone_right
)
}
}
}
.
show
()
}
}
}
\ No newline at end of file
video/app/src/main/res/drawable/shape_phone_left.xml
View file @
d48b9df8
...
@@ -5,7 +5,6 @@
...
@@ -5,7 +5,6 @@
<solid
android:color=
"@color/my_color_gray"
/>
<solid
android:color=
"@color/my_color_gray"
/>
<!-- 设置按钮的四个角为弧形 -->
<!-- 设置按钮的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<!-- android:radius 弧形的半径 -->
<corners
android:bottomLeftRadius=
"30dp"
<corners
android:radius=
"5dp"
/>
android:topLeftRadius=
"30dp"
/>
</shape>
</shape>
\ No newline at end of file
video/app/src/main/res/layout/float_app.xml
View file @
d48b9df8
...
@@ -4,15 +4,15 @@
...
@@ -4,15 +4,15 @@
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"@drawable/shape_phone_left"
android:background=
"@drawable/shape_phone_left"
android:drawable
Left
=
"@mipmap/ic_kefu"
android:drawable
Top
=
"@mipmap/ic_kefu"
android:drawablePadding=
"
4
dp"
android:drawablePadding=
"
8
dp"
android:gravity=
"center"
android:gravity=
"center"
android:paddingTop=
"4dp"
android:paddingLeft=
"4dp"
android:paddingBottom=
"4dp"
android:paddingTop=
"10dp"
android:paddingLeft=
"10dp"
android:paddingRight=
"4dp"
android:paddingBottom=
"10dp"
android:text=
"联\n系\n客\n服"
android:textColor=
"@color/black"
android:textColor=
"@color/black"
android:paddingRight=
"10dp"
android:textSize=
"11sp"
>
android:textSize=
"11sp"
android:text=
"联系\n客服"
>
</TextView>
</TextView>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment