SpreadSheet #3
|
@ -7,6 +7,7 @@
|
|||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="jbr-17" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
|
|
@ -37,9 +37,6 @@
|
|||
android:name=".Maps"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_maps" />
|
||||
<activity
|
||||
android:name=".Map_Activity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".TutorialActivity"
|
||||
android:exported="false" />
|
||||
|
|
|
@ -3,9 +3,8 @@ import androidx.room.Database;
|
|||
import androidx.room.RoomDatabase;
|
||||
import androidx.room.TypeConverters;
|
||||
|
||||
@Database(entities = {QuestionnaireForm.class}, version = 1)
|
||||
@TypeConverters({Converters.class})
|
||||
@Database(entities = {SetUpTable.class}, version = 1)
|
||||
public abstract class AppDatabase extends RoomDatabase {
|
||||
// データベースにアクセスするためのメソッドを提供する
|
||||
public abstract QuestionnaireFormDao questionnaireFormDao();
|
||||
public abstract SetUpTableDao setUpTableDao();
|
||||
}
|
|
@ -1,5 +1,29 @@
|
|||
package com.example.oplogy;
|
||||
|
||||
public class CreateRoot {
|
||||
import android.util.Log;
|
||||
|
||||
}
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.google.firebase.Timestamp;
|
||||
|
||||
public class CreateRoot {
|
||||
private String address;
|
||||
private Timestamp startTimestamp;
|
||||
private Timestamp endTimestamp;
|
||||
private long studentNumber;
|
||||
private LatLng latLng;
|
||||
|
||||
public void receiveData(String address, Timestamp startTimestamp, Timestamp endTimestamp, long studentNumber, LatLng latLng) {
|
||||
this.address = address;
|
||||
this.startTimestamp = startTimestamp;
|
||||
this.endTimestamp = endTimestamp;
|
||||
this.studentNumber = studentNumber;
|
||||
this.latLng = latLng;
|
||||
|
||||
// 受け取ったデータを利用してログを出力
|
||||
Log.d("CreateRoot", "address: " + address);
|
||||
Log.d("CreateRoot", "startTimestamp: " + startTimestamp);
|
||||
Log.d("CreateRoot", "endTimestamp: " + endTimestamp);
|
||||
Log.d("CreateRoot", "studentNumber: " + studentNumber);
|
||||
Log.d("CreateRoot", "latLng: " + latLng);
|
||||
}
|
||||
}
|
|
@ -4,11 +4,15 @@ import android.util.Log;
|
|||
|
||||
import com.google.android.gms.tasks.OnCompleteListener;
|
||||
import com.google.android.gms.tasks.Task;
|
||||
import com.google.firebase.Timestamp;
|
||||
import com.google.firebase.firestore.CollectionReference;
|
||||
import com.google.firebase.firestore.FirebaseFirestore;
|
||||
import com.google.firebase.firestore.QueryDocumentSnapshot;
|
||||
import com.google.firebase.firestore.QuerySnapshot;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class FirestoreReception {
|
||||
|
@ -19,6 +23,9 @@ public class FirestoreReception {
|
|||
db = FirebaseFirestore.getInstance();
|
||||
}
|
||||
|
||||
//firestoreから受け取ったデータを束ねるためのマップ
|
||||
public List<MyDataClass>myDataList = new ArrayList<>();
|
||||
|
||||
//ClassIdを引数にデータの作成を行う
|
||||
public void getDocumentsByClassId(int classId, MainActivity context) {
|
||||
CollectionReference collectionRef = db.collection("QuestionnaireForms");
|
||||
|
@ -33,14 +40,33 @@ public class FirestoreReception {
|
|||
for (QueryDocumentSnapshot document : task.getResult()) {
|
||||
Map<String, Object> data = document.getData();
|
||||
|
||||
// CreateRootクラスのインスタンスを作成し、dataを引数として渡す
|
||||
GeoCoder geoCoder = new GeoCoder();
|
||||
geoCoder.processData(data, context);
|
||||
//CreateRootクラスのインスタンスを生成、dataを渡す
|
||||
// GeoCoder geoCoder = new GeoCoder();
|
||||
// geoCoder.processData(data, context);
|
||||
|
||||
// ドキュメントのデータをMyDataClassのインスタンスにマッピング
|
||||
MyDataClass myData = new MyDataClass(
|
||||
(String) data.get("patronName"),
|
||||
((Long) data.get("classId")).intValue(),
|
||||
(List<String>) data.get("address"),
|
||||
(List<Timestamp>) data.get("firstDay"),
|
||||
((Long) data.get("studentNumber")).intValue(),
|
||||
(String) data.get("childName"),
|
||||
(List<Timestamp>) data.get("thirdDay"),
|
||||
(List<Timestamp>) data.get("secondDay")
|
||||
);
|
||||
//リストに追加
|
||||
myDataList.add(myData);
|
||||
}
|
||||
//取得したデータをログ表示
|
||||
for(MyDataClass data :myDataList){
|
||||
Log.i("FirestoreReceptiond", "data: " + data.toString());
|
||||
}
|
||||
} else {
|
||||
Log.w("FirestoreReception", "Error getting documents.", task.getException());
|
||||
Log.w("FirestoreReceptiond", "Error getting documents.", task.getException());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,13 +29,18 @@ public class GeoCoder {
|
|||
// 住所を緯度経度に変換
|
||||
LatLng latLng = geocodeAddress(address.get(0));
|
||||
|
||||
//デバッグ用ログ
|
||||
Log.d("FirestoreReception", "address: " + address.get(0));
|
||||
Log.d("FirestoreReception", "firstDay: " + firstDay.get(0));
|
||||
Log.d("FirestoreReception", "firstDay: " + firstDay.get(1));
|
||||
Log.d("FirestoreReception", "studentNumber: " + studentNumber);
|
||||
Log.d("FirestoreReception", "latLng: "+latLng );
|
||||
|
||||
// CreateRootクラスのインスタンスを作成
|
||||
CreateRoot createRoot = new CreateRoot();
|
||||
// データを渡す
|
||||
createRoot.receiveData(address.get(0), firstDay.get(0), firstDay.get(1), studentNumber, latLng);
|
||||
|
||||
// 緯度経度をLogに出力
|
||||
Log.d("緯度経度", "latLng: "+latLng );
|
||||
} catch (NullPointerException e) {
|
||||
Log.e("NullPointerException", "getの中身がnull" + e);
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
// ルート作成のクリック処理
|
||||
if(view == root){
|
||||
imageRoot.setImageResource(R.drawable.pin);
|
||||
Intent toRoot = new Intent(MainActivity.this, Map_Activity.class);
|
||||
Intent toRoot = new Intent(MainActivity.this,Maps.class);
|
||||
startActivity(toRoot);
|
||||
}
|
||||
// 提出状況のクリック処理
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
package com.example.oplogy;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.android.gms.maps.GoogleMap;
|
||||
import com.google.android.gms.maps.MapFragment;
|
||||
import com.google.android.gms.maps.OnMapReadyCallback;
|
||||
import com.google.android.gms.maps.SupportMapFragment;
|
||||
|
||||
public class Map_Activity extends AppCompatActivity implements View.OnClickListener, OnMapReadyCallback {
|
||||
ImageView toMain;
|
||||
private GoogleMap mMap;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.map_activity);
|
||||
|
||||
|
||||
// ボタンの戻る処理
|
||||
toMain = findViewById(R.id.toMain);
|
||||
toMain.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if(view == toMain){
|
||||
Intent toMain = new Intent(Map_Activity.this,MainActivity.class);
|
||||
startActivity(toMain);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onMapReady(@NonNull GoogleMap googleMap) {
|
||||
mMap = googleMap;
|
||||
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
package com.example.oplogy;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.oplogy.databinding.MapsBinding;
|
||||
import com.google.android.gms.maps.GoogleMap;
|
||||
import com.google.android.gms.maps.MapFragment;
|
||||
import com.google.android.gms.maps.OnMapReadyCallback;
|
||||
import com.google.android.gms.maps.SupportMapFragment;
|
||||
import com.google.common.collect.MapMaker;
|
||||
|
||||
public class MapsActivity extends AppCompatActivity implements View.OnClickListener, OnMapReadyCallback{
|
||||
ImageView toMain;
|
||||
private GoogleMap mMap;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_maps);
|
||||
|
||||
// ボタンの戻る処理
|
||||
toMain = findViewById(R.id.toMain);
|
||||
toMain.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// メイン画面に戻る
|
||||
if(view == toMain){
|
||||
Intent toMain = new Intent(MapsActivity.this,MainActivity.class);
|
||||
startActivity(toMain);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onMapReady(@NonNull GoogleMap googleMap) {
|
||||
mMap = googleMap;
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
|
||||
}
|
||||
}
|
98
app/src/main/java/com/example/oplogy/MyDataClass.java
Normal file
98
app/src/main/java/com/example/oplogy/MyDataClass.java
Normal file
|
@ -0,0 +1,98 @@
|
|||
package com.example.oplogy;
|
||||
|
||||
import com.google.firebase.Timestamp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MyDataClass {
|
||||
String patronName;
|
||||
int classId;
|
||||
List<String> address;
|
||||
List<Timestamp> firstDay;
|
||||
int studentNumber;
|
||||
String childName;
|
||||
List<Timestamp> thirdDay;
|
||||
List<Timestamp> secondDay;
|
||||
double latitude;
|
||||
|
||||
public MyDataClass(String patronName, int classId, List<String> address, List<Timestamp> firstDay, int studentNumber, String childName, List<Timestamp> thirdDay, List<Timestamp> secondDay) {
|
||||
this.patronName = patronName;
|
||||
this.classId = classId;
|
||||
this.address = address;
|
||||
this.firstDay = firstDay;
|
||||
this.studentNumber = studentNumber;
|
||||
this.childName = childName;
|
||||
this.thirdDay = thirdDay;
|
||||
this.secondDay = secondDay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MyDataClass{" +
|
||||
"patronName='" + patronName + '\'' +
|
||||
", classId=" + classId +
|
||||
", address=" + address +
|
||||
", firstDay=" + firstDay +
|
||||
", studentNumber=" + studentNumber +
|
||||
", childName='" + childName + '\'' +
|
||||
", thirdDay=" + thirdDay +
|
||||
", secondDay=" + secondDay +
|
||||
'}';
|
||||
}
|
||||
//getter
|
||||
public String getPatronName() {
|
||||
return patronName;
|
||||
}
|
||||
public int getClassId() {
|
||||
return classId;
|
||||
}
|
||||
public List<String> getAddress() {
|
||||
return address;
|
||||
}
|
||||
public List<Timestamp> getFirstDay() {
|
||||
return firstDay;
|
||||
}
|
||||
public int getStudentNumber() {
|
||||
return studentNumber;
|
||||
}
|
||||
public String getChildName() {
|
||||
return childName;
|
||||
}
|
||||
public List<Timestamp> getThirdDay() {
|
||||
return thirdDay;
|
||||
}
|
||||
public List<Timestamp> getSecondDay() {
|
||||
return secondDay;
|
||||
}
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
//setter
|
||||
public void setPatronName(String patronName) {
|
||||
this.patronName = patronName;
|
||||
}
|
||||
public void setClassId(int classId) {
|
||||
this.classId = classId;
|
||||
}
|
||||
public void setAddress(List<String> address) {
|
||||
this.address = address;
|
||||
}
|
||||
public void setFirstDay(List<Timestamp> firstDay) {
|
||||
this.firstDay = firstDay;
|
||||
}
|
||||
public void setStudentNumber(int studentNumber) {
|
||||
this.studentNumber = studentNumber;
|
||||
}
|
||||
public void setChildName(String childName) {
|
||||
this.childName = childName;
|
||||
}
|
||||
public void setThirdDay(List<Timestamp> thirdDay) {
|
||||
this.thirdDay = thirdDay;
|
||||
}
|
||||
public void setSecondDay(List<Timestamp> secondDay) {
|
||||
this.secondDay = secondDay;
|
||||
}
|
||||
public void setLatitude(double latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package com.example.oplogy;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
@Entity
|
||||
public class QuestionnaireForm {
|
||||
//主キー
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
public int id;
|
||||
|
||||
//その他フィールド
|
||||
public int classId;
|
||||
public String patronName;
|
||||
public String address;
|
||||
public String firstDay;
|
||||
public int studentNumber;
|
||||
public String childName;
|
||||
public String thirdDay;
|
||||
public String secondDay;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package com.example.oplogy;
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Dao
|
||||
public interface QuestionnaireFormDao {
|
||||
|
||||
@Query("SELECT * FROM QuestionnaireForm")
|
||||
List<QuestionnaireForm> getAll();
|
||||
|
||||
// このメソッドは、QuestionnaireFormのリストを受け取り、それらをデータベースに挿入します。
|
||||
@Insert
|
||||
void insertAll(QuestionnaireForm... questionnaireForms);
|
||||
}
|
86
app/src/main/java/com/example/oplogy/SetUpTable.java
Normal file
86
app/src/main/java/com/example/oplogy/SetUpTable.java
Normal file
|
@ -0,0 +1,86 @@
|
|||
package com.example.oplogy;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
@Entity
|
||||
public class SetUpTable {
|
||||
//主キー
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
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 int totalStudent;
|
||||
|
||||
//コンストラクタ
|
||||
public SetUpTable(String teacherName, String startPoint, String endPoint, String startTime, String endTime, String breakStartTime,String breakEndTime, int totalStudent) {
|
||||
this.teacherName = teacherName;
|
||||
this.startPoint = startPoint;
|
||||
this.endPoint = endPoint;
|
||||
this.startTime = startTime;
|
||||
this.endTime = endTime;
|
||||
this.breakStartTime = breakStartTime;
|
||||
this.breakEndTime = breakEndTime;
|
||||
this.totalStudent = totalStudent;
|
||||
}
|
||||
//getter
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public String getTeacherName() {
|
||||
return teacherName;
|
||||
}
|
||||
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;
|
||||
}
|
||||
//setter
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
public void setTeacherName(String teacherName) {
|
||||
this.teacherName = teacherName;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
12
app/src/main/java/com/example/oplogy/SetUpTableDao.java
Normal file
12
app/src/main/java/com/example/oplogy/SetUpTableDao.java
Normal file
|
@ -0,0 +1,12 @@
|
|||
package com.example.oplogy;
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Dao
|
||||
public interface SetUpTableDao {
|
||||
@Insert
|
||||
void insertAll(SetUpTable... setUpTables);
|
||||
}
|
Loading…
Reference in New Issue
Block a user