diff --git a/app/src/main/java/com/example/citrusclient/views/CreateScheduleFragment.java b/app/src/main/java/com/example/citrusclient/views/CreateScheduleFragment.java index 76aeb32..ddb359c 100644 --- a/app/src/main/java/com/example/citrusclient/views/CreateScheduleFragment.java +++ b/app/src/main/java/com/example/citrusclient/views/CreateScheduleFragment.java @@ -14,6 +14,7 @@ import androidx.lifecycle.Observer; import androidx.lifecycle.ViewModelProvider; +import android.text.Editable; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -31,6 +32,7 @@ import com.example.citrusclient.models.Book; import com.example.citrusclient.viewmodels.BooksViewModel; import com.example.citrusclient.viewmodels.ScheduleViewModel; +import com.google.android.material.snackbar.Snackbar; import java.util.ArrayList; import java.util.Calendar; @@ -233,7 +235,16 @@ int year = Integer.parseInt(dates[0]); int month = Integer.parseInt(dates[1]); int day = Integer.parseInt(dates[2]); + Editable tmp = scheduleTitle.getText(); + if(tmp == null){ + Snackbar.make(view, "タイトルを入力してください", Snackbar.LENGTH_SHORT).show(); + return; + } String title = scheduleTitle.getText().toString(); + if(title == null || title.isEmpty()){ + Snackbar.make(view, "タイトルを入力してください", Snackbar.LENGTH_SHORT).show(); + return; + } String startDateTime = startDateButton.getText() + " " + startTimeButton.getText(); String endDateTime = endDateButton.getText() + " " + endTimeButton.getText(); scheduleViewModel.createSchedule(accountId, year, month, day, token, title, startDateTime, endDateTime, spinner.getSelectedItemPosition());