Verified Commit 873ecb71 authored by Sarath's avatar Sarath
Browse files

Refactor mix adapter

parent 8676d68d
...@@ -28,6 +28,7 @@ import io.reactivex.schedulers.Schedulers ...@@ -28,6 +28,7 @@ import io.reactivex.schedulers.Schedulers
import org.json.JSONObject import org.json.JSONObject
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
import kotlin.math.abs
class MixTxAdapter(private val mContext: Context) : class MixTxAdapter(private val mContext: Context) :
RecyclerView.Adapter<MixTxAdapter.TxViewHolder>() { RecyclerView.Adapter<MixTxAdapter.TxViewHolder>() {
...@@ -65,13 +66,13 @@ class MixTxAdapter(private val mContext: Context) : ...@@ -65,13 +66,13 @@ class MixTxAdapter(private val mContext: Context) :
} }
override fun onBindViewHolder(holder: TxViewHolder, position: Int) { override fun onBindViewHolder(holder: TxViewHolder, position: Int) {
val is_sat_prefs = PrefsUtil.getInstance(mContext).getValue(PrefsUtil.IS_SAT, false) val isSatPrefs = PrefsUtil.getInstance(mContext).getValue(PrefsUtil.IS_SAT, false)
val tx = mDiffer.currentList[position] val tx = mDiffer.currentList[position]
val isPremix = this.preMixTxs.contains(tx) val isPremix = this.preMixTxs.contains(tx)
if (tx!!.section == null) { if (tx!!.section == null) {
var _amount = 0L var _amount = 0L
_amount = if (tx.amount < 0.0) { _amount = if (tx.amount < 0.0) {
Math.abs(tx.amount.toLong()) abs(tx.amount.toLong())
} else { } else {
tx.amount.toLong() tx.amount.toLong()
} }
...@@ -98,8 +99,8 @@ class MixTxAdapter(private val mContext: Context) : ...@@ -98,8 +99,8 @@ class MixTxAdapter(private val mContext: Context) :
R.drawable.out_going_tx_whtie_arrow R.drawable.out_going_tx_whtie_arrow
) )
) )
holder.tvAmount!!.setTextColor(ContextCompat.getColor(mContext, R.color.white)) holder.tvAmount?.setTextColor(ContextCompat.getColor(mContext, R.color.white))
holder.tvAmount!!.text = "-" + if (is_sat_prefs) FormatsUtil.formatSats(_amount) else FormatsUtil.formatBTC( holder.tvAmount?.text = "-" + if (isSatPrefs) FormatsUtil.formatSats(_amount) else FormatsUtil.formatBTC(
_amount _amount
) )
holder.txSubText!!.visibility = View.VISIBLE holder.txSubText!!.visibility = View.VISIBLE
...@@ -107,7 +108,7 @@ class MixTxAdapter(private val mContext: Context) : ...@@ -107,7 +108,7 @@ class MixTxAdapter(private val mContext: Context) :
} else { } else {
TransitionManager.beginDelayedTransition( TransitionManager.beginDelayedTransition(
holder.tvAmount!!.rootView as ViewGroup, holder.tvAmount?.rootView as ViewGroup,
ChangeBounds() ChangeBounds()
) )
holder.tvDirection!!.setImageDrawable( holder.tvDirection!!.setImageDrawable(
...@@ -117,22 +118,22 @@ class MixTxAdapter(private val mContext: Context) : ...@@ -117,22 +118,22 @@ class MixTxAdapter(private val mContext: Context) :
) )
) )
val amount = val amount =
if (is_sat_prefs) FormatsUtil.formatSats(_amount) else FormatsUtil.formatBTC( if (isSatPrefs) FormatsUtil.formatSats(_amount) else FormatsUtil.formatBTC(
_amount _amount
) )
holder.tvAmount!!.text = amount holder.tvAmount?.text = amount
holder.tvAmount!!.setTextColor(ContextCompat.getColor(mContext, R.color.green_ui_2)) holder.tvAmount?.setTextColor(ContextCompat.getColor(mContext, R.color.green_ui_2))
if (_amount == 0L) { if (_amount == 0L) {
holder.txSubText!!.visibility = View.VISIBLE holder.txSubText?.visibility = View.VISIBLE
holder.txSubText!!.setText(R.string.remix_note_tag) holder.txSubText?.setText(R.string.remix_note_tag)
} else if (BlockedUTXO.BLOCKED_UTXO_THRESHOLD >= _amount) { } else if (BlockedUTXO.BLOCKED_UTXO_THRESHOLD >= _amount) {
holder.txSubText!!.visibility = View.VISIBLE holder.txSubText?.visibility = View.VISIBLE
holder.txSubText!!.setText(R.string.dust) holder.txSubText?.setText(R.string.dust)
} else { } else {
if(!isPremix) { if(!isPremix) {
holder.txSubText!!.visibility = View.VISIBLE holder.txSubText?.visibility = View.VISIBLE
holder.txSubText!!.setText(R.string.mixed) holder.txSubText?.setText(R.string.mixed)
holder.tvDirection!!.setImageDrawable( holder.tvDirection?.setImageDrawable(
ContextCompat.getDrawable( ContextCompat.getDrawable(
mContext, mContext,
R.drawable.ic_whirlpool R.drawable.ic_whirlpool
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment