From a46ad91f791d210999b315ddcdbdb18539965331 Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Wed, 23 May 2018 17:17:33 +0200 Subject: [PATCH] Fix watchlist loading - Watchlist was no longer refreshing - No loading indicator when first loading the fragment --- .../HomeActivityFragments/Watchlist.java | 21 ++++++++++++++++++- .../moodl/Activities/SettingsActivity.java | 16 -------------- .../fragment_watchlist_homeactivity.xml | 2 +- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/nauk/moodl/Activities/HomeActivityFragments/Watchlist.java b/app/src/main/java/com/nauk/moodl/Activities/HomeActivityFragments/Watchlist.java index 0c2cbad..4028081 100644 --- a/app/src/main/java/com/nauk/moodl/Activities/HomeActivityFragments/Watchlist.java +++ b/app/src/main/java/com/nauk/moodl/Activities/HomeActivityFragments/Watchlist.java @@ -74,7 +74,7 @@ public class Watchlist extends Fragment { defaultCurrency = preferencesManager.getDefaultCurrency(); currencyTickerList = new CurrencyTickerList(getActivity()); tickerUpdated = false; - checkUpdatedData(); + updateTickerList(); editModeEnabled = false; @@ -98,6 +98,25 @@ public class Watchlist extends Fragment { return view; } + private void updateTickerList() + { + AsyncTask updater = new AsyncTask() { + @Override + protected Void doInBackground(Void... voids) { + currencyTickerList.update(new BalanceManager.IconCallBack() { + @Override + public void onSuccess() { + tickerUpdated = true; + checkUpdatedData(); + } + }); + return null; + } + }; + + updater.execute(); + } + private void setupEditButton() { ImageButton editButton = view.findViewById(R.id.edit_button); diff --git a/app/src/main/java/com/nauk/moodl/Activities/SettingsActivity.java b/app/src/main/java/com/nauk/moodl/Activities/SettingsActivity.java index 1369336..5e7738e 100644 --- a/app/src/main/java/com/nauk/moodl/Activities/SettingsActivity.java +++ b/app/src/main/java/com/nauk/moodl/Activities/SettingsActivity.java @@ -216,22 +216,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity { addPreferencesFromResource(R.xml.pref_general); setHasOptionsMenu(true); - /*findPreference("hide_balance").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { - @Override - public boolean onPreferenceClick(Preference preference) { - boolean isChecked = ((SwitchPreference) findPreference("hide_balance")).isChecked(); - - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext()); - - SharedPreferences.Editor editor = preferences.edit(); - - editor.putBoolean("hide_balance", isChecked); - editor.apply(); - - return isChecked; - } - });*/ - findPreference("version").setSummary(BuildConfig.VERSION_NAME); bindPreferenceSummaryToValue(findPreference("default_currency")); diff --git a/app/src/main/res/layout/fragment_watchlist_homeactivity.xml b/app/src/main/res/layout/fragment_watchlist_homeactivity.xml index 7f70043..5dce68e 100644 --- a/app/src/main/res/layout/fragment_watchlist_homeactivity.xml +++ b/app/src/main/res/layout/fragment_watchlist_homeactivity.xml @@ -91,7 +91,7 @@ style="?android:attr/progressBarStyleLarge" android:layout_gravity="center" android:background="@drawable/circular_progress_bar" - android:visibility="gone"/> + android:visibility="visible"/>