Skip to content

Commit

Permalink
Update paid invoices and payment list
Browse files Browse the repository at this point in the history
  • Loading branch information
lvaccaro committed Mar 26, 2020
1 parent 74c818a commit 3b79e4e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 23 deletions.
19 changes: 11 additions & 8 deletions app/src/main/java/com/lvaccaro/lamp/HistoryFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,21 @@ class ListAdapter(val list: ArrayList<Item>)
}
class ItemViewHolder(inflater: LayoutInflater, parent: ViewGroup) :
RecyclerView.ViewHolder(inflater.inflate(R.layout.list_tx, parent, false)) {
private var mTitleView: TextView? = null
private var mDescriptionView: TextView? = null
private var mDateView: TextView? = null
private var mAmountView: TextView? = null
private var mLabelView: TextView? = null

init {
mTitleView = itemView.findViewById(R.id.text1)
mDescriptionView = itemView.findViewById(R.id.text2)
mDateView = itemView.findViewById(R.id.date)
mAmountView = itemView.findViewById(R.id.amount)
mLabelView = itemView.findViewById(R.id.label)
}

fun bind(item: Item) {
val date = Date(item.time * 1000L)
mDescriptionView?.text = String.format("%s %dmsat", if (item.incoming) "+" else "-", item.amount)
mTitleView?.text = SimpleDateFormat("dd MMM yyyy, HH:mm:ss").format(date)
mAmountView?.text = String.format("%s %dmsat", if (item.incoming) "+" else "-", item.amount)
mDateView?.text = SimpleDateFormat("dd MMM yyyy, HH:mm:ss").format(date)
mLabelView?.text = item.label
}
}

Expand Down Expand Up @@ -102,8 +105,8 @@ class HistoryFragment: BottomSheetDialogFragment() {
if (status.equals("complete")) {
val createdAt = payment["created_at"] as Int
val msatoshi = payment["msatoshi"] as Int
val id = payment["id"] as String
payments.add(Item(msatoshi, createdAt, id, false))
val id = payment["id"] as Int
payments.add(Item(msatoshi, createdAt, "Payment ID ${id.toString()}", false))
}
}
return payments
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_history.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/id_transactions"
android:text="@string/id_history"
android:textStyle="bold"
android:padding="8dp" />

Expand Down
40 changes: 26 additions & 14 deletions app/src/main/res/layout/list_tx.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<TwoLineListItem xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/listPreferredItemHeight"
android:mode="twoLine"
android:paddingStart="?attr/listPreferredItemPaddingStart"
android:paddingEnd="?attr/listPreferredItemPaddingEnd">
android:paddingEnd="?attr/listPreferredItemPaddingEnd"
android:orientation="vertical">

<TextView android:id="@+id/text1"
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:textAppearance="?attr/textAppearanceListItemSecondary"/>
android:orientation="horizontal">

<TextView android:id="@+id/date"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="8dp"
android:textAppearance="?attr/textAppearanceListItemSecondary"/>

<TextView
android:id="@+id/amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:textAppearance="?attr/textAppearanceListItem" />

</LinearLayout>

<TextView
android:id="@+id/text2"
android:layout_width="wrap_content"
android:id="@+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignEnd="@id/text1"
android:layout_alignParentEnd="true"
android:layout_marginTop="8dp"
android:textAppearance="?attr/textAppearanceListItem" />
android:layout_marginTop="4dp" />

</TwoLineListItem>
</LinearLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@
<string name="id_using_esplora_plugin">Using Esplora plugin as bitcoind backend</string>
<string name="action_settings">Settings</string>
<string name="id_channels">Channels</string>
<string name="id_history">History</string>
</resources>

0 comments on commit 3b79e4e

Please sign in to comment.