From 9d4673ab17e8b7a319f6271bb0717261a9bb3eac Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Tue, 4 Dec 2018 21:19:11 +0000 Subject: [PATCH] getActivity() may return null --- .../main/java/net/ktnx/mobileledger/DatePickerFragment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/DatePickerFragment.java b/app/src/main/java/net/ktnx/mobileledger/DatePickerFragment.java index 16437131..5dbd2794 100644 --- a/app/src/main/java/net/ktnx/mobileledger/DatePickerFragment.java +++ b/app/src/main/java/net/ktnx/mobileledger/DatePickerFragment.java @@ -27,7 +27,7 @@ implements DatePickerDialog.OnDateSetListener, DatePicker.OnDateChangedListener int year = c.get(GregorianCalendar.YEAR); int month = c.get(GregorianCalendar.MONTH); int day = c.get(GregorianCalendar.DAY_OF_MONTH); - TextView date = getActivity().findViewById(R.id.new_transaction_date); + TextView date = Objects.requireNonNull(getActivity()).findViewById(R.id.new_transaction_date); CharSequence present = date.getText(); @@ -59,7 +59,7 @@ implements DatePickerDialog.OnDateSetListener, DatePicker.OnDateChangedListener @TargetApi(Build.VERSION_CODES.O) public void onDateSet(DatePicker view, int year, int month, int day) { - TextView date = getActivity().findViewById(R.id.new_transaction_date); + TextView date = Objects.requireNonNull(getActivity()).findViewById(R.id.new_transaction_date); final Calendar c = GregorianCalendar.getInstance(); if ( c.get(GregorianCalendar.YEAR) == year && c.get(GregorianCalendar.MONTH) == month) { -- 2.39.5