CreateRoot2 #19

Merged
Utahshi merged 5 commits from CreateRoot2 into master 2024-06-28 01:21:56 +00:00
5 changed files with 32 additions and 30 deletions
Showing only changes of commit 56d54192d2 - Show all commits

View File

@ -98,21 +98,19 @@ public class CreateRoot {
if (!secondDuplicates) { if (!secondDuplicates) {
sortSchedule(myDataList); sortSchedule(myDataList);
outPutLogSchedule(myDataList); outPutLogSchedule(myDataList);
}else{ } else {
Log.d("CreateRoot", "重複によるエラー"); Log.d("CreateRoot", "重複によるエラー");
} }
} }
}); });
if(!secondDuplicates){ if (!secondDuplicates) {
return true; return true;
}else{ } else {
return false; return false;
} }
} }
private void setData(List<MyDataClass> myDataList) { private void setData(List<MyDataClass> myDataList) {
for (int i = 0; i < myDataList.size(); i++) { for (int i = 0; i < myDataList.size(); i++) {
// 希望時間帯の終了時刻から開始時刻を引いて希望時間帯の長さ(timezone)に入れる // 希望時間帯の終了時刻から開始時刻を引いて希望時間帯の長さ(timezone)に入れる
@ -287,7 +285,7 @@ public class CreateRoot {
private void outPutLogIntervalArray(int[][][] intervalArray) { private void outPutLogIntervalArray(int[][][] intervalArray) {
for (int i = 0; i < intervalArray[0].length; i++) { for (int i = 0; i < intervalArray[0].length; i++) {
Log.d("CreateRoot","inteintervalArray:(intex:" + i + ") :"+intervalArray[0][i][0]); Log.d("CreateRoot", "inteintervalArray:(intex:" + i + ") :" + intervalArray[0][i][0]);
} }
} }
@ -297,9 +295,9 @@ public class CreateRoot {
for (int i = 0; i < myDataList.size(); i++) { for (int i = 0; i < myDataList.size(); i++) {
for (int j = 0; j < intervalArray[0].length - 1; j++) { for (int j = 0; j < intervalArray[0].length - 1; j++) {
for (int x = 0; x < 3; x++) { for (int x = 0; x < 3; x++) {
if (testdata[x].equals(myDataList.get(i).getStartDateString())&&myDataList.get(i).getSchedule()==0) { if (testdata[x].equals(myDataList.get(i).getStartDateString()) && myDataList.get(i).getSchedule() == 0) {
String desiredDate=myDataList.get(i).getStartDateString(); String desiredDate = myDataList.get(i).getStartDateString();
checkSchedule(myDataList, intervalArray, i, j, x,desiredDate); checkSchedule(myDataList, intervalArray, i, j, x, desiredDate);
break; break;
} }
} }
@ -319,8 +317,8 @@ public class CreateRoot {
for (int j = 0; j < intervalArray[0].length - 1; j++) { for (int j = 0; j < intervalArray[0].length - 1; j++) {
for (int x = 0; x < 3; x++) { for (int x = 0; x < 3; x++) {
if (testdata[x].equals(myDataList.get(i).getSecondDayStartDateString()) && myDataList.get(i).getSchedule() == 0) { if (testdata[x].equals(myDataList.get(i).getSecondDayStartDateString()) && myDataList.get(i).getSchedule() == 0) {
String desiredDate=myDataList.get(i).getSecondDayStartDateString(); String desiredDate = myDataList.get(i).getSecondDayStartDateString();
checkSchedule(myDataList, intervalArray, i, j, x,desiredDate); checkSchedule(myDataList, intervalArray, i, j, x, desiredDate);
} }
} }
} }
@ -334,11 +332,11 @@ public class CreateRoot {
return false; return false;
} }
private void checkSchedule(List<MyDataClass> myDataList, int[][][] intervalArray, int i, int j, int x,String desiredDate) { private void checkSchedule(List<MyDataClass> myDataList, int[][][] intervalArray, int i, int j, int x, String desiredDate) {
if (intervalArray[x][j][0] >= Integer.parseInt(myDataList.get(i).getParentStartTimeString()) && intervalArray[x][j + 1][0] <= Integer.parseInt(myDataList.get(i).getParentEndTimeString()) && intervalArray[x][j][1] == 0) { if (intervalArray[x][j][0] >= Integer.parseInt(myDataList.get(i).getParentStartTimeString()) && intervalArray[x][j + 1][0] <= Integer.parseInt(myDataList.get(i).getParentEndTimeString()) && intervalArray[x][j][1] == 0) {
intervalArray[x][j][1] += 1;//割り当て済みを表す intervalArray[x][j][1] += 1;//割り当て済みを表す
myDataList.get(i).setSchedule(Integer.parseInt(desiredDate.substring(4,8)+String.valueOf(intervalArray[x][j][0]))); myDataList.get(i).setSchedule(Integer.parseInt(desiredDate.substring(4, 8) + String.valueOf(intervalArray[x][j][0])));
} }
} }

View File

@ -11,7 +11,6 @@ import com.google.firebase.firestore.QueryDocumentSnapshot;
import com.google.firebase.firestore.QuerySnapshot; import com.google.firebase.firestore.QuerySnapshot;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -24,7 +23,7 @@ public class FirestoreReception {
} }
//firestoreから受け取ったデータを束ねるためのマップ //firestoreから受け取ったデータを束ねるためのマップ
public List<MyDataClass>myDataList = new ArrayList<>(); public List<MyDataClass> myDataList = new ArrayList<>();
//ClassIdを引数にデータの作成を行う //ClassIdを引数にデータの作成を行う
public void getDocumentsByClassId(int classId) { public void getDocumentsByClassId(int classId) {
@ -61,7 +60,7 @@ public class FirestoreReception {
//取得したデータをログ表示 //取得したデータをログ表示
for(MyDataClass data :myDataList){ for (MyDataClass data : myDataList) {
Log.i("FirestoreReceptiond", "data: " + data.toString()); Log.i("FirestoreReceptiond", "data: " + data.toString());
} }
} else { } else {
@ -72,12 +71,14 @@ public class FirestoreReception {
}); });
} }
//Dataのリストのサイズを返す //Dataのリストのサイズを返す
public int getMyDataListSize(){ public int getMyDataListSize() {
return myDataList.size(); return myDataList.size();
} }
//Dataのリストを返す //Dataのリストを返す
public List<MyDataClass> getMyDataList(){ public List<MyDataClass> getMyDataList() {
return myDataList; return myDataList;
} }
} }

View File

@ -34,7 +34,7 @@ public class GeoCoder {
Log.d("FirestoreReception", "firstDay: " + firstDay.get(0)); Log.d("FirestoreReception", "firstDay: " + firstDay.get(0));
Log.d("FirestoreReception", "firstDay: " + firstDay.get(1)); Log.d("FirestoreReception", "firstDay: " + firstDay.get(1));
Log.d("FirestoreReception", "studentNumber: " + studentNumber); Log.d("FirestoreReception", "studentNumber: " + studentNumber);
Log.d("FirestoreReception", "latLng: "+latLng ); Log.d("FirestoreReception", "latLng: " + latLng);
} catch (NullPointerException e) { } catch (NullPointerException e) {
Log.e("NullPointerException", "getの中身がnull" + e); Log.e("NullPointerException", "getの中身がnull" + e);

View File

@ -131,11 +131,11 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
} else { } else {
latch.countDown(); latch.countDown();
} }
}); });
}); });
executor.execute(() -> { executor.execute(() -> {
List<MyDataClass> myDataList = null; List<MyDataClass> myDataList = null;
while (myDataList == null) { while (myDataList == null) {
myDataList = firestoreReception.getMyDataList(); myDataList = firestoreReception.getMyDataList();
@ -150,6 +150,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
CreateRoot createRoot = new CreateRoot(MainActivity.this); CreateRoot createRoot = new CreateRoot(MainActivity.this);
Boolean notDuplicates=createRoot.receiveData(myDataList); Boolean notDuplicates=createRoot.receiveData(myDataList);
latch.countDown(); latch.countDown();
if(notDuplicates){ if(notDuplicates){
Log.d("MainActivity","スケジュール作成成功"); Log.d("MainActivity","スケジュール作成成功");
}else{ }else{
@ -221,6 +222,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
latch.countDown(); latch.countDown();
} }
}) })
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override @Override

View File

@ -200,27 +200,28 @@ public class MyDataClass {
} }
public void setSecondDayStartDateString(String secondDayStartDateString) { public void setSecondDayStartDateString(String secondDayStartDateString) {
this.secondDayStartDateString=secondDayStartDateString; this.secondDayStartDateString = secondDayStartDateString;
} }
public void setSecondDayEndDateString(String secondDayEndDateString) { public void setSecondDayEndDateString(String secondDayEndDateString) {
this.secondDayEndDateString=secondDayEndDateString; this.secondDayEndDateString = secondDayEndDateString;
}
public void setSecondDayTimezone(Long secondDayTimezone) {
this.secondDayTimezone=secondDayTimezone;
} }
public Long getSecondDayTimezone(){ public void setSecondDayTimezone(Long secondDayTimezone) {
this.secondDayTimezone = secondDayTimezone;
}
public Long getSecondDayTimezone() {
return secondDayTimezone; return secondDayTimezone;
} }
public void setSecondDayParentStartTimeString(String secondDayParentStartTimeString) { public void setSecondDayParentStartTimeString(String secondDayParentStartTimeString) {
this.secondDayParentStartTimeString=secondDayParentStartTimeString; this.secondDayParentStartTimeString = secondDayParentStartTimeString;
} }
public void setSecondDayParentEndTimeString(String secondDayParentEndTimeString) { public void setSecondDayParentEndTimeString(String secondDayParentEndTimeString) {
this.secondDayParentEndTimeString=secondDayParentEndTimeString; this.secondDayParentEndTimeString = secondDayParentEndTimeString;
} }
public String getSecondDayParentStartTimeString() { public String getSecondDayParentStartTimeString() {