Skip to content

Commit ecf7be1

Browse files
committed
Reminders: fix null adapter issue
1 parent 7b0947f commit ecf7be1

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

app/src/main/java/com/eveningoutpost/dexdrip/Reminders.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,10 @@ private synchronized void reinject(Reminder reminder) {
796796
// TODO lock?
797797
Log.d(TAG, "child Reinjection position: " + i);
798798
reminders.add(i, reminder);
799+
if (mAdapter == null) {
800+
Log.d(TAG, "Returning from reinject as no UI adapter");
801+
return;
802+
}
799803
mAdapter.notifyItemInserted(i);
800804
final AtomicBoolean corrected = new AtomicBoolean();
801805

@@ -810,12 +814,9 @@ public void onScrollStateChanged(RecyclerView rv, int state) {
810814
if (highlighted < 2) {
811815
Log.d(TAG, "Reinjection: scrolling to: " + i);
812816
recyclerView.smoothScrollToPosition(i);
813-
JoH.runOnUiThreadDelayed(new Runnable() {
814-
@Override
815-
public void run() {
816-
// failsafe
817-
correctiveScrolling(i, corrected);
818-
}
817+
JoH.runOnUiThreadDelayed(() -> {
818+
// failsafe
819+
correctiveScrolling(i, corrected);
819820
}, 1000);
820821
} else {
821822
Log.d(TAG, "Not scrolling due to highlighted: " + highlighted);

0 commit comments

Comments
 (0)