From 34ff605de243a96d90e2f3ea71b96617083e9097 Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Wed, 1 Aug 2018 16:03:43 +0200 Subject: [PATCH] Fix exchange list not updating correctly --- .../herbron/moodl/Activities/ExchangeListActivity.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/herbron/moodl/Activities/ExchangeListActivity.java b/app/src/main/java/com/herbron/moodl/Activities/ExchangeListActivity.java index df06da0..ad0955f 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/ExchangeListActivity.java +++ b/app/src/main/java/com/herbron/moodl/Activities/ExchangeListActivity.java @@ -6,6 +6,7 @@ import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; +import android.util.Log; import android.view.MenuItem; import android.view.View; import android.widget.ListView; @@ -38,11 +39,7 @@ public class ExchangeListActivity extends AppCompatActivity { getSupportActionBar().setDisplayShowHomeEnabled(true); databaseManager = new DatabaseManager(this); - - exchangeListAdapter = new ExchangeListAdapter(getApplicationContext(), databaseManager.getExchanges()); - exchangeListView = findViewById(R.id.exchange_listView); - exchangeListView.setAdapter(exchangeListAdapter); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @@ -58,8 +55,9 @@ public class ExchangeListActivity extends AppCompatActivity { protected void onResume() { super.onResume(); - exchangeListAdapter.clear(); - exchangeListAdapter.addAll(databaseManager.getExchanges()); + exchangeListAdapter = new ExchangeListAdapter(getApplicationContext(), databaseManager.getExchanges()); + + exchangeListView.setAdapter(exchangeListAdapter); exchangeListAdapter.notifyDataSetChanged(); }