Skip to content

Commit

Permalink
Play movie button
Browse files Browse the repository at this point in the history
  • Loading branch information
kl3jvi committed Oct 26, 2021
1 parent a04b27d commit adfcc2c
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 9 deletions.
4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ android {
viewBinding true
}

packagingOptions {
exclude 'META-INF/atomicfu.kotlin_module'
}

splits {
// Configures multiple APKs based on ABI.
abi {
Expand Down
6 changes: 5 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

-keep class * extends androidx.room.RoomDatabase
-keep @androidx.room.Entity class *
-dontwarn androidx.room.paging.**
8 changes: 4 additions & 4 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,26 @@
"filters": [
{
"filterType": "ABI",
"value": "armeabi-v7a"
"value": "arm64-v8a"
}
],
"attributes": [],
"versionCode": 1,
"versionName": "1.0",
"outputFile": "app-armeabi-v7a-release.apk"
"outputFile": "app-arm64-v8a-release.apk"
},
{
"type": "ONE_OF_MANY",
"filters": [
{
"filterType": "ABI",
"value": "arm64-v8a"
"value": "armeabi-v7a"
}
],
"attributes": [],
"versionCode": 1,
"versionName": "1.0",
"outputFile": "app-arm64-v8a-release.apk"
"outputFile": "app-armeabi-v7a-release.apk"
}
],
"elementType": "File"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class PlayerActivity : AppCompatActivity() {

public override fun onStart() {
super.onStart()
if (Util.SDK_INT > 23) {
if (Util.SDK_INT > 23 && player == null) {
initializePlayer()
}
}
Expand All @@ -89,7 +89,7 @@ class PlayerActivity : AppCompatActivity() {

public override fun onStop() {
super.onStop()
if (Util.SDK_INT > 23) {
if (Util.SDK_INT > 23 && player == null) {
if (player != null) {
player?.pause()
}
Expand Down Expand Up @@ -142,7 +142,7 @@ class PlayerActivity : AppCompatActivity() {
})
}

fun getDataSourceFactory(currentUrl: String?): DefaultHttpDataSource.Factory {
private fun getDataSourceFactory(currentUrl: String?): DefaultHttpDataSource.Factory {
return DefaultHttpDataSource.Factory().apply {
setUserAgent(USER_AGENT)
if (currentUrl != null) {
Expand All @@ -160,7 +160,7 @@ class PlayerActivity : AppCompatActivity() {
}
}

fun buildMediaSource(uri: Uri): HlsMediaSource {
private fun buildMediaSource(uri: Uri): HlsMediaSource {
val dataSourceFactory: DataSource.Factory = getDataSourceFactory(uri.toString())
return HlsMediaSource.Factory(dataSourceFactory).createMediaSource(uri)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.kl3jvi.animity.view.fragments.details


import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.view.*
Expand All @@ -16,10 +17,12 @@ import com.google.android.material.chip.Chip
import com.google.android.material.snackbar.Snackbar
import com.kl3jvi.animity.R
import com.kl3jvi.animity.databinding.FragmentDetailsBinding
import com.kl3jvi.animity.utils.Constants
import com.kl3jvi.animity.utils.Constants.Companion.getBackgroundColor
import com.kl3jvi.animity.utils.Constants.Companion.getColor
import com.kl3jvi.animity.utils.Resource
import com.kl3jvi.animity.view.activities.MainActivity
import com.kl3jvi.animity.view.activities.player.PlayerActivity
import com.kl3jvi.animity.view.adapters.CustomEpisodeAdapter
import com.kl3jvi.animity.viewmodels.DetailsViewModel
import dagger.hilt.android.AndroidEntryPoint
Expand Down Expand Up @@ -97,6 +100,8 @@ class DetailsFragment : Fragment() {
binding.episodeListRecycler.visibility = View.GONE
resultPlayMovie.visibility = View.VISIBLE
imageButton.visibility = View.GONE


}
} else {

Expand Down Expand Up @@ -180,6 +185,17 @@ class DetailsFragment : Fragment() {
episodeListResponse.data?.let { episodeList ->
episodeAdapter.getEpisodeInfo(episodeList)
binding.resultEpisodesText.text = "${episodeList.size} Episodes"
if (episodeList.isNotEmpty()) {
binding.resultPlayMovie.setOnClickListener {
val intent =
Intent(requireActivity(), PlayerActivity::class.java)
intent.putExtra(Constants.EPISODE_DETAILS, episodeList.first())
requireContext().startActivity(intent)
}
} else {
binding.resultPlayMovie.isEnabled = false
binding.resultPlayMovie.text = getString(R.string.movie_not_released)
}
}
})
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@
<string name="result_go_back">goback</string>
<string name="favorite">Add to Favorites</string>
<string name="order">Order Animes</string>
<string name="movie_not_released">Movie not released yet</string>
</resources>

0 comments on commit adfcc2c

Please sign in to comment.