|
@@ -14,6 +14,7 @@ import com.opensource.svgaplayer.SVGAVideoEntity
|
|
import com.swago.baseswago.dialog.BaseXDFragment
|
|
import com.swago.baseswago.dialog.BaseXDFragment
|
|
import com.swago.baseswago.model.mine.StoreItemBean
|
|
import com.swago.baseswago.model.mine.StoreItemBean
|
|
import com.swago.baseswago.util.AppContext
|
|
import com.swago.baseswago.util.AppContext
|
|
|
|
+import com.swago.baseswago.util.LogUtil
|
|
import com.swago.baseswago.util.NoDoubleClickListener
|
|
import com.swago.baseswago.util.NoDoubleClickListener
|
|
import com.swago.loadUrl
|
|
import com.swago.loadUrl
|
|
import com.swago.user.R
|
|
import com.swago.user.R
|
|
@@ -22,25 +23,26 @@ import com.swago.user.vm.StoreVm
|
|
import java.io.File
|
|
import java.io.File
|
|
import java.net.URL
|
|
import java.net.URL
|
|
|
|
|
|
-class StoreBuyDialog : BaseXDFragment<DialogStoreDetailBinding>(){
|
|
|
|
|
|
+class StoreBuyDialog : BaseStoreDFragment<DialogStoreDetailBinding>() {
|
|
private val storeVm by viewModels<StoreVm>()
|
|
private val storeVm by viewModels<StoreVm>()
|
|
|
|
|
|
private var svgaParser: SVGAParser? = null
|
|
private var svgaParser: SVGAParser? = null
|
|
- var storeBean: StoreItemBean ?= null
|
|
|
|
- var storeType:Int = 0
|
|
|
|
- var buySuccessFun:(()->Unit)? = null
|
|
|
|
|
|
+ var storeBean: StoreItemBean? = null
|
|
|
|
+ var storeType: Int = 0
|
|
|
|
+ var buySuccessFun: (() -> Unit)? = null
|
|
|
|
+
|
|
init {
|
|
init {
|
|
setGravity(Gravity.BOTTOM)
|
|
setGravity(Gravity.BOTTOM)
|
|
setDimAmount(0.5f)
|
|
setDimAmount(0.5f)
|
|
setCanCancel(true)
|
|
setCanCancel(true)
|
|
}
|
|
}
|
|
|
|
|
|
- companion object{
|
|
|
|
- fun newInstance(bean: StoreItemBean,storeType:Int): StoreBuyDialog {
|
|
|
|
|
|
+ companion object {
|
|
|
|
+ fun newInstance(bean: StoreItemBean, storeType: Int): StoreBuyDialog {
|
|
val dialog = StoreBuyDialog()
|
|
val dialog = StoreBuyDialog()
|
|
val bundle = Bundle()
|
|
val bundle = Bundle()
|
|
- bundle.putParcelable("data" , bean)
|
|
|
|
- bundle.putInt("storeType",storeType)
|
|
|
|
|
|
+ bundle.putParcelable("data", bean)
|
|
|
|
+ bundle.putInt("storeType", storeType)
|
|
dialog.arguments = bundle
|
|
dialog.arguments = bundle
|
|
return dialog
|
|
return dialog
|
|
}
|
|
}
|
|
@@ -51,63 +53,63 @@ class StoreBuyDialog : BaseXDFragment<DialogStoreDetailBinding>(){
|
|
svgaParser = SVGAParser(activity)
|
|
svgaParser = SVGAParser(activity)
|
|
arguments?.let {
|
|
arguments?.let {
|
|
storeBean = it.getParcelable("data")
|
|
storeBean = it.getParcelable("data")
|
|
- storeType = it.getInt("storeType",0)
|
|
|
|
|
|
+ storeType = it.getInt("storeType", 0)
|
|
}
|
|
}
|
|
storeBean?.let {
|
|
storeBean?.let {
|
|
- binding.tvName.text = it.product_name
|
|
|
|
- binding.tvCoin.text = "${it.product_coin}"
|
|
|
|
- if (storeType == 1){
|
|
|
|
- binding.ivIcon.visibility = View.GONE
|
|
|
|
- binding.svgContent.visibility = View.VISIBLE
|
|
|
|
- binding.svgAvatar.visibility = View.GONE
|
|
|
|
|
|
+ binding?.tvName?.text = it.product_name
|
|
|
|
+ binding?.tvCoin?.text = "${it.product_coin}"
|
|
|
|
+ if (storeType == 1) {
|
|
|
|
+ binding?.ivIcon?.visibility = View.GONE
|
|
|
|
+ binding?.svgContent?.visibility = View.VISIBLE
|
|
|
|
+ binding?.svgAvatar?.visibility = View.GONE
|
|
it.product_svg_url?.let { svgUrl ->
|
|
it.product_svg_url?.let { svgUrl ->
|
|
- svgaParser?.decodeFromURL(URL(svgUrl), object : SVGAParser.ParseCompletion{
|
|
|
|
|
|
+ svgaParser?.decodeFromURL(URL(svgUrl), object : SVGAParser.ParseCompletion {
|
|
override fun onComplete(videoItem: SVGAVideoEntity) {
|
|
override fun onComplete(videoItem: SVGAVideoEntity) {
|
|
val drawable = SVGADrawable(videoItem)
|
|
val drawable = SVGADrawable(videoItem)
|
|
- binding.svgContent.visibility = View.VISIBLE
|
|
|
|
- binding.svgAvatar.visibility = View.GONE
|
|
|
|
- binding.svgContent.setImageDrawable(drawable)
|
|
|
|
- binding.svgContent.startAnimation()
|
|
|
|
|
|
+ binding?.svgContent?.setImageDrawable(drawable)
|
|
|
|
+ binding?.svgContent?.startAnimation()
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+
|
|
override fun onError() {
|
|
override fun onError() {
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
- } else if (storeType == 2){
|
|
|
|
- binding.ivIcon.visibility = View.GONE
|
|
|
|
- binding.svgContent.visibility = View.GONE
|
|
|
|
- binding.svgAvatar.visibility = View.VISIBLE
|
|
|
|
|
|
+ } else if (storeType == 2) {
|
|
|
|
+ binding?.ivIcon?.visibility = View.GONE
|
|
|
|
+ binding?.svgContent?.visibility = View.GONE
|
|
|
|
+ binding?.svgAvatar?.visibility = View.VISIBLE
|
|
it.product_svg_url?.let { svgUrl ->
|
|
it.product_svg_url?.let { svgUrl ->
|
|
- svgaParser?.decodeFromURL(URL(svgUrl), object : SVGAParser.ParseCompletion{
|
|
|
|
|
|
+ svgaParser?.decodeFromURL(URL(svgUrl), object : SVGAParser.ParseCompletion {
|
|
override fun onComplete(videoItem: SVGAVideoEntity) {
|
|
override fun onComplete(videoItem: SVGAVideoEntity) {
|
|
val drawable = SVGADrawable(videoItem)
|
|
val drawable = SVGADrawable(videoItem)
|
|
- binding.svgContent.visibility = View.GONE
|
|
|
|
- binding.svgAvatar.visibility = View.VISIBLE
|
|
|
|
- binding.svgAvatar.setImageDrawable(drawable)
|
|
|
|
- binding.svgAvatar.startAnimation()
|
|
|
|
|
|
+ binding?.svgAvatar?.setImageDrawable(drawable)
|
|
|
|
+ binding?.svgAvatar?.startAnimation()
|
|
}
|
|
}
|
|
|
|
+
|
|
override fun onError() {
|
|
override fun onError() {
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
- }else {
|
|
|
|
- binding.svgContent.visibility = View.GONE
|
|
|
|
- binding.svgAvatar.visibility = View.GONE
|
|
|
|
- binding.ivIcon.visibility = View.VISIBLE
|
|
|
|
|
|
+ } else {
|
|
|
|
+ binding?.svgContent?.visibility = View.GONE
|
|
|
|
+ binding?.svgAvatar?.visibility = View.GONE
|
|
|
|
+ binding?.ivIcon?.visibility = View.VISIBLE
|
|
it.product_url?.let { imageUrl ->
|
|
it.product_url?.let { imageUrl ->
|
|
- binding.ivIcon.loadUrl(AppContext.getContext(),imageUrl)
|
|
|
|
|
|
+ binding?.ivIcon?.loadUrl(AppContext.getContext(), imageUrl)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
override fun initLiveData() {
|
|
override fun initLiveData() {
|
|
- binding.tvBuy.setOnClickListener(object: NoDoubleClickListener(){
|
|
|
|
|
|
+ binding?.tvBuy?.setOnClickListener(object : NoDoubleClickListener() {
|
|
override fun onClick() {
|
|
override fun onClick() {
|
|
storeBean?.let {
|
|
storeBean?.let {
|
|
- if (it.product_status ==1){
|
|
|
|
|
|
+ if (it.product_status == 1) {
|
|
Toast.makeText(
|
|
Toast.makeText(
|
|
AppContext.getContext(),
|
|
AppContext.getContext(),
|
|
AppContext.getContext().resources.getString(R.string.this_product_has_been_purchased),
|
|
AppContext.getContext().resources.getString(R.string.this_product_has_been_purchased),
|
|
@@ -120,12 +122,12 @@ class StoreBuyDialog : BaseXDFragment<DialogStoreDetailBinding>(){
|
|
|
|
|
|
}
|
|
}
|
|
})
|
|
})
|
|
- binding.svgContent.setOnClickListener {
|
|
|
|
|
|
+ binding?.svgContent?.setOnClickListener {
|
|
dismissAllowingStateLoss()
|
|
dismissAllowingStateLoss()
|
|
}
|
|
}
|
|
|
|
|
|
- storeVm.buyProductSuccess.observe(this){
|
|
|
|
- if (it){
|
|
|
|
|
|
+ storeVm.buyProductSuccess.observe(this) {
|
|
|
|
+ if (it) {
|
|
buySuccessFun?.invoke()
|
|
buySuccessFun?.invoke()
|
|
}
|
|
}
|
|
dismissAllowingStateLoss()
|
|
dismissAllowingStateLoss()
|