Added music note off for empty view

main
h4h13 2019-06-23 20:17:49 +05:30
parent 40ac73e2c9
commit 14a113e73f
10 changed files with 36 additions and 37 deletions

File diff suppressed because one or more lines are too long

View File

@ -12,7 +12,7 @@ import code.name.monkey.retromusic.util.PreferenceUtil
open class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager>(), AlbumContract.AlbumView { open class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager>(), AlbumContract.AlbumView {
private var presenter: AlbumPresenter? = null private lateinit var presenter: AlbumPresenter
override val emptyMessage: Int override val emptyMessage: Int
@ -48,7 +48,7 @@ open class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Al
} }
override fun setSortOrder(sortOrder: String) { override fun setSortOrder(sortOrder: String) {
presenter!!.loadAlbums() presenter.loadAlbums()
} }
override fun loadSortOrder(): String { override fun loadSortOrder(): String {
@ -87,7 +87,7 @@ open class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Al
} }
override fun onMediaStoreChanged() { override fun onMediaStoreChanged() {
presenter!!.loadAlbums() presenter.loadAlbums()
} }
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
@ -113,13 +113,13 @@ open class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Al
libraryFragment.setTitle( libraryFragment.setTitle(
if (PreferenceUtil.getInstance().tabTitles()) R.string.library else R.string.albums) if (PreferenceUtil.getInstance().tabTitles()) R.string.library else R.string.albums)
if (adapter!!.dataSet.isEmpty()) { if (adapter!!.dataSet.isEmpty()) {
presenter!!.subscribe() presenter.subscribe()
} }
} }
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
presenter!!.unsubscribe() presenter.unsubscribe()
} }
override fun loading() {} override fun loading() {}
@ -136,7 +136,7 @@ open class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Al
companion object { companion object {
val TAG = AlbumsFragment::class.java.simpleName val TAG: String = AlbumsFragment::class.java.simpleName
fun newInstance(): AlbumsFragment { fun newInstance(): AlbumsFragment {
val args = Bundle() val args = Bundle()

View File

@ -12,7 +12,7 @@ import code.name.monkey.retromusic.util.PreferenceUtil
import java.util.* import java.util.*
class ArtistsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<ArtistAdapter, GridLayoutManager>(), ArtistContract.ArtistView { class ArtistsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<ArtistAdapter, GridLayoutManager>(), ArtistContract.ArtistView {
private var presenter: ArtistPresenter? = null private lateinit var presenter: ArtistPresenter
override val emptyMessage: Int override val emptyMessage: Int
get() = R.string.no_artists get() = R.string.no_artists
@ -37,7 +37,7 @@ class ArtistsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Artist
} }
override fun onMediaStoreChanged() { override fun onMediaStoreChanged() {
presenter!!.loadArtists() presenter.loadArtists()
} }
override fun loadGridSize(): Int { override fun loadGridSize(): Int {
@ -83,7 +83,7 @@ class ArtistsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Artist
} }
override fun setSortOrder(sortOrder: String) { override fun setSortOrder(sortOrder: String) {
presenter!!.loadArtists() presenter.loadArtists()
} }
@ -103,13 +103,13 @@ class ArtistsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Artist
libraryFragment.setTitle( libraryFragment.setTitle(
if (PreferenceUtil.getInstance().tabTitles()) R.string.library else R.string.artists) if (PreferenceUtil.getInstance().tabTitles()) R.string.library else R.string.artists)
if (adapter!!.dataSet.isEmpty()) { if (adapter!!.dataSet.isEmpty()) {
presenter!!.subscribe() presenter.subscribe()
} }
} }
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
presenter!!.unsubscribe() presenter.unsubscribe()
} }
override fun loading() {} override fun loading() {}

View File

