作業中なう

This commit is contained in:
nemukemo 2024-07-09 09:13:41 +09:00
parent 69cbdf41f0
commit 1e2fcec90b
2 changed files with 75 additions and 32 deletions

View File

@ -2,10 +2,11 @@ package com.example.oplogy;
import static android.content.ContentValues.TAG;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.TimePickerDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Paint;
@ -44,6 +45,16 @@ public class SetUpActivity extends FragmentActivity
String startBreakTime;
String endBreakTime;
int totalStudent;
String stringYear;
String stringMonth;
String stringDayOfMonth;
String stringHourOfDay;
String stringMinute;
Button buttonFirstDay;
Button buttonSecondDay;
Button buttonThirdDay;
Button buttonStartTimeButton;
Button buttonEndTimeButton;
private TextView textViewTeacherName;
private TextView textViewStartPoint;
private TextView textViewStartTime;
@ -54,22 +65,6 @@ public class SetUpActivity extends FragmentActivity
private int intIsDateSelected;
private int intIsStartTimeSelected;
String stringYear;
String stringMonth;
String stringDayOfMonth;
String stringHourOfDay;
String stringMinute;
Button buttonFirstDay;
Button buttonSecondDay;
Button buttonThirdDay;
Button buttonStartTimeButton;
Button buttonEndTimeButton;
@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -110,6 +105,9 @@ public class SetUpActivity extends FragmentActivity
startActivity(intent);
});
//SetUpTableに情報があった場合それをeditTextに表示するメソッド
showLoadDataYesNoDialog();
setUp.setOnClickListener(view -> {
teacherName = textViewTeacherName.getText().toString(); //各変数に値を挿入
@ -350,4 +348,48 @@ public class SetUpActivity extends FragmentActivity
newFragment.show(getSupportFragmentManager(), "timePicker");
}
private void showLoadDataYesNoDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("データの読み込み");
builder.setMessage("SetUpテーブルからデータを読み込みますか");
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
loadSetupData();
dialog.dismiss();
}
});
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
private void loadSetupData() {
ExecutorService executor = Executors.newSingleThreadExecutor();
executor.execute(() -> {
AppDatabase db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "SetUpTable").build();
SetUpTableDao setUpTableDao = db.setUpTableDao();
String teacherName = setUpTableDao.getTeacherName();
String startPoint = setUpTableDao.getStartPoint();
int totalStudent = setUpTableDao.getTotalStudent();
runOnUiThread(() -> {
textViewTeacherName.setText(teacherName);
textViewStartPoint.setText(startPoint);
textViewTotalStudent.setText(String.valueOf(totalStudent));
});
});
}
}
//TODO: 教師名開始地点生徒総数を取得し表示する

View File

@ -41,6 +41,7 @@ public interface SetUpTableDao {
//教師名の取得
@Query("SELECT teacherName FROM SetUpTable")
String getTeacherName();
@Query("SELECT intervalTime FROM SetUpTable")
String getIntervalTime();