├── .idea
├── .name
├── .gitignore
├── compiler.xml
├── kotlinc.xml
├── vcs.xml
├── migrations.xml
├── misc.xml
├── gradle.xml
└── deploymentTargetDropDown.xml
├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── themes.xml
│ │ │ ├── drawable
│ │ │ │ ├── logo.png
│ │ │ │ ├── media_playing.gif
│ │ │ │ ├── rounded_corner.xml
│ │ │ │ ├── icon_arrow_right.xml
│ │ │ │ ├── icon_menu.xml
│ │ │ │ ├── ic_launcher_foreground.xml
│ │ │ │ └── ic_launcher_background.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── menu
│ │ │ │ └── option_menu.xml
│ │ │ ├── values-night
│ │ │ │ └── themes.xml
│ │ │ ├── mipmap-anydpi
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── xml
│ │ │ │ ├── backup_rules.xml
│ │ │ │ └── data_extraction_rules.xml
│ │ │ └── layout
│ │ │ │ ├── category_item_recycler_row.xml
│ │ │ │ ├── section_song_list_recycler_row.xml
│ │ │ │ ├── activity_songs_list.xml
│ │ │ │ ├── song_list_item_recycler_row.xml
│ │ │ │ ├── activity_player.xml
│ │ │ │ ├── activity_login.xml
│ │ │ │ ├── activity_signup.xml
│ │ │ │ └── activity_main.xml
│ │ ├── java
│ │ │ └── np
│ │ │ │ └── com
│ │ │ │ └── bimalkafle
│ │ │ │ └── musicstream
│ │ │ │ ├── models
│ │ │ │ ├── CategoryModel.kt
│ │ │ │ └── SongModel.kt
│ │ │ │ ├── SongsListActivity.kt
│ │ │ │ ├── MyExoplayer.kt
│ │ │ │ ├── PlayerActivity.kt
│ │ │ │ ├── adapter
│ │ │ │ ├── CategoryAdapter.kt
│ │ │ │ ├── SongsListAdapter.kt
│ │ │ │ └── SectionSongListAdapter.kt
│ │ │ │ ├── LoginActivity.kt
│ │ │ │ ├── SignupActivity.kt
│ │ │ │ └── MainActivity.kt
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── np
│ │ │ └── com
│ │ │ └── bimalkafle
│ │ │ └── musicstream
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ └── java
│ │ └── np
│ │ └── com
│ │ └── bimalkafle
│ │ └── musicstream
│ │ └── ExampleInstrumentedTest.kt
├── google-services.json
├── proguard-rules.pro
└── build.gradle.kts
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── settings.gradle.kts
├── gradle.properties
├── gradlew.bat
└── gradlew
/.idea/.name:
--------------------------------------------------------------------------------
1 | Music Stream
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Music Stream
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bimalkaf/Android_MusicStreamFirebase/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bimalkaf/Android_MusicStreamFirebase/HEAD/app/src/main/res/drawable/logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/media_playing.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bimalkaf/Android_MusicStreamFirebase/HEAD/app/src/main/res/drawable/media_playing.gif
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bimalkaf/Android_MusicStreamFirebase/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bimalkaf/Android_MusicStreamFirebase/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bimalkaf/Android_MusicStreamFirebase/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bimalkaf/Android_MusicStreamFirebase/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bimalkaf/Android_MusicStreamFirebase/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bimalkaf/Android_MusicStreamFirebase/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bimalkaf/Android_MusicStreamFirebase/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bimalkaf/Android_MusicStreamFirebase/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bimalkaf/Android_MusicStreamFirebase/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bimalkaf/Android_MusicStreamFirebase/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/option_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FF000000
4 | #FFFFFFFF
5 | #010B28
6 | #CFCFD0
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Dec 31 11:06:41 NPT 2023
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 | local.properties
16 |
--------------------------------------------------------------------------------
/app/src/main/java/np/com/bimalkafle/musicstream/models/CategoryModel.kt:
--------------------------------------------------------------------------------
1 | package np.com.bimalkafle.musicstream.models
2 |
3 | data class CategoryModel(
4 | val name : String,
5 | val coverUrl : String,
6 | var songs : List
7 | ) {
8 | constructor() : this("","", listOf())
9 | }
10 |
--------------------------------------------------------------------------------
/.idea/migrations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/rounded_corner.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/java/np/com/bimalkafle/musicstream/models/SongModel.kt:
--------------------------------------------------------------------------------
1 | package np.com.bimalkafle.musicstream.models
2 |
3 | data class SongModel(
4 | val id : String,
5 | val title : String,
6 | val subtitle : String,
7 | val url : String,
8 | val coverUrl : String,
9 | ) {
10 | constructor() : this("","","","","")
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/icon_arrow_right.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/icon_menu.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | google()
4 | mavenCentral()
5 | gradlePluginPortal()
6 | }
7 | }
8 | dependencyResolutionManagement {
9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
10 | repositories {
11 | google()
12 | mavenCentral()
13 | }
14 | }
15 |
16 | rootProject.name = "Music Stream"
17 | include(":app")
18 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/test/java/np/com/bimalkafle/musicstream/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package np.com.bimalkafle.musicstream
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/google-services.json:
--------------------------------------------------------------------------------
1 | {
2 | "project_info": {
3 | "project_number": "683543778524",
4 | "project_id": "music-stream-ddfba",
5 | "storage_bucket": "music-stream-ddfba.appspot.com"
6 | },
7 | "client": [
8 | {
9 | "client_info": {
10 | "mobilesdk_app_id": "1:683543778524:android:ac0592a97f201ce96dd019",
11 | "android_client_info": {
12 | "package_name": "np.com.bimalkafle.musicstream"
13 | }
14 | },
15 | "oauth_client": [],
16 | "api_key": [
17 | {
18 | "current_key": "AIzaSyAAkhyirU5n9KU_lIFjSSRh1U5ABmusn9o"
19 | }
20 | ],
21 | "services": {
22 | "appinvite_service": {
23 | "other_platform_oauth_client": []
24 | }
25 | }
26 | }
27 | ],
28 | "configuration_version": "1"
29 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/androidTest/java/np/com/bimalkafle/musicstream/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package np.com.bimalkafle.musicstream
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("np.com.bimalkafle.musicstream", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/.idea/deploymentTargetDropDown.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/category_item_recycler_row.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/section_song_list_recycler_row.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
16 |
17 |
25 |
26 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Kotlin code style for this project: "official" or "obsolete":
19 | kotlin.code.style=official
20 | # Enables namespacing of each library's R class so that its R class includes only the
21 | # resources declared in the library itself and none from the library's dependencies,
22 | # thereby reducing the size of the R class for that library
23 | android.nonTransitiveRClass=true
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
15 |
18 |
21 |
24 |
27 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_songs_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
18 |
19 |
27 |
28 |
33 |
34 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/song_list_item_recycler_row.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
23 |
31 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/app/src/main/java/np/com/bimalkafle/musicstream/SongsListActivity.kt:
--------------------------------------------------------------------------------
1 | package np.com.bimalkafle.musicstream
2 |
3 | import androidx.appcompat.app.AppCompatActivity
4 | import android.os.Bundle
5 | import androidx.recyclerview.widget.LinearLayoutManager
6 | import com.bumptech.glide.Glide
7 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners
8 | import com.bumptech.glide.request.RequestOptions
9 | import np.com.bimalkafle.musicstream.adapter.SongsListAdapter
10 | import np.com.bimalkafle.musicstream.databinding.ActivitySongsListBinding
11 | import np.com.bimalkafle.musicstream.models.CategoryModel
12 |
13 | class SongsListActivity : AppCompatActivity() {
14 |
15 | companion object{
16 | lateinit var category : CategoryModel
17 | }
18 |
19 | lateinit var binding: ActivitySongsListBinding
20 | lateinit var songsListAdapter: SongsListAdapter
21 |
22 | override fun onCreate(savedInstanceState: Bundle?) {
23 | super.onCreate(savedInstanceState)
24 | binding = ActivitySongsListBinding.inflate(layoutInflater)
25 | setContentView(binding.root)
26 |
27 | binding.nameTextView.text = category.name
28 | Glide.with(binding.coverImageView).load(category.coverUrl)
29 | .apply(
30 | RequestOptions().transform(RoundedCorners(32))
31 | )
32 | .into(binding.coverImageView)
33 |
34 |
35 | setupSongsListRecyclerView()
36 | }
37 |
38 | fun setupSongsListRecyclerView(){
39 | songsListAdapter = SongsListAdapter(category.songs)
40 | binding.songsListRecyclerView.layoutManager = LinearLayoutManager(this)
41 | binding.songsListRecyclerView.adapter = songsListAdapter
42 | }
43 |
44 | }
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.android.application")
3 | id("org.jetbrains.kotlin.android")
4 | id("com.google.gms.google-services")
5 | }
6 |
7 | android {
8 | namespace = "np.com.bimalkafle.musicstream"
9 | compileSdk = 34
10 |
11 | defaultConfig {
12 | applicationId = "np.com.bimalkafle.musicstream"
13 | minSdk = 26
14 | targetSdk = 34
15 | versionCode = 1
16 | versionName = "1.0"
17 |
18 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
19 | }
20 |
21 | buildTypes {
22 | release {
23 | isMinifyEnabled = false
24 | proguardFiles(
25 | getDefaultProguardFile("proguard-android-optimize.txt"),
26 | "proguard-rules.pro"
27 | )
28 | }
29 | }
30 | compileOptions {
31 | sourceCompatibility = JavaVersion.VERSION_1_8
32 | targetCompatibility = JavaVersion.VERSION_1_8
33 | }
34 | kotlinOptions {
35 | jvmTarget = "1.8"
36 | }
37 |
38 | buildFeatures {
39 | viewBinding = true
40 | }
41 | }
42 |
43 | dependencies {
44 |
45 | implementation("androidx.core:core-ktx:1.12.0")
46 | implementation("androidx.appcompat:appcompat:1.6.1")
47 | implementation("com.google.android.material:material:1.10.0")
48 | implementation("androidx.constraintlayout:constraintlayout:2.1.4")
49 | implementation("com.google.firebase:firebase-firestore:24.10.0")
50 | implementation("com.google.firebase:firebase-auth:22.3.1")
51 | testImplementation("junit:junit:4.13.2")
52 | androidTestImplementation("androidx.test.ext:junit:1.1.5")
53 | androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
54 |
55 | implementation ("com.github.bumptech.glide:glide:4.16.0")
56 |
57 | implementation ("androidx.media3:media3-exoplayer:1.2.0")
58 | implementation ("androidx.media3:media3-exoplayer-dash:1.2.0")
59 | implementation ("androidx.media3:media3-ui:1.2.0")
60 | }
--------------------------------------------------------------------------------
/app/src/main/java/np/com/bimalkafle/musicstream/MyExoplayer.kt:
--------------------------------------------------------------------------------
1 | package np.com.bimalkafle.musicstream
2 |
3 | import android.content.Context
4 | import androidx.media3.common.MediaItem
5 | import androidx.media3.exoplayer.ExoPlayer
6 | import com.google.firebase.firestore.FirebaseFirestore
7 | import np.com.bimalkafle.musicstream.models.SongModel
8 |
9 | object MyExoplayer {
10 |
11 | private var exoPlayer : ExoPlayer? = null
12 | private var currentSong : SongModel? =null
13 |
14 | fun getCurrentSong() : SongModel?{
15 | return currentSong
16 | }
17 |
18 | fun getInstance() : ExoPlayer?{
19 | return exoPlayer
20 | }
21 |
22 | fun startPlaying(context : Context, song : SongModel){
23 | if(exoPlayer==null)
24 | exoPlayer = ExoPlayer.Builder(context).build()
25 |
26 | if(currentSong!=song){
27 | //Its a new song so start playing
28 | currentSong = song
29 | updateCount()
30 | currentSong?.url?.apply {
31 | val mediaItem = MediaItem.fromUri(this)
32 | exoPlayer?.setMediaItem(mediaItem)
33 | exoPlayer?.prepare()
34 | exoPlayer?.play()
35 |
36 | }
37 | }
38 |
39 |
40 | }
41 |
42 | fun updateCount(){
43 | currentSong?.id?.let {id->
44 | FirebaseFirestore.getInstance().collection("songs")
45 | .document(id)
46 | .get().addOnSuccessListener {
47 | var latestCount = it.getLong("count")
48 | if(latestCount==null){
49 | latestCount = 1L
50 | }else{
51 | latestCount = latestCount+1
52 | }
53 |
54 | FirebaseFirestore.getInstance().collection("songs")
55 | .document(id)
56 | .update(mapOf("count" to latestCount))
57 |
58 | }
59 | }
60 | }
61 |
62 | }
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/app/src/main/java/np/com/bimalkafle/musicstream/PlayerActivity.kt:
--------------------------------------------------------------------------------
1 | package np.com.bimalkafle.musicstream
2 |
3 | import androidx.appcompat.app.AppCompatActivity
4 | import android.os.Bundle
5 | import android.view.View
6 | import androidx.media3.common.Player
7 | import androidx.media3.exoplayer.ExoPlayer
8 | import com.bumptech.glide.Glide
9 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners
10 | import com.bumptech.glide.request.RequestOptions
11 | import np.com.bimalkafle.musicstream.databinding.ActivityPlayerBinding
12 |
13 | class PlayerActivity : AppCompatActivity() {
14 |
15 | lateinit var binding: ActivityPlayerBinding
16 | lateinit var exoPlayer: ExoPlayer
17 |
18 | var playerListener = object : Player.Listener{
19 | override fun onIsPlayingChanged(isPlaying: Boolean) {
20 | super.onIsPlayingChanged(isPlaying)
21 | showGif(isPlaying)
22 | }
23 | }
24 |
25 | override fun onCreate(savedInstanceState: Bundle?) {
26 | super.onCreate(savedInstanceState)
27 | binding = ActivityPlayerBinding.inflate(layoutInflater)
28 | setContentView(binding.root)
29 |
30 |
31 | MyExoplayer.getCurrentSong()?.apply {
32 | binding.songTitleTextView.text = title
33 | binding.songSubtitleTextView.text = subtitle
34 | Glide.with(binding.songCoverImageView).load(coverUrl)
35 | .circleCrop()
36 | .into(binding.songCoverImageView)
37 | Glide.with(binding.songGifImageView).load(R.drawable.media_playing)
38 | .circleCrop()
39 | .into(binding.songGifImageView)
40 | exoPlayer = MyExoplayer.getInstance()!!
41 | binding.playerView.player = exoPlayer
42 | binding.playerView.showController()
43 | exoPlayer.addListener(playerListener)
44 |
45 |
46 | }
47 |
48 | }
49 |
50 | override fun onDestroy() {
51 | super.onDestroy()
52 | exoPlayer?.removeListener(playerListener)
53 | }
54 |
55 | fun showGif(show : Boolean){
56 | if(show)
57 | binding.songGifImageView.visibility = View.VISIBLE
58 | else
59 | binding.songGifImageView.visibility = View.INVISIBLE
60 | }
61 | }
--------------------------------------------------------------------------------
/app/src/main/java/np/com/bimalkafle/musicstream/adapter/CategoryAdapter.kt:
--------------------------------------------------------------------------------
1 | package np.com.bimalkafle.musicstream.adapter
2 |
3 | import android.content.Intent
4 | import android.util.Log
5 | import android.view.LayoutInflater
6 | import android.view.ViewGroup
7 | import androidx.recyclerview.widget.RecyclerView
8 | import com.bumptech.glide.Glide
9 | import com.bumptech.glide.load.resource.bitmap.CenterCrop
10 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners
11 | import com.bumptech.glide.request.RequestOptions
12 | import np.com.bimalkafle.musicstream.SongsListActivity
13 | import np.com.bimalkafle.musicstream.databinding.CategoryItemRecyclerRowBinding
14 | import np.com.bimalkafle.musicstream.models.CategoryModel
15 |
16 | class CategoryAdapter (private val categoryList : List) :
17 | RecyclerView.Adapter() {
18 |
19 | class MyViewHolder(private val binding : CategoryItemRecyclerRowBinding) :
20 | RecyclerView.ViewHolder(binding.root){
21 | //bind the data with views
22 | fun bindData(category : CategoryModel){
23 | binding.nameTextView.text = category.name
24 | Glide.with(binding.coverImageView).load(category.coverUrl)
25 | .apply(
26 | RequestOptions().transform(RoundedCorners(32))
27 | )
28 | .into(binding.coverImageView)
29 |
30 | //Start SongsList Activity
31 | val context = binding.root.context
32 | binding.root.setOnClickListener {
33 | SongsListActivity.category = category
34 | context.startActivity(Intent(context,SongsListActivity::class.java))
35 | }
36 |
37 | }
38 | }
39 |
40 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
41 | val binding = CategoryItemRecyclerRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
42 | return MyViewHolder(binding)
43 | }
44 |
45 | override fun getItemCount(): Int {
46 | return categoryList.size
47 | }
48 |
49 | override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
50 | holder.bindData(categoryList[position])
51 | }
52 |
53 | }
--------------------------------------------------------------------------------
/app/src/main/java/np/com/bimalkafle/musicstream/adapter/SongsListAdapter.kt:
--------------------------------------------------------------------------------
1 | package np.com.bimalkafle.musicstream.adapter
2 |
3 | import android.content.Intent
4 | import android.view.LayoutInflater
5 | import android.view.ViewGroup
6 | import androidx.recyclerview.widget.RecyclerView
7 | import com.bumptech.glide.Glide
8 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners
9 | import com.bumptech.glide.request.RequestOptions
10 | import com.google.firebase.firestore.FirebaseFirestore
11 | import np.com.bimalkafle.musicstream.MyExoplayer
12 | import np.com.bimalkafle.musicstream.PlayerActivity
13 | import np.com.bimalkafle.musicstream.SongsListActivity
14 | import np.com.bimalkafle.musicstream.databinding.SongListItemRecyclerRowBinding
15 | import np.com.bimalkafle.musicstream.models.SongModel
16 |
17 | class SongsListAdapter(private val songIdList : List) :
18 | RecyclerView.Adapter() {
19 |
20 | class MyViewHolder(private val binding: SongListItemRecyclerRowBinding) : RecyclerView.ViewHolder(binding.root){
21 | //bind data with view
22 | fun bindData(songId : String){
23 |
24 | FirebaseFirestore.getInstance().collection("songs")
25 | .document(songId).get()
26 | .addOnSuccessListener {
27 | val song = it.toObject(SongModel::class.java)
28 | song?.apply {
29 | binding.songTitleTextView.text = title
30 | binding.songSubtitleTextView.text = subtitle
31 | Glide.with(binding.songCoverImageView).load(coverUrl)
32 | .apply(
33 | RequestOptions().transform(RoundedCorners(32))
34 | )
35 | .into(binding.songCoverImageView)
36 | binding.root.setOnClickListener {
37 | MyExoplayer.startPlaying(binding.root.context,song)
38 | it.context.startActivity(Intent(it.context,PlayerActivity::class.java))
39 | }
40 | }
41 | }
42 |
43 | }
44 | }
45 |
46 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
47 | val binding = SongListItemRecyclerRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
48 | return MyViewHolder(binding)
49 | }
50 |
51 | override fun getItemCount(): Int {
52 | return songIdList.size
53 | }
54 |
55 | override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
56 | holder.bindData(songIdList[position])
57 | }
58 |
59 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_player.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
22 |
23 |
24 |
27 |
33 |
34 |
40 |
41 |
42 |
43 |
52 |
60 |
61 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/app/src/main/java/np/com/bimalkafle/musicstream/adapter/SectionSongListAdapter.kt:
--------------------------------------------------------------------------------
1 | package np.com.bimalkafle.musicstream.adapter
2 |
3 | import android.content.Intent
4 | import android.view.LayoutInflater
5 | import android.view.ViewGroup
6 | import androidx.recyclerview.widget.RecyclerView
7 | import com.bumptech.glide.Glide
8 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners
9 | import com.bumptech.glide.request.RequestOptions
10 | import com.google.firebase.firestore.FirebaseFirestore
11 | import np.com.bimalkafle.musicstream.MyExoplayer
12 | import np.com.bimalkafle.musicstream.PlayerActivity
13 | import np.com.bimalkafle.musicstream.SongsListActivity
14 | import np.com.bimalkafle.musicstream.databinding.SectionSongListRecyclerRowBinding
15 | import np.com.bimalkafle.musicstream.databinding.SongListItemRecyclerRowBinding
16 | import np.com.bimalkafle.musicstream.models.SongModel
17 |
18 | class SectionSongListAdapter(private val songIdList : List) :
19 | RecyclerView.Adapter() {
20 |
21 | class MyViewHolder(private val binding: SectionSongListRecyclerRowBinding) : RecyclerView.ViewHolder(binding.root){
22 | //bind data with view
23 | fun bindData(songId : String){
24 |
25 | FirebaseFirestore.getInstance().collection("songs")
26 | .document(songId).get()
27 | .addOnSuccessListener {
28 | val song = it.toObject(SongModel::class.java)
29 | song?.apply {
30 | binding.songTitleTextView.text = title
31 | binding.songSubtitleTextView.text = subtitle
32 | Glide.with(binding.songCoverImageView).load(coverUrl)
33 | .apply(
34 | RequestOptions().transform(RoundedCorners(32))
35 | )
36 | .into(binding.songCoverImageView)
37 | binding.root.setOnClickListener {
38 | MyExoplayer.startPlaying(binding.root.context,song)
39 | it.context.startActivity(Intent(it.context,PlayerActivity::class.java))
40 | }
41 | }
42 | }
43 |
44 | }
45 | }
46 |
47 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
48 | val binding = SectionSongListRecyclerRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
49 | return MyViewHolder(binding)
50 | }
51 |
52 | override fun getItemCount(): Int {
53 | return songIdList.size
54 | }
55 |
56 | override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
57 | holder.bindData(songIdList[position])
58 | }
59 |
60 | }
--------------------------------------------------------------------------------
/app/src/main/java/np/com/bimalkafle/musicstream/LoginActivity.kt:
--------------------------------------------------------------------------------
1 | package np.com.bimalkafle.musicstream
2 |
3 | import android.content.Intent
4 | import androidx.appcompat.app.AppCompatActivity
5 | import android.os.Bundle
6 | import android.util.Patterns
7 | import android.view.View
8 | import android.widget.Toast
9 | import com.google.firebase.auth.FirebaseAuth
10 | import np.com.bimalkafle.musicstream.databinding.ActivityLoginBinding
11 | import java.util.regex.Pattern
12 |
13 | class LoginActivity : AppCompatActivity() {
14 |
15 | lateinit var binding: ActivityLoginBinding
16 | override fun onCreate(savedInstanceState: Bundle?) {
17 | super.onCreate(savedInstanceState)
18 | binding = ActivityLoginBinding.inflate(layoutInflater)
19 | setContentView(binding.root)
20 |
21 | binding.loginBtn.setOnClickListener {
22 | val email = binding.emailEdittext.text.toString()
23 | val password = binding.passwordEdittext.text.toString()
24 |
25 | if(!Pattern.matches(Patterns.EMAIL_ADDRESS.pattern(),email)){
26 | binding.emailEdittext.setError("Invalid email")
27 | return@setOnClickListener
28 | }
29 |
30 | if(password.length < 6){
31 | binding.passwordEdittext.setError("Length should be 6 char")
32 | return@setOnClickListener
33 | }
34 |
35 |
36 | loginWithFirebase(email,password)
37 | }
38 |
39 | binding.gotoSignupBtn.setOnClickListener {
40 | startActivity(Intent(this,SignupActivity::class.java))
41 | }
42 |
43 | }
44 |
45 | fun loginWithFirebase(email : String,password: String){
46 | setInProgress(true)
47 | FirebaseAuth.getInstance().signInWithEmailAndPassword(email,password)
48 | .addOnSuccessListener {
49 | setInProgress(false)
50 | startActivity(Intent(this@LoginActivity,MainActivity::class.java))
51 | finish()
52 | }.addOnFailureListener {
53 | setInProgress(false)
54 | Toast.makeText(applicationContext,"Login account failed", Toast.LENGTH_SHORT).show()
55 | }
56 | }
57 |
58 | override fun onResume() {
59 | super.onResume()
60 | FirebaseAuth.getInstance().currentUser?.apply {
61 | startActivity(Intent(this@LoginActivity,MainActivity::class.java))
62 | finish()
63 | }
64 | }
65 |
66 | fun setInProgress(inProgress : Boolean){
67 | if(inProgress){
68 | binding.loginBtn.visibility = View.GONE
69 | binding.progressBar.visibility = View.VISIBLE
70 | }else{
71 | binding.loginBtn.visibility = View.VISIBLE
72 | binding.progressBar.visibility = View.GONE
73 | }
74 | }
75 | }
--------------------------------------------------------------------------------
/app/src/main/java/np/com/bimalkafle/musicstream/SignupActivity.kt:
--------------------------------------------------------------------------------
1 | package np.com.bimalkafle.musicstream
2 |
3 | import androidx.appcompat.app.AppCompatActivity
4 | import android.os.Bundle
5 | import android.util.Patterns
6 | import android.view.View
7 | import android.widget.Toast
8 | import com.google.firebase.auth.FirebaseAuth
9 | import np.com.bimalkafle.musicstream.databinding.ActivitySignupBinding
10 | import java.util.regex.Pattern
11 |
12 | class SignupActivity : AppCompatActivity() {
13 |
14 |
15 | lateinit var binding: ActivitySignupBinding
16 |
17 | override fun onCreate(savedInstanceState: Bundle?) {
18 | super.onCreate(savedInstanceState)
19 | binding = ActivitySignupBinding.inflate(layoutInflater)
20 | setContentView(binding.root)
21 |
22 | binding.createAccountBtn.setOnClickListener {
23 |
24 | val email = binding.emailEdittext.text.toString()
25 | val password = binding.passwordEdittext.text.toString()
26 | val confirmPassword = binding.confirmPasswordEdittext.text.toString()
27 |
28 | if(!Pattern.matches(Patterns.EMAIL_ADDRESS.pattern(),email)){
29 | binding.emailEdittext.setError("Invalid email")
30 | return@setOnClickListener
31 | }
32 |
33 | if(password.length < 6){
34 | binding.passwordEdittext.setError("Length should be 6 char")
35 | return@setOnClickListener
36 | }
37 |
38 | if(!password.equals(confirmPassword)){
39 | binding.confirmPasswordEdittext.setError("Password not matched")
40 | return@setOnClickListener
41 | }
42 |
43 | createAccountWithFirebase(email,password)
44 |
45 |
46 |
47 | }
48 |
49 | binding.gotoLoginBtn.setOnClickListener {
50 | finish()
51 | }
52 |
53 | }
54 |
55 | fun createAccountWithFirebase(email : String,password: String){
56 | setInProgress(true)
57 | FirebaseAuth.getInstance().createUserWithEmailAndPassword(email,password)
58 | .addOnSuccessListener {
59 | setInProgress(false)
60 | Toast.makeText(applicationContext,"User created successfully",Toast.LENGTH_SHORT).show()
61 | finish()
62 | }.addOnFailureListener {
63 | setInProgress(false)
64 | Toast.makeText(applicationContext,"Create account failed",Toast.LENGTH_SHORT).show()
65 | }
66 | }
67 |
68 |
69 | fun setInProgress(inProgress : Boolean){
70 | if(inProgress){
71 | binding.createAccountBtn.visibility = View.GONE
72 | binding.progressBar.visibility = View.VISIBLE
73 | }else{
74 | binding.createAccountBtn.visibility = View.VISIBLE
75 | binding.progressBar.visibility = View.GONE
76 | }
77 | }
78 |
79 |
80 | }
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
17 |
18 |
22 |
23 |
33 |
34 |
35 |
36 |
37 |
43 |
44 |
53 |
54 |
57 |
58 |
67 |
70 |
71 |
72 |
77 |
78 |
84 |
87 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_signup.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
17 |
18 |
22 |
23 |
33 |
34 |
35 |
36 |
37 |
43 |
44 |
53 |
54 |
57 |
58 |
67 |
70 |
71 |
80 |
81 |
84 |
85 |
86 |
91 |
92 |
98 |
101 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/app/src/main/java/np/com/bimalkafle/musicstream/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package np.com.bimalkafle.musicstream
2 |
3 | import android.content.Intent
4 | import androidx.appcompat.app.AppCompatActivity
5 | import android.os.Bundle
6 | import android.view.View
7 | import android.widget.PopupMenu
8 | import android.widget.RelativeLayout
9 | import android.widget.TextView
10 | import androidx.recyclerview.widget.LinearLayoutManager
11 | import androidx.recyclerview.widget.RecyclerView
12 | import com.bumptech.glide.Glide
13 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners
14 | import com.bumptech.glide.request.RequestOptions
15 | import com.google.firebase.auth.FirebaseAuth
16 | import com.google.firebase.firestore.FirebaseFirestore
17 | import com.google.firebase.firestore.Query
18 | import com.google.firebase.firestore.toObjects
19 | import np.com.bimalkafle.musicstream.adapter.CategoryAdapter
20 | import np.com.bimalkafle.musicstream.adapter.SectionSongListAdapter
21 | import np.com.bimalkafle.musicstream.databinding.ActivityMainBinding
22 | import np.com.bimalkafle.musicstream.models.CategoryModel
23 | import np.com.bimalkafle.musicstream.models.SongModel
24 |
25 | class MainActivity : AppCompatActivity() {
26 |
27 | lateinit var binding: ActivityMainBinding
28 | lateinit var categoryAdapter: CategoryAdapter
29 | override fun onCreate(savedInstanceState: Bundle?) {
30 | super.onCreate(savedInstanceState)
31 | binding = ActivityMainBinding.inflate(layoutInflater)
32 | setContentView(binding.root)
33 |
34 | getCategories()
35 | setupSection("secion_1",binding.section1MainLayout,binding.section1Title,binding.section1RecyclerView)
36 | setupSection("section_2",binding.section2MainLayout,binding.section2Title,binding.section2RecyclerView)
37 | setupSection("section_3",binding.section3MainLayout,binding.section3Title,binding.section3RecyclerView)
38 | setupMostlyPlayed("mostly_played",binding.mostlyPlayedMainLayout,binding.mostlyPlayedTitle,binding.mostlyPlayedRecyclerView)
39 |
40 | binding.optionBtn.setOnClickListener {
41 | showPopupMenu()
42 | }
43 |
44 |
45 | }
46 |
47 | fun showPopupMenu(){
48 |
49 | val popupMenu = PopupMenu(this,binding.optionBtn)
50 | val inflator = popupMenu.menuInflater
51 | inflator.inflate(R.menu.option_menu,popupMenu.menu)
52 | popupMenu.show()
53 | popupMenu.setOnMenuItemClickListener {
54 | when(it.itemId){
55 | R.id.logout -> {
56 | logout()
57 | true
58 | }
59 | }
60 | false
61 | }
62 |
63 |
64 | }
65 |
66 | fun logout(){
67 | MyExoplayer.getInstance()?.release()
68 | FirebaseAuth.getInstance().signOut()
69 | startActivity(Intent(this,LoginActivity::class.java))
70 | finish()
71 | }
72 |
73 |
74 |
75 | override fun onResume() {
76 | super.onResume()
77 | showPlayerView()
78 | }
79 |
80 | fun showPlayerView(){
81 | binding.playerView.setOnClickListener {
82 | startActivity(Intent(this,PlayerActivity::class.java))
83 | }
84 | MyExoplayer.getCurrentSong()?.let {
85 | binding.playerView.visibility = View.VISIBLE
86 | binding.songTitleTextView.text = "Now Playing : " + it.title
87 | Glide.with(binding.songCoverImageView).load(it.coverUrl)
88 | .apply(
89 | RequestOptions().transform(RoundedCorners(32))
90 | ).into(binding.songCoverImageView)
91 | } ?: run{
92 | binding.playerView.visibility = View.GONE
93 | }
94 | }
95 |
96 |
97 | //Categories
98 | fun getCategories(){
99 | FirebaseFirestore.getInstance().collection("category")
100 | .get().addOnSuccessListener {
101 | val categoryList = it.toObjects(CategoryModel::class.java)
102 | setupCategoryRecyclerView(categoryList)
103 | }
104 | }
105 |
106 | fun setupCategoryRecyclerView(categoryList : List){
107 | categoryAdapter = CategoryAdapter(categoryList)
108 | binding.categoriesRecyclerView.layoutManager = LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,false)
109 | binding.categoriesRecyclerView.adapter = categoryAdapter
110 | }
111 |
112 |
113 | //Sections
114 | fun setupSection(id : String,mainLayout : RelativeLayout,titleView : TextView,recyclerView: RecyclerView){
115 | FirebaseFirestore.getInstance().collection("sections")
116 | .document(id)
117 | .get().addOnSuccessListener {
118 | val section = it.toObject(CategoryModel::class.java)
119 | section?.apply {
120 | mainLayout.visibility = View.VISIBLE
121 | titleView.text = name
122 | recyclerView.layoutManager = LinearLayoutManager(this@MainActivity,LinearLayoutManager.HORIZONTAL,false)
123 | recyclerView.adapter = SectionSongListAdapter(songs)
124 | mainLayout.setOnClickListener {
125 | SongsListActivity.category = section
126 | startActivity(Intent(this@MainActivity,SongsListActivity::class.java))
127 | }
128 | }
129 | }
130 |
131 | }
132 |
133 | fun setupMostlyPlayed(id : String,mainLayout : RelativeLayout,titleView : TextView,recyclerView: RecyclerView){
134 | FirebaseFirestore.getInstance().collection("sections")
135 | .document(id)
136 | .get().addOnSuccessListener {
137 | //get most played songs
138 | FirebaseFirestore.getInstance().collection("songs")
139 | .orderBy("count",Query.Direction.DESCENDING)
140 | .limit(5)
141 | .get().addOnSuccessListener {songListSnapshot->
142 | val songsModelList = songListSnapshot.toObjects()
143 | val songsIdList = songsModelList.map{
144 | it.id
145 | }.toList()
146 | val section = it.toObject(CategoryModel::class.java)
147 | section?.apply {
148 | section.songs = songsIdList
149 | mainLayout.visibility = View.VISIBLE
150 | titleView.text = name
151 | recyclerView.layoutManager = LinearLayoutManager(this@MainActivity,LinearLayoutManager.HORIZONTAL,false)
152 | recyclerView.adapter = SectionSongListAdapter(songs)
153 | mainLayout.setOnClickListener {
154 | SongsListActivity.category = section
155 | startActivity(Intent(this@MainActivity,SongsListActivity::class.java))
156 | }
157 | }
158 | }
159 |
160 |
161 | }
162 | }
163 |
164 |
165 |
166 |
167 | }
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
15 |
20 |
21 |
28 |
35 |
36 |
37 |
38 |
44 |
45 |
49 |
50 |
57 |
58 |
62 |
63 |
66 |
67 |
72 |
73 |
81 |
82 |
87 |
88 |
93 |
94 |
97 |
102 |
103 |
111 |
112 |
117 |
118 |
123 |
124 |
127 |
132 |
133 |
141 |
142 |
147 |
148 |
153 |
154 |
157 |
162 |
163 |
171 |
172 |
177 |
178 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
200 |
201 |
205 |
206 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
--------------------------------------------------------------------------------