+/*
+ * Copyright © 2018 Damyan Ivanov.
+ * This file is part of Mobile-Ledger.
+ * Mobile-Ledger is free software: you can distribute it and/or modify it
+ * under the term of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your opinion), any later version.
+ *
+ * Mobile-Ledger is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License terms for details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mobile-Ledger. If not, see <https://www.gnu.org/licenses/>.
+ */
+
package net.ktnx.mobileledger;
import android.annotation.TargetApi;
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();
}
DatePickerDialog dpd = new DatePickerDialog(Objects.requireNonNull(getActivity()), this, year, month, day);
-
// quicker date selection available in API 26
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
DatePicker dp = dpd.getDatePicker();
@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) {
else {
date.setText(String.format(Locale.US, "%d/%d", month+1, day));
}
+
+ TextView description = Objects.requireNonNull(getActivity())
+ .findViewById(R.id.new_transaction_description);
+ description.requestFocus();
}
@Override
date.setText(String.format(Locale.US, "%d/%d", monthOfYear+1, dayOfMonth));
}
+ TextView description = Objects.requireNonNull(getActivity())
+ .findViewById(R.id.new_transaction_description);
+ description.requestFocus();
+
this.dismiss();
}
}