|
@@ -3,11 +3,13 @@ package com.swago.user.store
|
|
|
import android.os.Bundle
|
|
|
import android.view.Gravity
|
|
|
import android.view.View
|
|
|
+import android.view.View.OnClickListener
|
|
|
import android.widget.Toast
|
|
|
import androidx.activity.viewModels
|
|
|
import androidx.fragment.app.viewModels
|
|
|
import com.opensource.svgaplayer.SVGADrawable
|
|
|
import com.opensource.svgaplayer.SVGAParser
|
|
|
+import com.opensource.svgaplayer.SVGASoundManager
|
|
|
import com.opensource.svgaplayer.SVGAVideoEntity
|
|
|
import com.swago.baseswago.dialog.BaseXDFragment
|
|
|
import com.swago.baseswago.model.mine.StoreItemBean
|
|
@@ -25,6 +27,7 @@ class StoreBuyDialog : BaseXDFragment<DialogStoreDetailBinding>(){
|
|
|
|
|
|
private var svgaParser: SVGAParser? = null
|
|
|
var storeBean: StoreItemBean ?= null
|
|
|
+ var storeType:Int = 0
|
|
|
var buySuccessFun:(()->Unit)? = null
|
|
|
init {
|
|
|
setGravity(Gravity.BOTTOM)
|
|
@@ -33,10 +36,11 @@ class StoreBuyDialog : BaseXDFragment<DialogStoreDetailBinding>(){
|
|
|
}
|
|
|
|
|
|
companion object{
|
|
|
- fun newInstance(bean: StoreItemBean): StoreBuyDialog {
|
|
|
+ fun newInstance(bean: StoreItemBean,storeType:Int): StoreBuyDialog {
|
|
|
val dialog = StoreBuyDialog()
|
|
|
val bundle = Bundle()
|
|
|
bundle.putParcelable("data" , bean)
|
|
|
+ bundle.putInt("storeType",storeType)
|
|
|
dialog.arguments = bundle
|
|
|
return dialog
|
|
|
}
|
|
@@ -47,17 +51,28 @@ class StoreBuyDialog : BaseXDFragment<DialogStoreDetailBinding>(){
|
|
|
svgaParser = SVGAParser(activity)
|
|
|
arguments?.let {
|
|
|
storeBean = it.getParcelable("data")
|
|
|
+ storeType = it.getInt("storeType",0)
|
|
|
}
|
|
|
storeBean?.let {
|
|
|
binding.tvName.text = it.product_name
|
|
|
binding.tvCoin.text = "${it.product_coin}"
|
|
|
- if (!it.product_svg_url.isNullOrEmpty() && it.product_svg_url?.endsWith(".svga") == true){
|
|
|
+ if (storeType == 1 || storeType == 2){
|
|
|
binding.ivIcon.visibility = View.GONE
|
|
|
svgaParser?.decodeFromURL(URL(it.product_svg_url), object : SVGAParser.ParseCompletion{
|
|
|
override fun onComplete(videoItem: SVGAVideoEntity) {
|
|
|
val drawable = SVGADrawable(videoItem)
|
|
|
- binding.svgContent.setImageDrawable(drawable)
|
|
|
- binding.svgContent.startAnimation()
|
|
|
+ if (storeType == 1){
|
|
|
+ binding.svgContent.visibility = View.VISIBLE
|
|
|
+ binding.svgAvatar.visibility = View.GONE
|
|
|
+ binding.svgContent.setImageDrawable(drawable)
|
|
|
+ binding.svgContent.startAnimation()
|
|
|
+ } else {
|
|
|
+ binding.svgContent.visibility = View.GONE
|
|
|
+ binding.svgAvatar.visibility = View.VISIBLE
|
|
|
+ binding.svgAvatar.setImageDrawable(drawable)
|
|
|
+ binding.svgAvatar.startAnimation()
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
override fun onError() {
|
|
@@ -65,14 +80,13 @@ class StoreBuyDialog : BaseXDFragment<DialogStoreDetailBinding>(){
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
+ binding.svgContent.visibility = View.GONE
|
|
|
+ binding.svgAvatar.visibility = View.GONE
|
|
|
binding.ivIcon.visibility = View.VISIBLE
|
|
|
it.product_url?.let { imageUrl ->
|
|
|
binding.ivIcon.loadUrl(AppContext.getContext(),imageUrl)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -95,5 +109,8 @@ class StoreBuyDialog : BaseXDFragment<DialogStoreDetailBinding>(){
|
|
|
|
|
|
}
|
|
|
})
|
|
|
+ binding.svgContent.setOnClickListener {
|
|
|
+ dismissAllowingStateLoss()
|
|
|
+ }
|
|
|
}
|
|
|
}
|