Kotlin code refactor

This commit is contained in:
Hemanth S 2020-05-25 00:02:32 +05:30
parent b9a4c01a91
commit 530b42608b
14 changed files with 41 additions and 56 deletions

View file

@ -25,6 +25,7 @@ import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter
import code.name.monkey.retromusic.adapter.song.SimpleSongAdapter
import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
import code.name.monkey.retromusic.dialogs.DeleteSongsDialog
import code.name.monkey.retromusic.extensions.extraNotNull
import code.name.monkey.retromusic.extensions.ripAlpha
import code.name.monkey.retromusic.extensions.show
import code.name.monkey.retromusic.extensions.surfaceColor
@ -101,34 +102,23 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
setLightNavigationBar(true)
setBottomBarVisibility(View.GONE)
window.sharedElementsUseOverlay = true
windowEnterTransition()
App.musicComponent.inject(this)
albumDetailsPresenter.attachView(this)
val albumId = extraNotNull<Int>(EXTRA_ALBUM_ID).value
albumDetailsPresenter.loadAlbum(albumId)
if (intent.extras!!.containsKey(EXTRA_ALBUM_ID)) {
intent.extras?.getInt(EXTRA_ALBUM_ID)?.let {
albumDetailsPresenter.loadAlbum(it)
albumCoverContainer?.transitionName =
"${getString(R.string.transition_album_art)}_$it"
}
} else {
finish()
}
windowEnterTransition()
ActivityCompat.postponeEnterTransition(this)
artistImage = findViewById(R.id.artistImage)
setupRecyclerView()
artistImage = findViewById(R.id.artistImage)
artistImage.setOnClickListener {
val artistPairs = ActivityOptions.makeSceneTransitionAnimation(
this,
UtilPair.create(
artistImage,
"${getString(R.string.transition_artist_image)}_${album.artistId}"
getString(R.string.transition_artist_image)
)
)
NavigationUtil.goToArtistOptions(this, album.artistId, artistPairs)
@ -394,11 +384,8 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
}
private fun reload() {
if (intent.extras!!.containsKey(EXTRA_ALBUM_ID)) {
intent.extras?.getInt(EXTRA_ALBUM_ID)?.let { albumDetailsPresenter.loadAlbum(it) }
} else {
finish()
}
val albumId = extraNotNull<Int>(EXTRA_ALBUM_ID).value
albumDetailsPresenter.loadAlbum(albumId)
}
override fun onBackPressed() {

View file

@ -22,6 +22,7 @@ import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter
import code.name.monkey.retromusic.adapter.song.SimpleSongAdapter
import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
import code.name.monkey.retromusic.extensions.extraNotNull
import code.name.monkey.retromusic.extensions.ripAlpha
import code.name.monkey.retromusic.extensions.show
import code.name.monkey.retromusic.extensions.surfaceColor
@ -95,21 +96,13 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
setLightNavigationBar(true)
setBottomBarVisibility(View.GONE)
window.sharedElementsUseOverlay = true
windowEnterTransition()
App.musicComponent.inject(this)
artistDetailsPresenter.attachView(this)
val artistId = extraNotNull<Int>(EXTRA_ARTIST_ID).value
artistDetailsPresenter.loadArtist(artistId)
if (intent.extras!!.containsKey(EXTRA_ARTIST_ID)) {
intent.extras?.getInt(EXTRA_ARTIST_ID)?.let {
artistDetailsPresenter.loadArtist(it)
val name = "${getString(R.string.transition_artist_image)}_$it"
artistCoverContainer?.transitionName = name
}
} else {
finish()
}
windowEnterTransition()
ActivityCompat.postponeEnterTransition(this)
setupRecyclerView()

View file

@ -91,7 +91,7 @@ class AlbumTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
setDrawUnderStatusBar()
super.onCreate(savedInstanceState)
window.sharedElementsUseOverlay = true
imageContainer?.transitionName = "${getString(R.string.transition_album_art)}_$id"
imageContainer?.transitionName = getString(R.string.transition_album_art)
windowEnterTransition()
setUpViews()
setupToolbar()
@ -162,7 +162,7 @@ class AlbumTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
writeValuesToFiles(
fieldKeyValueMap,
if (deleteAlbumArt) ArtworkInfo(id, null)
if (deleteAlbumArt) AbsTagEditorActivity.ArtworkInfo(id, null)
else if (albumArtBitmap == null) null else ArtworkInfo(id, albumArtBitmap!!)
)
}

View file

@ -180,7 +180,7 @@ open class AlbumAdapter(
val activityOptions = ActivityOptions.makeSceneTransitionAnimation(
activity,
imageContainerCard ?: image,
"${activity.getString(R.string.transition_album_art)}_${dataSet[layoutPosition].id}"
activity.getString(R.string.transition_album_art)
)
NavigationUtil.goToAlbumOptions(
activity,

View file

@ -100,7 +100,7 @@ class AlbumFullWidthAdapter(
val activityOptions = ActivityOptions.makeSceneTransitionAnimation(
activity,
imageContainerCard ?: image,
"${activity.getString(R.string.transition_album_art)}_${dataSet[layoutPosition].id}"
activity.getString(R.string.transition_album_art)
)
NavigationUtil.goToAlbumOptions(activity, dataSet[layoutPosition].id, activityOptions)
}

View file

@ -142,7 +142,7 @@ class ArtistAdapter(
val activityOptions = ActivityOptions.makeSceneTransitionAnimation(
activity,
imageContainerCard ?: image,
"${activity.getString(R.string.transition_artist_image)}_${dataSet[layoutPosition].id}"
activity.getString(R.string.transition_artist_image)
)
NavigationUtil.goToArtistOptions(
activity, dataSet[layoutPosition].id, activityOptions

View file

@ -60,7 +60,7 @@ open class PlaylistSongAdapter(
val activityOptions = ActivityOptions.makeSceneTransitionAnimation(
activity,
imageContainerCard ?: image,
"${activity.getString(R.string.transition_album_art)}_${song.albumId}"
activity.getString(R.string.transition_album_art)
)
NavigationUtil.goToAlbumOptions(activity, song.albumId, activityOptions)
return true

View file

@ -186,7 +186,7 @@ open class SongAdapter(
val activityOptions = ActivityOptions.makeSceneTransitionAnimation(
activity,
imageContainerCard ?: image,
"${activity.getString(R.string.transition_album_art)}_${song.albumId}"
activity.getString(R.string.transition_album_art)
)
NavigationUtil.goToAlbumOptions(activity, song.albumId, activityOptions)
return true

View file

@ -22,11 +22,13 @@
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorSurface"
app:liftOnScroll="true">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
style="@style/Toolbar"
android:background="?attr/colorSurface"
app:layout_collapseMode="pin"
app:navigationIcon="@drawable/ic_keyboard_backspace_black_24dp"
app:title="@string/action_about"
@ -36,9 +38,9 @@
<androidx.core.widget.NestedScrollView
android:id="@+id/container"
android:overScrollMode="never"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
<include layout="@layout/activity_about_content" />

View file

@ -74,7 +74,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
tools:srcCompat="@tools:sample/backgrounds/scenic[16]" />
tools:srcCompat="@tools:sample/backgrounds/scenic" />
</com.google.android.material.card.MaterialCardView>
@ -94,7 +94,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/artistCoverContainer"
tools:ignore="MissingPrefix"
tools:text="Title" />
tools:text="@tools:sample/full_names" />
<code.name.monkey.retromusic.views.BaselineGridTextView
android:id="@+id/text"
@ -109,7 +109,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/artistTitle"
tools:ignore="MissingPrefix"
tools:text="Title" />
tools:text="@tools:sample/full_names" />
<include
layout="@layout/activity_artist_content"

View file

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView 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="wrap_content"
app:cardCornerRadius="@dimen/about_card_radius"
app:cardUseCompatPadding="true">
android:layout_margin="4dp"
app:cardCornerRadius="@dimen/about_card_radius">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<code.name.monkey.appthemehelper.common.views.ATEAccentTextView
android:id="@+id/sb1"
android:layout_width="wrap_content"
@ -36,7 +36,9 @@
android:overScrollMode="never"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/sb1" />
app:layout_constraintTop_toBottomOf="@+id/sb1"
tools:itemCount="3"
tools:listitem="@layout/item_contributor" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>

View file

@ -3,8 +3,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="@dimen/about_card_radius"
app:cardUseCompatPadding="true">
android:layout_margin="4dp"
app:cardCornerRadius="@dimen/about_card_radius">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"

View file

@ -3,8 +3,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="@dimen/about_card_radius"
app:cardUseCompatPadding="true">
android:layout_margin="4dp"
app:cardCornerRadius="@dimen/about_card_radius">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"

View file

@ -32,16 +32,15 @@
android:scaleType="centerCrop"
app:civ_border="false"
app:civ_shadow="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:retroCornerSize="21dp"
app:srcCompat="@drawable/ic_account_white_24dp"
tools:srcCompat="@tools:sample/backgrounds/scenic[20]" />
tools:srcCompat="@tools:sample/backgrounds/scenic" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:textAppearance="@style/TextViewSubtitle1"
@ -54,9 +53,11 @@
<code.name.monkey.retromusic.views.BaselineGridTextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:ellipsize="end"
android:maxLines="1"
android:textColor="?android:attr/textColorSecondary"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toBottomOf="@+id/icon"
@ -64,6 +65,6 @@
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toEndOf="@id/icon"
app:lineHeightHint="24sp"
tools:text="@tools:sample/full_names" />
tools:text="@tools:sample/lorem/random" />
</androidx.constraintlayout.widget.ConstraintLayout>