Skip to content
This repository was archived by the owner on Jun 27, 2020. It is now read-only.

Commit 1be0887

Browse files
author
Evgenii Kanivets
committed
Fix bug with wrong exchange rate was deleted.
1 parent b07bbdc commit 1be0887

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app/src/main/java/com/blogspot/e_kanivets/moneytracker/fragment/ExchangeRatesFragment.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class ExchangeRatesFragment extends Fragment {
4141
ListView listView;
4242

4343
private ExchangeRateController rateController;
44+
private List<ExchangeRate> exchangeRateList;
4445

4546
public static ExchangeRatesFragment newInstance() {
4647
ExchangeRatesFragment fragment = new ExchangeRatesFragment();
@@ -95,7 +96,7 @@ public boolean onContextItemSelected(MenuItem item) {
9596

9697
switch (item.getItemId()) {
9798
case R.id.delete:
98-
rateController.delete(rateController.readAll().get(info.position));
99+
rateController.delete(exchangeRateList.get(info.position));
99100
update();
100101
return true;
101102
default:
@@ -120,7 +121,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
120121
}
121122

122123
private void update() {
123-
List<ExchangeRate> exchangeRateList = rateController.readAll();
124+
exchangeRateList = rateController.readAll();
124125
Collections.reverse(exchangeRateList);
125126

126127
listView.setAdapter(new ExchangeRateAdapter(getActivity(), exchangeRateList));

0 commit comments

Comments
 (0)