Merge pull request 'murakumo_UUIDを何とかするの会_roomに追加し隊' (#22) from murakumo_UUIDを何とかするの会_roomに追加し隊 into master
Reviewed-on: #22
This commit is contained in:
commit
b29545dc0d
|
@ -27,6 +27,7 @@ public class FirestoreReception {
|
|||
|
||||
//ClassIdを引数にデータの作成を行う
|
||||
public void getDocumentsByClassId(int classId) {
|
||||
myDataList.clear();
|
||||
CollectionReference collectionRef = db.collection("QuestionnaireForms");
|
||||
|
||||
// classIdが引数のものを取得する
|
||||
|
|
|
@ -84,10 +84,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
db = FirebaseFirestore.getInstance();
|
||||
firestoreReception = new FirestoreReception();
|
||||
|
||||
if(classId!=100000){
|
||||
firestoreReception.getDocumentsByClassId(classId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -107,6 +103,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
if(view == setUp){
|
||||
imageSetup.setImageResource(R.drawable.ischecked_uuid);
|
||||
Intent toSetup = new Intent(MainActivity.this,SetUpActivity.class);
|
||||
toSetup.putExtra("classId", classId);
|
||||
startActivity(toSetup);
|
||||
finish(); // 画面遷移後元の状態に戻す
|
||||
}
|
||||
|
@ -177,7 +174,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
|
||||
CountDownLatch latch = new CountDownLatch(2);
|
||||
|
||||
// タスク1: ローカルDBから生徒数を取得
|
||||
// タスク1: ローカルDBから生徒数を取得してtotalStudentと比較
|
||||
executor.execute(() -> {
|
||||
AppDatabase db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "SetUpTable").build();
|
||||
SetUpTableDao setUpTableDao = db.setUpTableDao();
|
||||
|
@ -196,7 +193,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
});
|
||||
});
|
||||
|
||||
// タスク2: Firestoreからデータを取得
|
||||
// タスク2: ルート作成を行う
|
||||
executor.execute(() -> {
|
||||
List<MyDataClass> myDataList = null;
|
||||
while (myDataList == null) {
|
||||
|
@ -341,9 +338,15 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
@Override
|
||||
protected void onResume(){
|
||||
super.onResume();
|
||||
if (classId != 100000) {
|
||||
//roomからclassIdを取得
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
executor.execute(() -> {
|
||||
AppDatabase db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "SetUpTable").build();
|
||||
SetUpTableDao setUpTableDao = db.setUpTableDao();
|
||||
classId = setUpTableDao.getClassId();
|
||||
});
|
||||
if (classId != 100000 ) {
|
||||
firestoreReception.getDocumentsByClassId(classId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -50,6 +50,8 @@ public class SetUpActivity extends FragmentActivity
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
Button startTimeSetButton;
|
||||
Button endTimeSetButton;
|
||||
|
||||
|
@ -61,6 +63,8 @@ public class SetUpActivity extends FragmentActivity
|
|||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_set_up);
|
||||
|
||||
int classId= getIntent().getIntExtra("classId", 100000);
|
||||
|
||||
setTeacherName = findViewById(R.id.teacherName); //先生の名前
|
||||
setStartPoint = findViewById(R.id.startPoint); //開始地点
|
||||
|
||||
|
@ -139,7 +143,8 @@ public class SetUpActivity extends FragmentActivity
|
|||
intervalTime,
|
||||
startBreakTime,
|
||||
endBreakTime,
|
||||
totalStudent
|
||||
totalStudent,
|
||||
classId
|
||||
);
|
||||
|
||||
// 同じ名前のエントリが存在するかどうかを確認
|
||||
|
|
|
@ -16,12 +16,12 @@ public class SetUpTable {
|
|||
public String endBreakTime;
|
||||
public int totalStudent;
|
||||
|
||||
//TODO: ここのコードをあとで実装する。roomにString classIdの作成
|
||||
int classId;
|
||||
|
||||
|
||||
//コンストラクタ
|
||||
public SetUpTable(String teacherName, String startPoint, String startTime, String endTime,
|
||||
String intervalTime, String startBreakTime, String endBreakTime, int totalStudent) {
|
||||
String intervalTime, String startBreakTime, String endBreakTime, int totalStudent,int classId) {
|
||||
this.teacherName = teacherName;
|
||||
this.startPoint = startPoint;
|
||||
this.startTime = startTime;
|
||||
|
@ -30,6 +30,7 @@ public class SetUpTable {
|
|||
this.startBreakTime = startBreakTime;
|
||||
this.endBreakTime = endBreakTime;
|
||||
this.totalStudent = totalStudent;
|
||||
this.classId = classId;
|
||||
}
|
||||
//getter
|
||||
public int getId() {
|
||||
|
|
|
@ -39,4 +39,7 @@ public interface SetUpTableDao {
|
|||
String getStartBreakTime();
|
||||
@Query("SELECT EndBreakTime FROM SetUpTable")
|
||||
String getEndBreakTime();
|
||||
//クラスIDの取得
|
||||
@Query("SELECT classId FROM SetUpTable")
|
||||
int getClassId();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user