]> git.ktnx.net Git - mobile-ledger.git/commitdiff
getActivity() may return null
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Tue, 4 Dec 2018 21:19:11 +0000 (21:19 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Tue, 4 Dec 2018 21:19:11 +0000 (21:19 +0000)
app/src/main/java/net/ktnx/mobileledger/DatePickerFragment.java

index 164371319e08e542c816d816a8d88ec9975ad150..5dbd2794651f61fee2489fc577016a896f518760 100644 (file)
@@ -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) {