Merge pull request 'CreateRoot2' (#7) from CreateRoot2 into master
Reviewed-on: #7
This commit is contained in:
commit
a3dd2f922d
|
@ -2,17 +2,55 @@ package com.example.oplogy;
|
|||
|
||||
import android.util.Log;
|
||||
|
||||
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;
|
||||
|
||||
public class CreateRoot {
|
||||
public void receiveData(List<MyDataClass> myDataList) {
|
||||
|
||||
// デバッグ用ログ
|
||||
for(MyDataClass data : myDataList){
|
||||
Log.d("CreateRoot", "data: "+ data.toString());
|
||||
for (int i = 0; i < myDataList.size(); i++) {
|
||||
MyDataClass data = myDataList.get(i);
|
||||
List<Timestamp> firstDay = data.getFirstDay();
|
||||
Timestamp startTime = firstDay.get(0);
|
||||
Timestamp endTime = firstDay.get(1);
|
||||
Long timezone = endTime.getSeconds() - startTime.getSeconds();
|
||||
data.setTimezone(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));
|
||||
}
|
||||
Log.d("CreateRoot", "myDataList[0]: " + myDataList.get(0).toString());
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -14,6 +14,9 @@ public class MyDataClass {
|
|||
List<Timestamp> thirdDay;
|
||||
List<Timestamp> secondDay;
|
||||
double latitude;
|
||||
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) {
|
||||
this.patronName = patronName;
|
||||
|
@ -39,60 +42,97 @@ public class MyDataClass {
|
|||
", 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 int getClassId() {
|
||||
return classId;
|
||||
}
|
||||
|
||||
public void setClassId(int classId) {
|
||||
this.classId = classId;
|
||||
}
|
||||
|
||||
public List<String> getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(List<String> address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public List<Timestamp> getFirstDay() {
|
||||
return firstDay;
|
||||
}
|
||||
|
||||
public void setFirstDay(List<Timestamp> firstDay) {
|
||||
this.firstDay = firstDay;
|
||||
}
|
||||
|
||||
public int getStudentNumber() {
|
||||
return studentNumber;
|
||||
}
|
||||
|
||||
public void setStudentNumber(int studentNumber) {
|
||||
this.studentNumber = studentNumber;
|
||||
}
|
||||
|
||||
public String getChildName() {
|
||||
return childName;
|
||||
}
|
||||
|
||||
public void setChildName(String childName) {
|
||||
this.childName = childName;
|
||||
}
|
||||
|
||||
public List<Timestamp> getThirdDay() {
|
||||
return thirdDay;
|
||||
}
|
||||
|
||||
public void setThirdDay(List<Timestamp> thirdDay) {
|
||||
this.thirdDay = thirdDay;
|
||||
}
|
||||
|
||||
public List<Timestamp> getSecondDay() {
|
||||
return secondDay;
|
||||
}
|
||||
|
||||
public void setSecondDay(List<Timestamp> secondDay) {
|
||||
this.secondDay = secondDay;
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public void setLatitude(double latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public void setEndDateString(String endDateString) {
|
||||
this.endDateString = endDateString;
|
||||
}
|
||||
|
||||
public Long getTimezone() {
|
||||
return Timezone;
|
||||
}
|
||||
|
||||
public void setTimezone(Long 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;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class RootSearchActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue
Block a user