Code refactor

This commit is contained in:
h4h13 2019-12-30 16:31:50 +05:30
parent c3153a9650
commit 5a51d0bfc0
50 changed files with 2137 additions and 2105 deletions

View file

@ -14,9 +14,18 @@
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.activities.AlbumDetailsActivity
import code.name.monkey.retromusic.activities.ArtistDetailActivity
import code.name.monkey.retromusic.activities.GenreDetailsActivity
import code.name.monkey.retromusic.activities.PlaylistDetailActivity
import code.name.monkey.retromusic.activities.SearchActivity
import code.name.monkey.retromusic.dagger.module.AppModule
import code.name.monkey.retromusic.dagger.module.PresenterModule
import code.name.monkey.retromusic.fragments.mainactivity.AlbumsFragment
import code.name.monkey.retromusic.fragments.mainactivity.ArtistsFragment
import code.name.monkey.retromusic.fragments.mainactivity.GenresFragment
import code.name.monkey.retromusic.fragments.mainactivity.PlaylistsFragment
import code.name.monkey.retromusic.fragments.mainactivity.SongsFragment
import code.name.monkey.retromusic.fragments.mainactivity.home.BannerHomeFragment
import dagger.Component
import javax.inject.Singleton
@ -25,17 +34,12 @@ import javax.inject.Singleton
* Created by hemanths on 2019-09-04.
*/
@Singleton
@Component(modules = [
RepositoryModule::class,
AlbumModule::class,
ArtistModule::class,
GenreModule::class,
HomeModule::class,
PlaylistModule::class,
SearchModule::class,
SongModule::class,
ActivityModule::class
])
@Component(
modules = [
AppModule::class,
PresenterModule::class
]
)
interface MusicComponent {
fun inject(songsFragment: SongsFragment)

View file

@ -1,34 +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.dagger.module
import android.app.Activity
import dagger.Module
import dagger.Provides
import javax.inject.Singleton
/**
* Created by hemanths on 2019-09-04.
*/
@Module
class ActivityModule(private val activity: Activity) {
@Provides
@Singleton
fun provideActivity(): Activity {
return activity
}
}

View file

@ -1,39 +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.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
}
}

View file

@ -14,6 +14,7 @@
package code.name.monkey.retromusic.dagger.module
import android.app.Application
import android.content.Context
import dagger.Module
@ -24,11 +25,9 @@ import javax.inject.Singleton
* Created by hemanths on 2019-09-04.
*/
@Module
class AppModule(private val context: Context) {
class AppModule(private val application: Application) {
@Provides
@Singleton
fun provideContext(): Context {
return context
}
fun provideContext(): Context = application
}

View file

@ -1,39 +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.dagger.module
import code.name.monkey.retromusic.mvp.presenter.ArtistDetailsPresenter
import code.name.monkey.retromusic.mvp.presenter.ArtistDetailsPresenter.ArtistDetailsPresenterImpl
import code.name.monkey.retromusic.mvp.presenter.ArtistsPresenter
import code.name.monkey.retromusic.mvp.presenter.ArtistsPresenter.ArtistsPresenterImpl
import dagger.Module
import dagger.Provides
/**
* 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
}
}

View file

@ -1,40 +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.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
}
}

View file

@ -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.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 2019-09-04.
*/
@Module
class HomeModule {
@Provides
fun providesHomePresenter(presenter: HomePresenterImpl): HomePresenter {
return presenter
}
}

View file

@ -1,38 +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.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
}
}

View file

@ -0,0 +1,111 @@
/*
* 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 android.content.Context
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 code.name.monkey.retromusic.mvp.presenter.ArtistDetailsPresenter
import code.name.monkey.retromusic.mvp.presenter.ArtistDetailsPresenter.ArtistDetailsPresenterImpl
import code.name.monkey.retromusic.mvp.presenter.ArtistsPresenter
import code.name.monkey.retromusic.mvp.presenter.ArtistsPresenter.ArtistsPresenterImpl
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 code.name.monkey.retromusic.mvp.presenter.HomePresenter
import code.name.monkey.retromusic.mvp.presenter.HomePresenter.HomePresenterImpl
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 code.name.monkey.retromusic.mvp.presenter.SearchPresenter
import code.name.monkey.retromusic.mvp.presenter.SearchPresenter.SearchPresenterImpl
import code.name.monkey.retromusic.mvp.presenter.SongPresenter
import code.name.monkey.retromusic.mvp.presenter.SongPresenter.SongPresenterImpl
import code.name.monkey.retromusic.providers.RepositoryImpl
import code.name.monkey.retromusic.providers.interfaces.Repository
import dagger.Module
import dagger.Provides
/**
* Created by hemanths on 2019-12-30.
*/
@Module
class PresenterModule {
@Provides
fun providesRepository(context: Context): Repository {
return RepositoryImpl(context)
}
@Provides
fun providesAlbumsPresenter(presenter: AlbumsPresenterImpl): AlbumsPresenter {
return presenter
}
@Provides
fun providesAlbumDetailsPresenter(presenter: AlbumDetailsPresenterImpl): AlbumDetailsPresenter {
return presenter
}
@Provides
fun providesArtistDetailsPresenter(presenter: ArtistDetailsPresenterImpl): ArtistDetailsPresenter {
return presenter
}
@Provides
fun providesArtistsPresenter(presenter: ArtistsPresenterImpl): ArtistsPresenter {
return presenter
}
@Provides
fun providesGenresPresenter(presenter: GenresPresenterImpl): GenresPresenter {
return presenter
}
@Provides
fun providesGenreDetailsPresenter(presenter: GenreDetailsPresenterImpl): GenreDetailsPresenter {
return presenter
}
@Provides
fun providesHomePresenter(presenter: HomePresenterImpl): HomePresenter {
return presenter
}
@Provides
fun providesPlaylistSongPresenter(presenter: PlaylistSongsPresenterImpl): PlaylistSongsPresenter {
return presenter
}
@Provides
fun providesPlaylistsPresenter(presenter: PlaylistsPresenterImpl): PlaylistsPresenter {
return presenter
}
@Provides
fun providesSearchPresenter(presenter: SearchPresenterImpl): SearchPresenter {
return presenter
}
@Provides
fun providesSongPresenter(presenter: SongPresenterImpl): SongPresenter {
return presenter
}
}

View file

@ -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.dagger.module
import android.content.Context
import code.name.monkey.retromusic.providers.RepositoryImpl
import code.name.monkey.retromusic.providers.interfaces.Repository
import dagger.Module
import dagger.Provides
/**
* Created by hemanths on 2019-09-04.
*/
@Module(includes = [AppModule::class])
class RepositoryModule {
@Provides
fun providesRepository(context: Context): Repository {
return RepositoryImpl(context)
}
}

View file

@ -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.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 2019-09-04.
*/
@Module
class SearchModule {
@Provides
fun providesSearchPresenter(presenter: SearchPresenterImpl): SearchPresenter {
return presenter
}
}

View file

@ -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.dagger.module
import code.name.monkey.retromusic.mvp.presenter.SongPresenter
import code.name.monkey.retromusic.mvp.presenter.SongPresenter.SongPresenterImpl
import dagger.Module
import dagger.Provides
/**
* Created by hemanths on 2019-09-04.
*/
@Module
class SongModule {
@Provides
fun providesSongPresenter(presenter: SongPresenterImpl): SongPresenter {
return presenter
}
}