[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:
Jace 2022-03-21 07:25:25 +08:00 committed by GitHub
parent 092fad148b
commit c2ba8dc7e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 4 deletions

View file

@ -17,11 +17,13 @@ import android.view.View
import android.view.View.GONE import android.view.View.GONE
import android.view.View.VISIBLE import android.view.View.VISIBLE
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import android.widget.Toast import android.widget.Toast
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.core.content.FileProvider import androidx.core.content.FileProvider
import androidx.core.graphics.drawable.toBitmap
import androidx.core.view.isGone import androidx.core.view.isGone
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.core.widget.NestedScrollView import androidx.core.widget.NestedScrollView
@ -1358,9 +1360,32 @@ class ResultFragment : Fragment(), PanelsChildGestureRegionObserver.GestureRegio
result_meta_site?.text = d.apiName result_meta_site?.text = d.apiName
if (!d.posterUrl.isNullOrEmpty()) { val posterImageLink = d.posterUrl
result_poster?.setImage(d.posterUrl) if (!posterImageLink.isNullOrEmpty()) {
result_poster_blur?.setImageBlur(d.posterUrl, 10, 3) 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 { } else {
result_poster?.setImageResource(R.drawable.default_cover) result_poster?.setImageResource(R.drawable.default_cover)
result_poster_blur?.setImageResource(R.drawable.default_cover) result_poster_blur?.setImageResource(R.drawable.default_cover)

View 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>

View file

@ -429,4 +429,5 @@
<string name="actor_background">Background</string> <string name="actor_background">Background</string>
<string name="home_source">Source</string> <string name="home_source">Source</string>
<string name="poster_image">Poster Image</string>
</resources> </resources>