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