Skip to content

Commit 48bf9da

Browse files
committed
[mymusicplayer] Add new lib for implementation
1 parent c767a6a commit 48bf9da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+6474
-4
lines changed

app-catalog/samples/mymusicplayer/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ android {
2121
}
2222

2323
dependencies {
24-
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
25-
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.6.2"
26-
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2"
27-
implementation project(path: ':app-catalog:samples:toaster:libtoaster')
24+
implementation libs.androidx.constraintlayout
25+
implementation libs.androidx.lifecycle.livedata.ktx
26+
implementation libs.androidx.lifecycle.viewmodel.ktx
2827
implementation 'com.karumi:dexter:5.0.0'
28+
implementation project(path: ':app-catalog:samples:toaster:libtoaster')
2929
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
apply from: "$rootDir/gradle/sample-build.gradle"
2+
3+
android {
4+
namespace 'lib.wintmain.music'
5+
buildFeatures {
6+
buildConfig = true
7+
dataBinding = true
8+
}
9+
}
10+
11+
dependencies {
12+
api(libs.kotlinx.coroutines.core)
13+
api(libs.kotlinx.coroutines.android)
14+
15+
api(libs.androidx.viewpager2)
16+
17+
api(libs.androidx.constraintlayout)
18+
api(libs.multidex)
19+
20+
/**
21+
* lifecycle相关包括liveData、viewModel
22+
*/
23+
api(libs.androidx.lifecycle.extensions)
24+
api(libs.androidx.lifecycle.livedata.ktx)
25+
api(libs.androidx.lifecycle.viewmodel.ktx)
26+
27+
/**
28+
* navigation相关
29+
*/
30+
api(libs.androidx.navigation.fragment)
31+
api(libs.androidx.navigation.ui)
32+
33+
api(libs.androidx.room.runtime)
34+
api(libs.androidx.room.ktx)
35+
//kapt("androidx.room:room-compiler:2.2.3")
36+
37+
api("com.squareup.okhttp3:okhttp:4.12.0")
38+
api("io.reactivex.rxjava2:rxjava:2.2.14")
39+
api("io.reactivex.rxjava2:rxandroid:2.1.1")
40+
api("com.github.franmontiel:PersistentCookieJar:v1.0.1")
41+
api("com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.50")
42+
api("org.greenrobot:eventbus:3.2.0")
43+
api("com.wang.avi:library:2.1.3")
44+
api("cn.bingoogolapple:bga-banner:2.2.7")
45+
api("com.github.hackware1993:MagicIndicator:1.6.0")
46+
api("pub.devrel:easypermissions:3.0.0")
47+
api("com.github.donkingliang:LabelsView:1.6.1")
48+
api("com.github.tbruyelle:rxpermissions:0.12")
49+
api("com.github.lihangleo2:ShadowLayout:3.1.3")
50+
51+
api("com.squareup.retrofit2:retrofit:2.9.0")
52+
api("com.squareup.retrofit2:converter-scalars:2.9.0")
53+
api("com.squareup.retrofit2:converter-gson:2.9.0")
54+
55+
api("com.github.bumptech.glide:glide:4.11.0")
56+
api("jp.wasabeef:glide-transformations:4.1.0")
57+
58+
api(libs.smartrefreshlayout)
59+
api(libs.smartrefreshheader)
60+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright 2023-2024 wintmain
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ https://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
18+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
19+
package="lib.wintmain.music">
20+
21+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
22+
23+
</manifest>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2023-2024 wintmain
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package lib.wintmain.music
18+
19+
import android.app.Application
20+
import android.content.Context
21+
22+
open class BaseApp : Application() {
23+
24+
override fun onCreate() {
25+
super.onCreate()
26+
baseApplication = this
27+
}
28+
29+
companion object {
30+
private lateinit var baseApplication: BaseApp
31+
32+
fun getContext(): Context {
33+
return baseApplication
34+
}
35+
}
36+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright 2023-2024 wintmain
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package lib.wintmain.music.base
18+
19+
import android.content.Context
20+
import android.widget.FrameLayout
21+
import androidx.coordinatorlayout.widget.CoordinatorLayout
22+
import androidx.fragment.app.FragmentActivity
23+
import com.google.android.material.bottomsheet.BottomSheetBehavior
24+
import com.google.android.material.bottomsheet.BottomSheetDialog
25+
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
26+
import lib.wintmain.music.R
27+
28+
/**
29+
* des 可滑动的dialog
30+
*/
31+
open class BaseBottomSheetDialog : BottomSheetDialogFragment() {
32+
private var bottomSheet: FrameLayout? = null
33+
private var behavior: BottomSheetBehavior<FrameLayout>? = null
34+
35+
protected var fragmentActivity: FragmentActivity? = null
36+
37+
override fun onAttach(context: Context) {
38+
super.onAttach(context)
39+
if (context is FragmentActivity) {
40+
fragmentActivity = context
41+
}
42+
}
43+
44+
override fun onStart() {
45+
super.onStart()
46+
val dialog = dialog as BottomSheetDialog?
47+
bottomSheet =
48+
dialog?.delegate?.findViewById(com.google.android.material.R.id.design_bottom_sheet)
49+
bottomSheet?.let {
50+
val layoutParams = it.layoutParams as CoordinatorLayout.LayoutParams
51+
layoutParams.height = getHeight()
52+
it.layoutParams = layoutParams
53+
behavior = BottomSheetBehavior.from(it)
54+
behavior?.peekHeight = getHeight()
55+
// 初始为展开状态
56+
behavior?.state = BottomSheetBehavior.STATE_EXPANDED
57+
}
58+
}
59+
60+
/**
61+
* 主题
62+
*/
63+
override fun getTheme(): Int {
64+
return R.style.sheet_dialog_style
65+
}
66+
67+
/**
68+
* 高度 子类可复写
69+
*/
70+
protected fun getHeight(): Int {
71+
return (resources.displayMetrics.heightPixels.toFloat() * 0.7).toInt()
72+
}
73+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2023-2024 wintmain
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package lib.wintmain.music.base
18+
19+
import android.content.Context
20+
import android.view.ViewGroup
21+
import androidx.databinding.ViewDataBinding
22+
import lib.wintmain.music.utils.StatusUtils
23+
import lib.wintmain.music.view.LoadingTip
24+
25+
abstract class BaseLazyLoadingFragment<BD : ViewDataBinding> : LazyVmFragment<BD>() {
26+
27+
private var gloding: LoadingTip? = null
28+
override fun onAttach(context: Context) {
29+
super.onAttach(context)
30+
if (context is BaseLoadingActivity) {
31+
gloding = context.loadingTip
32+
}
33+
}
34+
35+
/**
36+
* 设置loadingView上下变局
37+
*/
38+
protected fun setLoadingMargin(topMargin: Int, bottomMargin: Int) {
39+
val loadMarginTop = StatusUtils.getStatusBarHeight(mActivity) + topMargin
40+
val loadMarginBottom = StatusUtils.getNavigationBarHeight(mActivity) + bottomMargin
41+
val params = gloding?.layoutParams as ViewGroup.MarginLayoutParams
42+
params.topMargin = loadMarginTop
43+
params.bottomMargin = loadMarginBottom
44+
gloding?.layoutParams = params
45+
}
46+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright 2023-2024 wintmain
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package lib.wintmain.music.base
18+
19+
import android.os.Bundle
20+
import android.widget.FrameLayout
21+
import lib.wintmain.music.common.dip2px
22+
import lib.wintmain.music.utils.StatusUtils
23+
import lib.wintmain.music.view.LoadingTip
24+
25+
/**
26+
* des 带loading的Activity
27+
*/
28+
abstract class BaseLoadingActivity : BaseVmActivity() {
29+
private var decorView: FrameLayout? = null
30+
var loadingTip: LoadingTip? = null
31+
32+
override fun init(savedInstanceState: Bundle?) {
33+
decorView = window.decorView as FrameLayout
34+
val loadMarginTop = StatusUtils.getStatusBarHeight(this) + dip2px(this, 50f)
35+
val loadMarginBottom = StatusUtils.getNavigationBarHeight(this)
36+
val params = FrameLayout.LayoutParams(
37+
FrameLayout.LayoutParams.MATCH_PARENT,
38+
FrameLayout.LayoutParams.MATCH_PARENT
39+
)
40+
params.topMargin = loadMarginTop
41+
params.bottomMargin = loadMarginBottom
42+
loadingTip = LoadingTip(this)
43+
decorView?.addView(loadingTip, params)
44+
init2(savedInstanceState)
45+
}
46+
47+
abstract fun init2(savedInstanceState: Bundle?)
48+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2023-2024 wintmain
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package lib.wintmain.music.base
18+
19+
import android.content.Context
20+
import android.view.ViewGroup
21+
import androidx.databinding.ViewDataBinding
22+
import lib.wintmain.music.utils.StatusUtils
23+
import lib.wintmain.music.view.LoadingTip
24+
25+
abstract class BaseLoadingFragment<BD : ViewDataBinding> : BaseVmFragment<BD>() {
26+
27+
private var gloding: LoadingTip? = null
28+
override fun onAttach(context: Context) {
29+
super.onAttach(context)
30+
if (context is BaseLoadingActivity) {
31+
gloding = context.loadingTip
32+
}
33+
}
34+
35+
/**
36+
* 设置loadingView上下变局
37+
*/
38+
protected fun setLoadingMargin(topMargin: Int, bottomMargin: Int) {
39+
val loadMarginTop = StatusUtils.getStatusBarHeight(mActivity) + topMargin
40+
val loadMarginBottom = StatusUtils.getNavigationBarHeight(mActivity) + bottomMargin
41+
val params = gloding?.layoutParams as ViewGroup.MarginLayoutParams
42+
params.topMargin = loadMarginTop
43+
params.bottomMargin = loadMarginBottom
44+
gloding?.layoutParams = params
45+
}
46+
}

0 commit comments

Comments
 (0)