From: Damyan Ivanov Date: Tue, 4 Dec 2018 21:19:11 +0000 (+0000) Subject: getActivity() may return null X-Git-Tag: v0.3~342 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=9d4673ab17e8b7a319f6271bb0717261a9bb3eac;p=mobile-ledger.git getActivity() may return null --- 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) {