Change section headers in home to chip

This commit is contained in:
h4h13 2019-06-23 22:53:50 +05:30
parent 2f769d7823
commit 5f81f48b7f
4 changed files with 36 additions and 59 deletions

View file

@ -4,7 +4,6 @@ import android.util.DisplayMetrics
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.TextView
import androidx.annotation.IntDef import androidx.annotation.IntDef
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
@ -17,7 +16,8 @@ import code.name.monkey.retromusic.adapter.song.SongAdapter
import code.name.monkey.retromusic.loaders.PlaylistSongsLoader import code.name.monkey.retromusic.loaders.PlaylistSongsLoader
import code.name.monkey.retromusic.model.* import code.name.monkey.retromusic.model.*
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.views.IconImageView import com.google.android.material.chip.Chip
import kotlinx.android.synthetic.main.item_option_menu.view.*
class HomeAdapter(private val activity: AppCompatActivity, private var homes: List<Home>, private val displayMetrics: DisplayMetrics) : RecyclerView.Adapter<RecyclerView.ViewHolder>() { class HomeAdapter(private val activity: AppCompatActivity, private var homes: List<Home>, private val displayMetrics: DisplayMetrics) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
@ -91,8 +91,8 @@ class HomeAdapter(private val activity: AppCompatActivity, private var homes: Li
recyclerView.apply { recyclerView.apply {
adapter = AlbumFullWidthAdapter(activity, home.arrayList as ArrayList<Album>, displayMetrics) adapter = AlbumFullWidthAdapter(activity, home.arrayList as ArrayList<Album>, displayMetrics)
} }
title.text = activity.getString(home.title) chip.text = activity.getString(home.title)
icon.setImageResource(home.icon) chip.setChipIconResource(home.icon)
} }
} }
@ -103,8 +103,8 @@ class HomeAdapter(private val activity: AppCompatActivity, private var homes: Li
val artistAdapter = ArtistAdapter(activity, home.arrayList as ArrayList<Artist>, PreferenceUtil.getInstance().getHomeGridStyle(context!!), false, null) val artistAdapter = ArtistAdapter(activity, home.arrayList as ArrayList<Artist>, PreferenceUtil.getInstance().getHomeGridStyle(context!!), false, null)
adapter = artistAdapter adapter = artistAdapter
} }
title.text = activity.getString(home.title) chip.text = activity.getString(home.title)
icon.setImageResource(home.icon) chip.setChipIconResource(home.icon)
} }
} }
@ -116,8 +116,8 @@ class HomeAdapter(private val activity: AppCompatActivity, private var homes: Li
adapter = genreAdapter adapter = genreAdapter
} }
title.text = activity.getString(home.title) chip.text = activity.getString(home.title)
icon.setImageResource(home.icon) chip.setChipIconResource(home.icon)
} }
} }
@ -130,14 +130,13 @@ class HomeAdapter(private val activity: AppCompatActivity, private var homes: Li
adapter = songAdapter adapter = songAdapter
} }
title.text = activity.getString(home.title) chip.text = activity.getString(home.title)
icon.setImageResource(home.icon) chip.setChipIconResource(home.icon)
} }
} }
private open inner class AbsHomeViewItem(itemView: View) : RecyclerView.ViewHolder(itemView) { private open inner 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: TextView = itemView.findViewById(R.id.sectionTitle) val chip: Chip = itemView.findViewById(R.id.chipHead)
val icon: IconImageView = itemView.findViewById(R.id.sectionIcon)
} }
} }

View file

@ -1,37 +1,26 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:paddingBottom="12dp"> android:paddingBottom="12dp">
<LinearLayout <com.google.android.material.chip.Chip
android:id="@+id/chipHead"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="12dp" android:layout_margin="12dp"
android:background="@drawable/material_design_outline" android:fontFamily="@font/circular"
android:backgroundTint="?dividerColor" android:textColor="?android:textColorSecondary"
android:gravity="center_vertical" app:chipBackgroundColor="?colorPrimary"
android:paddingStart="12dp" app:chipIconTint="?iconColor"
android:paddingTop="6dp" app:chipStrokeColor="?dividerColor"
android:paddingEnd="12dp" app:chipStrokeWidth="1dp"
android:paddingBottom="6dp"> app:iconStartPadding="8dp"
tools:chipIcon="@drawable/ic_person_white_24dp"
<code.name.monkey.retromusic.views.IconImageView tools:text="@string/for_you" />
android:id="@+id/sectionIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp"
app:srcCompat="@drawable/ic_person_white_24dp" />
<code.name.monkey.appthemehelper.common.views.ATESecondaryTextView
android:id="@+id/sectionTitle"
style="@style/SubTitleTextAppearance"
android:padding="0dp"
android:text="@string/for_you" />
</LinearLayout>
<code.name.monkey.retromusic.views.MetalRecyclerViewPager <code.name.monkey.retromusic.views.MetalRecyclerViewPager
android:id="@+id/recyclerView" android:id="@+id/recyclerView"

View file

@ -2,37 +2,26 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/recentArtistContainer" android:id="@+id/recentArtistContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <com.google.android.material.chip.Chip
android:id="@+id/chipHead"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="12dp" android:layout_margin="12dp"
android:background="@drawable/material_design_outline" android:fontFamily="@font/circular"
android:backgroundTint="?dividerColor" android:textColor="?android:textColorSecondary"
android:gravity="center_vertical" app:chipBackgroundColor="?colorPrimary"
android:paddingStart="12dp" app:chipIconTint="?iconColor"
android:paddingTop="6dp" app:chipStrokeColor="?dividerColor"
android:paddingEnd="12dp" app:chipStrokeWidth="1dp"
android:paddingBottom="6dp"> app:iconStartPadding="8dp"
tools:chipIcon="@drawable/ic_person_white_24dp"
<code.name.monkey.retromusic.views.IconImageView tools:text="@string/for_you" />
android:id="@+id/sectionIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp"
app:srcCompat="@drawable/ic_person_white_24dp" />
<code.name.monkey.appthemehelper.common.views.ATESecondaryTextView
android:id="@+id/sectionTitle"
style="@style/SubTitleTextAppearance"
android:padding="0dp"
android:text="@string/for_you" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView" android:id="@+id/recyclerView"

View file

@ -67,7 +67,7 @@
<item name="cardBackgroundColor">@color/card_dark_color</item> <item name="cardBackgroundColor">@color/card_dark_color</item>
<item name="defaultFooterColor">@color/dark_color</item> <item name="defaultFooterColor">@color/dark_color</item>
<item name="dividerColor">@color/dark_color</item> <item name="dividerColor">@color/md_grey_800</item>
<item name="iconColor">@color/ate_secondary_text_dark</item> <item name="iconColor">@color/ate_secondary_text_dark</item>