CreateRoot2 #7
|
@ -4,25 +4,53 @@ import android.util.Log;
|
||||||
|
|
||||||
import com.google.firebase.Timestamp;
|
import com.google.firebase.Timestamp;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CreateRoot {
|
public class CreateRoot {
|
||||||
public void receiveData(List<MyDataClass> myDataList) {
|
public void receiveData(List<MyDataClass> myDataList) {
|
||||||
|
|
||||||
// デバッグ用ログ
|
for (int i = 0; i < myDataList.size(); i++) {
|
||||||
for(MyDataClass data : myDataList){
|
MyDataClass data = myDataList.get(i);
|
||||||
Log.d("CreateRoot", "data: "+ data.toString());
|
List<Timestamp> firstDay = data.getFirstDay();
|
||||||
}
|
Timestamp startTime = firstDay.get(0);
|
||||||
Log.d("CreateRoot", "myDataList[0]: " + myDataList.get(0).toString());
|
Timestamp endTime = firstDay.get(1);
|
||||||
|
|
||||||
for (MyDataClass data : myDataList) {
|
|
||||||
Log.d("CreateRoot", "data: " + data.toString());
|
|
||||||
Timestamp startTime = data.getFirstDay().get(0);
|
|
||||||
Timestamp endTime = data.getFirstDay().get(1);
|
|
||||||
Long timezone = endTime.getSeconds() - startTime.getSeconds();
|
Long timezone = endTime.getSeconds() - startTime.getSeconds();
|
||||||
data.setTimezone(timezone);
|
data.setTimezone(timezone);
|
||||||
Log.d("CreateRoot", "timezone: " + timezone);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Date startDate = new Date(startTime.getSeconds() * 1000);
|
||||||
|
Date endDate = new Date(endTime.getSeconds() * 1000);
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
String startDateString = sdf.format(startDate);
|
||||||
|
String endDateString = sdf.format(endDate);
|
||||||
|
|
||||||
|
// myDataList の中の data に追加する処理
|
||||||
|
myDataList.get(i).setTimezone(timezone);
|
||||||
|
myDataList.get(i).setStartDateString(startDateString);
|
||||||
|
myDataList.get(i).setEndDateString(endDateString);
|
||||||
|
|
||||||
|
// ログ出力
|
||||||
|
Log.d("CreateRoot", "(index: " + i + ") timezone: " + myDataList.get(i).getTimezone());
|
||||||
|
Log.d("CreateRoot", "(index: " + i + ") startDate: " + myDataList.get(i).getStartDateString());
|
||||||
|
Log.d("CreateRoot", "(index: " + i + ") data: " + myDataList.get(i));
|
||||||
|
}
|
||||||
|
// timezoneを比較するComparatorを作成
|
||||||
|
Comparator<MyDataClass> comparator = new Comparator<MyDataClass>() {
|
||||||
|
@Override
|
||||||
|
public int compare(MyDataClass data1, MyDataClass data2) {
|
||||||
|
return data1.getTimezone().compareTo(data2.getTimezone());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// myDataListをtimezoneの値でソート
|
||||||
|
Collections.sort(myDataList, comparator);
|
||||||
|
// ソート後のmyDataListをログ出力
|
||||||
|
for (int i = 0; i < myDataList.size(); i++) {
|
||||||
|
Log.d("CreateRoot", "(index: " + i + ") timezone: " + myDataList.get(i).getTimezone());
|
||||||
|
Log.d("CreateRoot", "(index: " + i + ") startDate: " + myDataList.get(i).getStartDateString());
|
||||||
|
Log.d("CreateRoot", "(index: " + i + ") data: " + myDataList.get(i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,6 +15,8 @@ public class MyDataClass {
|
||||||
List<Timestamp> secondDay;
|
List<Timestamp> secondDay;
|
||||||
double latitude;
|
double latitude;
|
||||||
private Long Timezone;
|
private Long Timezone;
|
||||||
|
private String startDateString;
|
||||||
|
private String endDateString;
|
||||||
|
|
||||||
public MyDataClass(String patronName, int classId, List<String> address, List<Timestamp> firstDay, int studentNumber, String childName, List<Timestamp> thirdDay, List<Timestamp> secondDay) {
|
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.patronName = patronName;
|
||||||
|
@ -40,66 +42,97 @@ public class MyDataClass {
|
||||||
", secondDay=" + secondDay +
|
", secondDay=" + secondDay +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
//getter
|
//getter
|
||||||
public String getPatronName() {
|
public String getPatronName() {
|
||||||
return patronName;
|
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
|
//setter
|
||||||
public void setPatronName(String patronName) {
|
public void setPatronName(String patronName) {
|
||||||
this.patronName = patronName;
|
this.patronName = patronName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getClassId() {
|
||||||
|
return classId;
|
||||||
|
}
|
||||||
|
|
||||||
public void setClassId(int classId) {
|
public void setClassId(int classId) {
|
||||||
this.classId = classId;
|
this.classId = classId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getAddress() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
public void setAddress(List<String> address) {
|
public void setAddress(List<String> address) {
|
||||||
this.address = address;
|
this.address = address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Timestamp> getFirstDay() {
|
||||||
|
return firstDay;
|
||||||
|
}
|
||||||
|
|
||||||
public void setFirstDay(List<Timestamp> firstDay) {
|
public void setFirstDay(List<Timestamp> firstDay) {
|
||||||
this.firstDay = firstDay;
|
this.firstDay = firstDay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getStudentNumber() {
|
||||||
|
return studentNumber;
|
||||||
|
}
|
||||||
|
|
||||||
public void setStudentNumber(int studentNumber) {
|
public void setStudentNumber(int studentNumber) {
|
||||||
this.studentNumber = studentNumber;
|
this.studentNumber = studentNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getChildName() {
|
||||||
|
return childName;
|
||||||
|
}
|
||||||
|
|
||||||
public void setChildName(String childName) {
|
public void setChildName(String childName) {
|
||||||
this.childName = childName;
|
this.childName = childName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Timestamp> getThirdDay() {
|
||||||
|
return thirdDay;
|
||||||
|
}
|
||||||
|
|
||||||
public void setThirdDay(List<Timestamp> thirdDay) {
|
public void setThirdDay(List<Timestamp> thirdDay) {
|
||||||
this.thirdDay = thirdDay;
|
this.thirdDay = thirdDay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Timestamp> getSecondDay() {
|
||||||
|
return secondDay;
|
||||||
|
}
|
||||||
|
|
||||||
public void setSecondDay(List<Timestamp> secondDay) {
|
public void setSecondDay(List<Timestamp> secondDay) {
|
||||||
this.secondDay = secondDay;
|
this.secondDay = secondDay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getLatitude() {
|
||||||
|
return latitude;
|
||||||
|
}
|
||||||
|
|
||||||
public void setLatitude(double latitude) {
|
public void setLatitude(double latitude) {
|
||||||
this.latitude = latitude;
|
this.latitude = latitude;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setEndDateString(String endDateString) {
|
||||||
|
this.endDateString = endDateString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getTimezone() {
|
||||||
|
return Timezone;
|
||||||
|
}
|
||||||
|
|
||||||
public void setTimezone(Long Timezone) {
|
public void setTimezone(Long Timezone) {
|
||||||
this.Timezone = Timezone;
|
this.Timezone = Timezone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getStartDateString() {
|
||||||
|
return startDateString;
|
||||||
|
}
|
||||||
|
public void setStartDateString(String startDateString) {
|
||||||
|
this.startDateString = startDateString;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package com.example.oplogy;
|
package com.example.oplogy;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
public class RootSearchActivity extends AppCompatActivity {
|
public class RootSearchActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue
Block a user