From 91418b73fa30f1a2ab8d6316b6f503094c76f8c9 Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Wed, 15 Aug 2018 04:23:54 +0200 Subject: [PATCH] Fix SDK 19 crash --- .../CurrencyData/CurrencyCardview.java | 20 +- .../moodl/DataManagers/DatabaseManager.java | 2 +- .../main/res/layout-v21/cardview_currency.xml | 203 +++++++++++++++++ .../res/layout-v21/cardview_watchlist.xml | 214 ++++++++++++++++++ app/src/main/res/layout/cardview_currency.xml | 4 +- .../main/res/layout/cardview_watchlist.xml | 10 +- 6 files changed, 442 insertions(+), 11 deletions(-) create mode 100644 app/src/main/res/layout-v21/cardview_currency.xml create mode 100644 app/src/main/res/layout-v21/cardview_watchlist.xml diff --git a/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/CurrencyCardview.java b/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/CurrencyCardview.java index 8e9333d..f660b1b 100644 --- a/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/CurrencyCardview.java +++ b/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/CurrencyCardview.java @@ -233,14 +233,22 @@ public class CurrencyCardview extends CardView implements CurrencyInfoUpdateNoti .setText(PlaceholderManager.getPercentageString(numberConformer(currency.getDayFluctuationPercentage()), getContext())); Drawable arrowDrawable = ((ImageView) findViewById(R.id.detailsArrow)).getDrawable(); - arrowDrawable.mutate(); - arrowDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN)); - arrowDrawable.invalidateSelf(); + + if(arrowDrawable != null) + { + arrowDrawable.mutate(); + arrowDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN)); + arrowDrawable.invalidateSelf(); + } Drawable progressDrawable = ((ProgressBar) findViewById(R.id.progressBarLinechartWatchlist)).getIndeterminateDrawable(); - progressDrawable.mutate(); - progressDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN)); - progressDrawable.invalidateSelf(); + + if(progressDrawable != null) + { + progressDrawable.mutate(); + progressDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN)); + progressDrawable.invalidateSelf(); + } } private void updateCardViewInfos(Currency currency, float totalValue, boolean isBalanceHidden) diff --git a/app/src/main/java/com/herbron/moodl/DataManagers/DatabaseManager.java b/app/src/main/java/com/herbron/moodl/DataManagers/DatabaseManager.java index 1c6d791..d08e6dc 100644 --- a/app/src/main/java/com/herbron/moodl/DataManagers/DatabaseManager.java +++ b/app/src/main/java/com/herbron/moodl/DataManagers/DatabaseManager.java @@ -204,7 +204,7 @@ public class DatabaseManager extends SQLiteOpenHelper{ result.moveToFirst(); - return result.getInt(result.getColumnIndex(KEY_WATCHLIST_ID)); + return result.getInt(0); } public void deleteExchangeAccountFromId(int id) diff --git a/app/src/main/res/layout-v21/cardview_currency.xml b/app/src/main/res/layout-v21/cardview_currency.xml new file mode 100644 index 0000000..eba4726 --- /dev/null +++ b/app/src/main/res/layout-v21/cardview_currency.xml @@ -0,0 +1,203 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-v21/cardview_watchlist.xml b/app/src/main/res/layout-v21/cardview_watchlist.xml new file mode 100644 index 0000000..fc35486 --- /dev/null +++ b/app/src/main/res/layout-v21/cardview_watchlist.xml @@ -0,0 +1,214 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/cardview_currency.xml b/app/src/main/res/layout/cardview_currency.xml index eba4726..2192da1 100644 --- a/app/src/main/res/layout/cardview_currency.xml +++ b/app/src/main/res/layout/cardview_currency.xml @@ -1,5 +1,6 @@ diff --git a/app/src/main/res/layout/cardview_watchlist.xml b/app/src/main/res/layout/cardview_watchlist.xml index fc35486..636d54d 100644 --- a/app/src/main/res/layout/cardview_watchlist.xml +++ b/app/src/main/res/layout/cardview_watchlist.xml @@ -1,5 +1,6 @@ @@ -129,7 +131,8 @@ @@ -202,7 +205,8 @@ android:id="@+id/detailsArrow" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:src="@drawable/ic_keyboard_arrow_right_grey_48dp" + app:srcCompat="@drawable/ic_keyboard_arrow_right_grey_48dp" + android:background="@color/transparent" android:layout_gravity="center_vertical|end"/>