Code refactor
This commit is contained in:
parent
3489e3ba28
commit
d5d77afaaf
14 changed files with 40 additions and 99 deletions
BIN
app/src/debug/res/font/google_sans_bold.ttf
Normal file
BIN
app/src/debug/res/font/google_sans_bold.ttf
Normal file
Binary file not shown.
BIN
app/src/debug/res/font/google_sans_medium.ttf
Normal file
BIN
app/src/debug/res/font/google_sans_medium.ttf
Normal file
Binary file not shown.
BIN
app/src/debug/res/font/google_sans_regular.ttf
Normal file
BIN
app/src/debug/res/font/google_sans_regular.ttf
Normal file
Binary file not shown.
|
@ -1,13 +1,12 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<font-family xmlns:android="http://schemas.android.com/apk/res/android"
|
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
|
||||||
<font
|
<font
|
||||||
android:font="@font/regular"
|
android:font="@font/google_sans_regular"
|
||||||
android:fontWeight="400" />
|
android:fontWeight="400" />
|
||||||
<font
|
<font
|
||||||
android:font="@font/medium"
|
android:font="@font/google_sans_medium"
|
||||||
android:fontWeight="600" />
|
android:fontWeight="600" />
|
||||||
<font
|
<font
|
||||||
android:font="@font/bold"
|
android:font="@font/google_sans_bold"
|
||||||
android:fontWeight="700" />
|
android:fontWeight="700" />
|
||||||
</font-family>
|
</font-family>
|
|
@ -255,11 +255,9 @@
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="com.bumptech.glide.integration.okhttp3.OkHttpGlideModule"
|
android:name="com.bumptech.glide.integration.okhttp3.OkHttpGlideModule"
|
||||||
android:value="GlideModule" />
|
android:value="GlideModule" />
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="com.android.vending.splits.required"
|
android:name="com.android.vending.splits.required"
|
||||||
android:value="true" />
|
android:value="true" />
|
||||||
<meta-data
|
|
||||||
android:name="preloaded_fonts"
|
|
||||||
android:resource="@array/preloaded_fonts" />
|
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
|
@ -109,6 +109,12 @@ class HomeAdapter(
|
||||||
FAVOURITES -> {
|
FAVOURITES -> {
|
||||||
val viewHolder = holder as PlaylistViewHolder
|
val viewHolder = holder as PlaylistViewHolder
|
||||||
viewHolder.bindView(home.arrayList, R.string.favorites)
|
viewHolder.bindView(home.arrayList, R.string.favorites)
|
||||||
|
viewHolder.clickableArea.setOnClickListener {
|
||||||
|
activity.findNavController(R.id.fragment_container).navigate(
|
||||||
|
R.id.detailListFragment,
|
||||||
|
bundleOf("type" to FAVOURITES)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
GENRES -> {
|
GENRES -> {
|
||||||
val viewHolder = holder as GenreViewHolder
|
val viewHolder = holder as GenreViewHolder
|
||||||
|
@ -183,7 +189,6 @@ class HomeAdapter(
|
||||||
|
|
||||||
private inner class PlaylistViewHolder(view: View) : AbsHomeViewItem(view) {
|
private inner class PlaylistViewHolder(view: View) : AbsHomeViewItem(view) {
|
||||||
fun bindView(songs: List<Any>, titleRes: Int) {
|
fun bindView(songs: List<Any>, titleRes: Int) {
|
||||||
arrow.hide()
|
|
||||||
recyclerView.apply {
|
recyclerView.apply {
|
||||||
val songAdapter = SongAdapter(
|
val songAdapter = SongAdapter(
|
||||||
activity,
|
activity,
|
||||||
|
@ -210,7 +215,7 @@ class HomeAdapter(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open inner class AbsHomeViewItem(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
open class AbsHomeViewItem(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||||
val recyclerView: RecyclerView = itemView.findViewById(R.id.recyclerView)
|
val recyclerView: RecyclerView = itemView.findViewById(R.id.recyclerView)
|
||||||
val title: AppCompatTextView = itemView.findViewById(R.id.title)
|
val title: AppCompatTextView = itemView.findViewById(R.id.title)
|
||||||
val arrow: ImageView = itemView.findViewById(R.id.arrow)
|
val arrow: ImageView = itemView.findViewById(R.id.arrow)
|
||||||
|
|
|
@ -23,6 +23,7 @@ import android.widget.CheckBox
|
||||||
import android.widget.SeekBar
|
import android.widget.SeekBar
|
||||||
import androidx.annotation.AttrRes
|
import androidx.annotation.AttrRes
|
||||||
import androidx.annotation.ColorInt
|
import androidx.annotation.ColorInt
|
||||||
|
import androidx.appcompat.widget.AppCompatImageView
|
||||||
import androidx.appcompat.widget.Toolbar
|
import androidx.appcompat.widget.Toolbar
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
import code.name.monkey.appthemehelper.ThemeStore
|
||||||
|
@ -141,3 +142,7 @@ fun TextInputLayout.accentColor() {
|
||||||
fun TextInputEditText.accentColor() {
|
fun TextInputEditText.accentColor() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun AppCompatImageView.accentColor(): Int {
|
||||||
|
return ThemeStore.accentColor(context)
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package code.name.monkey.retromusic.fragments
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.navigation.fragment.navArgs
|
import androidx.navigation.fragment.navArgs
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
@ -18,7 +19,6 @@ import code.name.monkey.retromusic.model.Artist
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.repository.RealRepository
|
import code.name.monkey.retromusic.repository.RealRepository
|
||||||
import kotlinx.android.synthetic.main.fragment_playlist_detail.*
|
import kotlinx.android.synthetic.main.fragment_playlist_detail.*
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import kotlinx.coroutines.Dispatchers.IO
|
import kotlinx.coroutines.Dispatchers.IO
|
||||||
import kotlinx.coroutines.Dispatchers.Main
|
import kotlinx.coroutines.Dispatchers.Main
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
@ -56,7 +56,7 @@ class DetailListFragment : AbsMainActivityFragment(R.layout.fragment_playlist_de
|
||||||
|
|
||||||
private fun loadFavorite() {
|
private fun loadFavorite() {
|
||||||
toolbar.setTitle(R.string.favorites)
|
toolbar.setTitle(R.string.favorites)
|
||||||
CoroutineScope(IO).launch {
|
lifecycleScope.launch(IO) {
|
||||||
val songs = repository.favoritePlaylistHome()
|
val songs = repository.favoritePlaylistHome()
|
||||||
withContext(Main) {
|
withContext(Main) {
|
||||||
recyclerView.apply {
|
recyclerView.apply {
|
||||||
|
@ -73,7 +73,7 @@ class DetailListFragment : AbsMainActivityFragment(R.layout.fragment_playlist_de
|
||||||
|
|
||||||
private fun loadArtists(title: Int, type: Int) {
|
private fun loadArtists(title: Int, type: Int) {
|
||||||
toolbar.setTitle(title)
|
toolbar.setTitle(title)
|
||||||
CoroutineScope(IO).launch {
|
lifecycleScope.launch(IO) {
|
||||||
val artists =
|
val artists =
|
||||||
if (type == TOP_ARTISTS) repository.topArtists() else repository.recentArtists()
|
if (type == TOP_ARTISTS) repository.topArtists() else repository.recentArtists()
|
||||||
withContext(Main) {
|
withContext(Main) {
|
||||||
|
@ -87,7 +87,7 @@ class DetailListFragment : AbsMainActivityFragment(R.layout.fragment_playlist_de
|
||||||
|
|
||||||
private fun loadAlbums(title: Int, type: Int) {
|
private fun loadAlbums(title: Int, type: Int) {
|
||||||
toolbar.setTitle(title)
|
toolbar.setTitle(title)
|
||||||
CoroutineScope(IO).launch {
|
lifecycleScope.launch(IO) {
|
||||||
val albums =
|
val albums =
|
||||||
if (type == TOP_ALBUMS) repository.topAlbums() else repository.recentAlbums()
|
if (type == TOP_ALBUMS) repository.topAlbums() else repository.recentAlbums()
|
||||||
withContext(Main) {
|
withContext(Main) {
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package code.name.monkey.retromusic.views
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.res.ColorStateList
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import androidx.appcompat.widget.AppCompatImageView
|
||||||
|
import code.name.monkey.retromusic.extensions.accentColor
|
||||||
|
|
||||||
|
class AccentIcon @JvmOverloads constructor(
|
||||||
|
context: Context,
|
||||||
|
attrs: AttributeSet? = null,
|
||||||
|
defStyleAttr: Int = -1
|
||||||
|
) : AppCompatImageView(context, attrs, defStyleAttr) {
|
||||||
|
init {
|
||||||
|
imageTintList = ColorStateList.valueOf(accentColor())
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<font-family xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
app:fontProviderAuthority="com.google.android.gms.fonts"
|
|
||||||
app:fontProviderPackage="com.google.android.gms"
|
|
||||||
app:fontProviderQuery="Pacifico"
|
|
||||||
app:fontProviderCerts="@array/com_google_android_gms_fonts_certs">
|
|
||||||
</font-family>
|
|
|
@ -1,63 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="?colorSurface"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:elevation="0dp"
|
|
||||||
tools:ignore="UnusedAttribute">
|
|
||||||
|
|
||||||
<include layout="@layout/status_bar" />
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
|
||||||
android:id="@+id/mainContent"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
|
||||||
android:id="@+id/appBarLayout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
app:liftOnScroll="true">
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
app:layout_scrollFlags="scroll|enterAlways">
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.Toolbar
|
|
||||||
android:id="@+id/toolbar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:background="?attr/colorSurface"
|
|
||||||
app:popupTheme="?attr/toolbarPopupTheme"
|
|
||||||
app:title="@string/app_name"
|
|
||||||
app:titleTextAppearance="@style/ToolbarTextAppearanceNormal.Library"
|
|
||||||
app:titleTextColor="?attr/colorControlNormal"
|
|
||||||
tools:ignore="UnusedAttribute" />
|
|
||||||
|
|
||||||
<ViewStub
|
|
||||||
android:id="@+id/cab_stub"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/toolbar_height" />
|
|
||||||
</FrameLayout>
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
|
||||||
|
|
||||||
<androidx.fragment.app.FragmentContainerView
|
|
||||||
android:id="@+id/fragment_container"
|
|
||||||
android:name="code.name.monkey.retromusic.fragments.main.MainFragment"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
app:defaultNavHost="true"
|
|
||||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
|
|
||||||
app:navGraph="@navigation/main_graph" />
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
||||||
</LinearLayout>
|
|
|
@ -30,13 +30,12 @@
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
tools:text="@tools:sample/full_names" />
|
tools:text="@tools:sample/full_names" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
<code.name.monkey.retromusic.views.AccentIcon
|
||||||
android:id="@+id/arrow"
|
android:id="@+id/arrow"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
app:srcCompat="@drawable/ic_arrow_forward"
|
app:srcCompat="@drawable/ic_arrow_forward" />
|
||||||
app:tint="?attr/colorControlNormal" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<resources>
|
|
||||||
<array name="preloaded_fonts" translatable="false">
|
|
||||||
<item>@font/pacifico</item>
|
|
||||||
</array>
|
|
||||||
</resources>
|
|
|
@ -63,12 +63,6 @@
|
||||||
<item name="android:textColor">?android:attr/textColorPrimary</item>
|
<item name="android:textColor">?android:attr/textColorPrimary</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="ToolbarTextAppearanceNormal.Library" parent="ToolbarTextAppearanceNormal">
|
|
||||||
<item name="android:textAppearance">@style/TextViewHeadline6</item>
|
|
||||||
<item name="fontFamily">@font/pacifico</item>
|
|
||||||
<item name="android:fontFamily">@font/pacifico</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="BigTitleTextAppearanceToolbar">
|
<style name="BigTitleTextAppearanceToolbar">
|
||||||
<item name="android:textAppearance">@style/TextViewHeadline6</item>
|
<item name="android:textAppearance">@style/TextViewHeadline6</item>
|
||||||
<item name="android:layout_width">wrap_content</item>
|
<item name="android:layout_width">wrap_content</item>
|
||||||
|
|
Loading…
Reference in a new issue