Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
deBeauvoir
samourai-wallet-android
Commits
0384b399
Verified
Commit
0384b399
authored
Dec 01, 2021
by
Sarath
⚔
Browse files
Use updated transaction adapter for mix transactions list
parent
292c0958
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
19 deletions
+31
-19
app/src/main/java/com/samourai/wallet/whirlpool/fragments/TransactionsFragment.kt
...mourai/wallet/whirlpool/fragments/TransactionsFragment.kt
+30
-19
app/src/main/res/values/strings.xml
app/src/main/res/values/strings.xml
+1
-0
No files found.
app/src/main/java/com/samourai/wallet/whirlpool/fragments/TransactionsFragment.kt
View file @
0384b399
...
...
@@ -5,6 +5,7 @@ import android.content.Context
import
android.content.Intent
import
android.content.IntentFilter
import
android.os.Bundle
import
android.util.Log
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
...
...
@@ -21,14 +22,13 @@ import androidx.recyclerview.widget.RecyclerView
import
androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import
com.samourai.wallet.R
import
com.samourai.wallet.api.APIFactory
import
com.samourai.wallet.api.Tx
import
com.samourai.wallet.databinding.WhirlpoolIntroViewBinding
import
com.samourai.wallet.home.BalanceActivity
import
com.samourai.wallet.home.BalanceViewModel
import
com.samourai.wallet.home.adapters.TxAdapter
import
com.samourai.wallet.service.JobRefreshService
import
com.samourai.wallet.tx.TxDetailsActivity
import
com.samourai.wallet.whirlpool.WhirlPoolHomeViewModel
import
com.samourai.wallet.whirlpool.WhirlpoolHome.Companion.NEWPOOL_REQ_CODE
import
com.samourai.wallet.whirlpool.adapters.MixTxAdapter
import
com.samourai.wallet.whirlpool.newPool.NewPoolActivity
import
com.samourai.whirlpool.client.wallet.beans.WhirlpoolAccount
import
kotlinx.coroutines.Dispatchers
...
...
@@ -37,9 +37,8 @@ import kotlinx.coroutines.withContext
class
TransactionsFragment
:
Fragment
()
{
private
val
viewModel
:
BalanceViewModel
by
viewModels
()
private
val
whirlPoolHomeViewModel
:
WhirlPoolHomeViewModel
by
activityViewModels
()
lateinit
var
adapter
:
TxAdapter
lateinit
var
adapter
:
Mix
TxAdapter
lateinit
var
recyclerView
:
RecyclerView
lateinit
var
containerLayout
:
FrameLayout
private
var
swipeRefreshLayout
:
SwipeRefreshLayout
?
=
null
...
...
@@ -61,32 +60,43 @@ class TransactionsFragment : Fragment() {
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
super
.
onViewCreated
(
view
,
savedInstanceState
)
viewModel
.
setAccount
(
WhirlpoolAccount
.
POSTMIX
.
accountIndex
);
val
filter
=
IntentFilter
(
BalanceActivity
.
DISPLAY_INTENT
)
LocalBroadcastManager
.
getInstance
(
requireContext
())
.
registerReceiver
(
whirlPoolHomeViewModel
.
broadCastReceiver
,
filter
)
LocalBroadcastManager
.
getInstance
(
requireContext
())
.
registerReceiver
(
broadCastReceiver
,
filter
)
v
iewModel
.
loadOfflineData
()
whirlPoolHomeV
iewModel
.
loadOffline
Tx
Data
(
requireContext
()
)
whirlPoolHomeViewModel
.
onboardStatus
.
observe
(
viewLifecycleOwner
,
{
showOnBoarding
->
if
(
showOnBoarding
)
{
showIntroView
()
}
else
{
adapter
=
TxAdapter
(
adapter
=
Mix
TxAdapter
(
view
.
context
,
listOf
(
),
WhirlpoolAccount
.
POSTMIX
.
accountIndex
)
adapter
.
setClickListener
{
_
,
tx
->
adapter
.
setClickListener
{
tx
->
val
txIntent
=
Intent
(
requireContext
(),
TxDetailsActivity
::
class
.
java
)
txIntent
.
putExtra
(
"TX"
,
tx
.
toJSON
().
toString
())
txIntent
.
putExtra
(
"_account"
,
WhirlpoolAccount
.
POSTMIX
.
accountIndex
)
startActivity
(
txIntent
)
}
recyclerView
.
adapter
=
adapter
viewModel
.
txs
.
observe
(
viewLifecycleOwner
,
{
adapter
.
setTxes
(
it
)
whirlPoolHomeViewModel
.
mixTransactionsList
.
observe
(
viewLifecycleOwner
,
{
mix
->
val
postMix
=
mutableListOf
<
Tx
>()
val
preMix
=
mutableListOf
<
Tx
>()
if
(
mix
.
containsKey
(
WhirlpoolAccount
.
POSTMIX
)){
postMix
.
clear
()
mix
[
WhirlpoolAccount
.
POSTMIX
]
?.
let
{
postMix
.
addAll
(
it
)
}
}
if
(
mix
.
containsKey
(
WhirlpoolAccount
.
PREMIX
)){
preMix
.
clear
()
mix
[
WhirlpoolAccount
.
PREMIX
]
?.
let
{
preMix
.
addAll
(
it
)
}
}
adapter
.
setTx
(
postMix
,
preMix
)
})
}
})
...
...
@@ -109,12 +119,16 @@ class TransactionsFragment : Fragment() {
}
private
fun
loadFromRepo
()
{
v
iewModel
.
viewModelScope
.
launch
{
whirlPoolHomeV
iewModel
.
viewModelScope
.
launch
{
withContext
(
Dispatchers
.
IO
)
{
val
postMixList
=
APIFactory
.
getInstance
(
requireContext
()).
allPostMixTxs
val
premixList
=
APIFactory
.
getInstance
(
requireContext
()).
allPremixTx
val
list
=
arrayListOf
<
Tx
>()
list
.
addAll
(
postMixList
)
list
.
addAll
(
premixList
)
if
(
postMixList
!=
null
)
{
withContext
(
Dispatchers
.
Main
)
{
v
iewModel
.
setTx
(
postMixList
)
whirlPoolHomeV
iewModel
.
setTx
(
postMixList
,
premixList
)
}
}
}
...
...
@@ -148,8 +162,6 @@ class TransactionsFragment : Fragment() {
drawable
?.
let
{
this
.
setDrawable
(
it
)
}
})
}
swipeRefreshLayout
=
SwipeRefreshLayout
(
container
.
context
)
.
apply
{
layoutParams
=
FrameLayout
.
LayoutParams
(
...
...
@@ -171,7 +183,6 @@ class TransactionsFragment : Fragment() {
}
companion
object
{
@JvmStatic
fun
newInstance
():
TransactionsFragment
{
return
TransactionsFragment
().
apply
{
...
...
app/src/main/res/values/strings.xml
View file @
0384b399
...
...
@@ -894,5 +894,6 @@
<string
name=
"mixed"
>
Mixed
</string>
<string
name=
"postmix_spend"
>
Postmix spend
</string>
<string
name=
"you_cannot_follow_your_own_paynym"
>
You cannot follow your own paynym
</string>
<string
name=
"transfer_to_whirlpool"
>
Transfer to whirlpool
</string>
</resources>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment