Roomに関する不具合を修正

This commit is contained in:
it232115 2024-06-20 19:51:17 +09:00
parent 6fc1e6daa5
commit 4dfc928571
5 changed files with 20 additions and 40 deletions

View File

@ -3,7 +3,7 @@ package com.example.oplogy;
import androidx.room.Database; import androidx.room.Database;
import androidx.room.RoomDatabase; import androidx.room.RoomDatabase;
@Database(entities = {SetUpTable.class}, version = 1) @Database(entities = {SetUpTable.class}, version = 2)
public abstract class AppDatabase extends RoomDatabase { public abstract class AppDatabase extends RoomDatabase {
// データベースにアクセスするためのメソッドを提供する // データベースにアクセスするためのメソッドを提供する
public abstract SetUpTableDao setUpTableDao(); public abstract SetUpTableDao setUpTableDao();

View File

@ -70,13 +70,13 @@ public class CreateRoot {
} }
ExecutorService executor = Executors.newSingleThreadExecutor(); ExecutorService executor = Executors.newSingleThreadExecutor();
executor.execute(new Runnable() { executor.execute(() -> {
@Override SetUpTableDao setUpTableDao = db.setUpTableDao();
public void run() { String startTime=setUpTableDao.getStartTime();
SetUpTableDao setUpTableDao = db.setUpTableDao(); String endTime=setUpTableDao.getEndTime();
String startTime=setUpTableDao.getStartTime(); Log.d("CreateRoot", "開始時間" + startTime);
Log.d("CreateRoot", "開始時間" + startTime); Log.d("CreateRoot", "終了時刻" + endTime);
}
}); });
} }
} }

View File

@ -14,7 +14,6 @@ import androidx.appcompat.app.AppCompatActivity;
import com.google.firebase.firestore.FirebaseFirestore; import com.google.firebase.firestore.FirebaseFirestore;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class MainActivity extends AppCompatActivity implements View.OnClickListener { public class MainActivity extends AppCompatActivity implements View.OnClickListener {
@ -92,14 +91,10 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
} }
// ルート作成のクリック処理 // ルート作成のクリック処理
if (view == root) { if (view == root) {
//CreateRootにmyDataListを渡す
imageRoot.setImageResource(R.drawable.pin); imageRoot.setImageResource(R.drawable.pin);
List<MyDataClass> myDataList = firestoreReception.getMyDataList(); List<MyDataClass> myDataList = firestoreReception.getMyDataList();
CreateRoot createRoot = new CreateRoot(MainActivity.this); CreateRoot createRoot = new CreateRoot(MainActivity.this);
createRoot.receiveData(myDataList); createRoot.receiveData(myDataList);
Intent toRoot = new Intent(MainActivity.this, CreateRoot.class);
toRoot.putExtra("myDataList", (ArrayList<MyDataClass>) myDataList);
startActivity(toRoot);
} }
// 提出状況のクリック処理 // 提出状況のクリック処理

View File

@ -19,7 +19,6 @@ import androidx.fragment.app.FragmentActivity;
import androidx.room.Room; import androidx.room.Room;
import java.util.Locale; import java.util.Locale;
import java.util.Set;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
@ -125,7 +124,9 @@ public class SetUpActivity extends FragmentActivity
getApplicationContext(), getApplicationContext(),
AppDatabase.class, AppDatabase.class,
"SetUpTable" "SetUpTable"
).build(); )
.fallbackToDestructiveMigration()
.build();
SetUpTableDao setUpTableDao = db.setUpTableDao(); SetUpTableDao setUpTableDao = db.setUpTableDao();
// Roomの操作を行う // Roomの操作を行う
SetUpTable setUpTable = new SetUpTable( SetUpTable setUpTable = new SetUpTable(

View File

@ -9,22 +9,24 @@ public class SetUpTable {
public int id; public int id;
public String teacherName; public String teacherName;
public String startPoint; public String startPoint;
public String endPoint;
public String startTime; public String startTime;
public String endTime; public String endTime;
public String breakStartTime; public String intervalTime;
public String breakEndTime; public String startBreakTime;
public String endBreakTime;
public int totalStudent; public int totalStudent;
//コンストラクタ //コンストラクタ
public SetUpTable(String teacherName, String startPoint, String endPoint, String startTime, String endTime, String breakStartTime,String breakEndTime, int totalStudent) { public SetUpTable(String teacherName, String startPoint, String startTime, String endTime,
String intervalTime, String startBreakTime, String endBreakTime, int totalStudent) {
this.teacherName = teacherName; this.teacherName = teacherName;
this.startPoint = startPoint; this.startPoint = startPoint;
this.endPoint = endPoint;
this.startTime = startTime; this.startTime = startTime;
this.endTime = endTime; this.endTime = endTime;
this.breakStartTime = breakStartTime; this.intervalTime = intervalTime;
this.breakEndTime = breakEndTime; this.startBreakTime = startBreakTime;
this.endBreakTime = endBreakTime;
this.totalStudent = totalStudent; this.totalStudent = totalStudent;
} }
//getter //getter
@ -37,21 +39,12 @@ public class SetUpTable {
public String getStartPoint() { public String getStartPoint() {
return startPoint; return startPoint;
} }
public String getEndPoint() {
return endPoint;
}
public String getStartTime() { public String getStartTime() {
return startTime; return startTime;
} }
public String getEndTime() { public String getEndTime() {
return endTime; return endTime;
} }
public String getBreakStartTime() {
return breakStartTime;
}
public String getBreakEndTime() {
return breakEndTime;
}
public int getTotalStudent() { public int getTotalStudent() {
return totalStudent; return totalStudent;
} }
@ -65,21 +58,12 @@ public class SetUpTable {
public void setStartPoint(String startPoint) { public void setStartPoint(String startPoint) {
this.startPoint = startPoint; this.startPoint = startPoint;
} }
public void setEndPoint(String endPoint) {
this.endPoint = endPoint;
}
public void setStartTime(String startTime) { public void setStartTime(String startTime) {
this.startTime = startTime; this.startTime = startTime;
} }
public void setEndTime(String endTime) { public void setEndTime(String endTime) {
this.endTime = endTime; this.endTime = endTime;
} }
public void setBreakStartTime(String breakStartTime) {
this.breakStartTime = breakStartTime;
}
public void setBreakEndTime(String breakEndTime) {
this.breakEndTime = breakEndTime;
}
public void setTotalStudent(int totalStudent) { public void setTotalStudent(int totalStudent) {
this.totalStudent = totalStudent; this.totalStudent = totalStudent;
} }