This commit is contained in:
nemukemo 2024-06-12 20:25:16 +09:00
parent 87e610d4f4
commit aa189688d3
6 changed files with 129 additions and 36 deletions

View File

@ -45,4 +45,15 @@ dependencies {
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
} }
//room用の依存関係を追加
dependencies {
def room_version = "2.4.1"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
}
dependencies {
implementation 'com.google.code.gson:gson:2.8.8'
}

View File

@ -36,26 +36,8 @@ public class FirestoreReception {
Map<String, Object> data = document.getData(); Map<String, Object> data = document.getData();
// デバッグ用のログ出力 // デバッグ用のログ出力
Log.d("FirestoreReception", "Document ID: " + document.getId()); // Log.d("FirestoreReception", "Document ID: " + document.getId());
Log.d("FirestoreReception", "Data: " + data); Log.d("FirestoreReception", "Data: " + data);
// ここでデータを取得し必要に応じて処理を行います
// String parentName = (String) data.get("patronName");
// String childName = (String) data.get("childName");
// String studentId = (String) data.get("studentNumber");
//// Timestamp address = (Timestamp) data.get("address");
// List<Timestamp> firstDay = (List<Timestamp>) data.get("firstDay");
// List<Timestamp> secondDay = (List<Timestamp>) data.get("secondDay");
// List<Timestamp> thirdDay = (List<Timestamp>) data.get("thirdDay");
//
// // 取得したデータを使って必要な処理を行う
// Log.d("FirestoreReception", "ParentName: " + parentName);
// Log.d("FirestoreReception", "ChildName: " + childName);
// Log.d("FirestoreReception", "StudentNumber: " + studentId);
//// Log.d("FirestoreReception", "Address: " + address.toDate());
// Log.d("FirestoreReception", "First Day: " + firstDay);
// Log.d("FirestoreReception", "Second Day: " + secondDay);
// Log.d("FirestoreReception", "Third Day: " + thirdDay);
} }
} else { } else {
Log.w("FirestoreReception", "Error getting documents.", task.getException()); Log.w("FirestoreReception", "Error getting documents.", task.getException());

View File

@ -0,0 +1,26 @@
package com.example.oplogy;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.PrimaryKey;
import androidx.room.TypeConverters;
import java.util.Map;
@Entity(
foreignKeys = @ForeignKey(entity = SetupTable.class,//外部キーとしてSetupTableクラスを指定
parentColumns = "id",//親クラスのidと結びつけ
childColumns = "data",//子クラスのprofileIdと結びつけ
onDelete = ForeignKey.CASCADE//親クラスが削除されたら子クラスも削除
)
)
public class FormTable {
@PrimaryKey(autoGenerate = true)
public int id;
@ColumnInfo(name = "data")
public Map<String, Object> data;
// Getters and setters if needed
}

View File

@ -63,10 +63,10 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
submission = findViewById(R.id.submission); submission = findViewById(R.id.submission);
submission.setOnClickListener(this); submission.setOnClickListener(this);
// firestoreの受信関連 // firestoreの受信関連の宣言
db = FirebaseFirestore.getInstance(); db = FirebaseFirestore.getInstance();
firestoreReception = new FirestoreReception(); firestoreReception = new FirestoreReception();
// 受信するメソッドの呼び出し
firestoreReception.getDocumentsByClassId(100); firestoreReception.getDocumentsByClassId(100);

View File

@ -1,14 +0,0 @@
package com.example.oplogy;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class SetUpActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_set_up);
}
}

View File

@ -0,0 +1,88 @@
package com.example.oplogy;
import androidx.room.ColumnInfo;
import androidx.room.Embedded;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;
import androidx.room.Relation;
import java.util.Date;
import java.util.List;
@Entity(tableName = "teacher_table")
public class SetupTable {
//フィールド
@PrimaryKey()
public int classId;
@ColumnInfo(name = "teacher_name")
public String teacherName;
@ColumnInfo(name = "startpoint")
public String startpoint;
@ColumnInfo(name = "subject")
public String startTime;
@ColumnInfo(name = "end_time")
public String endTime;
@ColumnInfo(name = "break_time")
public String breakTime;
@ColumnInfo(name = "total_students")
public int totalStudents;
//コンストラクタ
public SetupTable(int classId,String startpoint , String teacherName, String startTime, String endTime, String breakTime, int totalStudents) {
this.classId = classId;
this.startpoint = startpoint;
this.teacherName = teacherName;
this.startTime = startTime;
this.endTime = endTime;
this.breakTime = breakTime;
this.totalStudents = totalStudents;
}
//ゲッター
public int getClassId() {
return classId;
}
public String getTeacherName() {
return teacherName;
}
public String getStartTime() {
return startTime;
}
public String getEndTime() {
return endTime;
}
public String getBreakTime() {
return breakTime;
}
public int getTotalStudents() {
return totalStudents;
}
public String getStartpoint() {
return startpoint;
}
//セッター
public void setClassId(int classId) {
this.classId = classId;
}
public void setTeacherName(String teacherName) {
this.teacherName = teacherName;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public void setBreakTime(String breakTime) {
this.breakTime = breakTime;
}
public void setTotalStudents(int totalStudents) {
this.totalStudents = totalStudents;
}
public void setStartpoint(String startpoint) {
this.startpoint = startpoint;
}
}