mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Updated Icon & Added Animation for Nearby (#6201)
* Applied better animation in nearby * Refactor: Reduce Duration of Rotate Animation Decreased the duration of the rotate animation from 1000ms to 500ms in `rotate.xml`, resulting in a faster rotation speed.
This commit is contained in:
parent
d32ab15d42
commit
a8e38f4329
3 changed files with 102 additions and 1 deletions
|
|
@ -46,6 +46,9 @@ import androidx.recyclerview.widget.DividerItemDecoration
|
|||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.engine.GlideException
|
||||
import com.bumptech.glide.request.RequestListener
|
||||
import com.bumptech.glide.request.target.Target
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
|
|
@ -134,6 +137,7 @@ import java.util.UUID
|
|||
import java.util.concurrent.TimeUnit
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Named
|
||||
import javax.sql.DataSource
|
||||
import kotlin.concurrent.Volatile
|
||||
|
||||
|
||||
|
|
@ -2353,12 +2357,50 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(),
|
|||
selectedPlace?.pic?.substringAfterLast("/")?.takeIf { it.isNotEmpty() }?.let { imageName ->
|
||||
Glide.with(binding!!.bottomSheetDetails.icon.context)
|
||||
.clear(binding!!.bottomSheetDetails.icon)
|
||||
|
||||
val loadingDrawable = ContextCompat.getDrawable(
|
||||
binding!!.bottomSheetDetails.icon.context,
|
||||
R.drawable.loading_icon
|
||||
)
|
||||
val animation = AnimationUtils.loadAnimation(
|
||||
binding!!.bottomSheetDetails.icon.context,
|
||||
R.anim.rotate
|
||||
)
|
||||
|
||||
Glide.with(binding!!.bottomSheetDetails.icon.context)
|
||||
.load("https://commons.wikimedia.org/wiki/Special:Redirect/file/$imageName?width=25")
|
||||
.placeholder(fr.free.nrw.commons.R.drawable.ic_refresh_24dp_nearby)
|
||||
.placeholder(loadingDrawable)
|
||||
.error(selectedPlace!!.label.icon)
|
||||
.listener(object : RequestListener<Drawable> {
|
||||
override fun onLoadFailed(
|
||||
e: GlideException?,
|
||||
model: Any?,
|
||||
target: Target<Drawable>,
|
||||
isFirstResource: Boolean
|
||||
): Boolean {
|
||||
binding!!.bottomSheetDetails.icon.clearAnimation()
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onResourceReady(
|
||||
resource: Drawable,
|
||||
model: Any,
|
||||
target: Target<Drawable>?,
|
||||
dataSource: com.bumptech.glide.load.DataSource,
|
||||
isFirstResource: Boolean
|
||||
): Boolean {
|
||||
binding!!.bottomSheetDetails.icon.clearAnimation()
|
||||
return false
|
||||
}
|
||||
})
|
||||
.into(binding!!.bottomSheetDetails.icon)
|
||||
|
||||
if (binding!!.bottomSheetDetails.icon.drawable != null && binding!!.bottomSheetDetails.icon.drawable.constantState == loadingDrawable?.constantState) {
|
||||
binding!!.bottomSheetDetails.icon.startAnimation(animation)
|
||||
} else {
|
||||
binding!!.bottomSheetDetails.icon.clearAnimation()
|
||||
}
|
||||
|
||||
binding!!.bottomSheetDetails.icon.setOnClickListener {
|
||||
handleMediaClick(imageName)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue