From 462053e409aaa05b7f2d041dac88691ea92fa13c Mon Sep 17 00:00:00 2001 From: Forrest Guice Date: Sat, 12 Feb 2022 21:20:13 -0700 Subject: [PATCH] nullcheck prevent NPE (#556) --- .../forrestguice/suntimeswidget/SuntimesActivity.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/forrestguice/suntimeswidget/SuntimesActivity.java b/app/src/main/java/com/forrestguice/suntimeswidget/SuntimesActivity.java index c8fc93aa7..b93784d57 100644 --- a/app/src/main/java/com/forrestguice/suntimeswidget/SuntimesActivity.java +++ b/app/src/main/java/com/forrestguice/suntimeswidget/SuntimesActivity.java @@ -1941,15 +1941,14 @@ public boolean onMoonHeaderLongClick(CardAdapter adapter, int position) { @Override public void onLightmapClick(CardAdapter adapter, int position) { - if (Math.abs(CardAdapter.TODAY_POSITION - position) > 1) { - showSunPositionAt(adapter.initData(SuntimesActivity.this, position).first.dataNoon.calendar().getTimeInMillis()); + Pair cardData = adapter.initData(SuntimesActivity.this, position); + if (Math.abs(CardAdapter.TODAY_POSITION - position) > 1 && cardData != null) { + showSunPositionAt(cardData.first.dataNoon.calendar().getTimeInMillis()); } else showLightMapDialog(); } @Override public boolean onLightmapLongClick(CardAdapter adapter, int position) { - if (Math.abs(CardAdapter.TODAY_POSITION - position) > 1) { - showSunPositionAt(adapter.initData(SuntimesActivity.this, position).first.dataNoon.calendar().getTimeInMillis()); - } else showLightMapDialog(); + onLightmapClick(adapter, position); return true; }