CreateRoot2 #10

Merged
Utahshi merged 2 commits from CreateRoot2 into master 2024-06-20 10:57:03 +00:00
6 changed files with 29 additions and 40 deletions

View File

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

View File

@ -70,13 +70,13 @@ public class CreateRoot {
}
ExecutorService executor = Executors.newSingleThreadExecutor();
executor.execute(new Runnable() {
@Override
public void run() {
executor.execute(() -> {
SetUpTableDao setUpTableDao = db.setUpTableDao();
String startTime=setUpTableDao.getStartTime();
String endTime=setUpTableDao.getEndTime();
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 java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
@ -92,14 +91,10 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
}
// ルート作成のクリック処理
if (view == root) {
//CreateRootにmyDataListを渡す
imageRoot.setImageResource(R.drawable.pin);
List<MyDataClass> myDataList = firestoreReception.getMyDataList();
CreateRoot createRoot = new CreateRoot(MainActivity.this);
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 java.util.Locale;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -125,7 +124,9 @@ public class SetUpActivity extends FragmentActivity
getApplicationContext(),
AppDatabase.class,
"SetUpTable"
).build();
)
.fallbackToDestructiveMigration()
.build();
SetUpTableDao setUpTableDao = db.setUpTableDao();
// Roomの操作を行う
SetUpTable setUpTable = new SetUpTable(

View File

@ -9,22 +9,24 @@ public class SetUpTable {
public int id;
public String teacherName;
public String startPoint;
public String endPoint;
public String startTime;
public String endTime;
public String breakStartTime;
public String breakEndTime;
public String intervalTime;
public String startBreakTime;
public String endBreakTime;
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.startPoint = startPoint;
this.endPoint = endPoint;
this.startTime = startTime;
this.endTime = endTime;
this.breakStartTime = breakStartTime;
this.breakEndTime = breakEndTime;
this.intervalTime = intervalTime;
this.startBreakTime = startBreakTime;
this.endBreakTime = endBreakTime;
this.totalStudent = totalStudent;
}
//getter
@ -37,21 +39,12 @@ public class SetUpTable {
public String getStartPoint() {
return startPoint;
}
public String getEndPoint() {
return endPoint;
}
public String getStartTime() {
return startTime;
}
public String getEndTime() {
return endTime;
}
public String getBreakStartTime() {
return breakStartTime;
}
public String getBreakEndTime() {
return breakEndTime;
}
public int getTotalStudent() {
return totalStudent;
}
@ -65,21 +58,12 @@ public class SetUpTable {
public void setStartPoint(String startPoint) {
this.startPoint = startPoint;
}
public void setEndPoint(String endPoint) {
this.endPoint = endPoint;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public void setEndTime(String 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) {
this.totalStudent = totalStudent;
}

View File

@ -20,4 +20,13 @@ public interface SetUpTableDao {
String getStartTime();
@Query("SELECT endTime FROM SetUpTable")
String getEndTime();
//インターバル時間の取得
@Query("SELECT intervalTime FROM SetUpTable")
String getIntervalTime();
//休憩開始時間の取得
@Query("SELECT startBreakTime FROM SetUpTable")
String getStartBreakTime();
//休憩終了時間の取得
@Query("SELECT endBreakTime FROM SetUpTable")
String getEndBreakTime();
}