@ -16,7 +16,7 @@ import java.util.*
class PlaylistsFragment : AbsLibraryPagerRecyclerViewFragment<PlaylistAdapter, LinearLayoutManager>(), PlaylistContract.PlaylistView { class PlaylistsFragment : AbsLibraryPagerRecyclerViewFragment<PlaylistAdapter, LinearLayoutManager>(), PlaylistContract.PlaylistView {
private var presenter: PlaylistPresenter? = null private lateinit var presenter: PlaylistPresenter
override val emptyMessage: Int override val emptyMessage: Int
get() = R.string.no_playlists get() = R.string.no_playlists
@ -47,18 +47,18 @@ class PlaylistsFragment : AbsLibraryPagerRecyclerViewFragment<PlaylistAdapter, L
super.onResume() super.onResume()
libraryFragment.setTitle(if (PreferenceUtil.getInstance().tabTitles()) R.string.library else R.string.playlists) libraryFragment.setTitle(if (PreferenceUtil.getInstance().tabTitles()) R.string.library else R.string.playlists)
if (adapter!!.dataSet.isEmpty()) { if (adapter!!.dataSet.isEmpty()) {
presenter!!.subscribe() presenter.subscribe()
} }
} }
override fun onDestroy() { override fun onDestroy() {
presenter!!.unsubscribe() presenter.unsubscribe()
super.onDestroy() super.onDestroy()
} }
override fun onMediaStoreChanged() { override fun onMediaStoreChanged() {
super.onMediaStoreChanged() super.onMediaStoreChanged()
presenter!!.loadPlaylists() presenter.loadPlaylists()
} }
override fun loading() { override fun loading() {

View File

@ -83,7 +83,7 @@ class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdap
super.onResume() super.onResume()
libraryFragment.setTitle(if (PreferenceUtil.getInstance().tabTitles()) R.string.library else R.string.songs) libraryFragment.setTitle(if (PreferenceUtil.getInstance().tabTitles()) R.string.library else R.string.songs)
if (adapter!!.dataSet.isEmpty()) { if (adapter!!.dataSet.isEmpty()) {
presenter!!.subscribe() presenter.subscribe()
} }
} }
@ -128,7 +128,7 @@ class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdap
} }
override fun setSortOrder(sortOrder: String) { override fun setSortOrder(sortOrder: String) {
presenter!!.loadSongs() presenter.loadSongs()
} }
companion object { companion object {

View File

@ -42,10 +42,6 @@ import java.util.*
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallbacks, HomeContract.HomeView { class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallbacks, HomeContract.HomeView {
override fun showEmpty() {
emptyContainer.show()
emptyText.setText(R.string.start_play_music)
}
private var disposable: Disposable? = null private var disposable: Disposable? = null
private lateinit var homePresenter: HomePresenter private lateinit var homePresenter: HomePresenter
@ -185,7 +181,7 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
} }
override fun showEmptyView() { override fun showEmptyView() {
emptyContainer.show()
} }
override fun completed() { override fun completed() {
@ -205,6 +201,10 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
private lateinit var homeAdapter: HomeAdapter private lateinit var homeAdapter: HomeAdapter
override fun showData(list: ArrayList<Home>) { override fun showData(list: ArrayList<Home>) {
if (list.isEmpty()){
showEmptyView()
return
}
val finalList = list.sortedWith(compareBy { it.priority }) val finalList = list.sortedWith(compareBy { it.priority })
homeAdapter.swapData(finalList) homeAdapter.swapData(finalList)
recyclerView.apply { recyclerView.apply {

View File

@ -20,12 +20,9 @@ import code.name.monkey.retromusic.mvp.BaseView
interface HomeContract { interface HomeContract {
interface HomeView : BaseView<ArrayList<Home>> { interface HomeView : BaseView<ArrayList<Home>>
fun showEmpty()
}
interface HomePresenter : BasePresenter<HomeView> { interface HomePresenter : BasePresenter<HomeView> {
fun homeSections()
fun homeSections();
} }
} }

View File

@ -59,7 +59,7 @@ class HomePresenter(private val view: HomeContract.HomeView) : Presenter(), Home
if (it.isNotEmpty()) hashSet.add(Home(0, R.string.recent_artists, 0, it, RECENT_ARTISTS, R.drawable.ic_artist_white_24dp)) if (it.isNotEmpty()) hashSet.add(Home(0, R.string.recent_artists, 0, it, RECENT_ARTISTS, R.drawable.ic_artist_white_24dp))
view.showData(ArrayList(hashSet)) view.showData(ArrayList(hashSet))
}, { }, {
view.showEmpty() view.showEmptyView()
}) })
} }
@ -69,7 +69,7 @@ class HomePresenter(private val view: HomeContract.HomeView) : Presenter(), Home
if (it.isNotEmpty()) hashSet.add(Home(1, R.string.recent_albums, 0, it, RECENT_ALBUMS, R.drawable.ic_album_white_24dp)) if (it.isNotEmpty()) hashSet.add(Home(1, R.string.recent_albums, 0, it, RECENT_ALBUMS, R.drawable.ic_album_white_24dp))
view.showData(ArrayList(hashSet)) view.showData(ArrayList(hashSet))
}, { }, {
view.showEmpty() view.showEmptyView()
}) })
} }
@ -79,7 +79,7 @@ class HomePresenter(private val view: HomeContract.HomeView) : Presenter(), Home
if (it.isNotEmpty()) hashSet.add(Home(3, R.string.top_albums, 0, it, TOP_ALBUMS, R.drawable.ic_album_white_24dp)) if (it.isNotEmpty()) hashSet.add(Home(3, R.string.top_albums, 0, it, TOP_ALBUMS, R.drawable.ic_album_white_24dp))
view.showData(ArrayList(hashSet)) view.showData(ArrayList(hashSet))
}, { }, {
view.showEmpty() view.showEmptyView()
}) })
} }
@ -89,7 +89,7 @@ class HomePresenter(private val view: HomeContract.HomeView) : Presenter(), Home
if (it.isNotEmpty()) hashSet.add(Home(2, R.string.top_artists, 0, it, TOP_ARTISTS, R.drawable.ic_artist_white_24dp)) if (it.isNotEmpty()) hashSet.add(Home(2, R.string.top_artists, 0, it, TOP_ARTISTS, R.drawable.ic_artist_white_24dp))
view.showData(ArrayList(hashSet)) view.showData(ArrayList(hashSet))
}, { }, {
view.showEmpty() view.showEmptyView()
}) })
} }
@ -99,7 +99,7 @@ class HomePresenter(private val view: HomeContract.HomeView) : Presenter(), Home
if (it.isNotEmpty()) hashSet.add(Home(4, R.string.favorites, 0, it, PLAYLISTS, R.drawable.ic_favorite_white_24dp)) if (it.isNotEmpty()) hashSet.add(Home(4, R.string.favorites, 0, it, PLAYLISTS, R.drawable.ic_favorite_white_24dp))
view.showData(ArrayList(hashSet)) view.showData(ArrayList(hashSet))
}, { }, {
view.showEmpty() view.showEmptyView()
}) })
} }
@ -109,7 +109,7 @@ class HomePresenter(private val view: HomeContract.HomeView) : Presenter(), Home
if (it.isNotEmpty()) hashSet.add(Home(6, R.string.genres, 0, it, GENRES, R.drawable.ic_guitar_acoustic_white_24dp)) if (it.isNotEmpty()) hashSet.add(Home(6, R.string.genres, 0, it, GENRES, R.drawable.ic_guitar_acoustic_white_24dp))
view.showData(ArrayList(hashSet)) view.showData(ArrayList(hashSet))
}, { }, {
view.showEmpty() view.showEmptyView()
}) })
} }
} }

View File

@ -26,7 +26,7 @@
<code.name.monkey.retromusic.views.IconImageView <code.name.monkey.retromusic.views.IconImageView
android:layout_width="96dp" android:layout_width="96dp"
android:layout_height="96dp" android:layout_height="96dp"
app:srcCompat="@drawable/ic_disc_full_black_24dp" /> app:srcCompat="@drawable/ic_music_note_off_white_24dp" />
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:id="@+id/emptyText" android:id="@+id/emptyText"

View File

@ -17,6 +17,7 @@
<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/contentContainer" android:id="@+id/contentContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -40,19 +41,20 @@
android:layout_gravity="center" android:layout_gravity="center"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:orientation="vertical" android:orientation="vertical"
tools:visibility="visible"
android:visibility="gone"> android:visibility="gone">
<code.name.monkey.retromusic.views.IconImageView <code.name.monkey.retromusic.views.IconImageView
android:layout_width="96dp" android:layout_width="96dp"
android:layout_height="96dp" android:layout_height="96dp"
app:srcCompat="@drawable/ic_disc_full_black_24dp" /> app:srcCompat="@drawable/ic_music_note_off_white_24dp" />
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:id="@+id/emptyText" android:id="@+id/emptyText"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:text="@string/empty" android:text="@string/start_play_music"
android:textColor="?android:textColorSecondary" /> android:textColor="?android:textColorSecondary" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>