全ての変数名に型名がわかるように追記
This commit is contained in:
parent
0652ce505b
commit
470abcd53e
|
@ -16,11 +16,11 @@ public class Converters {
|
||||||
// タイムスタンプを文字列(yyyy-mm-dd,日時)に変換
|
// タイムスタンプを文字列(yyyy-mm-dd,日時)に変換
|
||||||
@TypeConverter
|
@TypeConverter
|
||||||
public static List<String> fromTimestampList(List<Timestamp> timestamps) {
|
public static List<String> fromTimestampList(List<Timestamp> timestamps) {
|
||||||
List<String> strings = new ArrayList<>();
|
List<String> stringsList = new ArrayList<>();
|
||||||
for (Timestamp timestamp : timestamps) {
|
for (Timestamp timestamp : timestamps) {
|
||||||
strings.add(format.format(timestamp.toDate()));
|
stringsList.add(format.format(timestamp.toDate()));
|
||||||
}
|
}
|
||||||
return strings;
|
return stringsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@TypeConverter
|
@TypeConverter
|
||||||
|
|
|
@ -7,10 +7,10 @@ public class CreateUUID {
|
||||||
|
|
||||||
public static int generateUUID(List<Integer> classIdList ){
|
public static int generateUUID(List<Integer> classIdList ){
|
||||||
while (true){
|
while (true){
|
||||||
int uuid = (int)(Math.random() * 1000000);
|
int uuidInt = (int)(Math.random() * 1000000);
|
||||||
boolean isDuplicate = false;
|
boolean isDuplicate = false;
|
||||||
for(int classId : classIdList){
|
for(int classIdInt : classIdList){
|
||||||
if(classId==uuid){
|
if(classIdInt==uuidInt){
|
||||||
//重複があればフラグを立て、ループを抜ける
|
//重複があればフラグを立て、ループを抜ける
|
||||||
isDuplicate = true;
|
isDuplicate = true;
|
||||||
break;
|
break;
|
||||||
|
@ -20,10 +20,10 @@ public class CreateUUID {
|
||||||
if (!isDuplicate) {
|
if (!isDuplicate) {
|
||||||
//firestoreに挿入処理
|
//firestoreに挿入処理
|
||||||
InsertClassIdforFirebase insertClassIdforFirebase = new InsertClassIdforFirebase();
|
InsertClassIdforFirebase insertClassIdforFirebase = new InsertClassIdforFirebase();
|
||||||
insertClassIdforFirebase.insertClassId(uuid);
|
insertClassIdforFirebase.insertClassId(uuidInt);
|
||||||
//テスト用
|
//テスト用
|
||||||
uuid=100;
|
uuidInt=100;
|
||||||
return uuid;
|
return uuidInt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@ import android.widget.DatePicker;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.fragment.app.DialogFragment;
|
import androidx.fragment.app.DialogFragment;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class DatePick extends DialogFragment implements
|
public class DatePick extends DialogFragment implements
|
||||||
DatePickerDialog.OnDateSetListener {
|
DatePickerDialog.OnDateSetListener {
|
||||||
|
@ -19,16 +19,16 @@ public class DatePick extends DialogFragment implements
|
||||||
|
|
||||||
//デフォルトのタイムゾーンおよびロケールを使用してカレンダを取得
|
//デフォルトのタイムゾーンおよびロケールを使用してカレンダを取得
|
||||||
final Calendar c = Calendar.getInstance();
|
final Calendar c = Calendar.getInstance();
|
||||||
int year = c.get(Calendar.YEAR);
|
int yearInt = c.get(Calendar.YEAR);
|
||||||
int month = c.get(Calendar.MONTH);
|
int monthInt = c.get(Calendar.MONTH);
|
||||||
int day = c.get(Calendar.DAY_OF_MONTH);
|
int dayInt = c.get(Calendar.DAY_OF_MONTH);
|
||||||
|
|
||||||
return new DatePickerDialog(requireActivity(), (DatePickerDialog.OnDateSetListener) getActivity(), year, month, day);
|
return new DatePickerDialog(requireActivity(), (DatePickerDialog.OnDateSetListener) getActivity(), yearInt, monthInt, dayInt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDateSet(DatePicker datePicker, int year, int month, int day) {
|
public void onDateSet(DatePicker datePicker, int yearInt, int monthInt, int dayInt) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,6 @@ import android.util.Log;
|
||||||
|
|
||||||
import com.google.android.gms.tasks.OnCompleteListener;
|
import com.google.android.gms.tasks.OnCompleteListener;
|
||||||
import com.google.android.gms.tasks.Task;
|
import com.google.android.gms.tasks.Task;
|
||||||
import com.google.firebase.firestore.CollectionReference;
|
|
||||||
import com.google.firebase.firestore.DocumentSnapshot;
|
|
||||||
import com.google.firebase.firestore.FirebaseFirestore;
|
import com.google.firebase.firestore.FirebaseFirestore;
|
||||||
import com.google.firebase.firestore.QueryDocumentSnapshot;
|
import com.google.firebase.firestore.QueryDocumentSnapshot;
|
||||||
import com.google.firebase.firestore.QuerySnapshot;
|
import com.google.firebase.firestore.QuerySnapshot;
|
||||||
|
@ -14,7 +12,6 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
public class FirestoreReception_classIdDatabase {
|
public class FirestoreReception_classIdDatabase {
|
||||||
private FirebaseFirestore db;
|
private FirebaseFirestore db;
|
||||||
private List<Integer> classIdList= new ArrayList<>();
|
private List<Integer> classIdList= new ArrayList<>();
|
||||||
|
|
|
@ -1,59 +0,0 @@
|
||||||
package com.example.oplogy;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.location.Address;
|
|
||||||
import android.location.Geocoder;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.google.android.gms.maps.model.LatLng;
|
|
||||||
import com.google.firebase.Timestamp;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class GeoCoder {
|
|
||||||
private Context context;
|
|
||||||
|
|
||||||
public void processData(Map<String, Object> data, Context context) {
|
|
||||||
try {
|
|
||||||
this.context = context;
|
|
||||||
|
|
||||||
//家庭訪問先の住所
|
|
||||||
List<String> address = (List<String>) data.get("address");
|
|
||||||
//家庭訪問の第一希望日(配列0が希望時間帯のはじめ、配列1がおわり)
|
|
||||||
List<Timestamp> firstDay = (List<Timestamp>) data.get("firstDay");
|
|
||||||
//出席番号
|
|
||||||
Long studentNumber = (Long) data.get("studentNumber");
|
|
||||||
// 住所を緯度経度に変換
|
|
||||||
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);
|
|
||||||
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
Log.e("NullPointerException", "getの中身がnull" + e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private LatLng geocodeAddress(String address) {
|
|
||||||
try {
|
|
||||||
Geocoder geocoder = new Geocoder(context, Locale.getDefault());
|
|
||||||
List<Address> addresses = geocoder.getFromLocationName(address, 1);
|
|
||||||
if (addresses != null && !addresses.isEmpty()) {
|
|
||||||
Address addressResult = addresses.get(0);
|
|
||||||
double latitude = addressResult.getLatitude();
|
|
||||||
double longitude = addressResult.getLongitude();
|
|
||||||
return new LatLng(latitude, longitude);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.e("GeocodingException", "Error geocoding address: " + address, e);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -195,12 +195,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
|
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
AppDatabase db = getDatabaseInstance(); SetUpTableDao setUpTableDao = db.setUpTableDao();
|
AppDatabase db = getDatabaseInstance(); SetUpTableDao setUpTableDao = db.setUpTableDao();
|
||||||
int totalStudent = setUpTableDao.getTotalStudent();
|
int totalStudentInt = setUpTableDao.getTotalStudent();
|
||||||
int myDataListSize = firestoreReception.getMyDataListSize();
|
int myDataListSizeInt = firestoreReception.getMyDataListSize();
|
||||||
|
|
||||||
//総生徒数と提出済みになっている生徒の数が一致するかの確認
|
//総生徒数と提出済みになっている生徒の数が一致するかの確認
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
if (totalStudent != myDataListSize) {
|
if (totalStudentInt != myDataListSizeInt) {
|
||||||
//未提出者がいることの警告ダイアログ
|
//未提出者がいることの警告ダイアログ
|
||||||
showRouteCreationDialog();
|
showRouteCreationDialog();
|
||||||
} else {
|
} else {
|
||||||
|
@ -271,10 +271,10 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
|
|
||||||
// MyDataListをJSON形式に変換
|
// MyDataListをJSON形式に変換
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
String json = gson.toJson(myDataList);
|
String jsonString = gson.toJson(myDataList);
|
||||||
|
|
||||||
// JSON形式のデータを共有プリファレンスに保存
|
// JSON形式のデータを共有プリファレンスに保存
|
||||||
editor.putString("myDataList", json);
|
editor.putString("myDataList", jsonString);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,17 +320,17 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
// 1. Roomデータベースから全生徒数を取得
|
// 1. Roomデータベースから全生徒数を取得
|
||||||
AppDatabase db = getDatabaseInstance();
|
AppDatabase db = getDatabaseInstance();
|
||||||
SetUpTableDao setUpTableDao = db.setUpTableDao();
|
SetUpTableDao setUpTableDao = db.setUpTableDao();
|
||||||
int totalStudent = setUpTableDao.getTotalStudent();
|
int totalStudentInt = setUpTableDao.getTotalStudent();
|
||||||
// 2. Firestoreから生徒番号のリストを取得
|
// 2. Firestoreから生徒番号のリストを取得
|
||||||
ArrayList<Integer> firestoreStudentNumbers = new ArrayList<>();
|
ArrayList<Integer> firestoreStudentNumbersList = new ArrayList<>();
|
||||||
for (MyDataClass myData : myDataList) {
|
for (MyDataClass myData : myDataList) {
|
||||||
int studentNumber = myData.getStudentNumber();
|
int studentNumberInt = myData.getStudentNumber();
|
||||||
firestoreStudentNumbers.add(studentNumber);
|
firestoreStudentNumbersList.add(studentNumberInt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. SubmissionStudentオブジェクトのリストを作成
|
// 3. SubmissionStudentオブジェクトのリストを作成
|
||||||
for (int i = 1; i <= totalStudent; i++) {
|
for (int i = 1; i <= totalStudentInt; i++) {
|
||||||
boolean submitted = firestoreStudentNumbers.contains(i);
|
boolean submitted = firestoreStudentNumbersList.contains(i);
|
||||||
submissionStudents.add(new SubmissionStudent(i, submitted));
|
submissionStudents.add(new SubmissionStudent(i, submitted));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,7 @@ public class Maps extends FragmentActivity implements OnMapReadyCallback, View.O
|
||||||
|
|
||||||
ImageView backMain;
|
ImageView backMain;
|
||||||
private GoogleMap mMap;
|
private GoogleMap mMap;
|
||||||
private MapsBinding binding;
|
|
||||||
private LinearLayout locationsName;
|
private LinearLayout locationsName;
|
||||||
private Spinner dateSpinner;
|
|
||||||
//GoogleMapAPiで使用可能な色
|
//GoogleMapAPiで使用可能な色
|
||||||
private static final int[] COLORS = new int[]{Color.parseColor("#007FFF"), // HUE_AZURE
|
private static final int[] COLORS = new int[]{Color.parseColor("#007FFF"), // HUE_AZURE
|
||||||
Color.parseColor("#0000FF"), // HUE_BLUE
|
Color.parseColor("#0000FF"), // HUE_BLUE
|
||||||
|
@ -60,20 +58,18 @@ public class Maps extends FragmentActivity implements OnMapReadyCallback, View.O
|
||||||
Color.parseColor("#FFFF00") // HUE_YELLOW
|
Color.parseColor("#FFFF00") // HUE_YELLOW
|
||||||
};
|
};
|
||||||
private int colorIndex = 0;
|
private int colorIndex = 0;
|
||||||
private List<LatLng> latLngList = new ArrayList<>();
|
private final List<LatLng> latLngList = new ArrayList<>();
|
||||||
private List<String> nameList = new ArrayList<>();
|
private final List<String> nameList = new ArrayList<>();
|
||||||
private List<Integer> colorList = new ArrayList<>();
|
private final List<Integer> colorList = new ArrayList<>();
|
||||||
|
|
||||||
private Map<String, Runnable> dateMap = new HashMap<>();
|
private final Map<String, Runnable> dateMap = new HashMap<>();
|
||||||
|
|
||||||
private AppDatabase db = null;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
// バインディングの設定
|
// バインディングの設定
|
||||||
binding = MapsBinding.inflate(getLayoutInflater());
|
com.example.oplogy.databinding.MapsBinding binding = MapsBinding.inflate(getLayoutInflater());
|
||||||
setContentView(binding.getRoot());
|
setContentView(binding.getRoot());
|
||||||
|
|
||||||
// マップフラグメントの設定
|
// マップフラグメントの設定
|
||||||
|
@ -103,7 +99,7 @@ public class Maps extends FragmentActivity implements OnMapReadyCallback, View.O
|
||||||
dateMap.put(formattedDayString, () -> loadMapAndNames(createlocationData(finalI), getscrollViewlData(finalI)));
|
dateMap.put(formattedDayString, () -> loadMapAndNames(createlocationData(finalI), getscrollViewlData(finalI)));
|
||||||
}
|
}
|
||||||
|
|
||||||
dateSpinner = findViewById(R.id.date);
|
Spinner dateSpinner = findViewById(R.id.date);
|
||||||
dateSpinner.setAdapter(adapter);
|
dateSpinner.setAdapter(adapter);
|
||||||
|
|
||||||
// スピナーのアイテム選択リスナーを設定
|
// スピナーのアイテム選択リスナーを設定
|
||||||
|
|
|
@ -31,17 +31,17 @@ import java.util.concurrent.Executors;
|
||||||
public class SetUpActivity extends FragmentActivity
|
public class SetUpActivity extends FragmentActivity
|
||||||
implements TimePickerDialog.OnTimeSetListener, DatePickerDialog.OnDateSetListener {
|
implements TimePickerDialog.OnTimeSetListener, DatePickerDialog.OnDateSetListener {
|
||||||
|
|
||||||
String teacherName;
|
String teacherNameString;
|
||||||
String startPoint;
|
String startPointString;
|
||||||
String firstDay;
|
String firstDayString;
|
||||||
String secondDay;
|
String secondDayString;
|
||||||
String thirdDay;
|
String thirdDayString;
|
||||||
String startTime;
|
String startTimeString;
|
||||||
String endTime;
|
String endTimeString;
|
||||||
String intervalTime;
|
String intervalTimeString;
|
||||||
String startBreakTime;
|
String startBreakTimeString;
|
||||||
String endBreakTime;
|
String endBreakTimeString;
|
||||||
int totalStudent;
|
int totalStudentString;
|
||||||
private TextView setTeacherName;
|
private TextView setTeacherName;
|
||||||
private TextView setStartPoint;
|
private TextView setStartPoint;
|
||||||
private TextView setStartTime;
|
private TextView setStartTime;
|
||||||
|
@ -49,16 +49,16 @@ public class SetUpActivity extends FragmentActivity
|
||||||
private TextView setStartBreakTime;
|
private TextView setStartBreakTime;
|
||||||
private TextView setEndBreakTime;
|
private TextView setEndBreakTime;
|
||||||
private TextView setTotalStudent;
|
private TextView setTotalStudent;
|
||||||
private int isDateSelected;
|
private int isDateSelectedInt;
|
||||||
private int isStartTimeSelected;
|
private int isStartTimeSelectedInt;
|
||||||
|
|
||||||
String stringYear;
|
String stringYearString;
|
||||||
String stringMonth;
|
String stringMonthString;
|
||||||
String stringDayOfMonth;
|
String stringDayOfMonthString;
|
||||||
|
|
||||||
|
|
||||||
String stringHourOfDay;
|
String stringHourOfDayString;
|
||||||
String stringMinute;
|
String stringMinuteString;
|
||||||
|
|
||||||
Button setFirstDay;
|
Button setFirstDay;
|
||||||
Button setSecondDay;
|
Button setSecondDay;
|
||||||
|
@ -74,7 +74,7 @@ public class SetUpActivity extends FragmentActivity
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_set_up);
|
setContentView(R.layout.activity_set_up);
|
||||||
|
|
||||||
int classId= getIntent().getIntExtra("classId", 100000);
|
int classIdInt= getIntent().getIntExtra("classId", 100000);
|
||||||
|
|
||||||
setTeacherName = findViewById(R.id.teacherName); //先生の名前
|
setTeacherName = findViewById(R.id.teacherName); //先生の名前
|
||||||
setStartPoint = findViewById(R.id.startPoint); //開始地点
|
setStartPoint = findViewById(R.id.startPoint); //開始地点
|
||||||
|
@ -110,29 +110,29 @@ public class SetUpActivity extends FragmentActivity
|
||||||
|
|
||||||
setUp.setOnClickListener(view -> {
|
setUp.setOnClickListener(view -> {
|
||||||
|
|
||||||
teacherName = setTeacherName.getText().toString(); //各変数に値を挿入
|
teacherNameString = setTeacherName.getText().toString(); //各変数に値を挿入
|
||||||
Log.d(TAG, "Teacher Name: " + teacherName);
|
Log.d(TAG, "Teacher Name: " + teacherNameString);
|
||||||
startPoint = setStartPoint.getText().toString();
|
startPointString = setStartPoint.getText().toString();
|
||||||
Log.d(TAG, "Start Point: " + startPoint);
|
Log.d(TAG, "Start Point: " + startPointString);
|
||||||
Log.d(TAG, "First Day:" + firstDay);
|
Log.d(TAG, "First Day:" + firstDayString);
|
||||||
Log.d(TAG, "Second Day:" + secondDay);
|
Log.d(TAG, "Second Day:" + secondDayString);
|
||||||
Log.d(TAG, "Third Day:" + thirdDay);
|
Log.d(TAG, "Third Day:" + thirdDayString);
|
||||||
Log.d(TAG, "Start Time" + startTime);
|
Log.d(TAG, "Start Time" + startTimeString);
|
||||||
Log.d(TAG, "End Time" + endTime);
|
Log.d(TAG, "End Time" + endTimeString);
|
||||||
if (setTenMinute.isChecked()){ //ラジオボタンの状態を取得
|
if (setTenMinute.isChecked()){ //ラジオボタンの状態を取得
|
||||||
intervalTime = "10";
|
intervalTimeString = "10";
|
||||||
} else if (setFifteenMinute.isChecked()) {
|
} else if (setFifteenMinute.isChecked()) {
|
||||||
intervalTime = "15";
|
intervalTimeString = "15";
|
||||||
} else if (setThirtyMinute.isChecked()) {
|
} else if (setThirtyMinute.isChecked()) {
|
||||||
intervalTime = "30";
|
intervalTimeString = "30";
|
||||||
} else {
|
} else {
|
||||||
intervalTime = "0";
|
intervalTimeString = "0";
|
||||||
}
|
}
|
||||||
Log.d(TAG, "Interval Time" + intervalTime);
|
Log.d(TAG, "Interval Time" + intervalTimeString);
|
||||||
Log.d(TAG, "Start Break Time" + startBreakTime);
|
Log.d(TAG, "Start Break Time" + startBreakTimeString);
|
||||||
Log.d(TAG, "End Break Time" + endBreakTime);
|
Log.d(TAG, "End Break Time" + endBreakTimeString);
|
||||||
totalStudent = Integer.parseInt(setTotalStudent.getText().toString()); //数値型に変更
|
totalStudentString = Integer.parseInt(setTotalStudent.getText().toString()); //数値型に変更
|
||||||
Log.d(TAG, "Total Student" + totalStudent);
|
Log.d(TAG, "Total Student" + totalStudentString);
|
||||||
Log.d(TAG, "onClick: できてるよ");
|
Log.d(TAG, "onClick: できてるよ");
|
||||||
|
|
||||||
|
|
||||||
|
@ -147,19 +147,19 @@ public class SetUpActivity extends FragmentActivity
|
||||||
SetUpTableDao setUpTableDao = db.setUpTableDao();
|
SetUpTableDao setUpTableDao = db.setUpTableDao();
|
||||||
// Roomの操作を行う
|
// Roomの操作を行う
|
||||||
SetUpTable setUpTable = new SetUpTable(
|
SetUpTable setUpTable = new SetUpTable(
|
||||||
teacherName,
|
teacherNameString,
|
||||||
startPoint,
|
startPointString,
|
||||||
startTime,
|
startTimeString,
|
||||||
endTime,
|
endTimeString,
|
||||||
intervalTime,
|
intervalTimeString,
|
||||||
startBreakTime,
|
startBreakTimeString,
|
||||||
endBreakTime,
|
endBreakTimeString,
|
||||||
totalStudent,
|
totalStudentString,
|
||||||
classId
|
classIdInt
|
||||||
);
|
);
|
||||||
|
|
||||||
// 同じ名前のエントリが存在するかどうかを確認
|
// 同じ名前のエントリが存在するかどうかを確認
|
||||||
SetUpTable existingSetUpTable = setUpTableDao.findByName(teacherName);
|
SetUpTable existingSetUpTable = setUpTableDao.findByName(teacherNameString);
|
||||||
if (existingSetUpTable != null) {
|
if (existingSetUpTable != null) {
|
||||||
// エントリが存在する場合は、そのエントリを更新
|
// エントリが存在する場合は、そのエントリを更新
|
||||||
setUpTable.setId(existingSetUpTable.getId()); // 既存のIDを設定
|
setUpTable.setId(existingSetUpTable.getId()); // 既存のIDを設定
|
||||||
|
@ -175,9 +175,9 @@ public class SetUpActivity extends FragmentActivity
|
||||||
SharedPreferences sharedPreferences=getSharedPreferences("visitingDate",MODE_PRIVATE);
|
SharedPreferences sharedPreferences=getSharedPreferences("visitingDate",MODE_PRIVATE);
|
||||||
SharedPreferences.Editor editor= sharedPreferences.edit();
|
SharedPreferences.Editor editor= sharedPreferences.edit();
|
||||||
|
|
||||||
editor.putString("day1",firstDay);
|
editor.putString("day1",firstDayString);
|
||||||
editor.putString("day2",secondDay);
|
editor.putString("day2",secondDayString);
|
||||||
editor.putString("day3",thirdDay);
|
editor.putString("day3",thirdDayString);
|
||||||
|
|
||||||
editor.apply();
|
editor.apply();
|
||||||
|
|
||||||
|
@ -187,37 +187,37 @@ public class SetUpActivity extends FragmentActivity
|
||||||
});
|
});
|
||||||
|
|
||||||
setFirstDay.setOnClickListener(v ->{
|
setFirstDay.setOnClickListener(v ->{
|
||||||
isDateSelected = 1;
|
isDateSelectedInt = 1;
|
||||||
showDatePickerDialog(); //DatePickerの表示
|
showDatePickerDialog(); //DatePickerの表示
|
||||||
});
|
});
|
||||||
|
|
||||||
setSecondDay.setOnClickListener(v ->{
|
setSecondDay.setOnClickListener(v ->{
|
||||||
isDateSelected = 2;
|
isDateSelectedInt = 2;
|
||||||
showDatePickerDialog();
|
showDatePickerDialog();
|
||||||
});
|
});
|
||||||
|
|
||||||
setThirdDay.setOnClickListener(v ->{
|
setThirdDay.setOnClickListener(v ->{
|
||||||
isDateSelected = 3;
|
isDateSelectedInt = 3;
|
||||||
showDatePickerDialog();
|
showDatePickerDialog();
|
||||||
});
|
});
|
||||||
|
|
||||||
setStartTimeButton.setOnClickListener(v -> {
|
setStartTimeButton.setOnClickListener(v -> {
|
||||||
isStartTimeSelected = 1; //ボタンの判別
|
isStartTimeSelectedInt = 1; //ボタンの判別
|
||||||
showTimePickerDialog(); //TimePickerの表示
|
showTimePickerDialog(); //TimePickerの表示
|
||||||
});
|
});
|
||||||
|
|
||||||
setEndTimeButton.setOnClickListener(v -> {
|
setEndTimeButton.setOnClickListener(v -> {
|
||||||
isStartTimeSelected = 2;
|
isStartTimeSelectedInt = 2;
|
||||||
showTimePickerDialog();
|
showTimePickerDialog();
|
||||||
});
|
});
|
||||||
|
|
||||||
setStartBreakTime.setOnClickListener(v -> {
|
setStartBreakTime.setOnClickListener(v -> {
|
||||||
isStartTimeSelected = 3;
|
isStartTimeSelectedInt = 3;
|
||||||
showTimePickerDialog();
|
showTimePickerDialog();
|
||||||
});
|
});
|
||||||
|
|
||||||
setEndBreakTime.setOnClickListener(v -> {
|
setEndBreakTime.setOnClickListener(v -> {
|
||||||
isStartTimeSelected = 4;
|
isStartTimeSelectedInt = 4;
|
||||||
showTimePickerDialog();
|
showTimePickerDialog();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -247,25 +247,25 @@ public class SetUpActivity extends FragmentActivity
|
||||||
// DatePickerDialogで選択された日付を処理する
|
// DatePickerDialogで選択された日付を処理する
|
||||||
String str = String.format(Locale.JAPAN, "%02d/%02d", month + 1, dayOfMonth); // TextViewに表示する日付の形式を設定
|
String str = String.format(Locale.JAPAN, "%02d/%02d", month + 1, dayOfMonth); // TextViewに表示する日付の形式を設定
|
||||||
|
|
||||||
if (isDateSelected == 1) {
|
if (isDateSelectedInt == 1) {
|
||||||
stringYear = String.valueOf(year); //年
|
stringYearString = String.valueOf(year); //年
|
||||||
stringMonth = String.format(Locale.JAPAN, "%02d", month + 1); //月
|
stringMonthString = String.format(Locale.JAPAN, "%02d", month + 1); //月
|
||||||
stringDayOfMonth = String.format(Locale.JAPAN, "%02d", dayOfMonth); //日
|
stringDayOfMonthString = String.format(Locale.JAPAN, "%02d", dayOfMonth); //日
|
||||||
firstDay = stringYear + stringMonth + stringDayOfMonth;
|
firstDayString = stringYearString + stringMonthString + stringDayOfMonthString;
|
||||||
setFirstDay.setText(str);
|
setFirstDay.setText(str);
|
||||||
} else if (isDateSelected == 2) {
|
} else if (isDateSelectedInt == 2) {
|
||||||
stringYear = String.valueOf(year);
|
stringYearString = String.valueOf(year);
|
||||||
stringMonth = String.format(Locale.JAPAN, "%02d", month + 1);
|
stringMonthString = String.format(Locale.JAPAN, "%02d", month + 1);
|
||||||
stringDayOfMonth = String.format(Locale.JAPAN, "%02d", dayOfMonth);
|
stringDayOfMonthString = String.format(Locale.JAPAN, "%02d", dayOfMonth);
|
||||||
secondDay = stringYear + stringMonth + stringDayOfMonth;
|
secondDayString = stringYearString + stringMonthString + stringDayOfMonthString;
|
||||||
setSecondDay.setText(str);
|
setSecondDay.setText(str);
|
||||||
|
|
||||||
|
|
||||||
} else if (isDateSelected == 3) {
|
} else if (isDateSelectedInt == 3) {
|
||||||
stringYear = String.valueOf(year);
|
stringYearString = String.valueOf(year);
|
||||||
stringMonth = String.format(Locale.JAPAN, "%02d", month + 1);
|
stringMonthString = String.format(Locale.JAPAN, "%02d", month + 1);
|
||||||
stringDayOfMonth = String.format(Locale.JAPAN, "%02d", dayOfMonth);
|
stringDayOfMonthString = String.format(Locale.JAPAN, "%02d", dayOfMonth);
|
||||||
thirdDay = stringYear + stringMonth + stringDayOfMonth;
|
thirdDayString = stringYearString + stringMonthString + stringDayOfMonthString;
|
||||||
setThirdDay.setText(str);
|
setThirdDay.setText(str);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -276,28 +276,28 @@ public class SetUpActivity extends FragmentActivity
|
||||||
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
||||||
String str = String.format(Locale.JAPAN, "%02d:%02d", hourOfDay, minute); // Textviewに保存する形式を設定
|
String str = String.format(Locale.JAPAN, "%02d:%02d", hourOfDay, minute); // Textviewに保存する形式を設定
|
||||||
|
|
||||||
if (isStartTimeSelected == 1) {
|
if (isStartTimeSelectedInt == 1) {
|
||||||
stringHourOfDay = String.format("%02d", hourOfDay);
|
stringHourOfDayString = String.format("%02d", hourOfDay);
|
||||||
stringMinute = String.format("%02d", minute);
|
stringMinuteString = String.format("%02d", minute);
|
||||||
startTime = stringHourOfDay + stringMinute;
|
startTimeString = stringHourOfDayString + stringMinuteString;
|
||||||
setStartTime.setText(str);
|
setStartTime.setText(str);
|
||||||
|
|
||||||
} else if (isStartTimeSelected == 2) {
|
} else if (isStartTimeSelectedInt == 2) {
|
||||||
stringHourOfDay = String.format("%02d", hourOfDay);
|
stringHourOfDayString = String.format("%02d", hourOfDay);
|
||||||
stringMinute = String.format("%02d", minute);
|
stringMinuteString = String.format("%02d", minute);
|
||||||
endTime = stringHourOfDay + stringMinute;
|
endTimeString = stringHourOfDayString + stringMinuteString;
|
||||||
setEndTime.setText(str);
|
setEndTime.setText(str);
|
||||||
|
|
||||||
} else if (isStartTimeSelected == 3) {
|
} else if (isStartTimeSelectedInt == 3) {
|
||||||
stringHourOfDay = String.format("%02d", hourOfDay);
|
stringHourOfDayString = String.format("%02d", hourOfDay);
|
||||||
stringMinute = String.format("%02d", minute);
|
stringMinuteString = String.format("%02d", minute);
|
||||||
startBreakTime =stringHourOfDay + stringMinute;
|
startBreakTimeString =stringHourOfDayString + stringMinuteString;
|
||||||
setStartBreakTime.setText(" " + str + " ");
|
setStartBreakTime.setText(" " + str + " ");
|
||||||
|
|
||||||
} else if (isStartTimeSelected == 4) {
|
} else if (isStartTimeSelectedInt == 4) {
|
||||||
stringHourOfDay = String.format("%02d", hourOfDay);
|
stringHourOfDayString = String.format("%02d", hourOfDay);
|
||||||
stringMinute = String.format("%02d", minute);
|
stringMinuteString = String.format("%02d", minute);
|
||||||
endBreakTime = stringHourOfDay + stringMinute;
|
endBreakTimeString = stringHourOfDayString + stringMinuteString;
|
||||||
setEndBreakTime.setText(" " + str + " ");
|
setEndBreakTime.setText(" " + str + " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package com.example.oplogy;
|
package com.example.oplogy;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import com.example.oplogy.databinding.SubmissionBinding;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -15,9 +13,8 @@ import java.util.List;
|
||||||
public class SubmissionActivity extends AppCompatActivity {
|
public class SubmissionActivity extends AppCompatActivity {
|
||||||
private RecyclerView recyclerView;
|
private RecyclerView recyclerView;
|
||||||
private SubmissionAdapter submissionAdapter;
|
private SubmissionAdapter submissionAdapter;
|
||||||
private List<SubmissionStudent> students = new ArrayList<>();
|
private final List<SubmissionStudent> studentsList = new ArrayList<>();
|
||||||
ArrayList<Integer> studentNumbers = new ArrayList<>();
|
ArrayList<Integer> studentNumbersList = new ArrayList<>();
|
||||||
private int totalStudent = 10;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -26,17 +23,15 @@ public class SubmissionActivity extends AppCompatActivity {
|
||||||
|
|
||||||
// 戻るボタンの処理
|
// 戻るボタンの処理
|
||||||
ImageView backButton = findViewById(R.id.BackMain_fromSubmission);
|
ImageView backButton = findViewById(R.id.BackMain_fromSubmission);
|
||||||
backButton.setOnClickListener(v -> {
|
backButton.setOnClickListener(v -> finish());
|
||||||
finish();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// インテントから提出状況の生徒の数を取得
|
// インテントから提出状況の生徒の数を取得
|
||||||
studentNumbers=getIntent().getIntegerArrayListExtra("submissionStudents");
|
studentNumbersList=getIntent().getIntegerArrayListExtra("submissionStudents");
|
||||||
|
|
||||||
recyclerView = findViewById(R.id.recyclerView);
|
recyclerView = findViewById(R.id.recyclerView);
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||||
submissionAdapter = new SubmissionAdapter(students);
|
submissionAdapter = new SubmissionAdapter(studentsList);
|
||||||
recyclerView.setAdapter(submissionAdapter);
|
recyclerView.setAdapter(submissionAdapter);
|
||||||
|
|
||||||
// 生徒のリストを取得
|
// 生徒のリストを取得
|
||||||
|
@ -44,12 +39,10 @@ public class SubmissionActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
private void fetchStudents() {
|
private void fetchStudents() {
|
||||||
// インテントから生徒のリストを取得
|
// インテントから生徒のリストを取得
|
||||||
ArrayList<SubmissionStudent> submissionStudents = getIntent().getParcelableArrayListExtra("submissionStudents");
|
ArrayList<SubmissionStudent> submissionStudentsList = getIntent().getParcelableArrayListExtra("submissionStudents");
|
||||||
|
|
||||||
// 生徒のリストを反復処理し、それをRecyclerViewに表示
|
// 生徒のリストを反復処理し、それをRecyclerViewに表示
|
||||||
for (SubmissionStudent student : submissionStudents) {
|
studentsList.addAll(submissionStudentsList);
|
||||||
students.add(student);
|
|
||||||
}
|
|
||||||
|
|
||||||
// データが変更されたことをアダプターに通知
|
// データが変更されたことをアダプターに通知
|
||||||
submissionAdapter.notifyDataSetChanged();
|
submissionAdapter.notifyDataSetChanged();
|
||||||
|
|
|
@ -5,12 +5,14 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SubmissionAdapter extends RecyclerView.Adapter<SubmissionAdapter.StudentViewHolder> {
|
public class SubmissionAdapter extends RecyclerView.Adapter<SubmissionAdapter.StudentViewHolder> {
|
||||||
|
|
||||||
private List<SubmissionStudent> students;
|
private final List<SubmissionStudent> studentsList;
|
||||||
|
|
||||||
public static class StudentViewHolder extends RecyclerView.ViewHolder {
|
public static class StudentViewHolder extends RecyclerView.ViewHolder {
|
||||||
public TextView studentNumberTextView;
|
public TextView studentNumberTextView;
|
||||||
|
@ -25,9 +27,10 @@ public class SubmissionAdapter extends RecyclerView.Adapter<SubmissionAdapter.St
|
||||||
}
|
}
|
||||||
|
|
||||||
public SubmissionAdapter(List<SubmissionStudent> students) {
|
public SubmissionAdapter(List<SubmissionStudent> students) {
|
||||||
this.students = students;
|
this.studentsList = students;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public StudentViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
public StudentViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
View view = LayoutInflater.from(parent.getContext())
|
View view = LayoutInflater.from(parent.getContext())
|
||||||
|
@ -37,7 +40,7 @@ public class SubmissionAdapter extends RecyclerView.Adapter<SubmissionAdapter.St
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(StudentViewHolder holder, int position) {
|
public void onBindViewHolder(StudentViewHolder holder, int position) {
|
||||||
SubmissionStudent student = students.get(position);
|
SubmissionStudent student = studentsList.get(position);
|
||||||
holder.studentNumberTextView.setText(String.valueOf(student.getStudentNumber()));
|
holder.studentNumberTextView.setText(String.valueOf(student.getStudentNumber()));
|
||||||
// 提出済みかどうかで表示を変える
|
// 提出済みかどうかで表示を変える
|
||||||
if (student.isSubmitted()) {
|
if (student.isSubmitted()) {
|
||||||
|
@ -57,6 +60,6 @@ public class SubmissionAdapter extends RecyclerView.Adapter<SubmissionAdapter.St
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return students.size();
|
return studentsList.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,16 +3,16 @@ import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
public class SubmissionStudent implements Parcelable {
|
public class SubmissionStudent implements Parcelable {
|
||||||
private int studentNumber;
|
private int studentNumberInt;
|
||||||
private boolean submitted;
|
private boolean submitted;
|
||||||
|
|
||||||
public SubmissionStudent(int studentNumber, boolean submitted) {
|
public SubmissionStudent(int studentNumber, boolean submitted) {
|
||||||
this.studentNumber = studentNumber;
|
this.studentNumberInt = studentNumber;
|
||||||
this.submitted = submitted;
|
this.submitted = submitted;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SubmissionStudent(Parcel in) {
|
protected SubmissionStudent(Parcel in) {
|
||||||
studentNumber = in.readInt();
|
studentNumberInt = in.readInt();
|
||||||
submitted = in.readByte() != 0;
|
submitted = in.readByte() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ public class SubmissionStudent implements Parcelable {
|
||||||
};
|
};
|
||||||
|
|
||||||
public int getStudentNumber() {
|
public int getStudentNumber() {
|
||||||
return studentNumber;
|
return studentNumberInt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSubmitted() {
|
public boolean isSubmitted() {
|
||||||
|
@ -43,7 +43,7 @@ public class SubmissionStudent implements Parcelable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel parcel, int i) {
|
public void writeToParcel(Parcel parcel, int i) {
|
||||||
parcel.writeInt(studentNumber);
|
parcel.writeInt(studentNumberInt);
|
||||||
parcel.writeByte((byte) (submitted ? 1 : 0));
|
parcel.writeByte((byte) (submitted ? 1 : 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,7 +2,6 @@ package com.example.oplogy;
|
||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.TimePickerDialog;
|
import android.app.TimePickerDialog;
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.widget.TimePicker;
|
import android.widget.TimePicker;
|
||||||
|
|
||||||
|
@ -18,14 +17,14 @@ public class TimePick extends DialogFragment implements
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) { // TimePeckerの生成
|
public Dialog onCreateDialog(Bundle savedInstanceState) { // TimePeckerの生成
|
||||||
final Calendar c = Calendar.getInstance();
|
final Calendar c = Calendar.getInstance();
|
||||||
int hour = c.get(Calendar.HOUR_OF_DAY);
|
int hourInt = c.get(Calendar.HOUR_OF_DAY);
|
||||||
int minute = c.get(Calendar.MINUTE);
|
int minuteInt = c.get(Calendar.MINUTE);
|
||||||
|
|
||||||
return new TimePickerDialog((Context) getActivity(),
|
return new TimePickerDialog(getActivity(),
|
||||||
(TimePickerDialog.OnTimeSetListener) getActivity(), hour, minute, true);
|
(TimePickerDialog.OnTimeSetListener) getActivity(), hourInt, minuteInt, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
public void onTimeSet(TimePicker view, int hourOfDayInt, int minuteInt) {
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user