From caa64fda6f40bb288977890141f9f4468428c904 Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Wed, 21 Nov 2018 14:28:54 +0100 Subject: [PATCH] Fix crash when looking for details on an iconless asset --- .idea/caches/build_file_checksums.ser | Bin 545 -> 540 bytes .../Activities/CurrencyDetailsActivity.java | 29 ++++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index e9a918a6b5c6061ecb3b0c399f93b8b539ba6e56..559c7c9af64e76725c7d32f4475cd8938586301b 100644 GIT binary patch delta 75 zcmV-R0JQ(11e^qrm;^R%imZ{GwGt~sI$TwAWpZ;|M|Ej*Z*^{ElfD5qlTiUg8PyUh hQsgO{MjOF-z)RJ-5p)0%XL4a=Y-N*x0Tq)F0ufR78}I-C delta 81 zcmV-X0IvU>1fc|wm;^1ScHWVkwUe0vL^7xp5}ld>Xcf?C5YOMJAn0@eFhe?ARdZ!> nb6i1WZE0?4b98cHbZ>H8E@yIKWNc+zlkfo>lZOEklkWj7Pq-ju diff --git a/app/src/main/java/com/herbron/moodl/Activities/CurrencyDetailsActivity.java b/app/src/main/java/com/herbron/moodl/Activities/CurrencyDetailsActivity.java index 841b24b..e23df12 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/CurrencyDetailsActivity.java +++ b/app/src/main/java/com/herbron/moodl/Activities/CurrencyDetailsActivity.java @@ -135,22 +135,25 @@ public class CurrencyDetailsActivity extends AppCompatActivity { Objects.requireNonNull(getSupportActionBar()).setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_USE_LOGO); - Bitmap result = Bitmap.createBitmap(150, 150, currency.getIcon().getConfig()); + if(currency.getIcon() != null) + { + Bitmap result = Bitmap.createBitmap(150, 150, currency.getIcon().getConfig()); - Paint paint = new Paint(); - paint.setStyle(Paint.Style.FILL); - paint.setColor(ContextCompat.getColor(this, R.color.white)); + Paint paint = new Paint(); + paint.setStyle(Paint.Style.FILL); + paint.setColor(ContextCompat.getColor(this, R.color.white)); - Canvas canvas = new Canvas(result); - canvas.drawCircle(result.getHeight()/2, result.getWidth()/2, 75, paint); - canvas.drawBitmap(Bitmap.createScaledBitmap(currency.getIcon(), 100, 100, false), result.getHeight()/2 - 50, result.getWidth()/2 - 50, null); + Canvas canvas = new Canvas(result); + canvas.drawCircle(result.getHeight()/2, result.getWidth()/2, 75, paint); + canvas.drawBitmap(Bitmap.createScaledBitmap(currency.getIcon(), 100, 100, false), result.getHeight()/2 - 50, result.getWidth()/2 - 50, null); - getSupportActionBar() - .setIcon(new BitmapDrawable(getResources(), - Bitmap.createScaledBitmap(result - , (int) MoodlBox.convertDpToPx(25, getResources()) - , (int) MoodlBox.convertDpToPx(25, getResources()) - , false))); + getSupportActionBar() + .setIcon(new BitmapDrawable(getResources(), + Bitmap.createScaledBitmap(result + , (int) MoodlBox.convertDpToPx(25, getResources()) + , (int) MoodlBox.convertDpToPx(25, getResources()) + , false))); + } } } /*for(int i = 0; i < dataChartList.size(); i++)