Code refactor
This commit is contained in:
parent
546d974084
commit
3af3a89ba5
7 changed files with 33 additions and 23 deletions
|
@ -32,7 +32,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), OnSharedPreferenceChangeLis
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createContentView(): View {
|
override fun createContentView(): View {
|
||||||
return wrapSlidingMusicPanel(R.layout.activity_main_content)
|
return wrapSlidingMusicPanel()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
package code.name.monkey.retromusic.activities.base
|
package code.name.monkey.retromusic.activities.base
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.ViewTreeObserver
|
import android.view.ViewTreeObserver
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import androidx.annotation.LayoutRes
|
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.fragment.app.commit
|
||||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
|
@ -124,12 +125,13 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
||||||
bottomSheetBehavior.removeBottomSheetCallback(bottomSheetCallbackList)
|
bottomSheetBehavior.removeBottomSheetCallback(bottomSheetCallbackList)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun wrapSlidingMusicPanel(@LayoutRes resId: Int): View {
|
@SuppressLint("InflateParams")
|
||||||
|
protected fun wrapSlidingMusicPanel(): View {
|
||||||
val slidingMusicPanelLayout =
|
val slidingMusicPanelLayout =
|
||||||
layoutInflater.inflate(R.layout.sliding_music_panel_layout, null)
|
layoutInflater.inflate(R.layout.sliding_music_panel_layout, null)
|
||||||
val contentContainer: ViewGroup =
|
val contentContainer: ViewGroup =
|
||||||
slidingMusicPanelLayout.findViewById(R.id.mainContentFrame)
|
slidingMusicPanelLayout.findViewById(R.id.mainContentFrame)
|
||||||
layoutInflater.inflate(resId, contentContainer)
|
layoutInflater.inflate(R.layout.activity_main_content, contentContainer)
|
||||||
return slidingMusicPanelLayout
|
return slidingMusicPanelLayout
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,8 +336,8 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
||||||
COLLAPSED_WITH -> {
|
COLLAPSED_WITH -> {
|
||||||
val heightOfBar = bottomNavigationView.height
|
val heightOfBar = bottomNavigationView.height
|
||||||
val height = if (isQueueEmpty) 0 else (heightOfBar * 2) - 24
|
val height = if (isQueueEmpty) 0 else (heightOfBar * 2) - 24
|
||||||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
ViewCompat.setElevation(bottomNavigationView, 20f)
|
||||||
ViewCompat.setElevation(slidingPanel, 10f)
|
ViewCompat.setElevation(slidingPanel, 20f)
|
||||||
bottomSheetBehavior.isHideable = false
|
bottomSheetBehavior.isHideable = false
|
||||||
bottomSheetBehavior.peekHeightAnimate(height)
|
bottomSheetBehavior.peekHeightAnimate(height)
|
||||||
bottomNavigationView.translateXAnimate(0f)
|
bottomNavigationView.translateXAnimate(0f)
|
||||||
|
@ -383,12 +385,11 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
||||||
Classic -> ClassicPlayerFragment()
|
Classic -> ClassicPlayerFragment()
|
||||||
else -> PlayerFragment()
|
else -> PlayerFragment()
|
||||||
} // must implement AbsPlayerFragment
|
} // must implement AbsPlayerFragment
|
||||||
supportFragmentManager.beginTransaction().replace(R.id.playerFragmentContainer, fragment)
|
supportFragmentManager.commit {
|
||||||
.commit()
|
replace(R.id.playerFragmentContainer, fragment)
|
||||||
|
}
|
||||||
supportFragmentManager.executePendingTransactions()
|
supportFragmentManager.executePendingTransactions()
|
||||||
|
playerFragment = whichFragment<AbsPlayerFragment>(R.id.playerFragmentContainer)
|
||||||
playerFragment =
|
|
||||||
supportFragmentManager.findFragmentById(R.id.playerFragmentContainer) as AbsPlayerFragment
|
|
||||||
miniPlayerFragment = whichFragment<MiniPlayerFragment>(R.id.miniPlayerFragment)
|
miniPlayerFragment = whichFragment<MiniPlayerFragment>(R.id.miniPlayerFragment)
|
||||||
miniPlayerFragment?.view?.setOnClickListener { expandPanel() }
|
miniPlayerFragment?.view?.setOnClickListener { expandPanel() }
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,7 +201,6 @@ class ClassicPlayerFragment : AbsPlayerFragment(R.layout.fragment_classic_player
|
||||||
|
|
||||||
override fun onPlayStateChanged() {
|
override fun onPlayStateChanged() {
|
||||||
updatePlayPauseDrawableState()
|
updatePlayPauseDrawableState()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onRepeatModeChanged() {
|
override fun onRepeatModeChanged() {
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
tools:ignore="ContentDescription,UnusedAttribute"
|
tools:ignore="ContentDescription,UnusedAttribute"
|
||||||
tools:srcCompat="@tools:sample/backgrounds/scenic[5]" />
|
tools:srcCompat="@tools:sample/backgrounds/scenic" />
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -12,15 +12,22 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<fragment
|
<FrameLayout
|
||||||
android:id="@+id/playerAlbumCoverFragment"
|
android:id="@+id/albumCoverContainer"
|
||||||
android:name="code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment"
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
app:layout_constraintDimensionRatio="1:1"
|
app:layout_constraintDimensionRatio="1:1"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/playerAlbumCoverFragment"
|
||||||
|
android:name="code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:layout="@layout/fragment_album_cover" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
|
||||||
<View
|
<View
|
||||||
|
@ -60,9 +67,10 @@
|
||||||
layout="@layout/fragment_classic_controls"
|
layout="@layout/fragment_classic_controls"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:elevation="24dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/playerAlbumCoverFragment" />
|
app:layout_constraintTop_toBottomOf="@id/albumCoverContainer" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
@ -70,10 +78,11 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="bottom"
|
android:gravity="bottom"
|
||||||
|
android:theme="@style/TopCornerCardView"
|
||||||
app:behavior_hideable="false"
|
app:behavior_hideable="false"
|
||||||
app:cardCornerRadius="0dp"
|
app:cardElevation="24dp"
|
||||||
app:cardElevation="12dp"
|
app:layout_behavior="code.name.monkey.retromusic.RetroBottomSheetBehavior"
|
||||||
app:layout_behavior="code.name.monkey.retromusic.RetroBottomSheetBehavior">
|
tools:peekHeight="0dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -94,7 +103,7 @@
|
||||||
android:paddingTop="16dp"
|
android:paddingTop="16dp"
|
||||||
android:scrollHorizontally="true"
|
android:scrollHorizontally="true"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textAppearance="@style/TextViewSubtitle1"
|
android:textAppearance="@style/TextViewHeadline6"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
tools:text="@tools:sample/lorem/random" />
|
tools:text="@tools:sample/lorem/random" />
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/container"
|
android:id="@+id/container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
|
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="56dp"
|
android:layout_height="56dp"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
|
android:background="?attr/colorSurface"
|
||||||
android:elevation="0dp"
|
android:elevation="0dp"
|
||||||
app:itemHorizontalTranslationEnabled="false"
|
app:itemHorizontalTranslationEnabled="false"
|
||||||
app:itemIconTint="@drawable/bottom_navigation_item_colors"
|
app:itemIconTint="@drawable/bottom_navigation_item_colors"
|
||||||
|
|
Loading…
Reference in a new issue