コード整形

This commit is contained in:
it232115 2024-06-28 10:08:29 +09:00
parent d98293a80d
commit 56d54192d2
5 changed files with 32 additions and 30 deletions

View File

@ -98,21 +98,19 @@ public class CreateRoot {
if (!secondDuplicates) {
sortSchedule(myDataList);
outPutLogSchedule(myDataList);
}else{
} else {
Log.d("CreateRoot", "重複によるエラー");
}
}
});
if(!secondDuplicates){
if (!secondDuplicates) {
return true;
}else{
} else {
return false;
}
}
private void setData(List<MyDataClass> myDataList) {
for (int i = 0; i < myDataList.size(); i++) {
// 希望時間帯の終了時刻から開始時刻を引いて希望時間帯の長さ(timezone)に入れる
@ -287,7 +285,7 @@ public class CreateRoot {
private void outPutLogIntervalArray(int[][][] intervalArray) {
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 j = 0; j < intervalArray[0].length - 1; j++) {
for (int x = 0; x < 3; x++) {
if (testdata[x].equals(myDataList.get(i).getStartDateString())&&myDataList.get(i).getSchedule()==0) {
String desiredDate=myDataList.get(i).getStartDateString();
checkSchedule(myDataList, intervalArray, i, j, x,desiredDate);
if (testdata[x].equals(myDataList.get(i).getStartDateString()) && myDataList.get(i).getSchedule() == 0) {
String desiredDate = myDataList.get(i).getStartDateString();
checkSchedule(myDataList, intervalArray, i, j, x, desiredDate);
break;
}
}
@ -319,8 +317,8 @@ public class CreateRoot {
for (int j = 0; j < intervalArray[0].length - 1; j++) {
for (int x = 0; x < 3; x++) {
if (testdata[x].equals(myDataList.get(i).getSecondDayStartDateString()) && myDataList.get(i).getSchedule() == 0) {
String desiredDate=myDataList.get(i).getSecondDayStartDateString();
checkSchedule(myDataList, intervalArray, i, j, x,desiredDate);
String desiredDate = myDataList.get(i).getSecondDayStartDateString();
checkSchedule(myDataList, intervalArray, i, j, x, desiredDate);
}
}
}
@ -334,11 +332,11 @@ public class CreateRoot {
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) {
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 java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -24,7 +23,7 @@ public class FirestoreReception {
}
//firestoreから受け取ったデータを束ねるためのマップ
public List<MyDataClass>myDataList = new ArrayList<>();
public List<MyDataClass> myDataList = new ArrayList<>();
//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());
}
} else {
@ -72,12 +71,14 @@ public class FirestoreReception {
});
}
//Dataのリストのサイズを返す
public int getMyDataListSize(){
public int getMyDataListSize() {
return myDataList.size();
}
//Dataのリストを返す
public List<MyDataClass> getMyDataList(){
public List<MyDataClass> getMyDataList() {
return myDataList;
}
}

View File

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

View File

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

View File

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