forked from recloudstream/cloudstream
[Feature] View poster image on fullscreen, when its clicked or tapped. (#824)
* View poster image on fullscreen, when its clicked or tapped. * fix missing string * inflate dialog from context * changed inflation to alertdialog custom dialog * [skip ci] remove unused imports * various changes * additional change * xml changes * Update ResultFragment.kt Co-authored-by: Osten <11805592+LagradOst@users.noreply.github.com>
This commit is contained in:
parent
092fad148b
commit
c2ba8dc7e4
3 changed files with 48 additions and 4 deletions
|
@ -17,11 +17,13 @@ import android.view.View
|
|||
import android.view.View.GONE
|
||||
import android.view.View.VISIBLE
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.content.FileProvider
|
||||
import androidx.core.graphics.drawable.toBitmap
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.widget.NestedScrollView
|
||||
|
@ -1358,9 +1360,32 @@ class ResultFragment : Fragment(), PanelsChildGestureRegionObserver.GestureRegio
|
|||
|
||||
result_meta_site?.text = d.apiName
|
||||
|
||||
if (!d.posterUrl.isNullOrEmpty()) {
|
||||
result_poster?.setImage(d.posterUrl)
|
||||
result_poster_blur?.setImageBlur(d.posterUrl, 10, 3)
|
||||
val posterImageLink = d.posterUrl
|
||||
if (!posterImageLink.isNullOrEmpty()) {
|
||||
result_poster?.setImage(posterImageLink)
|
||||
result_poster_blur?.setImageBlur(posterImageLink, 10, 3)
|
||||
//Full screen view of Poster image
|
||||
result_poster_holder?.setOnClickListener {
|
||||
try {
|
||||
context?.let { ctx ->
|
||||
val bitmap = result_poster.drawable.toBitmap()
|
||||
val sourceBuilder = AlertDialog.Builder(ctx)
|
||||
sourceBuilder.setView(R.layout.result_poster)
|
||||
|
||||
val sourceDialog = sourceBuilder.create()
|
||||
sourceDialog.show()
|
||||
|
||||
sourceDialog.findViewById<ImageView?>(R.id.imgPoster)?.apply {
|
||||
setImageBitmap(bitmap)
|
||||
setOnClickListener {
|
||||
sourceDialog.dismissSafe()
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
logError(e)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result_poster?.setImageResource(R.drawable.default_cover)
|
||||
result_poster_blur?.setImageResource(R.drawable.default_cover)
|
||||
|
@ -1681,4 +1706,4 @@ class ResultFragment : Fragment(), PanelsChildGestureRegionObserver.GestureRegio
|
|||
override fun onGestureRegionsUpdate(gestureRegions: List<Rect>) {
|
||||
result_overlapping_panels?.setChildGestureRegions(gestureRegions)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
18
app/src/main/res/layout/result_poster.xml
Normal file
18
app/src/main/res/layout/result_poster.xml
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/primaryBlackBackground" >
|
||||
<ImageView
|
||||
android:id="@+id/imgPoster"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="fitCenter"
|
||||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/default_cover"
|
||||
android:background="#fffff0"
|
||||
android:contentDescription="@string/poster_image"
|
||||
/>
|
||||
</LinearLayout>
|
|
@ -429,4 +429,5 @@
|
|||
<string name="actor_background">Background</string>
|
||||
|
||||
<string name="home_source">Source</string>
|
||||
<string name="poster_image">Poster Image</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue