/*
* Copyright © 2019 Damyan Ivanov.
- * This file is part of Mobile-Ledger.
- * Mobile-Ledger is free software: you can distribute it and/or modify it
+ * This file is part of MoLe.
+ * MoLe 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,
+ * MoLe 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/>.
+ * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
*/
package net.ktnx.mobileledger.ui;
return dpd;
}
-
- @TargetApi(Build.VERSION_CODES.O)
- public void onDateSet(DatePicker view, int year, int month, int day) {
+ private void updateDateInput(int year, int month, int day) {
TextView date =
Objects.requireNonNull(getActivity()).findViewById(R.id.new_transaction_date);
.findViewById(R.id.new_transaction_description);
description.requestFocus();
}
+ @TargetApi(Build.VERSION_CODES.O)
+ public void onDateSet(DatePicker view, int year, int month, int day) {
+ updateDateInput(year, month, day);
+ }
@Override
public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
- TextView date =
- Objects.requireNonNull(getActivity()).findViewById(R.id.new_transaction_date);
-
- final Calendar c = GregorianCalendar.getInstance();
- if (c.get(GregorianCalendar.YEAR) == year) {
- if (c.get(GregorianCalendar.MONTH) == monthOfYear) {
- date.setText(String.format(Locale.US, "%d", dayOfMonth));
- }
- else {
- date.setText(String.format(Locale.US, "%d/%d", monthOfYear + 1, dayOfMonth));
- }
- }
- else date.setText(String.format(Locale.US, "%d/%d/%d", year, monthOfYear + 1, dayOfMonth));
-
- TextView description = Objects.requireNonNull(getActivity())
- .findViewById(R.id.new_transaction_description);
- description.requestFocus();
+ updateDateInput(year, monthOfYear, dayOfMonth);
this.dismiss();
}