Added show empty in home
This commit is contained in:
parent
647e5b2d3f
commit
d2804bdcd4
11 changed files with 77 additions and 55 deletions
|
@ -147,7 +147,7 @@ dependencies {
|
|||
implementation 'com.github.bumptech.glide:okhttp3-integration:4.8.0'
|
||||
|
||||
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
|
||||
implementation 'io.reactivex.rxjava2:rxjava:2.2.8'
|
||||
implementation 'io.reactivex.rxjava2:rxjava:2.2.9'
|
||||
|
||||
implementation('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.11.0@aar') {
|
||||
transitive = true
|
||||
|
|
|
@ -17,6 +17,7 @@ import code.name.monkey.retromusic.Constants
|
|||
import code.name.monkey.retromusic.Constants.USER_BANNER
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.HomeAdapter
|
||||
import code.name.monkey.retromusic.extensions.show
|
||||
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
|
||||
import code.name.monkey.retromusic.glide.GlideApp
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
|
@ -31,7 +32,7 @@ import code.name.monkey.retromusic.mvp.presenter.HomePresenter
|
|||
import code.name.monkey.retromusic.util.*
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.android.synthetic.main.abs_playlists.*
|
||||
import kotlinx.android.synthetic.main.fragment_banner_home.*
|
||||
|
@ -42,16 +43,12 @@ import kotlin.collections.ArrayList
|
|||
|
||||
class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallbacks, HomeContract.HomeView {
|
||||
override fun showEmpty() {
|
||||
|
||||
emptyContainer.show()
|
||||
emptyText.setText(R.string.start_play_music)
|
||||
}
|
||||
|
||||
private lateinit var disposable: CompositeDisposable
|
||||
private var disposable: Disposable? = null
|
||||
private lateinit var homePresenter: HomePresenter
|
||||
private lateinit var contentContainerView: View
|
||||
private lateinit var lastAdded: View
|
||||
private lateinit var topPlayed: View
|
||||
private lateinit var actionShuffle: View
|
||||
private lateinit var history: View
|
||||
private lateinit var toolbar: Toolbar
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, viewGroup: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
|
@ -59,7 +56,10 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
|
|||
}
|
||||
|
||||
private fun loadImageFromStorage() {
|
||||
disposable.add(Compressor(context!!)
|
||||
if (disposable != null) {
|
||||
disposable?.dispose()
|
||||
}
|
||||
disposable = Compressor(context!!)
|
||||
.setMaxHeight(300)
|
||||
.setMaxWidth(300)
|
||||
.setQuality(75)
|
||||
|
@ -75,7 +75,7 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
|
|||
}
|
||||
}) {
|
||||
userImage.setImageDrawable(ContextCompat.getDrawable(context!!, R.drawable.ic_person_flat))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private val displayMetrics: DisplayMetrics
|
||||
|
@ -101,30 +101,25 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
|
|||
if (!PreferenceUtil.getInstance().isHomeBanner)
|
||||
setStatusbarColorAuto(view)
|
||||
|
||||
lastAdded = view.findViewById(R.id.lastAdded)
|
||||
lastAdded.setOnClickListener {
|
||||
NavigationUtil.goToPlaylistNew(mainActivity, LastAddedPlaylist(mainActivity))
|
||||
}
|
||||
|
||||
topPlayed = view.findViewById(R.id.topPlayed)
|
||||
topPlayed.setOnClickListener {
|
||||
NavigationUtil.goToPlaylistNew(mainActivity, MyTopTracksPlaylist(mainActivity))
|
||||
}
|
||||
|
||||
actionShuffle = view.findViewById(R.id.actionShuffle)
|
||||
actionShuffle.setOnClickListener {
|
||||
MusicPlayerRemote.openAndShuffleQueue(SongLoader.getAllSongs(mainActivity).blockingFirst(), true)
|
||||
}
|
||||
|
||||
history = view.findViewById(R.id.history)
|
||||
history.setOnClickListener {
|
||||
NavigationUtil.goToPlaylistNew(mainActivity, HistoryPlaylist(mainActivity))
|
||||
}
|
||||
|
||||
homePresenter = HomePresenter(this)
|
||||
|
||||
contentContainerView = view.findViewById(R.id.contentContainer)
|
||||
contentContainerView.setBackgroundColor(ThemeStore.primaryColor(context!!))
|
||||
contentContainer.setBackgroundColor(ThemeStore.primaryColor(context!!))
|
||||
|
||||
setupToolbar()
|
||||
homeAdapter = HomeAdapter(mainActivity, ArrayList(), displayMetrics)
|
||||
|
@ -176,13 +171,12 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
disposable = CompositeDisposable()
|
||||
getTimeOfTheDay()
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
disposable.dispose()
|
||||
disposable?.dispose()
|
||||
homePresenter.unsubscribe()
|
||||
}
|
||||
|
||||
|
@ -268,13 +262,13 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
|
|||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.into(bannerImage!!)
|
||||
} else {
|
||||
disposable.add(Compressor(context!!)
|
||||
disposable = Compressor(context!!)
|
||||
.setQuality(100)
|
||||
.setCompressFormat(Bitmap.CompressFormat.WEBP)
|
||||
.compressToBitmapAsFlowable(File(PreferenceUtil.getInstance().bannerImage, USER_BANNER))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe { bannerImage!!.setImageBitmap(it) })
|
||||
.subscribe { bannerImage?.setImageBitmap(it) }
|
||||
}
|
||||
}
|
||||
loadImageFromStorage()
|
||||
|
|
|
@ -87,11 +87,9 @@ object TopAndRecentlyPlayedTracksLoader {
|
|||
val songs = SongPlayCountStore.getInstance(context)
|
||||
.getTopPlayedResults(NUMBER_OF_TOP_TRACKS)
|
||||
|
||||
try {
|
||||
return makeSortedCursor(context, songs,
|
||||
songs!!.getColumnIndex(SongPlayCountStore.SongPlayCountColumns.ID))
|
||||
} finally {
|
||||
songs?.close()
|
||||
songs.use { localSongs ->
|
||||
return makeSortedCursor(context, localSongs,
|
||||
localSongs.getColumnIndex(SongPlayCountStore.SongPlayCountColumns.ID))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,15 +15,15 @@
|
|||
package code.name.monkey.retromusic.mvp.presenter
|
||||
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.model.Home
|
||||
import code.name.monkey.retromusic.mvp.Presenter
|
||||
import code.name.monkey.retromusic.mvp.contract.HomeContract
|
||||
import code.name.monkey.retromusic.adapter.HomeAdapter.Companion.GENRES
|
||||
import code.name.monkey.retromusic.adapter.HomeAdapter.Companion.PLAYLISTS
|
||||
import code.name.monkey.retromusic.adapter.HomeAdapter.Companion.RECENT_ALBUMS
|
||||
import code.name.monkey.retromusic.adapter.HomeAdapter.Companion.RECENT_ARTISTS
|
||||
import code.name.monkey.retromusic.adapter.HomeAdapter.Companion.TOP_ALBUMS
|
||||
import code.name.monkey.retromusic.adapter.HomeAdapter.Companion.TOP_ARTISTS
|
||||
import code.name.monkey.retromusic.model.Home
|
||||
import code.name.monkey.retromusic.mvp.Presenter
|
||||
import code.name.monkey.retromusic.mvp.contract.HomeContract
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
|
@ -55,7 +55,6 @@ class HomePresenter(private val view: HomeContract.HomeView) : Presenter(), Home
|
|||
|
||||
private fun loadRecentArtists() {
|
||||
disposable += repository.recentArtists
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
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))
|
||||
|
@ -66,7 +65,6 @@ class HomePresenter(private val view: HomeContract.HomeView) : Presenter(), Home
|
|||
|
||||
private fun loadRecentAlbums() {
|
||||
disposable += repository.recentAlbums
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
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))
|
||||
|
@ -77,7 +75,6 @@ class HomePresenter(private val view: HomeContract.HomeView) : Presenter(), Home
|
|||
|
||||
private fun loadATopAlbums() {
|
||||
disposable += repository.topAlbums
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
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))
|
||||
|
@ -88,7 +85,6 @@ class HomePresenter(private val view: HomeContract.HomeView) : Presenter(), Home
|
|||
|
||||
private fun loadTopArtists() {
|
||||
disposable += repository.topArtists
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
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))
|
||||
|
@ -99,7 +95,6 @@ class HomePresenter(private val view: HomeContract.HomeView) : Presenter(), Home
|
|||
|
||||
private fun loadFavorite() {
|
||||
disposable += repository.favoritePlaylist
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
if (it.isNotEmpty()) hashSet.add(Home(4, R.string.favorites, 0, it, PLAYLISTS, R.drawable.ic_favorite_white_24dp))
|
||||
view.showData(ArrayList(hashSet))
|
||||
|
@ -110,7 +105,6 @@ class HomePresenter(private val view: HomeContract.HomeView) : Presenter(), Home
|
|||
|
||||
private fun loadGenre() {
|
||||
disposable += repository.allGenres
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
if (it.isNotEmpty()) hashSet.add(Home(6, R.string.genres, 0, it, GENRES, R.drawable.ic_guitar_acoustic_white_24dp))
|
||||
view.showData(ArrayList(hashSet))
|
||||
|
|
|
@ -21,70 +21,110 @@ import code.name.monkey.retromusic.model.*
|
|||
import code.name.monkey.retromusic.model.smartplaylist.AbsSmartPlaylist
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
class RepositoryImpl(private val context: Context) : Repository {
|
||||
override val favoritePlaylist: Observable<ArrayList<Playlist>>
|
||||
get() = PlaylistLoader.getFavoritePlaylist(context)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
|
||||
override val allSongs: Observable<ArrayList<Song>>
|
||||
get() = SongLoader.getAllSongs(context)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
override val suggestionSongs: Observable<ArrayList<Song>>
|
||||
get() = SongLoader.suggestSongs(context)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
override val allAlbums: Observable<ArrayList<Album>>
|
||||
get() = AlbumLoader.getAllAlbums(context)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
override val recentAlbums: Observable<ArrayList<Album>>
|
||||
get() = LastAddedSongsLoader.getLastAddedAlbums(context)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
override val topAlbums: Observable<ArrayList<Album>>
|
||||
get() = TopAndRecentlyPlayedTracksLoader.getTopAlbums(context)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
override val allArtists: Observable<ArrayList<Artist>>
|
||||
get() = ArtistLoader.getAllArtists(context)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
override val recentArtists: Observable<ArrayList<Artist>>
|
||||
get() = LastAddedSongsLoader.getLastAddedArtists(context)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
override val topArtists: Observable<ArrayList<Artist>>
|
||||
get() = TopAndRecentlyPlayedTracksLoader.getTopArtists(context)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
override val allPlaylists: Observable<ArrayList<Playlist>>
|
||||
get() = PlaylistLoader.getAllPlaylists(context)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
override val homeList: Observable<ArrayList<Playlist>>
|
||||
get() = HomeLoader.getHomeLoader(context)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
override val allThings: Observable<ArrayList<AbsSmartPlaylist>>
|
||||
get() = HomeLoader.getRecentAndTopThings(context)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
override val allGenres: Observable<ArrayList<Genre>>
|
||||
get() = GenreLoader.getAllGenres(context)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
override fun getSong(id: Int): Observable<Song> {
|
||||
return SongLoader.getSong(context, id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
|
||||
override fun getAlbum(albumId: Int): Observable<Album> {
|
||||
return AlbumLoader.getAlbum(context, albumId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
|
||||
override fun getArtistById(artistId: Long): Observable<Artist> {
|
||||
return ArtistLoader.getArtist(context, artistId.toInt())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
|
||||
override fun search(query: String?): Observable<ArrayList<Any>> {
|
||||
return SearchLoader.searchAll(context, query)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
|
||||
override fun getPlaylistSongs(playlist: Playlist): Observable<ArrayList<Song>> {
|
||||
return PlaylistSongsLoader.getPlaylistSongList(context, playlist)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
|
||||
override fun getGenre(genreId: Int): Observable<ArrayList<Song>> {
|
||||
return GenreLoader.getSongs(context, genreId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,11 +19,12 @@ import android.content.Context;
|
|||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* This database tracks the number of play counts for an individual song. This is used to drive
|
||||
* the top played tracks as well as the playlist images
|
||||
|
|
|
@ -30,13 +30,14 @@
|
|||
app:elevation="0dp">
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/toolbarContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardElevation="6dp"
|
||||
android:id="@+id/toolbarContainer"
|
||||
app:strokeColor="@color/black_color"
|
||||
app:cardUseCompatPadding="true"
|
||||
app:layout_scrollFlags="scroll|enterAlways">
|
||||
app:layout_scrollFlags="scroll|enterAlways"
|
||||
app:strokeWidth="1dp">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
<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:id="@+id/contentContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -40,7 +39,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<code.name.monkey.retromusic.views.IconImageView
|
||||
android:layout_width="96dp"
|
||||
|
@ -53,7 +53,6 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/empty"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
tools:visibility="visible" />
|
||||
android:textColor="?android:textColorSecondary" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
|
@ -623,4 +623,5 @@
|
|||
<string name="premium">Get Premium</string>
|
||||
<string name="pro_summary">Now playing themes, Carousel effect, Color theme and more..</string>
|
||||
<string name="action_play_all">Play all</string>
|
||||
<string name="start_play_music">Start playing music.</string>
|
||||
</resources>
|
||||
|
|
|
@ -26,9 +26,9 @@ android {
|
|||
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0-alpha05'
|
||||
implementation 'com.google.android.material:material:1.1.0-alpha05'
|
||||
implementation 'androidx.preference:preference:1.1.0-alpha05'
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0-beta01'
|
||||
implementation 'com.google.android.material:material:1.1.0-alpha07'
|
||||
implementation 'androidx.preference:preference:1.1.0-beta01'
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
// Used for the list preference classes
|
||||
implementation 'com.afollestad.material-dialogs:core:3.0.0-alpha1'
|
||||
|
|
10
build.gradle
10
build.gradle
|
@ -1,19 +1,13 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.3.31'
|
||||
ext {
|
||||
supportLibVersion = '1.1.0-alpha05'
|
||||
firebase = "11.8.0"
|
||||
retrofit = "2.3.0"
|
||||
materialDialog = "2.0.0"
|
||||
}
|
||||
ext.kotlin_version = '1.3.40'
|
||||
repositories {
|
||||
jcenter()
|
||||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.3.1'
|
||||
classpath 'com.android.tools.build:gradle:3.3.2'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue