Implemented displaying balance
This commit is contained in:
parent
ca54712cc6
commit
7e930ff1d7
|
@ -5,9 +5,7 @@ import android.os.Bundle
|
||||||
import android.support.v4.app.Fragment
|
import android.support.v4.app.Fragment
|
||||||
import android.support.v7.widget.LinearLayoutManager
|
import android.support.v7.widget.LinearLayoutManager
|
||||||
import android.support.v7.widget.RecyclerView
|
import android.support.v7.widget.RecyclerView
|
||||||
import android.view.LayoutInflater
|
import android.view.*
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import net.dankito.banking.fints4java.android.MainActivity
|
import net.dankito.banking.fints4java.android.MainActivity
|
||||||
import net.dankito.banking.fints4java.android.R
|
import net.dankito.banking.fints4java.android.R
|
||||||
import net.dankito.banking.fints4java.android.ui.MainWindowPresenter
|
import net.dankito.banking.fints4java.android.ui.MainWindowPresenter
|
||||||
|
@ -27,12 +25,20 @@ class HomeFragment : Fragment() {
|
||||||
|
|
||||||
private lateinit var homeViewModel: HomeViewModel
|
private lateinit var homeViewModel: HomeViewModel
|
||||||
|
|
||||||
|
private var mnitmBalance: MenuItem? = null
|
||||||
|
|
||||||
private val transactionAdapter = AccountTransactionAdapter()
|
private val transactionAdapter = AccountTransactionAdapter()
|
||||||
|
|
||||||
|
|
||||||
private lateinit var presenter: MainWindowPresenter
|
private lateinit var presenter: MainWindowPresenter
|
||||||
|
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
setHasOptionsMenu(true)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
container: ViewGroup?,
|
container: ViewGroup?,
|
||||||
|
@ -57,6 +63,13 @@ class HomeFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun onCreateOptionsMenu(menu: Menu?, inflater: MenuInflater?) {
|
||||||
|
super.onCreateOptionsMenu(menu, inflater)
|
||||||
|
|
||||||
|
mnitmBalance = menu?.findItem(R.id.mnitmBalance)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun initLogic() {
|
private fun initLogic() {
|
||||||
|
|
||||||
// TODO: this is such a bad code style
|
// TODO: this is such a bad code style
|
||||||
|
@ -74,6 +87,10 @@ class HomeFragment : Fragment() {
|
||||||
context?.asActivity()?.runOnUiThread {
|
context?.asActivity()?.runOnUiThread {
|
||||||
if (response.isSuccessful) {
|
if (response.isSuccessful) {
|
||||||
transactionAdapter.items = response.bookedTransactions
|
transactionAdapter.items = response.bookedTransactions
|
||||||
|
|
||||||
|
response.balance?.let {
|
||||||
|
mnitmBalance?.title = it.toString()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// TODO: show error
|
// TODO: show error
|
||||||
|
|
|
@ -3,4 +3,9 @@
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
|
||||||
|
<item android:id="@+id/mnitmBalance"
|
||||||
|
android:title=""
|
||||||
|
app:showAsAction="always"
|
||||||
|
/>
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
|
|
Loading…
Reference in New Issue