Skip to content
This repository has been archived by the owner on Aug 24, 2023. It is now read-only.

Commit

Permalink
HomeFragment: Remove carousel
Browse files Browse the repository at this point in the history
Signed-off-by: Shinjo Akane <[email protected]>
  • Loading branch information
AkaneTan committed Jul 17, 2023
1 parent a592134 commit af45c26
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import android.widget.FrameLayout
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.google.android.material.carousel.MaskableFrameLayout
import com.google.android.material.card.MaterialCardView
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import org.akanework.symphonica.MainActivity
import org.akanework.symphonica.MainActivity.Companion.controllerViewModel
Expand All @@ -42,8 +42,8 @@ import org.akanework.symphonica.ui.fragment.LibraryAlbumDisplayFragment
* This is the carousel adapter used for
* songs.
*/
class SongCarouselAdapter(private val songList: MutableList<Song>) :
RecyclerView.Adapter<SongCarouselAdapter.ViewHolder>() {
class SongRecyclerViewAdapter(private val songList: MutableList<Song>) :
RecyclerView.Adapter<SongRecyclerViewAdapter.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.home_carousel_card, parent, false)
Expand Down Expand Up @@ -127,6 +127,6 @@ class SongCarouselAdapter(private val songList: MutableList<Song>) :
*/
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val songCover: ImageView = view.findViewById(R.id.carousel_image_view)
val container: MaskableFrameLayout = view.findViewById(R.id.carousel_item_container)
val container: MaterialCardView = view.findViewById(R.id.carousel_item_container)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ import android.view.View.VISIBLE
import android.view.ViewGroup
import android.widget.ImageView
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.appbar.CollapsingToolbarLayout
import com.google.android.material.appbar.MaterialToolbar
import com.google.android.material.button.MaterialButton
import com.google.android.material.card.MaterialCardView
import com.google.android.material.carousel.CarouselLayoutManager
import com.google.android.material.color.MaterialColors
import com.google.android.material.transition.MaterialSharedAxis
import org.akanework.symphonica.MainActivity
Expand All @@ -54,7 +54,7 @@ import org.akanework.symphonica.PAGE_TRANSITION_DURATION
import org.akanework.symphonica.R
import org.akanework.symphonica.logic.data.Song
import org.akanework.symphonica.logic.util.replacePlaylist
import org.akanework.symphonica.ui.adapter.SongCarouselAdapter
import org.akanework.symphonica.ui.adapter.SongRecyclerViewAdapter
import kotlin.math.abs

/**
Expand Down Expand Up @@ -115,9 +115,9 @@ class HomeFragment : Fragment() {
val collapsingToolbar =
rootView.findViewById<CollapsingToolbarLayout>(R.id.collapsingToolbar)
val appBarLayout = rootView.findViewById<AppBarLayout>(R.id.appBarLayout)
val shuffleCarouselRecyclerView =
val shuffleRecyclerView =
rootView.findViewById<RecyclerView>(R.id.shuffle_recycler_view)
val recentCarouselRecyclerView =
val recentRecyclerView =
rootView.findViewById<RecyclerView>(R.id.recent_recycler_view)

val homeShuffleButton =
Expand Down Expand Up @@ -180,15 +180,17 @@ class HomeFragment : Fragment() {
)
}

val shuffleLayoutManager = CarouselLayoutManager()
shuffleCarouselRecyclerView.layoutManager = shuffleLayoutManager
shuffleAdapter = SongCarouselAdapter(shuffleList)
shuffleCarouselRecyclerView.adapter = shuffleAdapter
val shuffleLayoutManager = LinearLayoutManager(context)
shuffleLayoutManager.orientation = RecyclerView.HORIZONTAL
shuffleRecyclerView.layoutManager = shuffleLayoutManager
shuffleAdapter = SongRecyclerViewAdapter(shuffleList)
shuffleRecyclerView.adapter = shuffleAdapter

val recentLayoutManager = CarouselLayoutManager()
recentCarouselRecyclerView.layoutManager = recentLayoutManager
recentAdapter = SongCarouselAdapter(recentList)
recentCarouselRecyclerView.adapter = recentAdapter
val recentLayoutManager = LinearLayoutManager(context)
recentLayoutManager.orientation = RecyclerView.HORIZONTAL
recentRecyclerView.layoutManager = recentLayoutManager
recentAdapter = SongRecyclerViewAdapter(recentList)
recentRecyclerView.adapter = recentAdapter

loadingPrompt = rootView.findViewById(R.id.loading_prompt_list)

Expand Down Expand Up @@ -274,8 +276,8 @@ class HomeFragment : Fragment() {
private val recentList: MutableList<Song> = mutableListOf()
private var isInitialized: Boolean = true
private lateinit var loadingPrompt: MaterialCardView
private lateinit var shuffleAdapter: SongCarouselAdapter
private lateinit var recentAdapter: SongCarouselAdapter
private lateinit var shuffleAdapter: SongRecyclerViewAdapter
private lateinit var recentAdapter: SongRecyclerViewAdapter

/**
* This is used for outer class to switch [loadingPrompt].
Expand Down
12 changes: 5 additions & 7 deletions app/src/main/res/layout/home_carousel_card.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@
~ along with this program. If not, see <https://www.gnu.org/licenses/>.
-->

<com.google.android.material.carousel.MaskableFrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/carousel_item_container"
style="?attr/materialCardViewOutlinedStyle"
android:layout_width="150dp"
android:layout_height="match_parent"
android:layout_marginStart="4dp"
android:layout_marginEnd="4dp"
android:foreground="?attr/selectableItemBackground"
app:shapeAppearance="?attr/shapeAppearanceCornerMedium">
android:layout_width="150dp"
android:layout_height="196dp"
android:foreground="?attr/selectableItemBackground">

<ImageView
android:id="@+id/carousel_image_view"
Expand All @@ -33,4 +31,4 @@
android:importantForAccessibility="no"
android:scaleType="centerCrop"
android:src="@drawable/ic_song_outline_default_cover" />
</com.google.android.material.carousel.MaskableFrameLayout>
</com.google.android.material.card.MaterialCardView>

0 comments on commit af45c26

Please sign in to comment.