- Create and add the new Transactions, Merchants and Settings icons and use them in the Balances toolbar.
- Remove the transactions section from the Balances fragment. - Create a new TransactionsFragment which hosts the list of trasactions. - Add the transactions destination to the navigation graph so that the Navigation component automatically handles the transition when the transactions icon is selected in Balances.
This commit is contained in:
parent
3d6ce645b5
commit
2619541e16
9 changed files with 107 additions and 38 deletions
|
@ -25,7 +25,6 @@ class BalancesFragment : Fragment() {
|
||||||
|
|
||||||
private lateinit var mUserAccountViewModel: UserAccountViewModel
|
private lateinit var mUserAccountViewModel: UserAccountViewModel
|
||||||
private lateinit var mBalanceDetailViewModel: BalanceDetailViewModel
|
private lateinit var mBalanceDetailViewModel: BalanceDetailViewModel
|
||||||
private lateinit var mTransferDetailViewModel: TransferDetailViewModel
|
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
@ -59,17 +58,6 @@ class BalancesFragment : Fragment() {
|
||||||
mBalanceDetailViewModel.getAll().observe(this, Observer<List<BalanceDetail>> { balancesDetails ->
|
mBalanceDetailViewModel.getAll().observe(this, Observer<List<BalanceDetail>> { balancesDetails ->
|
||||||
balancesAdapter.replaceAll(balancesDetails)
|
balancesAdapter.replaceAll(balancesDetails)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Configure TransferDetailViewModel to show the transaction history
|
|
||||||
mTransferDetailViewModel = ViewModelProviders.of(this).get(TransferDetailViewModel::class.java)
|
|
||||||
|
|
||||||
val transfersDetailsAdapter = TransfersDetailsAdapter(context!!)
|
|
||||||
rvTransactions.adapter = transfersDetailsAdapter
|
|
||||||
rvTransactions.layoutManager = LinearLayoutManager(context)
|
|
||||||
|
|
||||||
mTransferDetailViewModel.getAll(userId).observe(this, Observer<List<TransferDetail>> { transfersDetails ->
|
|
||||||
transfersDetailsAdapter.replaceAll(transfersDetails)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
package cy.agorise.bitsybitshareswallet.fragments
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.preference.PreferenceManager
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.lifecycle.Observer
|
||||||
|
import androidx.lifecycle.ViewModelProviders
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import cy.agorise.bitsybitshareswallet.R
|
||||||
|
import cy.agorise.bitsybitshareswallet.adapters.TransfersDetailsAdapter
|
||||||
|
import cy.agorise.bitsybitshareswallet.database.joins.TransferDetail
|
||||||
|
import cy.agorise.bitsybitshareswallet.utils.Constants
|
||||||
|
import cy.agorise.bitsybitshareswallet.viewmodels.TransferDetailViewModel
|
||||||
|
import kotlinx.android.synthetic.main.fragment_transactions.*
|
||||||
|
|
||||||
|
class TransactionsFragment : Fragment() {
|
||||||
|
|
||||||
|
private lateinit var mTransferDetailViewModel: TransferDetailViewModel
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
// setHasOptionsMenu(true)
|
||||||
|
|
||||||
|
return inflater.inflate(R.layout.fragment_transactions, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
val userId = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
.getString(Constants.KEY_CURRENT_ACCOUNT_ID, "") ?: ""
|
||||||
|
|
||||||
|
// Configure TransferDetailViewModel to show the transaction history
|
||||||
|
mTransferDetailViewModel = ViewModelProviders.of(this).get(TransferDetailViewModel::class.java)
|
||||||
|
|
||||||
|
val transfersDetailsAdapter = TransfersDetailsAdapter(context!!)
|
||||||
|
rvTransactions.adapter = transfersDetailsAdapter
|
||||||
|
rvTransactions.layoutManager = LinearLayoutManager(context)
|
||||||
|
|
||||||
|
mTransferDetailViewModel.getAll(userId).observe(this, Observer<List<TransferDetail>> { transfersDetails ->
|
||||||
|
transfersDetailsAdapter.replaceAll(transfersDetails)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||||
|
// inflater.inflate(R.menu.menu_balances, menu)
|
||||||
|
// }
|
||||||
|
}
|
|
@ -1,9 +1,12 @@
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:width="24dp"
|
android:width="24dp"
|
||||||
android:height="24dp"
|
android:height="24dp"
|
||||||
android:viewportWidth="24.0"
|
android:viewportWidth="24"
|
||||||
android:viewportHeight="24.0">
|
android:viewportHeight="24">
|
||||||
<path
|
<path
|
||||||
android:fillColor="#FF000000"
|
android:fillColor="#FFF"
|
||||||
android:pathData="M20,4L4,4v2h16L20,4zM21,14v-2l-1,-5L4,7l-1,5v2h1v6h10v-6h4v6h2v-6h1zM12,18L6,18v-4h6v4z"/>
|
android:pathData="M12,2C8.13,2 5,5.13 5,9c0,5.25 7,13 7,13s7,-7.75 7,-13c0,-3.87 -3.13,-7 -7,-7zM7,9c0,-2.76 2.24,-5 5,-5s5,2.24 5,5c0,2.88 -2.88,7.19 -5,9.88C9.92,16.21 7,11.85 7,9z"/>
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFF"
|
||||||
|
android:pathData="M12,9m-2.5,0a2.5,2.5 0,1 1,5 0a2.5,2.5 0,1 1,-5 0"/>
|
||||||
</vector>
|
</vector>
|
||||||
|
|
|
@ -4,6 +4,6 @@
|
||||||
android:viewportWidth="24.0"
|
android:viewportWidth="24.0"
|
||||||
android:viewportHeight="24.0">
|
android:viewportHeight="24.0">
|
||||||
<path
|
<path
|
||||||
android:fillColor="#FF000000"
|
android:fillColor="#FFF"
|
||||||
android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98s-0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.12,-0.22 -0.39,-0.3 -0.61,-0.22l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.23,-0.09 -0.49,0 -0.61,0.22l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98s0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.12,0.22 0.39,0.3 0.61,0.22l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.23,0.09 0.49,0 0.61,-0.22l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM12,15.5c-1.93,0 -3.5,-1.57 -3.5,-3.5s1.57,-3.5 3.5,-3.5 3.5,1.57 3.5,3.5 -1.57,3.5 -3.5,3.5z"/>
|
android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98s-0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.12,-0.22 -0.39,-0.3 -0.61,-0.22l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.23,-0.09 -0.49,0 -0.61,0.22l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98s0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.12,0.22 0.39,0.3 0.61,0.22l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.23,0.09 0.49,0 0.61,-0.22l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM12,15.5c-1.93,0 -3.5,-1.57 -3.5,-3.5s1.57,-3.5 3.5,-3.5 3.5,1.57 3.5,3.5 -1.57,3.5 -3.5,3.5z"/>
|
||||||
</vector>
|
</vector>
|
||||||
|
|
9
app/src/main/res/drawable/ic_transactions.xml
Normal file
9
app/src/main/res/drawable/ic_transactions.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFF"
|
||||||
|
android:pathData="M3,13h2v-2L3,11v2zM3,17h2v-2L3,15v2zM3,9h2L5,7L3,7v2zM7,13h14v-2L7,11v2zM7,17h14v-2L7,15v2zM7,7v2h14L21,7L7,7z"/>
|
||||||
|
</vector>
|
|
@ -35,20 +35,6 @@
|
||||||
tools:listitem="@layout/item_balance"
|
tools:listitem="@layout/item_balance"
|
||||||
tools:itemCount="3"/>
|
tools:itemCount="3"/>
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="@dimen/spacing_same_topic"
|
|
||||||
android:text="@string/title_transactions"
|
|
||||||
android:textAppearance="@style/TextAppearance.Bitsy.Subtitle1"/>
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/rvTransactions"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
tools:listitem="@layout/item_transaction"
|
|
||||||
tools:itemCount="6"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
15
app/src/main/res/layout/fragment_transactions.xml
Normal file
15
app/src/main/res/layout/fragment_transactions.xml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/rvTransactions"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
tools:listitem="@layout/item_transaction"
|
||||||
|
tools:itemCount="6"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -2,6 +2,12 @@
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/transactions_dest"
|
||||||
|
android:icon="@drawable/ic_transactions"
|
||||||
|
android:title="@string/title_transactions"
|
||||||
|
app:showAsAction="always"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/merchants_dest"
|
android:id="@+id/merchants_dest"
|
||||||
android:icon="@drawable/ic_merchants"
|
android:icon="@drawable/ic_merchants"
|
||||||
|
@ -9,7 +15,7 @@
|
||||||
app:showAsAction="always"/>
|
app:showAsAction="always"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_settings"
|
android:id="@+id/settings_dest"
|
||||||
android:icon="@drawable/ic_settings"
|
android:icon="@drawable/ic_settings"
|
||||||
android:title="@string/title_settings"
|
android:title="@string/title_settings"
|
||||||
app:showAsAction="ifRoom"/>
|
app:showAsAction="ifRoom"/>
|
||||||
|
|
|
@ -12,7 +12,16 @@
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
tools:layout="@layout/fragment_balances">
|
tools:layout="@layout/fragment_balances">
|
||||||
</fragment>
|
</fragment>
|
||||||
<fragment android:id="@+id/merchants_dest"
|
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/merchants_dest"
|
||||||
android:name="cy.agorise.bitsybitshareswallet.fragments.MerchantsFragment"
|
android:name="cy.agorise.bitsybitshareswallet.fragments.MerchantsFragment"
|
||||||
android:label="fragment_merchants" tools:layout="@layout/fragment_merchants"/>
|
android:label="@string/title_merchants"
|
||||||
|
tools:layout="@layout/fragment_merchants"/>
|
||||||
|
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/transactions_dest"
|
||||||
|
android:name="cy.agorise.bitsybitshareswallet.fragments.TransactionsFragment"
|
||||||
|
android:label="@string/title_transactions"
|
||||||
|
tools:layout="@layout/fragment_transactions"/>
|
||||||
</navigation>
|
</navigation>
|
Loading…
Reference in a new issue