commit
5df5f6c93e
47 changed files with 1130 additions and 826 deletions
|
@ -75,7 +75,9 @@ android {
|
|||
androidExtensions {
|
||||
experimental = true
|
||||
}
|
||||
|
||||
kapt {
|
||||
generateStubs = true
|
||||
}
|
||||
}
|
||||
|
||||
def getProperties(String fileName) {
|
||||
|
@ -150,6 +152,9 @@ dependencies {
|
|||
implementation 'com.r0adkll:slidableactivity:2.1.0'
|
||||
implementation 'com.heinrichreimersoftware:material-intro:1.6'
|
||||
|
||||
implementation 'com.google.dagger:dagger:2.23.1'
|
||||
kapt 'com.google.dagger:dagger-compiler:2.23.1'
|
||||
|
||||
implementation project(':appthemehelper')
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,9 @@ import androidx.multidex.MultiDexApplication
|
|||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||
import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager
|
||||
import code.name.monkey.retromusic.dagger.DaggerMusicComponent
|
||||
import code.name.monkey.retromusic.dagger.MusicComponent
|
||||
import code.name.monkey.retromusic.dagger.module.AppModule
|
||||
import com.anjlab.android.iab.v3.BillingProcessor
|
||||
import com.anjlab.android.iab.v3.TransactionDetails
|
||||
|
||||
|
@ -32,6 +35,11 @@ class App : MultiDexApplication() {
|
|||
super.onCreate()
|
||||
instance = this
|
||||
|
||||
|
||||
musicComponent = DaggerMusicComponent.builder()
|
||||
.appModule(AppModule(this))
|
||||
.build()
|
||||
|
||||
// default theme
|
||||
if (!ThemeStore.isConfigured(this, 3)) {
|
||||
ThemeStore.editTheme(this)
|
||||
|
@ -65,6 +73,9 @@ class App : MultiDexApplication() {
|
|||
|
||||
companion object {
|
||||
|
||||
|
||||
lateinit var musicComponent: MusicComponent
|
||||
|
||||
const val PRO_VERSION_PRODUCT_ID = "pro_version"
|
||||
|
||||
lateinit var instance: App
|
||||
|
|
|
@ -18,6 +18,7 @@ import code.name.monkey.appthemehelper.util.ATHUtil
|
|||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
|
||||
import code.name.monkey.retromusic.activities.tageditor.AbsTagEditorActivity
|
||||
|
@ -26,6 +27,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.show
|
||||
import code.name.monkey.retromusic.glide.GlideApp
|
||||
import code.name.monkey.retromusic.glide.RetroGlideExtension
|
||||
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
||||
|
@ -34,8 +36,9 @@ import code.name.monkey.retromusic.helper.SortOrder.AlbumSongSortOrder
|
|||
import code.name.monkey.retromusic.loaders.ArtistLoader
|
||||
import code.name.monkey.retromusic.misc.AppBarStateChangeListener
|
||||
import code.name.monkey.retromusic.model.Album
|
||||
import code.name.monkey.retromusic.mvp.contract.AlbumDetailsContract
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
import code.name.monkey.retromusic.mvp.presenter.AlbumDetailsPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.AlbumDetailsView
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
|
@ -45,10 +48,10 @@ import io.reactivex.disposables.CompositeDisposable
|
|||
import kotlinx.android.synthetic.main.activity_album.*
|
||||
import kotlinx.android.synthetic.main.activity_album_content.*
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsContract.AlbumDetailsView {
|
||||
class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView {
|
||||
|
||||
private lateinit var albumDetailsPresenter: AlbumDetailsPresenter
|
||||
private lateinit var simpleSongAdapter: SimpleSongAdapter
|
||||
private var disposable = CompositeDisposable()
|
||||
|
||||
|
@ -67,6 +70,9 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsContrac
|
|||
window.enterTransition = slide
|
||||
}
|
||||
|
||||
@Inject
|
||||
lateinit var albumDetailsPresenter: AlbumDetailsPresenter
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setDrawUnderStatusBar()
|
||||
setupWindowTransition()
|
||||
|
@ -81,10 +87,6 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsContrac
|
|||
|
||||
artistImage = findViewById(R.id.artistImage)
|
||||
|
||||
val albumId = intent.getIntExtra(EXTRA_ALBUM_ID, -1)
|
||||
albumDetailsPresenter = AlbumDetailsPresenter(this, albumId)
|
||||
albumDetailsPresenter.subscribe()
|
||||
|
||||
setupRecyclerView()
|
||||
setupToolbarMarginHeight()
|
||||
|
||||
|
@ -98,6 +100,15 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsContrac
|
|||
shuffleAction.apply {
|
||||
setOnClickListener { MusicPlayerRemote.openAndShuffleQueue(album.songs!!, true) }
|
||||
}
|
||||
|
||||
App.musicComponent.inject(this)
|
||||
albumDetailsPresenter.attachView(this)
|
||||
|
||||
if (intent.extras!!.containsKey(EXTRA_ALBUM_ID)) {
|
||||
albumDetailsPresenter.loadAlbum(intent.extras!!.getInt(EXTRA_ALBUM_ID))
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupRecyclerView() {
|
||||
|
@ -151,42 +162,31 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsContrac
|
|||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
albumDetailsPresenter.unsubscribe()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
disposable.dispose()
|
||||
albumDetailsPresenter.detachView()
|
||||
}
|
||||
|
||||
override fun loading() {
|
||||
|
||||
}
|
||||
|
||||
override fun showEmptyView() {
|
||||
|
||||
}
|
||||
|
||||
override fun completed() {
|
||||
override fun complete() {
|
||||
ActivityCompat.startPostponedEnterTransition(this)
|
||||
}
|
||||
|
||||
override fun showData(list: Album) {
|
||||
if (list.songs!!.isEmpty()) {
|
||||
override fun album(album: Album) {
|
||||
|
||||
if (album.songs!!.isEmpty()) {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
this.album = list
|
||||
this.album = album
|
||||
|
||||
albumTitle.text = list.title
|
||||
albumText.text = String.format("%s • %s • %s", list.artistName, MusicUtil.getYearString(list.year), MusicUtil.getReadableDurationString(MusicUtil.getTotalDuration(this, list.songs)))
|
||||
albumTitle.text = album.title
|
||||
albumText.text = String.format("%s • %s • %s", album.artistName, MusicUtil.getYearString(album.year), MusicUtil.getReadableDurationString(MusicUtil.getTotalDuration(this, album.songs)))
|
||||
|
||||
loadAlbumCover()
|
||||
loadMoreFrom(list)
|
||||
simpleSongAdapter.swapDataSet(album.songs)
|
||||
|
||||
simpleSongAdapter.swapDataSet(list.songs)
|
||||
albumDetailsPresenter.loadMore(album.artistId)
|
||||
}
|
||||
|
||||
private lateinit var artistImage: ImageView
|
||||
|
@ -194,17 +194,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsContrac
|
|||
private fun loadMoreFrom(album: Album) {
|
||||
disposable.add(ArtistLoader.getArtistFlowable(this, album.artistId)
|
||||
.map {
|
||||
GlideApp.with(this@AlbumDetailsActivity)
|
||||
.asBitmapPalette()
|
||||
.load(RetroGlideExtension.getArtistModel(it))
|
||||
.transition(RetroGlideExtension.getDefaultTransition())
|
||||
.artistOptions(it)
|
||||
.dontAnimate()
|
||||
.into(object : RetroMusicColoredTarget(artistImage) {
|
||||
override fun onColorReady(color: Int) {
|
||||
|
||||
}
|
||||
})
|
||||
return@map it.albums!!
|
||||
}
|
||||
.map { it.filter { albumSearch -> albumSearch.id != album.id } }
|
||||
|
@ -227,6 +217,30 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsContrac
|
|||
})
|
||||
}
|
||||
|
||||
override fun moreAlbums(albums: ArrayList<Album>) {
|
||||
moreTitle.show()
|
||||
moreRecyclerView.show()
|
||||
moreTitle.text = String.format("More from %s", album.artistName)
|
||||
|
||||
val albumAdapter = HorizontalAlbumAdapter(this, albums, false, null)
|
||||
moreRecyclerView.layoutManager = GridLayoutManager(this, 1, GridLayoutManager.HORIZONTAL, false)
|
||||
moreRecyclerView.adapter = albumAdapter
|
||||
}
|
||||
|
||||
override fun loadArtistImage(artist: Artist) {
|
||||
GlideApp.with(this@AlbumDetailsActivity)
|
||||
.asBitmapPalette()
|
||||
.load(RetroGlideExtension.getArtistModel(artist))
|
||||
.transition(RetroGlideExtension.getDefaultTransition())
|
||||
.artistOptions(artist)
|
||||
.dontAnimate()
|
||||
.into(object : RetroMusicColoredTarget(artistImage) {
|
||||
override fun onColorReady(color: Int) {
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun loadAlbumCover() {
|
||||
GlideApp.with(this)
|
||||
.asBitmapPalette()
|
||||
|
@ -238,7 +252,6 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsContrac
|
|||
override fun onColorReady(color: Int) {
|
||||
setColors(color)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -337,7 +350,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsContrac
|
|||
}
|
||||
|
||||
private fun reload() {
|
||||
albumDetailsPresenter.subscribe()
|
||||
albumDetailsPresenter.loadAlbum(intent.extras!!.getInt(ArtistDetailActivity.EXTRA_ARTIST_ID))
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -22,6 +22,7 @@ import code.name.monkey.appthemehelper.util.ATHUtil
|
|||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
|
||||
import code.name.monkey.retromusic.adapter.album.AlbumAdapter
|
||||
|
@ -34,26 +35,23 @@ import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
|||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.misc.AppBarStateChangeListener
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
import code.name.monkey.retromusic.mvp.contract.ArtistDetailContract
|
||||
import code.name.monkey.retromusic.mvp.presenter.ArtistDetailsPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.ArtistDetailsView
|
||||
import code.name.monkey.retromusic.rest.LastFMRestClient
|
||||
import code.name.monkey.retromusic.rest.model.LastFmArtist
|
||||
import code.name.monkey.retromusic.util.*
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
import kotlinx.android.synthetic.main.activity_artist_content.*
|
||||
import kotlinx.android.synthetic.main.activity_artist_details.*
|
||||
import retrofit2.Call
|
||||
import retrofit2.Callback
|
||||
import retrofit2.Response
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailContract.ArtistsDetailsView {
|
||||
class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView {
|
||||
|
||||
private var biography: Spanned? = null
|
||||
private lateinit var artist: Artist
|
||||
private var lastFMRestClient: LastFMRestClient? = null
|
||||
private lateinit var artistDetailsPresenter: ArtistDetailsPresenter
|
||||
private lateinit var songAdapter: SimpleSongAdapter
|
||||
private lateinit var albumAdapter: AlbumAdapter
|
||||
private var forceDownload: Boolean = false
|
||||
|
@ -68,11 +66,13 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailContrac
|
|||
return wrapSlidingMusicPanel(R.layout.activity_artist_details)
|
||||
}
|
||||
|
||||
@Inject
|
||||
lateinit var artistDetailsPresenter: ArtistDetailsPresenter
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setDrawUnderStatusBar()
|
||||
setupWindowTransitions()
|
||||
super.onCreate(savedInstanceState)
|
||||
//collapsingToolbarLayout?.setBackgroundColor(ThemeStore.primaryColor(this))
|
||||
contentContainer?.setCardBackgroundColor(ColorStateList.valueOf(ThemeStore.primaryColor(this)))
|
||||
toggleBottomNavigationView(true)
|
||||
setNavigationbarColorAuto()
|
||||
|
@ -80,13 +80,20 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailContrac
|
|||
|
||||
ActivityCompat.postponeEnterTransition(this)
|
||||
|
||||
|
||||
App.musicComponent.inject(this)
|
||||
artistDetailsPresenter.attachView(this)
|
||||
|
||||
if (intent.extras!!.containsKey(EXTRA_ARTIST_ID)) {
|
||||
artistDetailsPresenter.loadArtist(intent.extras!!.getInt(EXTRA_ARTIST_ID))
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
|
||||
lastFMRestClient = LastFMRestClient(this)
|
||||
|
||||
setUpViews()
|
||||
|
||||
artistDetailsPresenter = ArtistDetailsPresenter(this, intent.extras!!)
|
||||
artistDetailsPresenter.subscribe()
|
||||
|
||||
playAction.apply {
|
||||
setOnClickListener { MusicPlayerRemote.openQueue(artist.songs, 0, true) }
|
||||
}
|
||||
|
@ -110,10 +117,10 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailContrac
|
|||
}
|
||||
|
||||
private fun setupContainerHeight() {
|
||||
if (imageContainer != null) {
|
||||
val params = imageContainer!!.layoutParams
|
||||
imageContainer?.let {
|
||||
val params = it.layoutParams
|
||||
params.width = DensityUtil.getScreenHeight(this) / 2
|
||||
imageContainer!!.layoutParams = params
|
||||
it.layoutParams = params
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,7 +135,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailContrac
|
|||
toolbar?.setNavigationIcon(R.drawable.ic_keyboard_backspace_black_24dp)
|
||||
setSupportActionBar(toolbar)
|
||||
|
||||
supportActionBar!!.title = null
|
||||
supportActionBar?.title = null
|
||||
|
||||
if (toolbar != null && !PreferenceUtil.getInstance().fullScreenMode) {
|
||||
val params = toolbar!!.layoutParams as ViewGroup.MarginLayoutParams
|
||||
|
@ -183,23 +190,16 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailContrac
|
|||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
artistDetailsPresenter.unsubscribe()
|
||||
}
|
||||
|
||||
override fun loading() {}
|
||||
|
||||
override fun showEmptyView() {
|
||||
|
||||
}
|
||||
|
||||
override fun completed() {
|
||||
override fun complete() {
|
||||
ActivityCompat.startPostponedEnterTransition(this)
|
||||
}
|
||||
|
||||
override fun showData(list: Artist) {
|
||||
setArtist(list)
|
||||
override fun artist(artist: Artist) {
|
||||
setArtist(artist)
|
||||
}
|
||||
|
||||
private fun getArtist(): Artist {
|
||||
|
@ -214,11 +214,12 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailContrac
|
|||
loadArtistImage()
|
||||
|
||||
if (RetroUtil.isAllowedToDownloadMetadata(this)) {
|
||||
loadBiography()
|
||||
loadBiography(artist.name)
|
||||
}
|
||||
artistTitle.text = artist.name
|
||||
text.text = String.format("%s • %s", MusicUtil.getArtistInfoString(this, artist), MusicUtil
|
||||
.getReadableDurationString(MusicUtil.getTotalDuration(this, artist.songs)))
|
||||
|
||||
//val songs = artist.songs.sortedWith(compareBy { it.title }) as ArrayList<Song>
|
||||
songAdapter.swapDataSet(artist.songs)
|
||||
|
||||
|
@ -226,19 +227,17 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailContrac
|
|||
albumAdapter.swapDataSet(artist.albums!!)
|
||||
}
|
||||
|
||||
private fun loadBiography(lang: String? = Locale.getDefault().language) {
|
||||
private fun loadBiography(name: String,
|
||||
lang: String? = Locale.getDefault().language) {
|
||||
biography = null
|
||||
this.lang = lang
|
||||
artistDetailsPresenter.loadBiography(name, lang, null)
|
||||
}
|
||||
|
||||
lastFMRestClient!!.apiService
|
||||
.getArtistInfo(getArtist().name, lang, null)
|
||||
.enqueue(object : Callback<LastFmArtist> {
|
||||
override fun onResponse(call: Call<LastFmArtist>,
|
||||
response: Response<LastFmArtist>) {
|
||||
val lastFmArtist = response.body()
|
||||
override fun artistInfo(lastFmArtist: LastFmArtist?) {
|
||||
if (lastFmArtist != null && lastFmArtist.artist != null) {
|
||||
val bioContent = lastFmArtist.artist.bio.content
|
||||
if (bioContent != null && !bioContent.trim { it <= ' ' }.isEmpty()) {
|
||||
//TransitionManager.beginDelayedTransition(titleContainer);
|
||||
if (bioContent != null && bioContent.trim { it <= ' ' }.isNotEmpty()) {
|
||||
biographyText.visibility = View.VISIBLE
|
||||
biographyTitle.visibility = View.VISIBLE
|
||||
biography = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
|
@ -252,17 +251,11 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailContrac
|
|||
|
||||
// If the "lang" parameter is set and no biography is given, retry with default language
|
||||
if (biography == null && lang != null) {
|
||||
loadBiography(null)
|
||||
loadBiography(getArtist().name, null)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(call: Call<LastFmArtist>, t: Throwable) {
|
||||
t.printStackTrace()
|
||||
biography = null
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private var lang: String? = null
|
||||
|
||||
private fun loadArtistImage() {
|
||||
GlideApp.with(this)
|
||||
|
@ -281,7 +274,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailContrac
|
|||
setColors(defaultFooterColor)
|
||||
}
|
||||
})
|
||||
forceDownload = false;
|
||||
forceDownload = false
|
||||
}
|
||||
|
||||
private fun setColors(color: Int) {
|
||||
|
@ -351,8 +344,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailContrac
|
|||
}
|
||||
|
||||
private fun reload() {
|
||||
artistDetailsPresenter.unsubscribe()
|
||||
artistDetailsPresenter.subscribe()
|
||||
artistDetailsPresenter.loadArtist(intent.extras!!.getInt(EXTRA_ARTIST_ID))
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -10,31 +10,34 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
|||
import androidx.recyclerview.widget.RecyclerView
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
|
||||
import code.name.monkey.retromusic.adapter.song.ShuffleButtonSongAdapter
|
||||
import code.name.monkey.retromusic.adapter.song.SongAdapter
|
||||
import code.name.monkey.retromusic.extensions.applyToolbar
|
||||
import code.name.monkey.retromusic.helper.menu.GenreMenuHelper
|
||||
import code.name.monkey.retromusic.interfaces.CabHolder
|
||||
import code.name.monkey.retromusic.model.Genre
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.mvp.contract.GenreDetailsContract
|
||||
import code.name.monkey.retromusic.mvp.presenter.GenreDetailsPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.GenreDetailsView
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||
import code.name.monkey.retromusic.util.ViewUtil
|
||||
import com.afollestad.materialcab.MaterialCab
|
||||
import kotlinx.android.synthetic.main.activity_playlist_detail.*
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* @author Hemanth S (h4h13).
|
||||
*/
|
||||
|
||||
class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), GenreDetailsContract.GenreDetailsView, CabHolder {
|
||||
class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder, GenreDetailsView {
|
||||
|
||||
private var genre: Genre? = null
|
||||
private var presenter: GenreDetailsPresenter? = null
|
||||
@Inject
|
||||
lateinit var genreDetailsPresenter: GenreDetailsPresenter
|
||||
|
||||
private lateinit var genre: Genre
|
||||
private lateinit var songAdapter: ShuffleButtonSongAdapter
|
||||
private var cab: MaterialCab? = null
|
||||
|
||||
|
@ -53,49 +56,45 @@ class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), GenreDetailsContrac
|
|||
setLightStatusbar(ColorUtil.isColorLight(ThemeStore.primaryColor(this)))
|
||||
toggleBottomNavigationView(true)
|
||||
|
||||
genre = intent?.extras?.getParcelable(EXTRA_GENRE_ID)
|
||||
presenter = genre?.id?.let { GenreDetailsPresenter(this, it) }
|
||||
if (intent.extras != null) {
|
||||
genre = intent?.extras?.getParcelable(EXTRA_GENRE_ID)!!
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
|
||||
setUpToolBar()
|
||||
setupRecyclerView()
|
||||
|
||||
App.musicComponent.inject(this)
|
||||
genreDetailsPresenter.attachView(this)
|
||||
|
||||
}
|
||||
|
||||
private fun setUpToolBar() {
|
||||
val primaryColor = ThemeStore.primaryColor(this)
|
||||
appBarLayout.setBackgroundColor(primaryColor)
|
||||
applyToolbar(toolbar)
|
||||
|
||||
title = genre?.name
|
||||
title = genre.name
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
presenter?.subscribe()
|
||||
genreDetailsPresenter.loadGenreSongs(genre.id)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
presenter?.unsubscribe()
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
genreDetailsPresenter.detachView()
|
||||
}
|
||||
|
||||
override fun createContentView(): View {
|
||||
return wrapSlidingMusicPanel(R.layout.activity_playlist_detail)
|
||||
}
|
||||
|
||||
|
||||
override fun loading() {
|
||||
|
||||
}
|
||||
|
||||
override fun showEmptyView() {
|
||||
|
||||
}
|
||||
|
||||
override fun completed() {
|
||||
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.menu_genre_detail, menu)
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
|
@ -105,7 +104,7 @@ class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), GenreDetailsContrac
|
|||
if (item.itemId == android.R.id.home) {
|
||||
onBackPressed()
|
||||
}
|
||||
return GenreMenuHelper.handleMenuClick(this, genre!!, item)
|
||||
return GenreMenuHelper.handleMenuClick(this, genre, item)
|
||||
}
|
||||
|
||||
private fun setupRecyclerView() {
|
||||
|
@ -124,8 +123,8 @@ class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), GenreDetailsContrac
|
|||
})
|
||||
}
|
||||
|
||||
override fun showData(list: ArrayList<Song>) {
|
||||
songAdapter.swapDataSet(list)
|
||||
override fun songs(songs: ArrayList<Song>) {
|
||||
songAdapter.swapDataSet(songs)
|
||||
}
|
||||
|
||||
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
|
||||
|
@ -149,7 +148,7 @@ class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), GenreDetailsContrac
|
|||
|
||||
override fun onMediaStoreChanged() {
|
||||
super.onMediaStoreChanged()
|
||||
presenter?.subscribe()
|
||||
genreDetailsPresenter.loadGenreSongs(genre.id)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -9,6 +9,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
|||
import androidx.recyclerview.widget.RecyclerView
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
|
||||
import code.name.monkey.retromusic.adapter.song.OrderablePlaylistSongAdapter
|
||||
|
@ -21,9 +22,8 @@ import code.name.monkey.retromusic.loaders.PlaylistLoader
|
|||
import code.name.monkey.retromusic.model.AbsCustomPlaylist
|
||||
import code.name.monkey.retromusic.model.Playlist
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.mvp.contract.PlaylistSongsContract
|
||||
import code.name.monkey.retromusic.mvp.contract.PlaylistSongsContract.*
|
||||
import code.name.monkey.retromusic.mvp.presenter.PlaylistSongsPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.PlaylistSongsView
|
||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||
import code.name.monkey.retromusic.util.ViewUtil
|
||||
|
@ -32,16 +32,19 @@ import com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemA
|
|||
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager
|
||||
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils
|
||||
import kotlinx.android.synthetic.main.activity_playlist_detail.*
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
|
||||
class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, PlaylistSongsView {
|
||||
|
||||
private var playlist: Playlist? = null
|
||||
@Inject
|
||||
lateinit var playlistSongsPresenter: PlaylistSongsPresenter
|
||||
|
||||
private lateinit var playlist: Playlist
|
||||
private var cab: MaterialCab? = null
|
||||
private lateinit var adapter: SongAdapter
|
||||
private var wrappedAdapter: RecyclerView.Adapter<*>? = null
|
||||
private var recyclerViewDragDropManager: RecyclerViewDragDropManager? = null
|
||||
private var songsPresenter: PlaylistSongsPresenter? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setDrawUnderStatusBar()
|
||||
|
@ -55,8 +58,15 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
|
|||
|
||||
toggleBottomNavigationView(true)
|
||||
|
||||
playlist = intent.extras!!.getParcelable(EXTRA_PLAYLIST)
|
||||
songsPresenter = PlaylistSongsPresenter(this, playlist!!)
|
||||
if (intent.extras != null) {
|
||||
playlist = intent.extras!!.getParcelable(EXTRA_PLAYLIST)!!
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
|
||||
App.musicComponent.inject(this)
|
||||
|
||||
playlistSongsPresenter.attachView(this)
|
||||
|
||||
setUpToolBar()
|
||||
setUpRecyclerView()
|
||||
|
@ -78,7 +88,7 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
|
|||
adapter = OrderablePlaylistSongAdapter(this, ArrayList(), R.layout.item_list, false, this,
|
||||
object : OrderablePlaylistSongAdapter.OnMoveItemListener {
|
||||
override fun onMoveItem(fromPosition: Int, toPosition: Int) {
|
||||
if (PlaylistsUtil.moveItem(this@PlaylistDetailActivity, playlist!!.id, fromPosition, toPosition)) {
|
||||
if (PlaylistsUtil.moveItem(this@PlaylistDetailActivity, playlist.id, fromPosition, toPosition)) {
|
||||
val song = adapter.dataSet.removeAt(fromPosition)
|
||||
adapter.dataSet.add(toPosition, song)
|
||||
adapter.notifyItemMoved(fromPosition, toPosition)
|
||||
|
@ -102,12 +112,12 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
songsPresenter!!.subscribe()
|
||||
playlistSongsPresenter.loadPlaylistSongs(playlist)
|
||||
}
|
||||
|
||||
private fun setUpToolBar() {
|
||||
applyToolbar(toolbar)
|
||||
title = playlist!!.name
|
||||
title = playlist.name
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
|
@ -116,14 +126,13 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
|
|||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
val id = item.itemId
|
||||
when (id) {
|
||||
when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
onBackPressed()
|
||||
return true
|
||||
}
|
||||
}
|
||||
return PlaylistMenuHelper.handleMenuClick(this, playlist!!, item)
|
||||
return PlaylistMenuHelper.handleMenuClick(this, playlist, item)
|
||||
}
|
||||
|
||||
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
|
||||
|
@ -153,19 +162,19 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
|
|||
|
||||
if (playlist !is AbsCustomPlaylist) {
|
||||
// Playlist deleted
|
||||
if (!PlaylistsUtil.doesPlaylistExist(this, playlist!!.id)) {
|
||||
if (!PlaylistsUtil.doesPlaylistExist(this, playlist.id)) {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
|
||||
// Playlist renamed
|
||||
val playlistName = PlaylistsUtil.getNameForPlaylist(this, playlist!!.id.toLong())
|
||||
if (playlistName != playlist!!.name) {
|
||||
playlist = PlaylistLoader.getPlaylist(this, playlist!!.id)
|
||||
setToolbarTitle(playlist!!.name)
|
||||
val playlistName = PlaylistsUtil.getNameForPlaylist(this, playlist.id.toLong())
|
||||
if (playlistName != playlist.name) {
|
||||
playlist = PlaylistLoader.getPlaylist(this, playlist.id)
|
||||
setToolbarTitle(playlist.name)
|
||||
}
|
||||
}
|
||||
songsPresenter!!.subscribe()
|
||||
playlistSongsPresenter.loadPlaylistSongs(playlist)
|
||||
}
|
||||
|
||||
private fun setToolbarTitle(title: String) {
|
||||
|
@ -182,7 +191,6 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
|
|||
recyclerViewDragDropManager!!.cancelDrag()
|
||||
}
|
||||
super.onPause()
|
||||
songsPresenter!!.unsubscribe()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
@ -201,19 +209,16 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
|
|||
wrappedAdapter = null
|
||||
}
|
||||
super.onDestroy()
|
||||
playlistSongsPresenter.detachView()
|
||||
}
|
||||
|
||||
override fun loading() {}
|
||||
|
||||
override fun showEmptyView() {
|
||||
empty.visibility = View.VISIBLE
|
||||
emptyText.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
override fun completed() {}
|
||||
|
||||
override fun showData(list: ArrayList<Song>) {
|
||||
adapter.swapDataSet(list)
|
||||
override fun songs(songs: ArrayList<Song>) {
|
||||
adapter.swapDataSet(songs)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -21,19 +21,22 @@ import androidx.recyclerview.widget.RecyclerView
|
|||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
|
||||
import code.name.monkey.retromusic.adapter.SearchAdapter
|
||||
import code.name.monkey.retromusic.mvp.contract.SearchContract
|
||||
import code.name.monkey.retromusic.mvp.presenter.SearchPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.SearchView
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import kotlinx.android.synthetic.main.activity_search.*
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, SearchContract.SearchView, TextWatcher {
|
||||
class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatcher, SearchView {
|
||||
@Inject
|
||||
lateinit var searchPresenter: SearchPresenter
|
||||
|
||||
private lateinit var searchPresenter: SearchPresenter
|
||||
private var searchAdapter: SearchAdapter? = null
|
||||
private var query: String? = null
|
||||
|
||||
|
@ -42,7 +45,9 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, SearchCon
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_search)
|
||||
|
||||
searchPresenter = SearchPresenter(this)
|
||||
App.musicComponent.inject(this)
|
||||
|
||||
searchPresenter.attachView(this)
|
||||
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
|
@ -105,13 +110,12 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, SearchCon
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
searchPresenter.subscribe()
|
||||
searchPresenter.search(query)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
searchPresenter.unsubscribe()
|
||||
searchPresenter.detachView()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
|
@ -158,18 +162,10 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, SearchCon
|
|||
}
|
||||
}
|
||||
|
||||
override fun loading() {
|
||||
|
||||
}
|
||||
|
||||
override fun showEmptyView() {
|
||||
searchAdapter!!.swapDataSet(ArrayList())
|
||||
}
|
||||
|
||||
override fun completed() {
|
||||
|
||||
}
|
||||
|
||||
override fun showData(list: MutableList<Any>) {
|
||||
searchAdapter!!.swapDataSet(list)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.dagger
|
||||
|
||||
import code.name.monkey.retromusic.activities.*
|
||||
import code.name.monkey.retromusic.dagger.module.*
|
||||
import code.name.monkey.retromusic.fragments.mainactivity.*
|
||||
import code.name.monkey.retromusic.fragments.mainactivity.home.BannerHomeFragment
|
||||
import dagger.Component
|
||||
|
||||
/**
|
||||
* Created by hemanths on 2019-09-04.
|
||||
*/
|
||||
@Component(modules = [
|
||||
RepositoryModule::class,
|
||||
AlbumModule::class,
|
||||
ArtistModule::class,
|
||||
GenreModule::class,
|
||||
HomeModule::class,
|
||||
PlaylistModule::class,
|
||||
SearchModule::class,
|
||||
SongModule::class,
|
||||
ActivityModule::class
|
||||
])
|
||||
interface MusicComponent {
|
||||
|
||||
fun inject(songsFragment: SongsFragment)
|
||||
|
||||
fun inject(albumsFragment: AlbumsFragment)
|
||||
|
||||
fun inject(artistsFragment: ArtistsFragment)
|
||||
|
||||
fun inject(genresFragment: GenresFragment)
|
||||
|
||||
fun inject(playlistsFragment: PlaylistsFragment)
|
||||
|
||||
fun inject(artistDetailActivity: ArtistDetailActivity)
|
||||
|
||||
fun inject(albumDetailsActivity: AlbumDetailsActivity)
|
||||
|
||||
fun inject(playlistDetailActivity: PlaylistDetailActivity)
|
||||
|
||||
fun inject(genreDetailsActivity: GenreDetailsActivity)
|
||||
|
||||
fun inject(searchActivity: SearchActivity)
|
||||
|
||||
fun inject(bannerHomeFragment: BannerHomeFragment)
|
||||
}
|
|
@ -12,17 +12,21 @@
|
|||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.mvp.contract
|
||||
package code.name.monkey.retromusic.dagger.module
|
||||
|
||||
import code.name.monkey.retromusic.model.Home
|
||||
import code.name.monkey.retromusic.mvp.BasePresenter
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
import android.app.Activity
|
||||
|
||||
interface HomeContract {
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
|
||||
interface HomeView : BaseView<ArrayList<Home>>
|
||||
/**
|
||||
* Created by hemanths on 2019-09-04.
|
||||
*/
|
||||
@Module
|
||||
class ActivityModule(private val activity: Activity) {
|
||||
|
||||
interface HomePresenter : BasePresenter<HomeView> {
|
||||
fun homeSections()
|
||||
@Provides
|
||||
fun provideActivity(): Activity {
|
||||
return activity
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.dagger.module
|
||||
|
||||
import code.name.monkey.retromusic.mvp.presenter.AlbumDetailsPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.AlbumDetailsPresenter.AlbumDetailsPresenterImpl
|
||||
import code.name.monkey.retromusic.mvp.presenter.AlbumsPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.AlbumsPresenter.AlbumsPresenterImpl
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
|
||||
/**
|
||||
* Created by hemanths on 2019-09-04.
|
||||
*/
|
||||
@Module
|
||||
class AlbumModule {
|
||||
|
||||
@Provides
|
||||
fun providesAlbumsPresenter(presenter: AlbumsPresenterImpl): AlbumsPresenter {
|
||||
return presenter
|
||||
}
|
||||
|
||||
@Provides
|
||||
fun providesAlbumDetailsPresenter(presenter: AlbumDetailsPresenterImpl): AlbumDetailsPresenter {
|
||||
return presenter
|
||||
}
|
||||
}
|
|
@ -12,21 +12,21 @@
|
|||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.mvp.contract
|
||||
package code.name.monkey.retromusic.dagger.module
|
||||
|
||||
import code.name.monkey.retromusic.mvp.BasePresenter
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
import java.util.*
|
||||
import android.content.Context
|
||||
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
|
||||
/**
|
||||
* Created by hemanths on 20/08/17.
|
||||
* Created by hemanths on 2019-09-04.
|
||||
*/
|
||||
@Module
|
||||
class AppModule(private val context: Context) {
|
||||
|
||||
interface SearchContract {
|
||||
interface SearchView : BaseView<MutableList<Any>>
|
||||
|
||||
interface SearchPresenter : BasePresenter<SearchView> {
|
||||
fun search(query: String?)
|
||||
@Provides
|
||||
fun provideContext(): Context {
|
||||
return context
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.dagger.module
|
||||
|
||||
import code.name.monkey.retromusic.mvp.presenter.ArtistDetailsPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.ArtistsPresenter
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
|
||||
import code.name.monkey.retromusic.mvp.presenter.ArtistDetailsPresenter.*
|
||||
import code.name.monkey.retromusic.mvp.presenter.ArtistsPresenter.*
|
||||
|
||||
/**
|
||||
* Created by hemanths on 2019-09-04.
|
||||
*/
|
||||
@Module
|
||||
class ArtistModule {
|
||||
|
||||
@Provides
|
||||
fun providesArtistDetailsPresenter(presenter: ArtistDetailsPresenterImpl): ArtistDetailsPresenter {
|
||||
return presenter
|
||||
}
|
||||
|
||||
@Provides
|
||||
fun providesArtistsPresenter(presenter: ArtistsPresenterImpl): ArtistsPresenter {
|
||||
return presenter
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.dagger.module
|
||||
|
||||
import code.name.monkey.retromusic.mvp.presenter.GenreDetailsPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.GenreDetailsPresenter.GenreDetailsPresenterImpl
|
||||
import code.name.monkey.retromusic.mvp.presenter.GenresPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.GenresPresenter.GenresPresenterImpl
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
|
||||
/**
|
||||
* Created by hemanths on 2019-09-04.
|
||||
*/
|
||||
@Module
|
||||
class GenreModule {
|
||||
|
||||
@Provides
|
||||
fun providesGenresPresenter(presenter: GenresPresenterImpl): GenresPresenter {
|
||||
return presenter
|
||||
}
|
||||
|
||||
|
||||
@Provides
|
||||
fun providesGenreDetailsPresenter(presenter: GenreDetailsPresenterImpl): GenreDetailsPresenter {
|
||||
return presenter
|
||||
}
|
||||
}
|
|
@ -12,22 +12,22 @@
|
|||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.mvp.contract
|
||||
|
||||
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
import code.name.monkey.retromusic.mvp.BasePresenter
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
package code.name.monkey.retromusic.dagger.module
|
||||
|
||||
import code.name.monkey.retromusic.mvp.presenter.HomePresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.HomePresenter.HomePresenterImpl
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
|
||||
/**
|
||||
* Created by hemanths on 20/08/17.
|
||||
* Created by hemanths on 2019-09-04.
|
||||
*/
|
||||
@Module
|
||||
class HomeModule {
|
||||
|
||||
interface ArtistDetailContract {
|
||||
interface ArtistsDetailsView : BaseView<Artist>
|
||||
@Provides
|
||||
fun providesHomePresenter(presenter: HomePresenterImpl): HomePresenter {
|
||||
return presenter
|
||||
}
|
||||
|
||||
interface Presenter : BasePresenter<ArtistsDetailsView> {
|
||||
fun loadArtistById()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.dagger.module
|
||||
|
||||
import code.name.monkey.retromusic.mvp.presenter.PlaylistSongsPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.PlaylistSongsPresenter.PlaylistSongsPresenterImpl
|
||||
import code.name.monkey.retromusic.mvp.presenter.PlaylistsPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.PlaylistsPresenter.PlaylistsPresenterImpl
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
|
||||
/**
|
||||
* Created by hemanths on 2019-09-04.
|
||||
*/
|
||||
@Module
|
||||
class PlaylistModule {
|
||||
@Provides
|
||||
fun providesPlaylistSongPresenter(presenter: PlaylistSongsPresenterImpl): PlaylistSongsPresenter {
|
||||
return presenter
|
||||
}
|
||||
|
||||
@Provides
|
||||
fun providesPlaylistsPresenter(presenter: PlaylistsPresenterImpl): PlaylistsPresenter {
|
||||
return presenter
|
||||
}
|
||||
}
|
|
@ -12,22 +12,23 @@
|
|||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.mvp.contract
|
||||
package code.name.monkey.retromusic.dagger.module
|
||||
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.mvp.BasePresenter
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
import android.content.Context
|
||||
|
||||
import java.util.ArrayList
|
||||
import code.name.monkey.retromusic.providers.RepositoryImpl
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
|
||||
/**
|
||||
* @author Hemanth S (h4h13).
|
||||
* Created by hemanths on 2019-09-04.
|
||||
*/
|
||||
@Module(includes = [AppModule::class])
|
||||
class RepositoryModule {
|
||||
|
||||
interface GenreDetailsContract {
|
||||
interface GenreDetailsView : BaseView<ArrayList<Song>>
|
||||
|
||||
interface Presenter : BasePresenter<GenreDetailsView> {
|
||||
fun loadGenre(genreId: Int)
|
||||
@Provides
|
||||
fun providesRepository(context: Context): Repository {
|
||||
return RepositoryImpl(context)
|
||||
}
|
||||
}
|
|
@ -12,24 +12,22 @@
|
|||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.mvp.contract
|
||||
|
||||
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
import code.name.monkey.retromusic.mvp.BasePresenter
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
|
||||
import java.util.ArrayList
|
||||
package code.name.monkey.retromusic.dagger.module
|
||||
|
||||
import code.name.monkey.retromusic.mvp.presenter.SearchPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.SearchPresenter.SearchPresenterImpl
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
|
||||
/**
|
||||
* Created by hemanths on 16/08/17.
|
||||
* Created by hemanths on 2019-09-04.
|
||||
*/
|
||||
@Module
|
||||
class SearchModule {
|
||||
|
||||
interface ArtistContract {
|
||||
interface ArtistView : BaseView<ArrayList<Artist>>
|
||||
@Provides
|
||||
fun providesSearchPresenter(presenter: SearchPresenterImpl): SearchPresenter {
|
||||
return presenter
|
||||
}
|
||||
|
||||
interface Presenter : BasePresenter<ArtistView> {
|
||||
fun loadArtists()
|
||||
}
|
||||
}
|
|
@ -12,22 +12,20 @@
|
|||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.mvp.contract
|
||||
package code.name.monkey.retromusic.dagger.module
|
||||
|
||||
import code.name.monkey.retromusic.model.Genre
|
||||
import code.name.monkey.retromusic.mvp.BasePresenter
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
|
||||
import java.util.ArrayList
|
||||
import code.name.monkey.retromusic.mvp.presenter.SongPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.SongPresenter.SongPresenterImpl
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
|
||||
/**
|
||||
* @author Hemanth S (h4h13).
|
||||
* Created by hemanths on 2019-09-04.
|
||||
*/
|
||||
|
||||
interface GenreContract {
|
||||
interface GenreView : BaseView<ArrayList<Genre>>
|
||||
|
||||
interface Presenter : BasePresenter<GenreView> {
|
||||
fun loadGenre()
|
||||
@Module
|
||||
class SongModule {
|
||||
@Provides
|
||||
fun providesSongPresenter(presenter: SongPresenterImpl): SongPresenter {
|
||||
return presenter
|
||||
}
|
||||
}
|
|
@ -2,18 +2,23 @@ package code.name.monkey.retromusic.fragments.mainactivity
|
|||
|
||||
import android.os.Bundle
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.album.AlbumAdapter
|
||||
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment
|
||||
import code.name.monkey.retromusic.model.Album
|
||||
import code.name.monkey.retromusic.mvp.contract.AlbumContract
|
||||
import code.name.monkey.retromusic.mvp.presenter.AlbumPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.AlbumsPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.AlbumsView
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import javax.inject.Inject
|
||||
|
||||
open class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager>(), AlbumContract.AlbumView {
|
||||
|
||||
private lateinit var presenter: AlbumPresenter
|
||||
open class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager>(), AlbumsView {
|
||||
override fun albums(albums: java.util.ArrayList<Album>) {
|
||||
adapter?.swapDataSet(albums)
|
||||
}
|
||||
|
||||
@Inject
|
||||
lateinit var albumsPresenter: AlbumsPresenter
|
||||
|
||||
override val emptyMessage: Int
|
||||
get() = R.string.no_albums
|
||||
|
@ -26,15 +31,13 @@ open class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Al
|
|||
var itemLayoutRes = itemLayoutRes
|
||||
notifyLayoutResChanged(itemLayoutRes)
|
||||
if (itemLayoutRes != R.layout.item_list) {
|
||||
|
||||
itemLayoutRes = PreferenceUtil.getInstance().getAlbumGridStyle(context!!)
|
||||
itemLayoutRes = PreferenceUtil.getInstance().getAlbumGridStyle(requireContext())
|
||||
}
|
||||
val dataSet = if (adapter == null) ArrayList() else adapter!!.dataSet
|
||||
return AlbumAdapter(libraryFragment.mainActivity, dataSet, itemLayoutRes, loadUsePalette(), libraryFragment)
|
||||
}
|
||||
|
||||
public override fun loadUsePalette(): Boolean {
|
||||
|
||||
return PreferenceUtil.getInstance().albumColoredFooters()
|
||||
}
|
||||
|
||||
|
@ -43,13 +46,10 @@ open class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Al
|
|||
}
|
||||
|
||||
override fun setGridSize(gridSize: Int) {
|
||||
layoutManager!!.spanCount = gridSize
|
||||
adapter!!.notifyDataSetChanged()
|
||||
layoutManager?.spanCount = gridSize
|
||||
adapter?.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun setSortOrder(sortOrder: String) {
|
||||
presenter.loadAlbums()
|
||||
}
|
||||
|
||||
override fun loadSortOrder(): String {
|
||||
|
||||
|
@ -86,38 +86,36 @@ open class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Al
|
|||
PreferenceUtil.getInstance().setAlbumColoredFooters(usePalette)
|
||||
}
|
||||
|
||||
override fun onMediaStoreChanged() {
|
||||
presenter.loadAlbums()
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
presenter = AlbumPresenter(this)
|
||||
}
|
||||
|
||||
App.musicComponent.inject(this)
|
||||
albumsPresenter.attachView(this)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (adapter!!.dataSet.isEmpty()) {
|
||||
presenter.subscribe()
|
||||
albumsPresenter.loadAlbums()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
presenter.unsubscribe()
|
||||
override fun onMediaStoreChanged() {
|
||||
albumsPresenter.loadAlbums()
|
||||
}
|
||||
|
||||
override fun setSortOrder(sortOrder: String) {
|
||||
albumsPresenter.loadAlbums()
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
albumsPresenter.detachView()
|
||||
}
|
||||
|
||||
override fun loading() {}
|
||||
|
||||
override fun showEmptyView() {
|
||||
adapter!!.swapDataSet(ArrayList())
|
||||
}
|
||||
|
||||
override fun completed() {}
|
||||
|
||||
override fun showData(list: ArrayList<Album>) {
|
||||
adapter!!.swapDataSet(list)
|
||||
adapter?.swapDataSet(ArrayList())
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -2,24 +2,46 @@ package code.name.monkey.retromusic.fragments.mainactivity
|
|||
|
||||
import android.os.Bundle
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.artist.ArtistAdapter
|
||||
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
import code.name.monkey.retromusic.mvp.contract.ArtistContract
|
||||
import code.name.monkey.retromusic.mvp.presenter.ArtistPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.ArtistsPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.ArtistsView
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class ArtistsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<ArtistAdapter, GridLayoutManager>(), ArtistContract.ArtistView {
|
||||
private lateinit var presenter: ArtistPresenter
|
||||
class ArtistsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<ArtistAdapter, GridLayoutManager>(), ArtistsView {
|
||||
override fun artists(artists: ArrayList<Artist>) {
|
||||
adapter?.swapDataSet(artists)
|
||||
}
|
||||
|
||||
@Inject
|
||||
lateinit var artistsPresenter: ArtistsPresenter
|
||||
|
||||
override val emptyMessage: Int
|
||||
get() = R.string.no_artists
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
presenter = ArtistPresenter(this)
|
||||
App.musicComponent.inject(this)
|
||||
artistsPresenter.attachView(this)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (adapter!!.dataSet.isEmpty()) {
|
||||
artistsPresenter.loadArtists()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMediaStoreChanged() {
|
||||
artistsPresenter.loadArtists()
|
||||
}
|
||||
|
||||
override fun setSortOrder(sortOrder: String) {
|
||||
artistsPresenter.loadArtists()
|
||||
}
|
||||
|
||||
override fun createLayoutManager(): GridLayoutManager {
|
||||
|
@ -30,15 +52,12 @@ class ArtistsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Artist
|
|||
var itemLayoutRes = itemLayoutRes
|
||||
notifyLayoutResChanged(itemLayoutRes)
|
||||
if (itemLayoutRes != R.layout.item_list) {
|
||||
itemLayoutRes = PreferenceUtil.getInstance().getArtistGridStyle(context!!)
|
||||
itemLayoutRes = PreferenceUtil.getInstance().getArtistGridStyle(requireContext())
|
||||
}
|
||||
val dataSet = if (adapter == null) ArrayList() else adapter!!.dataSet
|
||||
return ArtistAdapter(libraryFragment.mainActivity, dataSet, itemLayoutRes, loadUsePalette(), libraryFragment)
|
||||
}
|
||||
|
||||
override fun onMediaStoreChanged() {
|
||||
presenter.loadArtists()
|
||||
}
|
||||
|
||||
override fun loadGridSize(): Int {
|
||||
return PreferenceUtil.getInstance().getArtistGridSize(activity!!)
|
||||
|
@ -65,12 +84,12 @@ class ArtistsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Artist
|
|||
}
|
||||
|
||||
override fun setUsePalette(usePalette: Boolean) {
|
||||
adapter!!.usePalette(usePalette)
|
||||
adapter?.usePalette(usePalette)
|
||||
}
|
||||
|
||||
override fun setGridSize(gridSize: Int) {
|
||||
layoutManager!!.spanCount = gridSize
|
||||
adapter!!.notifyDataSetChanged()
|
||||
layoutManager?.spanCount = gridSize
|
||||
adapter?.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
|
||||
|
@ -82,34 +101,13 @@ class ArtistsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Artist
|
|||
PreferenceUtil.getInstance().artistSortOrder = sortOrder
|
||||
}
|
||||
|
||||
override fun setSortOrder(sortOrder: String) {
|
||||
presenter.loadArtists()
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
artistsPresenter.detachView()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (adapter!!.dataSet.isEmpty()) {
|
||||
presenter.subscribe()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
presenter.unsubscribe()
|
||||
}
|
||||
|
||||
override fun loading() {}
|
||||
|
||||
override fun showEmptyView() {
|
||||
adapter!!.swapDataSet(ArrayList())
|
||||
}
|
||||
|
||||
override fun completed() {
|
||||
|
||||
}
|
||||
|
||||
override fun showData(list: ArrayList<Artist>) {
|
||||
adapter!!.swapDataSet(list)
|
||||
adapter?.swapDataSet(ArrayList())
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -125,5 +123,4 @@ class ArtistsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Artist
|
|||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,31 +16,25 @@ package code.name.monkey.retromusic.fragments.mainactivity
|
|||
|
||||
import android.os.Bundle
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.GenreAdapter
|
||||
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewFragment
|
||||
import code.name.monkey.retromusic.model.Genre
|
||||
import code.name.monkey.retromusic.mvp.contract.GenreContract
|
||||
import code.name.monkey.retromusic.mvp.presenter.GenrePresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.GenresPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.GenresView
|
||||
import javax.inject.Inject
|
||||
|
||||
|
||||
class GenresFragment : AbsLibraryPagerRecyclerViewFragment<GenreAdapter, LinearLayoutManager>(), GenreContract.GenreView {
|
||||
override fun loading() {
|
||||
|
||||
}
|
||||
|
||||
override fun showData(list: ArrayList<Genre>) {
|
||||
adapter?.swapDataSet(list)
|
||||
class GenresFragment : AbsLibraryPagerRecyclerViewFragment<GenreAdapter, LinearLayoutManager>(), GenresView {
|
||||
override fun genres(genres: ArrayList<Genre>) {
|
||||
adapter?.swapDataSet(genres)
|
||||
}
|
||||
|
||||
override fun showEmptyView() {
|
||||
|
||||
}
|
||||
|
||||
override fun completed() {
|
||||
|
||||
}
|
||||
|
||||
override fun createLayoutManager(): LinearLayoutManager {
|
||||
return LinearLayoutManager(activity)
|
||||
}
|
||||
|
@ -53,28 +47,31 @@ class GenresFragment : AbsLibraryPagerRecyclerViewFragment<GenreAdapter, LinearL
|
|||
override val emptyMessage: Int
|
||||
get() = R.string.no_genres
|
||||
|
||||
private lateinit var presenter: GenrePresenter
|
||||
|
||||
@Inject
|
||||
lateinit var genresPresenter: GenresPresenter
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
presenter = GenrePresenter(this)
|
||||
App.musicComponent.inject(this)
|
||||
genresPresenter.attachView(this)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (adapter!!.dataSet.isEmpty()) {
|
||||
presenter.subscribe()
|
||||
genresPresenter.loadGenres()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
presenter.unsubscribe()
|
||||
super.onDestroy()
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
genresPresenter.detachView()
|
||||
}
|
||||
|
||||
override fun onMediaStoreChanged() {
|
||||
presenter.loadGenre()
|
||||
genresPresenter.loadGenres()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -4,26 +4,28 @@ import android.os.Bundle
|
|||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.playlist.PlaylistAdapter
|
||||
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewFragment
|
||||
import code.name.monkey.retromusic.model.Playlist
|
||||
import code.name.monkey.retromusic.mvp.contract.PlaylistContract
|
||||
import code.name.monkey.retromusic.mvp.presenter.PlaylistPresenter
|
||||
import java.util.*
|
||||
import code.name.monkey.retromusic.mvp.presenter.PlaylistView
|
||||
import code.name.monkey.retromusic.mvp.presenter.PlaylistsPresenter
|
||||
import javax.inject.Inject
|
||||
|
||||
|
||||
class PlaylistsFragment : AbsLibraryPagerRecyclerViewFragment<PlaylistAdapter, LinearLayoutManager>(), PlaylistContract.PlaylistView {
|
||||
class PlaylistsFragment : AbsLibraryPagerRecyclerViewFragment<PlaylistAdapter, LinearLayoutManager>(), PlaylistView {
|
||||
|
||||
private lateinit var presenter: PlaylistPresenter
|
||||
@Inject
|
||||
lateinit var playlistsPresenter: PlaylistsPresenter
|
||||
|
||||
override val emptyMessage: Int
|
||||
get() = R.string.no_playlists
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setHasOptionsMenu(true)
|
||||
presenter = PlaylistPresenter(this)
|
||||
App.musicComponent.inject(this)
|
||||
playlistsPresenter.attachView(this)
|
||||
}
|
||||
|
||||
override fun createLayoutManager(): LinearLayoutManager {
|
||||
|
@ -38,33 +40,25 @@ class PlaylistsFragment : AbsLibraryPagerRecyclerViewFragment<PlaylistAdapter, L
|
|||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (adapter!!.dataSet.isEmpty()) {
|
||||
presenter.subscribe()
|
||||
playlistsPresenter.playlists()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
presenter.unsubscribe()
|
||||
super.onDestroy()
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
playlistsPresenter.detachView()
|
||||
}
|
||||
|
||||
override fun onMediaStoreChanged() {
|
||||
super.onMediaStoreChanged()
|
||||
presenter.loadPlaylists()
|
||||
}
|
||||
|
||||
override fun loading() {
|
||||
|
||||
playlistsPresenter.playlists()
|
||||
}
|
||||
|
||||
override fun showEmptyView() {
|
||||
adapter!!.swapDataSet(ArrayList())
|
||||
}
|
||||
|
||||
override fun completed() {
|
||||
|
||||
}
|
||||
|
||||
override fun showData(list: ArrayList<Playlist>) {
|
||||
override fun playlists(list: ArrayList<Playlist>) {
|
||||
adapter!!.swapDataSet(list)
|
||||
}
|
||||
|
||||
|
|
|
@ -2,27 +2,32 @@ package code.name.monkey.retromusic.fragments.mainactivity
|
|||
|
||||
import android.os.Bundle
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.song.ShuffleButtonSongAdapter
|
||||
import code.name.monkey.retromusic.adapter.song.SongAdapter
|
||||
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.mvp.contract.SongContract
|
||||
import code.name.monkey.retromusic.mvp.presenter.SongPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.SongView
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdapter, GridLayoutManager>(), SongContract.SongView {
|
||||
class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdapter, GridLayoutManager>(), SongView {
|
||||
|
||||
@Inject
|
||||
lateinit var songPresenter: SongPresenter
|
||||
|
||||
private lateinit var presenter: SongPresenter
|
||||
|
||||
override val emptyMessage: Int
|
||||
get() = R.string.no_songs
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
presenter = SongPresenter(this)
|
||||
App.musicComponent.inject(this)
|
||||
|
||||
songPresenter.attachView(this)
|
||||
}
|
||||
|
||||
override fun createLayoutManager(): GridLayoutManager {
|
||||
|
@ -41,8 +46,12 @@ class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdap
|
|||
} else SongAdapter(libraryFragment.mainActivity, dataSet, itemLayoutRes, usePalette, libraryFragment)
|
||||
}
|
||||
|
||||
override fun songs(songs: ArrayList<Song>) {
|
||||
adapter?.swapDataSet(songs)
|
||||
}
|
||||
|
||||
override fun onMediaStoreChanged() {
|
||||
presenter.loadSongs()
|
||||
songPresenter.loadSongs()
|
||||
}
|
||||
|
||||
override fun loadGridSize(): Int {
|
||||
|
@ -81,31 +90,19 @@ class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdap
|
|||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (adapter!!.dataSet.isEmpty()) {
|
||||
presenter.subscribe()
|
||||
songPresenter.loadSongs()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
presenter.unsubscribe()
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
override fun loading() {
|
||||
|
||||
}
|
||||
|
||||
override fun showData(list: ArrayList<Song>) {
|
||||
adapter!!.swapDataSet(list)
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
songPresenter.detachView()
|
||||
}
|
||||
|
||||
override fun showEmptyView() {
|
||||
adapter!!.swapDataSet(ArrayList())
|
||||
}
|
||||
|
||||
override fun completed() {
|
||||
|
||||
}
|
||||
|
||||
override fun loadSortOrder(): String {
|
||||
return PreferenceUtil.getInstance().songSortOrder
|
||||
}
|
||||
|
@ -115,7 +112,7 @@ class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdap
|
|||
}
|
||||
|
||||
override fun setSortOrder(sortOrder: String) {
|
||||
presenter.loadSongs()
|
||||
songPresenter.loadSongs()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -13,6 +13,7 @@ import code.name.monkey.appthemehelper.ThemeStore
|
|||
import code.name.monkey.appthemehelper.common.ATHToolbarActivity
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.Constants
|
||||
import code.name.monkey.retromusic.Constants.USER_BANNER
|
||||
import code.name.monkey.retromusic.R
|
||||
|
@ -29,8 +30,8 @@ import code.name.monkey.retromusic.model.Home
|
|||
import code.name.monkey.retromusic.model.smartplaylist.HistoryPlaylist
|
||||
import code.name.monkey.retromusic.model.smartplaylist.LastAddedPlaylist
|
||||
import code.name.monkey.retromusic.model.smartplaylist.MyTopTracksPlaylist
|
||||
import code.name.monkey.retromusic.mvp.contract.HomeContract
|
||||
import code.name.monkey.retromusic.mvp.presenter.HomePresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.HomeView
|
||||
import code.name.monkey.retromusic.util.*
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
|
@ -41,12 +42,29 @@ import kotlinx.android.synthetic.main.fragment_banner_home.*
|
|||
import kotlinx.android.synthetic.main.home_content.*
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallbacks, HomeContract.HomeView {
|
||||
class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallbacks, HomeView {
|
||||
|
||||
override fun sections(sections: ArrayList<Home>) {
|
||||
val finalList = sections.sortedWith(compareBy { it.priority })
|
||||
homeAdapter.swapData(finalList)
|
||||
recyclerView.apply {
|
||||
layoutManager = LinearLayoutManager(mainActivity)
|
||||
adapter = homeAdapter
|
||||
}
|
||||
if (sections.isEmpty()) {
|
||||
showEmptyView()
|
||||
} else {
|
||||
emptyContainer.hide()
|
||||
}
|
||||
}
|
||||
|
||||
@Inject
|
||||
lateinit var homePresenter: HomePresenter
|
||||
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
private lateinit var homePresenter: HomePresenter
|
||||
private lateinit var toolbar: Toolbar
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, viewGroup: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
|
@ -83,7 +101,8 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
homePresenter = HomePresenter(this)
|
||||
App.musicComponent.inject(this)
|
||||
homePresenter.attachView(this)
|
||||
}
|
||||
|
||||
|
||||
|
@ -115,15 +134,11 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
|
|||
NavigationUtil.goToPlaylistNew(requireActivity(), HistoryPlaylist(requireActivity()))
|
||||
}
|
||||
|
||||
homePresenter = HomePresenter(this)
|
||||
|
||||
contentContainer.setBackgroundColor(ThemeStore.primaryColor(requireContext()))
|
||||
|
||||
setupToolbar()
|
||||
homeAdapter = HomeAdapter(mainActivity, ArrayList(), displayMetrics)
|
||||
|
||||
homePresenter.subscribe()
|
||||
|
||||
checkPadding()
|
||||
|
||||
userInfoContainer.setOnClickListener {
|
||||
|
@ -131,6 +146,8 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
|
|||
}
|
||||
titleWelcome.setTextColor(ThemeStore.textColorPrimary(requireContext()))
|
||||
titleWelcome.text = String.format("%s", PreferenceUtil.getInstance().userName)
|
||||
|
||||
homePresenter.loadSections()
|
||||
}
|
||||
|
||||
private fun checkPadding() {
|
||||
|
@ -177,21 +194,13 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
|
|||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
disposable.dispose()
|
||||
homePresenter.unsubscribe()
|
||||
}
|
||||
|
||||
override fun loading() {
|
||||
|
||||
homePresenter.detachView()
|
||||
}
|
||||
|
||||
override fun showEmptyView() {
|
||||
emptyContainer.show()
|
||||
}
|
||||
|
||||
override fun completed() {
|
||||
|
||||
}
|
||||
|
||||
override fun onServiceConnected() {
|
||||
super.onServiceConnected()
|
||||
checkPadding()
|
||||
|
@ -204,20 +213,6 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
|
|||
|
||||
private lateinit var homeAdapter: HomeAdapter
|
||||
|
||||
override fun showData(list: ArrayList<Home>) {
|
||||
val finalList = list.sortedWith(compareBy { it.priority })
|
||||
homeAdapter.swapData(finalList)
|
||||
recyclerView.apply {
|
||||
layoutManager = LinearLayoutManager(mainActivity)
|
||||
adapter = homeAdapter
|
||||
}
|
||||
if (list.isEmpty()) {
|
||||
showEmptyView()
|
||||
} else {
|
||||
emptyContainer.hide()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater)
|
||||
inflater.inflate(R.menu.menu_search, menu)
|
||||
|
|
|
@ -18,12 +18,6 @@ package code.name.monkey.retromusic.mvp
|
|||
* Created by hemanths on 09/08/17.
|
||||
*/
|
||||
|
||||
interface BaseView<T> {
|
||||
fun loading()
|
||||
|
||||
fun showData(list: T)
|
||||
|
||||
interface BaseView {
|
||||
fun showEmptyView()
|
||||
|
||||
fun completed()
|
||||
}
|
||||
|
|
|
@ -14,17 +14,13 @@
|
|||
|
||||
package code.name.monkey.retromusic.mvp
|
||||
|
||||
import code.name.monkey.retromusic.Injection
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import code.name.monkey.retromusic.util.schedulers.BaseSchedulerProvider
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
|
||||
/**
|
||||
* Created by hemanths on 16/08/17.
|
||||
*/
|
||||
|
||||
open class Presenter {
|
||||
protected var repository: Repository = Injection.provideRepository()
|
||||
protected var disposable: CompositeDisposable = CompositeDisposable()
|
||||
protected var schedulerProvider: BaseSchedulerProvider = Injection.provideSchedulerProvider()
|
||||
|
||||
interface Presenter<T> {
|
||||
fun attachView(view: T)
|
||||
|
||||
fun detachView()
|
||||
}
|
||||
|
|
|
@ -12,15 +12,19 @@
|
|||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.mvp
|
||||
package code.name.monkey.retromusic.mvp;
|
||||
|
||||
/**
|
||||
* Created by hemanths on 09/08/17.
|
||||
* Created by hemanths on 2019-09-04.
|
||||
*/
|
||||
public abstract class PresenterImpl<T> {
|
||||
protected T view;
|
||||
|
||||
interface BasePresenter<T> {
|
||||
|
||||
fun subscribe()
|
||||
|
||||
fun unsubscribe()
|
||||
public void attachView(T view) {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
public void detachView() {
|
||||
view = null;
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.mvp.contract
|
||||
|
||||
import code.name.monkey.retromusic.model.Album
|
||||
import code.name.monkey.retromusic.mvp.BasePresenter
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
import java.util.ArrayList
|
||||
|
||||
interface AlbumContract {
|
||||
|
||||
interface AlbumView : BaseView<ArrayList<Album>>
|
||||
|
||||
interface Presenter : BasePresenter<AlbumView> {
|
||||
|
||||
fun loadAlbums()
|
||||
}
|
||||
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.mvp.contract
|
||||
|
||||
|
||||
import code.name.monkey.retromusic.model.Album
|
||||
import code.name.monkey.retromusic.mvp.BasePresenter
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
|
||||
interface AlbumDetailsContract {
|
||||
|
||||
interface AlbumDetailsView : BaseView<Album>
|
||||
|
||||
interface Presenter : BasePresenter<AlbumDetailsView> {
|
||||
|
||||
fun loadAlbumSongs(albumId: Int)
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.mvp.contract
|
||||
|
||||
import code.name.monkey.retromusic.model.Playlist
|
||||
import code.name.monkey.retromusic.mvp.BasePresenter
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
/**
|
||||
* Created by hemanths on 19/08/17.
|
||||
*/
|
||||
|
||||
interface PlaylistContract {
|
||||
interface PlaylistView : BaseView<ArrayList<Playlist>>
|
||||
|
||||
interface Presenter : BasePresenter<PlaylistView> {
|
||||
fun loadPlaylists()
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.mvp.contract
|
||||
|
||||
import code.name.monkey.retromusic.model.Playlist
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.mvp.BasePresenter
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
|
||||
/**
|
||||
* Created by hemanths on 20/08/17.
|
||||
*/
|
||||
|
||||
interface PlaylistSongsContract {
|
||||
interface PlaylistSongsView : BaseView<ArrayList<Song>>
|
||||
|
||||
interface Presenter : BasePresenter<PlaylistSongsView> {
|
||||
fun loadSongs(playlist: Playlist)
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.mvp.contract
|
||||
|
||||
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.mvp.BasePresenter
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
|
||||
/**
|
||||
* Created by hemanths on 10/08/17.
|
||||
*/
|
||||
|
||||
interface SongContract {
|
||||
|
||||
interface SongView : BaseView<ArrayList<Song>>
|
||||
|
||||
interface Presenter : BasePresenter<SongView> {
|
||||
fun loadSongs()
|
||||
}
|
||||
}
|
|
@ -15,37 +15,71 @@
|
|||
package code.name.monkey.retromusic.mvp.presenter
|
||||
|
||||
import code.name.monkey.retromusic.model.Album
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
import code.name.monkey.retromusic.mvp.Presenter
|
||||
import code.name.monkey.retromusic.mvp.contract.AlbumDetailsContract
|
||||
import code.name.monkey.retromusic.mvp.PresenterImpl
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import io.reactivex.disposables.Disposable
|
||||
import javax.inject.Inject
|
||||
|
||||
|
||||
/**
|
||||
* Created by hemanths on 20/08/17.
|
||||
*/
|
||||
interface AlbumDetailsView {
|
||||
fun album(album: Album)
|
||||
|
||||
class AlbumDetailsPresenter(private val view: AlbumDetailsContract.AlbumDetailsView, private val albumId: Int) : Presenter(), AlbumDetailsContract.Presenter {
|
||||
fun complete()
|
||||
|
||||
override fun subscribe() {
|
||||
loadAlbumSongs(albumId)
|
||||
fun loadArtistImage(artist: Artist)
|
||||
|
||||
fun moreAlbums(albums: ArrayList<Album>)
|
||||
}
|
||||
|
||||
override fun unsubscribe() {
|
||||
disposable.clear()
|
||||
interface AlbumDetailsPresenter : Presenter<AlbumDetailsView> {
|
||||
fun loadAlbum(albumId: Int)
|
||||
|
||||
fun loadMore(artistId: Int)
|
||||
|
||||
class AlbumDetailsPresenterImpl @Inject constructor(
|
||||
private val repository: Repository
|
||||
) : PresenterImpl<AlbumDetailsView>(), AlbumDetailsPresenter {
|
||||
|
||||
private lateinit var album: Album
|
||||
|
||||
override fun loadMore(artistId: Int) {
|
||||
disposable = repository.getArtistByIdFlowable(artistId)
|
||||
.map {
|
||||
view.loadArtistImage(it)
|
||||
return@map it.albums
|
||||
}
|
||||
.map {
|
||||
it.filter { filterAlbum -> album.id != filterAlbum.id }
|
||||
}
|
||||
.subscribe {
|
||||
if (it.isEmpty()) {
|
||||
return@subscribe
|
||||
}
|
||||
view.moreAlbums(ArrayList(it))
|
||||
}
|
||||
}
|
||||
|
||||
override fun loadAlbumSongs(albumId: Int) {
|
||||
disposable.add(repository.getAlbumFlowable(albumId)
|
||||
.doOnSubscribe { view.loading() }
|
||||
.subscribe({ this.showAlbum(it) },
|
||||
{ view.showEmptyView() },
|
||||
{ view.completed() }))
|
||||
private var disposable: Disposable? = null
|
||||
|
||||
override fun loadAlbum(albumId: Int) {
|
||||
disposable = repository.getAlbumFlowable(albumId)
|
||||
.doOnComplete {
|
||||
view.complete()
|
||||
}
|
||||
.subscribe {
|
||||
album = it
|
||||
view.album(it)
|
||||
}
|
||||
}
|
||||
|
||||
private fun showAlbum(album: Album?) {
|
||||
if (album != null) {
|
||||
view.showData(album)
|
||||
} else {
|
||||
view.showEmptyView()
|
||||
override fun detachView() {
|
||||
super.detachView()
|
||||
disposable?.dispose()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,34 +15,43 @@
|
|||
package code.name.monkey.retromusic.mvp.presenter
|
||||
|
||||
import code.name.monkey.retromusic.model.Album
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
import code.name.monkey.retromusic.mvp.Presenter
|
||||
import code.name.monkey.retromusic.mvp.contract.AlbumContract
|
||||
import code.name.monkey.retromusic.mvp.PresenterImpl
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import io.reactivex.disposables.Disposable
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
|
||||
/**
|
||||
* Created by hemanths on 12/08/17.
|
||||
*/
|
||||
|
||||
class AlbumPresenter(private val view: AlbumContract.AlbumView) : Presenter(), AlbumContract.Presenter {
|
||||
|
||||
override fun subscribe() {
|
||||
loadAlbums()
|
||||
interface AlbumsView : BaseView {
|
||||
fun albums(albums: ArrayList<Album>)
|
||||
}
|
||||
|
||||
override fun unsubscribe() {
|
||||
disposable.clear()
|
||||
}
|
||||
interface AlbumsPresenter : Presenter<AlbumsView> {
|
||||
|
||||
fun loadAlbums()
|
||||
|
||||
class AlbumsPresenterImpl @Inject constructor(
|
||||
private val repository: Repository
|
||||
) : PresenterImpl<AlbumsView>(), AlbumsPresenter {
|
||||
|
||||
private var disposable: Disposable? = null
|
||||
|
||||
private fun showList(albums: ArrayList<Album>) {
|
||||
view.showData(albums)
|
||||
if (albums.isNotEmpty()) view.albums(albums) else view.showEmptyView()
|
||||
}
|
||||
|
||||
override fun detachView() {
|
||||
super.detachView()
|
||||
disposable?.dispose()
|
||||
}
|
||||
override fun loadAlbums() {
|
||||
disposable.add(repository.allAlbumsFlowable
|
||||
.doOnSubscribe { view.loading() }
|
||||
.subscribe({ this.showList(it) },
|
||||
{ view.showEmptyView() },
|
||||
{ view.completed() }))
|
||||
disposable = repository.allAlbumsFlowable
|
||||
.subscribe { this.showList(it) }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,41 +14,62 @@
|
|||
|
||||
package code.name.monkey.retromusic.mvp.presenter
|
||||
|
||||
import android.os.Bundle
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
import code.name.monkey.retromusic.mvp.Presenter
|
||||
import code.name.monkey.retromusic.mvp.contract.ArtistDetailContract
|
||||
import code.name.monkey.retromusic.activities.ArtistDetailActivity
|
||||
import code.name.monkey.retromusic.mvp.PresenterImpl
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import code.name.monkey.retromusic.rest.model.LastFmArtist
|
||||
import io.reactivex.disposables.Disposable
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
|
||||
/**
|
||||
* Created by hemanths on 20/08/17.
|
||||
*/
|
||||
|
||||
class ArtistDetailsPresenter(private val view: ArtistDetailContract.ArtistsDetailsView,
|
||||
private val bundle: Bundle) : Presenter(), ArtistDetailContract.Presenter {
|
||||
|
||||
override fun subscribe() {
|
||||
loadArtistById()
|
||||
interface ArtistDetailsView : BaseView {
|
||||
fun artist(artist: Artist)
|
||||
fun artistInfo(lastFmArtist: LastFmArtist?)
|
||||
fun complete()
|
||||
}
|
||||
|
||||
override fun unsubscribe() {
|
||||
disposable.clear()
|
||||
interface ArtistDetailsPresenter : Presenter<ArtistDetailsView> {
|
||||
|
||||
fun loadArtist(artistId: Int)
|
||||
|
||||
fun loadBiography(name: String,
|
||||
lang: String? = Locale.getDefault().language,
|
||||
cache: String?)
|
||||
|
||||
class ArtistDetailsPresenterImpl @Inject constructor(
|
||||
private val repository: Repository
|
||||
) : PresenterImpl<ArtistDetailsView>(), ArtistDetailsPresenter {
|
||||
|
||||
override fun loadBiography(name: String,
|
||||
lang: String?,
|
||||
cache: String?) {
|
||||
disposable = repository.artistInfoFloable(name, lang, cache)
|
||||
.subscribe {
|
||||
view.artistInfo(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun loadArtistById() {
|
||||
disposable.add(repository.getArtistByIdFlowable(bundle.getInt(ArtistDetailActivity.EXTRA_ARTIST_ID))
|
||||
.doOnSubscribe { view.loading() }
|
||||
.subscribe({ this.showArtist(it) },
|
||||
{ view.showEmptyView() },
|
||||
{ view.completed() }))
|
||||
private var disposable: Disposable? = null
|
||||
|
||||
override fun loadArtist(artistId: Int) {
|
||||
disposable = repository.getArtistByIdFlowable(artistId)
|
||||
.doOnComplete {
|
||||
view.complete()
|
||||
}
|
||||
.subscribe {
|
||||
this.showArtist(it)
|
||||
}
|
||||
}
|
||||
|
||||
private fun showArtist(album: Artist?) {
|
||||
if (album != null) {
|
||||
view.showData(album)
|
||||
} else {
|
||||
view.showEmptyView()
|
||||
|
||||
private fun showArtist(artist: Artist) {
|
||||
view.artist(artist)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,34 +14,49 @@
|
|||
|
||||
package code.name.monkey.retromusic.mvp.presenter
|
||||
|
||||
import code.name.monkey.retromusic.helper.SearchQueryHelper.songs
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
import code.name.monkey.retromusic.mvp.Presenter
|
||||
import code.name.monkey.retromusic.mvp.contract.ArtistContract
|
||||
import java.util.*
|
||||
import code.name.monkey.retromusic.mvp.PresenterImpl
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.functions.Consumer
|
||||
import javax.inject.Inject
|
||||
|
||||
class ArtistPresenter(private val mView: ArtistContract.ArtistView) : Presenter(), ArtistContract.Presenter {
|
||||
|
||||
override fun subscribe() {
|
||||
loadArtists()
|
||||
interface ArtistsView : BaseView {
|
||||
fun artists(artists: ArrayList<Artist>)
|
||||
}
|
||||
|
||||
override fun unsubscribe() {
|
||||
disposable.clear()
|
||||
interface ArtistsPresenter : Presenter<ArtistsView> {
|
||||
|
||||
fun loadArtists()
|
||||
|
||||
class ArtistsPresenterImpl @Inject constructor(
|
||||
private val repository: Repository
|
||||
) : PresenterImpl<ArtistsView>(), ArtistsPresenter {
|
||||
|
||||
private var disposable: Disposable? = null
|
||||
|
||||
private fun showList(artists: ArrayList<Artist>) {
|
||||
if (songs.isNotEmpty())
|
||||
view.artists(artists)
|
||||
else
|
||||
view.showEmptyView()
|
||||
}
|
||||
|
||||
private fun showList(songs: ArrayList<Artist>) {
|
||||
if (songs.isEmpty()) {
|
||||
mView.showEmptyView()
|
||||
} else {
|
||||
mView.showData(songs)
|
||||
}
|
||||
override fun detachView() {
|
||||
super.detachView()
|
||||
disposable?.dispose()
|
||||
}
|
||||
|
||||
override fun loadArtists() {
|
||||
disposable.add(repository.allArtistsFlowable
|
||||
.doOnSubscribe { mView.loading() }
|
||||
.subscribe({ this.showList(it) },
|
||||
{ mView.showEmptyView() },
|
||||
{ mView.completed() }))
|
||||
disposable = repository.allArtistsFlowable
|
||||
.subscribe({
|
||||
view.artists(it)
|
||||
}, {
|
||||
println(it)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,39 +15,51 @@
|
|||
package code.name.monkey.retromusic.mvp.presenter
|
||||
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
import code.name.monkey.retromusic.mvp.Presenter
|
||||
import code.name.monkey.retromusic.mvp.contract.GenreDetailsContract
|
||||
import code.name.monkey.retromusic.mvp.PresenterImpl
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import io.reactivex.disposables.Disposable
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
|
||||
/**
|
||||
* Created by hemanths on 20/08/17.
|
||||
*/
|
||||
|
||||
class GenreDetailsPresenter(private val view: GenreDetailsContract.GenreDetailsView,
|
||||
private val genreId: Int) : Presenter(), GenreDetailsContract.Presenter {
|
||||
|
||||
override fun subscribe() {
|
||||
loadGenre(genreId)
|
||||
interface GenreDetailsView : BaseView {
|
||||
fun songs(songs: ArrayList<Song>)
|
||||
}
|
||||
|
||||
override fun unsubscribe() {
|
||||
disposable.clear()
|
||||
interface GenreDetailsPresenter : Presenter<GenreDetailsView> {
|
||||
fun loadGenreSongs(genreId: Int)
|
||||
|
||||
class GenreDetailsPresenterImpl @Inject constructor(
|
||||
private val repository: Repository
|
||||
) : PresenterImpl<GenreDetailsView>(), GenreDetailsPresenter {
|
||||
|
||||
override fun detachView() {
|
||||
super.detachView()
|
||||
disposable?.dispose()
|
||||
}
|
||||
|
||||
override fun loadGenre(genreId: Int) {
|
||||
disposable.add(repository.getGenreFlowable(genreId)
|
||||
.doOnSubscribe { view.loading() }
|
||||
.subscribe({ this.showGenre(it) },
|
||||
{ view.showEmptyView() },
|
||||
{ view.completed() }))
|
||||
private var disposable: Disposable? = null
|
||||
|
||||
override fun loadGenreSongs(genreId: Int) {
|
||||
disposable = repository.getGenreFlowable(genreId)
|
||||
.subscribe {
|
||||
showGenre(it)
|
||||
}
|
||||
|
||||
private fun showGenre(songs: ArrayList<Song>?) {
|
||||
if (songs != null) {
|
||||
view.showData(songs)
|
||||
}
|
||||
|
||||
private fun showGenre(songs: ArrayList<Song>) {
|
||||
if (songs.isNotEmpty()) {
|
||||
view.songs(songs)
|
||||
} else {
|
||||
view.showEmptyView()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,38 +15,42 @@
|
|||
package code.name.monkey.retromusic.mvp.presenter
|
||||
|
||||
import code.name.monkey.retromusic.model.Genre
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
import code.name.monkey.retromusic.mvp.Presenter
|
||||
import code.name.monkey.retromusic.mvp.contract.GenreContract
|
||||
import code.name.monkey.retromusic.mvp.PresenterImpl
|
||||
import code.name.monkey.retromusic.providers.RepositoryImpl
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import io.reactivex.disposables.Disposable
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* @author Hemanth S (h4h13).
|
||||
*/
|
||||
|
||||
class GenrePresenter(
|
||||
private val view: GenreContract.GenreView) : Presenter(), GenreContract.Presenter {
|
||||
|
||||
override fun subscribe() {
|
||||
loadGenre()
|
||||
interface GenresView : BaseView {
|
||||
fun genres(genres: ArrayList<Genre>)
|
||||
}
|
||||
|
||||
override fun unsubscribe() {
|
||||
disposable.clear()
|
||||
}
|
||||
interface GenresPresenter : Presenter<GenresView> {
|
||||
fun loadGenres()
|
||||
|
||||
override fun loadGenre() {
|
||||
disposable.add(repository.allGenresFlowable
|
||||
.doOnSubscribe { view.loading() }
|
||||
.subscribe({ this.showList(it) },
|
||||
{ view.showEmptyView() },
|
||||
{ view.completed() }))
|
||||
class GenresPresenterImpl @Inject constructor(
|
||||
private val repository: Repository
|
||||
) : PresenterImpl<GenresView>(), GenresPresenter {
|
||||
|
||||
private var disposable: Disposable? = null
|
||||
|
||||
override fun loadGenres() {
|
||||
disposable = repository.allGenresFlowable
|
||||
.subscribe { this.showList(it) }
|
||||
}
|
||||
|
||||
private fun showList(genres: ArrayList<Genre>) {
|
||||
if (genres.isEmpty()) {
|
||||
view.showEmptyView()
|
||||
if (genres.isNotEmpty()) {
|
||||
view.genres(genres)
|
||||
} else {
|
||||
view.showData(genres)
|
||||
view.showEmptyView()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,25 +15,135 @@
|
|||
package code.name.monkey.retromusic.mvp.presenter
|
||||
|
||||
import code.name.monkey.retromusic.R
|
||||
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.BaseView
|
||||
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 code.name.monkey.retromusic.mvp.PresenterImpl
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.disposables.Disposable
|
||||
import javax.inject.Inject
|
||||
|
||||
operator fun CompositeDisposable.plusAssign(disposable: Disposable) {
|
||||
add(disposable)
|
||||
}
|
||||
|
||||
class HomePresenter(private val view: HomeContract.HomeView) : Presenter(), HomeContract.HomePresenter {
|
||||
interface HomeView : BaseView {
|
||||
fun sections(sections: ArrayList<Home>)
|
||||
}
|
||||
|
||||
interface HomePresenter : Presenter<HomeView> {
|
||||
fun loadSections()
|
||||
|
||||
class HomePresenterImpl @Inject constructor(
|
||||
private val repository: Repository
|
||||
) : PresenterImpl<HomeView>(), HomePresenter {
|
||||
override fun loadSections() {
|
||||
loadRecentArtists()
|
||||
loadRecentAlbums()
|
||||
loadTopArtists()
|
||||
loadATopAlbums()
|
||||
loadFavorite()
|
||||
}
|
||||
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
private val hashSet: HashSet<Home> = HashSet()
|
||||
|
||||
private fun showData(sections: ArrayList<Home>) {
|
||||
if (sections.isEmpty()) {
|
||||
view.showEmptyView()
|
||||
} else {
|
||||
view.sections(sections)
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadRecentArtists() {
|
||||
disposable += repository.recentArtistsFlowable
|
||||
.subscribe {
|
||||
if (it.isNotEmpty()) hashSet.add(
|
||||
Home(0,
|
||||
R.string.recent_artists,
|
||||
0,
|
||||
it,
|
||||
RECENT_ARTISTS,
|
||||
R.drawable.ic_artist_white_24dp
|
||||
))
|
||||
showData(ArrayList(hashSet))
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadRecentAlbums() {
|
||||
disposable += repository.recentAlbumsFlowable
|
||||
.subscribe {
|
||||
if (it.isNotEmpty()) hashSet.add(
|
||||
Home(1,
|
||||
R.string.recent_albums,
|
||||
0,
|
||||
it,
|
||||
RECENT_ALBUMS,
|
||||
R.drawable.ic_album_white_24dp
|
||||
))
|
||||
showData(ArrayList(hashSet))
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadTopArtists() {
|
||||
disposable += repository.topArtistsFlowable
|
||||
.subscribe {
|
||||
if (it.isNotEmpty()) hashSet.add(
|
||||
Home(2,
|
||||
R.string.top_artists,
|
||||
0,
|
||||
it,
|
||||
TOP_ARTISTS,
|
||||
R.drawable.ic_artist_white_24dp
|
||||
))
|
||||
showData(ArrayList(hashSet))
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadATopAlbums() {
|
||||
disposable += repository.topAlbumsFlowable
|
||||
.subscribe {
|
||||
if (it.isNotEmpty()) hashSet.add(
|
||||
Home(3,
|
||||
R.string.top_albums,
|
||||
0,
|
||||
it,
|
||||
TOP_ALBUMS,
|
||||
R.drawable.ic_album_white_24dp
|
||||
))
|
||||
showData(ArrayList(hashSet))
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadFavorite() {
|
||||
disposable += repository.favoritePlaylistFlowable
|
||||
.subscribe {
|
||||
if (it.isNotEmpty()) hashSet.add(
|
||||
Home(4,
|
||||
R.string.favorites,
|
||||
0,
|
||||
it,
|
||||
PLAYLISTS,
|
||||
R.drawable.ic_favorite_white_24dp
|
||||
))
|
||||
showData(ArrayList(hashSet))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*class HomePresenter(
|
||||
private val view: HomeContract.HomeView,
|
||||
private val repositoryImpl: RepositoryImpl
|
||||
) : Presenter(), HomeContract.HomePresenter {
|
||||
private val hashSet: HashSet<Home> = HashSet()
|
||||
|
||||
override fun homeSections() {
|
||||
|
@ -53,7 +163,7 @@ class HomePresenter(private val view: HomeContract.HomeView) : Presenter(), Home
|
|||
}
|
||||
|
||||
private fun loadRecentArtists() {
|
||||
disposable += repository.recentArtistsFlowable
|
||||
disposable += repositoryImpl.recentArtistsFlowable
|
||||
.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))
|
||||
|
@ -63,7 +173,7 @@ class HomePresenter(private val view: HomeContract.HomeView) : Presenter(), Home
|
|||
}
|
||||
|
||||
private fun loadRecentAlbums() {
|
||||
disposable += repository.recentAlbumsFlowable
|
||||
disposable += repositoryImpl.recentAlbumsFlowable
|
||||
.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))
|
||||
|
@ -73,7 +183,7 @@ class HomePresenter(private val view: HomeContract.HomeView) : Presenter(), Home
|
|||
}
|
||||
|
||||
private fun loadATopAlbums() {
|
||||
disposable += repository.topAlbumsFlowable
|
||||
disposable += repositoryImpl.topAlbumsFlowable
|
||||
.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))
|
||||
|
@ -83,7 +193,7 @@ class HomePresenter(private val view: HomeContract.HomeView) : Presenter(), Home
|
|||
}
|
||||
|
||||
private fun loadTopArtists() {
|
||||
disposable += repository.topArtistsFlowable
|
||||
disposable += repositoryImpl.topArtistsFlowable
|
||||
.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))
|
||||
|
@ -93,7 +203,7 @@ class HomePresenter(private val view: HomeContract.HomeView) : Presenter(), Home
|
|||
}
|
||||
|
||||
private fun loadFavorite() {
|
||||
disposable += repository.favoritePlaylistFlowable
|
||||
disposable += repositoryImpl.favoritePlaylistFlowable
|
||||
.subscribe({
|
||||
if (it.isNotEmpty()) hashSet.add(Home(4, R.string.favorites, 0, it, PLAYLISTS, R.drawable.ic_favorite_white_24dp))
|
||||
view.showData(ArrayList(hashSet))
|
||||
|
@ -101,4 +211,4 @@ class HomePresenter(private val view: HomeContract.HomeView) : Presenter(), Home
|
|||
view.showEmptyView()
|
||||
})
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
|
|
@ -15,38 +15,45 @@
|
|||
package code.name.monkey.retromusic.mvp.presenter
|
||||
|
||||
import code.name.monkey.retromusic.model.Playlist
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
import code.name.monkey.retromusic.mvp.Presenter
|
||||
import code.name.monkey.retromusic.mvp.contract.PlaylistContract
|
||||
import java.util.*
|
||||
import code.name.monkey.retromusic.mvp.PresenterImpl
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import io.reactivex.disposables.Disposable
|
||||
import javax.inject.Inject
|
||||
|
||||
|
||||
/**
|
||||
* Created by hemanths on 19/08/17.
|
||||
*/
|
||||
|
||||
class PlaylistPresenter(private val view: PlaylistContract.PlaylistView) : Presenter(), PlaylistContract.Presenter {
|
||||
|
||||
override fun subscribe() {
|
||||
loadPlaylists()
|
||||
interface PlaylistView : BaseView {
|
||||
fun playlists(playlists: ArrayList<Playlist>)
|
||||
}
|
||||
|
||||
override fun unsubscribe() {
|
||||
disposable.clear()
|
||||
interface PlaylistsPresenter : Presenter<PlaylistView> {
|
||||
|
||||
fun playlists()
|
||||
|
||||
class PlaylistsPresenterImpl @Inject constructor(
|
||||
private val repository: Repository
|
||||
) : PresenterImpl<PlaylistView>(), PlaylistsPresenter {
|
||||
|
||||
private var disposable: Disposable? = null
|
||||
|
||||
override fun playlists() {
|
||||
disposable = repository.allPlaylistsFlowable
|
||||
.subscribe { this.showList(it) }
|
||||
}
|
||||
|
||||
override fun loadPlaylists() {
|
||||
disposable.add(repository.allPlaylistsFlowable
|
||||
.doOnSubscribe { view.loading() }
|
||||
.subscribe({ this.showList(it) },
|
||||
{ view.showEmptyView() },
|
||||
{ view.completed() }))
|
||||
}
|
||||
|
||||
private fun showList(songs: ArrayList<Playlist>) {
|
||||
if (songs.isEmpty()) {
|
||||
private fun showList(arrayList: ArrayList<Playlist>) {
|
||||
if (arrayList.isEmpty()) {
|
||||
view.showEmptyView()
|
||||
} else {
|
||||
view.showData(songs)
|
||||
view.playlists(arrayList)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,30 +15,45 @@
|
|||
package code.name.monkey.retromusic.mvp.presenter
|
||||
|
||||
import code.name.monkey.retromusic.model.Playlist
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
import code.name.monkey.retromusic.mvp.Presenter
|
||||
import code.name.monkey.retromusic.mvp.contract.PlaylistSongsContract
|
||||
import code.name.monkey.retromusic.mvp.PresenterImpl
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import io.reactivex.disposables.Disposable
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* Created by hemanths on 20/08/17.
|
||||
*/
|
||||
|
||||
class PlaylistSongsPresenter(private val view: PlaylistSongsContract.PlaylistSongsView,
|
||||
private val mPlaylist: Playlist) : Presenter(), PlaylistSongsContract.Presenter {
|
||||
|
||||
|
||||
override fun subscribe() {
|
||||
loadSongs(mPlaylist)
|
||||
interface PlaylistSongsView : BaseView {
|
||||
fun songs(songs: ArrayList<Song>)
|
||||
}
|
||||
|
||||
override fun unsubscribe() {
|
||||
disposable.clear()
|
||||
interface PlaylistSongsPresenter : Presenter<PlaylistSongsView> {
|
||||
fun loadPlaylistSongs(playlist: Playlist)
|
||||
|
||||
class PlaylistSongsPresenterImpl @Inject constructor(
|
||||
private val repository: Repository
|
||||
) : PresenterImpl<PlaylistSongsView>(), PlaylistSongsPresenter {
|
||||
|
||||
private var disposable: Disposable? = null
|
||||
|
||||
override fun loadPlaylistSongs(playlist: Playlist) {
|
||||
disposable = repository.getPlaylistSongsFlowable(playlist)
|
||||
.subscribe {
|
||||
view.songs(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun detachView() {
|
||||
super.detachView()
|
||||
disposable?.dispose()
|
||||
}
|
||||
|
||||
override fun attachView(view: PlaylistSongsView) {
|
||||
super.attachView(view)
|
||||
}
|
||||
|
||||
override fun loadSongs(playlist: Playlist) {
|
||||
disposable.add(repository.getPlaylistSongsFlowable(playlist)
|
||||
.doOnSubscribe { view.loading() }
|
||||
.subscribe({ songs -> view.showData(songs) },
|
||||
{ view.showEmptyView() },
|
||||
{ view.completed() }))
|
||||
}
|
||||
}
|
|
@ -15,33 +15,40 @@
|
|||
package code.name.monkey.retromusic.mvp.presenter
|
||||
|
||||
import code.name.monkey.retromusic.mvp.Presenter
|
||||
import code.name.monkey.retromusic.mvp.contract.SearchContract
|
||||
import java.util.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
import code.name.monkey.retromusic.mvp.PresenterImpl
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* Created by hemanths on 20/08/17.
|
||||
*/
|
||||
|
||||
class SearchPresenter(private val view: SearchContract.SearchView) : Presenter(), SearchContract.SearchPresenter {
|
||||
interface SearchView {
|
||||
fun showData(data: MutableList<Any>)
|
||||
|
||||
override fun subscribe() {
|
||||
search("")
|
||||
fun showEmptyView()
|
||||
}
|
||||
|
||||
override fun unsubscribe() {
|
||||
disposable.clear()
|
||||
interface SearchPresenter : Presenter<SearchView> {
|
||||
|
||||
fun search(query: String?)
|
||||
|
||||
class SearchPresenterImpl @Inject constructor(
|
||||
private val repository: Repository
|
||||
) : PresenterImpl<SearchView>(), SearchPresenter {
|
||||
|
||||
override fun attachView(view: SearchView) {
|
||||
super.attachView(view)
|
||||
}
|
||||
|
||||
private fun showList(albums: ArrayList<Any>) {
|
||||
if (albums.isEmpty()) {
|
||||
view.showEmptyView()
|
||||
} else {
|
||||
view.showData(albums)
|
||||
}
|
||||
override fun detachView() {
|
||||
super.detachView()
|
||||
}
|
||||
|
||||
override fun search(query: String?) {
|
||||
view.showData(repository.search(query))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,36 +16,42 @@ package code.name.monkey.retromusic.mvp.presenter
|
|||
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.mvp.Presenter
|
||||
import code.name.monkey.retromusic.mvp.contract.SongContract
|
||||
import code.name.monkey.retromusic.mvp.PresenterImpl
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import io.reactivex.disposables.Disposable
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* Created by hemanths on 10/08/17.
|
||||
*/
|
||||
interface SongView {
|
||||
fun songs(songs: ArrayList<Song>)
|
||||
|
||||
class SongPresenter(private val view: SongContract.SongView) : Presenter(), SongContract.Presenter {
|
||||
fun showEmptyView()
|
||||
}
|
||||
|
||||
interface SongPresenter : Presenter<SongView> {
|
||||
fun loadSongs()
|
||||
|
||||
class SongPresenterImpl @Inject constructor(
|
||||
private val repository: Repository
|
||||
) : PresenterImpl<SongView>(), SongPresenter {
|
||||
|
||||
private var disposable: Disposable? = null
|
||||
|
||||
override fun loadSongs() {
|
||||
disposable.add(repository.allSongsFlowable
|
||||
.doOnSubscribe { view.loading() }
|
||||
.subscribe({ this.showList(it) },
|
||||
{ view.showEmptyView() },
|
||||
{ view.completed() }))
|
||||
}
|
||||
|
||||
override fun subscribe() {
|
||||
loadSongs()
|
||||
}
|
||||
|
||||
private fun showList(songs: ArrayList<Song>) {
|
||||
if (songs.isEmpty()) {
|
||||
view.showEmptyView()
|
||||
} else {
|
||||
view.showData(songs)
|
||||
disposable = repository.allSongsFlowable
|
||||
.subscribe {
|
||||
view.songs(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun unsubscribe() {
|
||||
disposable.clear()
|
||||
override fun detachView() {
|
||||
super.detachView()
|
||||
disposable?.dispose()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,11 +19,23 @@ import code.name.monkey.retromusic.App
|
|||
import code.name.monkey.retromusic.loaders.*
|
||||
import code.name.monkey.retromusic.model.*
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import code.name.monkey.retromusic.rest.LastFMRestClient
|
||||
import code.name.monkey.retromusic.rest.model.LastFmArtist
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
class RepositoryImpl(private val context: Context) : Repository {
|
||||
override fun artistInfoFloable(
|
||||
name: String,
|
||||
lang: String?,
|
||||
cache: String?
|
||||
): Observable<LastFmArtist> {
|
||||
return LastFMRestClient(context).apiService.getArtistInfoFloable(name, lang, cache)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
|
||||
override fun search(query: String?): MutableList<Any> {
|
||||
return SearchLoader.searchAll(context, query)
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package code.name.monkey.retromusic.providers.interfaces
|
||||
|
||||
import code.name.monkey.retromusic.model.*
|
||||
import code.name.monkey.retromusic.rest.model.LastFmArtist
|
||||
import io.reactivex.Observable
|
||||
|
||||
/**
|
||||
|
@ -87,4 +88,7 @@ interface Repository {
|
|||
|
||||
val favoritePlaylist: ArrayList<Playlist>
|
||||
|
||||
fun artistInfoFloable(name: String,
|
||||
lang: String?,
|
||||
cache: String?): Observable<LastFmArtist>
|
||||
}
|
|
@ -16,11 +16,12 @@ package code.name.monkey.retromusic.rest;
|
|||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import code.name.monkey.retromusic.rest.service.LastFMService;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.Call;
|
||||
|
@ -43,7 +44,7 @@ public class LastFMRestClient {
|
|||
this(createDefaultOkHttpClientBuilder(context).build());
|
||||
}
|
||||
|
||||
public LastFMRestClient(@NonNull Call.Factory client) {
|
||||
private LastFMRestClient(@NonNull Call.Factory client) {
|
||||
Retrofit restAdapter = new Retrofit.Builder()
|
||||
.baseUrl(BASE_URL)
|
||||
.callFactory(client)
|
||||
|
@ -72,7 +73,8 @@ public class LastFMRestClient {
|
|||
};
|
||||
}
|
||||
|
||||
public static OkHttpClient.Builder createDefaultOkHttpClientBuilder(Context context) {
|
||||
@NonNull
|
||||
private static OkHttpClient.Builder createDefaultOkHttpClientBuilder(@NonNull Context context) {
|
||||
return new OkHttpClient.Builder()
|
||||
.connectionPool(new ConnectionPool(0, 1, TimeUnit.NANOSECONDS))
|
||||
.retryOnConnectionFailure(true)
|
||||
|
@ -83,6 +85,7 @@ public class LastFMRestClient {
|
|||
.addInterceptor(createCacheControlInterceptor());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public LastFMService getApiService() {
|
||||
return apiService;
|
||||
}
|
||||
|
|
|
@ -16,9 +16,9 @@ package code.name.monkey.retromusic.rest.service;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import code.name.monkey.retromusic.rest.model.LastFmAlbum;
|
||||
import code.name.monkey.retromusic.rest.model.LastFmArtist;
|
||||
import code.name.monkey.retromusic.rest.model.LastFmTrack;
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.GET;
|
||||
|
@ -37,12 +37,11 @@ public interface LastFMService {
|
|||
Observable<LastFmAlbum> getAlbumInfo(@Query("album") @NonNull String albumName, @Query("artist") @NonNull String artistName, @Nullable @Query("lang") String language);
|
||||
|
||||
@NonNull
|
||||
@GET("?api_key=" + API_KEY + "&format=json&autocorrect=1" + "&method=" + METHOD_TRACK)
|
||||
Observable<LastFmTrack> getTrackInfo(@Query("artist") @NonNull String artist, @Query("track") @NonNull String track);
|
||||
@GET(BASE_QUERY_PARAMETERS + "&method=artist.getinfo")
|
||||
Call<LastFmArtist> getArtistInfo(@Query("artist") @NonNull String artistName, @Nullable @Query("lang") String language, @Nullable @Header("Cache-Control") String cacheControl);
|
||||
|
||||
@NonNull
|
||||
@GET(BASE_QUERY_PARAMETERS + "&method=artist.getinfo")
|
||||
default Call<LastFmArtist> getArtistInfo(@Query("artist") @NonNull String artistName, @Nullable @Query("lang") String language, @Nullable @Header("Cache-Control") String cacheControl) {
|
||||
return null;
|
||||
}
|
||||
Observable<LastFmArtist> getArtistInfoFloable(@Query("artist") @NonNull String artistName, @Nullable @Query("lang") String language, @Nullable @Header("Cache-Control") String cacheControl);
|
||||
|
||||
}
|
Loading…
Reference in a new issue