Merge remote-tracking branch 'origin/api' into api
This commit is contained in:
commit
02212be21e
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -51,7 +51,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
|
|
||||||
//取得するためのクラスID
|
//取得するためのクラスID
|
||||||
private int classId;
|
private int classId;
|
||||||
private String address;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -196,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 {
|
||||||
|
@ -272,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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,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,12 +44,9 @@ 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[]{
|
private static final int[] COLORS = new int[]{Color.parseColor("#007FFF"), // HUE_AZURE
|
||||||
Color.parseColor("#007FFF"), // HUE_AZURE
|
|
||||||
Color.parseColor("#0000FF"), // HUE_BLUE
|
Color.parseColor("#0000FF"), // HUE_BLUE
|
||||||
Color.parseColor("#00FFFF"), // HUE_CYAN
|
Color.parseColor("#00FFFF"), // HUE_CYAN
|
||||||
Color.parseColor("#00FF00"), // HUE_GREEN
|
Color.parseColor("#00FF00"), // HUE_GREEN
|
||||||
|
@ -61,36 +58,35 @@ 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());
|
||||||
|
|
||||||
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
|
// マップフラグメントの設定
|
||||||
.findFragmentById(R.id.map);
|
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
|
||||||
mapFragment.getMapAsync(this);
|
mapFragment.getMapAsync(this);
|
||||||
|
|
||||||
|
// 各UI要素の設定
|
||||||
backMain = findViewById(R.id.BackMain);
|
backMain = findViewById(R.id.BackMain);
|
||||||
backMain.setOnClickListener(this);
|
backMain.setOnClickListener(this);
|
||||||
|
|
||||||
locationsName = findViewById(R.id.locationsName);
|
locationsName = findViewById(R.id.locationsName);
|
||||||
|
|
||||||
String dateData = formatDate(getSharedPreferencesData(0)) + "/" + formatDate(getSharedPreferencesData(1)) + "/" + formatDate(getSharedPreferencesData(2));
|
// スピナーの設定
|
||||||
|
String dateDataString = formatDate(getSharedPreferencesData(0)) + "/" + formatDate(getSharedPreferencesData(1)) + "/" + formatDate(getSharedPreferencesData(2));
|
||||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item);
|
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item);
|
||||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
String[] dates = dateData.split("/");
|
String[] dates = dateDataString.split("/");
|
||||||
for (String date : dates) {
|
for (String date : dates) {
|
||||||
adapter.add(date);
|
adapter.add(date);
|
||||||
}
|
}
|
||||||
|
@ -100,22 +96,18 @@ public class Maps extends FragmentActivity implements OnMapReadyCallback, View.O
|
||||||
int finalI = i;
|
int finalI = i;
|
||||||
String dayString = getSharedPreferencesData(i);
|
String dayString = getSharedPreferencesData(i);
|
||||||
String formattedDayString = formatDate(dayString);
|
String formattedDayString = formatDate(dayString);
|
||||||
if (i == 0) {
|
dateMap.put(formattedDayString, () -> loadMapAndNames(createlocationData(finalI), getscrollViewlData(finalI)));
|
||||||
dateMap.put(formattedDayString, () -> firstMapAndNames(createlocationData(finalI), getData(finalI)));
|
|
||||||
} else if (i == 1) {
|
|
||||||
dateMap.put(formattedDayString, () -> secondMapAndNames(createlocationData(finalI), getData(finalI)));
|
|
||||||
} else {
|
|
||||||
dateMap.put(formattedDayString, () -> thirdMapAndNames(createlocationData(finalI), getData(finalI)));
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
dateSpinner = findViewById(R.id.date);
|
Spinner dateSpinner = findViewById(R.id.date);
|
||||||
dateSpinner.setAdapter(adapter);
|
dateSpinner.setAdapter(adapter);
|
||||||
|
|
||||||
|
// スピナーのアイテム選択リスナーを設定
|
||||||
dateSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
dateSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
String selectedItem = (String) parent.getItemAtPosition(position);
|
String selectedItemString = (String) parent.getItemAtPosition(position);
|
||||||
Runnable mapLoader = dateMap.get(selectedItem);
|
Runnable mapLoader = dateMap.get(selectedItemString);
|
||||||
if (mapLoader != null) {
|
if (mapLoader != null) {
|
||||||
mapLoader.run();
|
mapLoader.run();
|
||||||
}
|
}
|
||||||
|
@ -128,16 +120,22 @@ public class Maps extends FragmentActivity implements OnMapReadyCallback, View.O
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//ルート表示を押して最初に表示されるルート(3日間の家庭訪問における1日目)の設定
|
||||||
@Override
|
@Override
|
||||||
public void onMapReady(GoogleMap googleMap) {
|
public void onMapReady(GoogleMap googleMap) {
|
||||||
|
//Google mapの定義
|
||||||
mMap = googleMap;
|
mMap = googleMap;
|
||||||
mMap.setOnMarkerClickListener(this);
|
mMap.setOnMarkerClickListener(this);
|
||||||
String latlngString = createlocationData(0);
|
//家庭訪問1日目のスケジュール順に緯度経度の情報をString型の変数に格納
|
||||||
String homeVisitDataString = getData(0);
|
//35.1711355,136.88552149999998/35.1696089,136.884084/35.1732838,136.88832890000003/...
|
||||||
firstMapAndNames(latlngString, homeVisitDataString);
|
String locationDataString = createlocationData(0);
|
||||||
|
//家庭訪問1日目のスケジュール順に住所や出席番号、家庭訪問の開始時間の情報をString型の変数に格納
|
||||||
|
//開始地点/出席番号2番:鈴木次郎<〒453-0015 愛知県名古屋市中村区椿町6−9 地下1階~5階> 06月04日12時00分/...
|
||||||
|
String scrollViewlDataString = getscrollViewlData(0);
|
||||||
|
loadMapAndNames(locationDataString, scrollViewlDataString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//家庭訪問の〇日目が何月何日かを返すメソッド
|
||||||
private String getSharedPreferencesData(int i) {
|
private String getSharedPreferencesData(int i) {
|
||||||
SharedPreferences sharedPreferences = getSharedPreferences("visitingDate", MODE_PRIVATE);
|
SharedPreferences sharedPreferences = getSharedPreferences("visitingDate", MODE_PRIVATE);
|
||||||
// SetUpで設定した8桁の数字表記の家庭訪問日を日付表記に変更
|
// SetUpで設定した8桁の数字表記の家庭訪問日を日付表記に変更
|
||||||
|
@ -152,49 +150,59 @@ public class Maps extends FragmentActivity implements OnMapReadyCallback, View.O
|
||||||
return dayString;
|
return dayString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//家庭訪問の日付を8桁の整数表記から○月〇日(20240707→07月07日)表記に変更する
|
||||||
private String formatDate(String date) {
|
private String formatDate(String date) {
|
||||||
if (date == null || date.length() != 8) {
|
if (date == null || date.length() != 8) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
String month = date.substring(4, 6);
|
String monthString = date.substring(4, 6);
|
||||||
String day = date.substring(6, 8);
|
String dayString = date.substring(6, 8);
|
||||||
return month + "月" + day + "日";
|
return monthString + "月" + dayString + "日";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//家庭訪問1日目のスケジュール順に緯度経度の情報をString型の変数に格納
|
||||||
private String createlocationData(int i) {
|
private String createlocationData(int i) {
|
||||||
|
//家庭訪問の開始地点の緯度経度
|
||||||
String startPointLatLngString = getIntent().getStringExtra("startPointLatLngString");
|
String startPointLatLngString = getIntent().getStringExtra("startPointLatLngString");
|
||||||
List<MyDataClass> myDataList = getMyDataList();
|
List<MyDataClass> myDataList = getMyDataList();
|
||||||
|
//家庭訪問の緯度経度情報をまとめる変数
|
||||||
StringBuilder latlngString = new StringBuilder();
|
StringBuilder latlngString = new StringBuilder();
|
||||||
|
|
||||||
for (int y = -1; y < myDataList.size(); y++) {
|
for (int y = -1; y < myDataList.size(); y++) {
|
||||||
if (y < 0) {
|
if (y < 0) {
|
||||||
|
//家庭訪問の開始地点を追加
|
||||||
latlngString.append(startPointLatLngString);
|
latlngString.append(startPointLatLngString);
|
||||||
} else if (myDataList.get(y).getScheduleDay().equals(getSharedPreferencesData(i))) {
|
} else if (myDataList.get(y).getScheduleDay().equals(getSharedPreferencesData(i))) {
|
||||||
if (latlngString.length() > 0) {
|
if (latlngString.length() > 0) {
|
||||||
|
//区切りのスラッシュ
|
||||||
latlngString.append("/");
|
latlngString.append("/");
|
||||||
}
|
}
|
||||||
|
//mydataListから取り出した家庭訪問の各家庭の住所の緯度経度を追加
|
||||||
|
//この時点ではlongitude latitudeのような不要な文字があるのでformatLatLngメソッドで緯度経度だけのデータにする
|
||||||
latlngString.append(formatLatLng(myDataList.get(y)));
|
latlngString.append(formatLatLng(myDataList.get(y)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//各家庭の緯度経度をまとめたものを返す
|
||||||
return latlngString.toString();
|
return latlngString.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//緯度と経度は(35.1711355,136.88552149999998)のように()の中に入っているのでそこだけを取り出す
|
||||||
private String formatLatLng(MyDataClass myData) {
|
private String formatLatLng(MyDataClass myData) {
|
||||||
String latlng = myData.getLatLngString();
|
String latlngString = myData.getLatLngString();
|
||||||
int startIndex = latlng.indexOf("(") + 1;
|
int startIndex = latlngString.indexOf("(") + 1;
|
||||||
int endIndex = latlng.indexOf(")");
|
int endIndex = latlngString.indexOf(")");
|
||||||
return latlng.substring(startIndex, endIndex);
|
return latlngString.substring(startIndex, endIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getData(int i) {
|
//ScrollViewにて表示するdataの作成メソッド
|
||||||
|
private String getscrollViewlData(int i) {
|
||||||
List<MyDataClass> myDataList = getMyDataList();
|
List<MyDataClass> myDataList = getMyDataList();
|
||||||
String homeVisitDataString = "";
|
String homeVisitDataString = "";
|
||||||
for (int y = -1; y < myDataList.size(); y++) {
|
for (int y = -1; y < myDataList.size(); y++) {
|
||||||
if (y < 0) {
|
if (y < 0) {
|
||||||
|
//家庭訪問の開始地点
|
||||||
homeVisitDataString += "開始地点/";
|
homeVisitDataString += "開始地点/";
|
||||||
} else if (myDataList.get(y).getScheduleDay().equals(getSharedPreferencesData(i)) && y + 1 < myDataList.size()) {
|
} else if (myDataList.get(y).getScheduleDay().equals(getSharedPreferencesData(i)) && y + 1 < myDataList.size()) {
|
||||||
|
//出席番号:生徒の名前 <住所> 家庭訪問の開始時間+/
|
||||||
homeVisitDataString += "出席番号" + String.valueOf(myDataList.get(y).getStudentNumber()) + "番:" + myDataList.get(y).getChildName() + "<" + myDataList.get(y).getAddress().get(0) + "> " + formatSchedule(String.valueOf(myDataList.get(y).getSchedule())) + "/";
|
homeVisitDataString += "出席番号" + String.valueOf(myDataList.get(y).getStudentNumber()) + "番:" + myDataList.get(y).getChildName() + "<" + myDataList.get(y).getAddress().get(0) + "> " + formatSchedule(String.valueOf(myDataList.get(y).getSchedule())) + "/";
|
||||||
} else if (myDataList.get(y).getScheduleDay().equals(getSharedPreferencesData(i))) {
|
} else if (myDataList.get(y).getScheduleDay().equals(getSharedPreferencesData(i))) {
|
||||||
homeVisitDataString += "出席番号" + String.valueOf(myDataList.get(y).getStudentNumber()) + "番:" + myDataList.get(y).getChildName() + " <" + myDataList.get(y).getAddress().get(0) + "> " + formatSchedule(String.valueOf(myDataList.get(y).getSchedule()));
|
homeVisitDataString += "出席番号" + String.valueOf(myDataList.get(y).getStudentNumber()) + "番:" + myDataList.get(y).getChildName() + " <" + myDataList.get(y).getAddress().get(0) + "> " + formatSchedule(String.valueOf(myDataList.get(y).getSchedule()));
|
||||||
|
@ -203,12 +211,13 @@ public class Maps extends FragmentActivity implements OnMapReadyCallback, View.O
|
||||||
return homeVisitDataString;
|
return homeVisitDataString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//家庭訪問のscheduleを7桁の整数から○月〇日●時〇分(6041200→06月12日05時20分)に変換
|
||||||
private String formatSchedule(String schedule) {
|
private String formatSchedule(String schedule) {
|
||||||
String month = "0" + schedule.substring(0, 1);
|
String monthString = "0" + schedule.substring(0, 1);
|
||||||
String day = schedule.substring(1, 3);
|
String dayString = schedule.substring(1, 3);
|
||||||
String hour = schedule.substring(3, 5);
|
String hourString = schedule.substring(3, 5);
|
||||||
String minute = schedule.substring(5, 7);
|
String minuteString = schedule.substring(5, 7);
|
||||||
return month + "月" + day + "日" + hour + "時" + minute + "分";
|
return monthString + "月" + dayString + "日" + hourString + "時" + minuteString + "分";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 共有プリファレンスからMyDataListを取得するメソッド
|
// 共有プリファレンスからMyDataListを取得するメソッド
|
||||||
|
@ -217,40 +226,22 @@ public class Maps extends FragmentActivity implements OnMapReadyCallback, View.O
|
||||||
SharedPreferences sharedPreferences = getSharedPreferences("MyDataList", MODE_PRIVATE);
|
SharedPreferences sharedPreferences = getSharedPreferences("MyDataList", MODE_PRIVATE);
|
||||||
|
|
||||||
// 共有プリファレンスからJSON形式のデータを取得
|
// 共有プリファレンスからJSON形式のデータを取得
|
||||||
String json = sharedPreferences.getString("myDataList", "");
|
String jsonString = sharedPreferences.getString("myDataList", "");
|
||||||
|
|
||||||
// JSON形式のデータをMyDataListに変換
|
// JSON形式のデータをMyDataListに変換
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
Type type = new TypeToken<List<MyDataClass>>() {
|
Type type = new TypeToken<List<MyDataClass>>() {
|
||||||
}.getType();
|
}.getType();
|
||||||
List<MyDataClass> myDataList = gson.fromJson(json, type);
|
List<MyDataClass> myDataList = gson.fromJson(jsonString, type);
|
||||||
|
|
||||||
return myDataList;
|
return myDataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void firstMapAndNames(String latlngStringFirstDay, String homeVisitDataString) {
|
|
||||||
String locationData = latlngStringFirstDay;
|
|
||||||
String labelData = homeVisitDataString;
|
|
||||||
Log.d("maps", "locationData" + locationData);
|
|
||||||
Log.d("maps", "labelData" + labelData);
|
|
||||||
loadMapAndNames(locationData, labelData);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void secondMapAndNames(String latlngStringSeconfDay, String homeVisitDataString) {
|
|
||||||
String locationData = latlngStringSeconfDay;
|
|
||||||
String labelData = homeVisitDataString;
|
|
||||||
loadMapAndNames(locationData, labelData);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void thirdMapAndNames(String latlngStringThirdDay, String homeVisitDataString) {
|
|
||||||
String locationData = latlngStringThirdDay;
|
|
||||||
String labelData = homeVisitDataString;
|
|
||||||
loadMapAndNames(locationData, labelData);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
//mapやgetscrollViewlに値を渡すハブの役割のメソッド
|
||||||
private void loadMapAndNames(String locationData, String nameData) {
|
private void loadMapAndNames(String locationData, String nameData) {
|
||||||
try {
|
try {
|
||||||
|
//mapに関するすべてのデータをリセット
|
||||||
latLngList.clear();
|
latLngList.clear();
|
||||||
nameList.clear();
|
nameList.clear();
|
||||||
colorList.clear();
|
colorList.clear();
|
||||||
|
@ -258,31 +249,31 @@ public class Maps extends FragmentActivity implements OnMapReadyCallback, View.O
|
||||||
mMap.clear();
|
mMap.clear();
|
||||||
|
|
||||||
// locationDataをスラッシュで分割して緯度経度リストを取得
|
// locationDataをスラッシュで分割して緯度経度リストを取得
|
||||||
String[] locArray = locationData.split("/");
|
String[] locArrayString = locationData.split("/");
|
||||||
// nameDataをスラッシュで分割して名前リストを取得
|
// nameDataをスラッシュで分割して名前リストを取得
|
||||||
String[] nameArray = nameData.split("/");
|
String[] nameArrayString = nameData.split("/");
|
||||||
|
|
||||||
for (int i = 0; i < locArray.length; i++) {
|
for (int i = 0; i < locArrayString.length; i++) {
|
||||||
// 緯度経度をカンマで分割してLatLngオブジェクトを作成
|
// 緯度経度をカンマで分割してLatLngオブジェクトを作成
|
||||||
String[] latLng = locArray[i].split(",");
|
String[] latLngString = locArrayString[i].split(",");
|
||||||
if (latLng.length == 2) {
|
if (latLngString.length == 2) {
|
||||||
double latitude = Double.parseDouble(latLng[0]);
|
double latitudeDouble = Double.parseDouble(latLngString[0]);
|
||||||
double longitude = Double.parseDouble(latLng[1]);
|
double longitudeDouble = Double.parseDouble(latLngString[1]);
|
||||||
LatLng position = new LatLng(latitude, longitude);
|
LatLng position = new LatLng(latitudeDouble, longitudeDouble);
|
||||||
latLngList.add(position);
|
latLngList.add(position);
|
||||||
|
|
||||||
// 名前リストから対応する名前を取得
|
// 名前リストから対応する名前を取得
|
||||||
String name = nameArray.length > i ? nameArray[i] : "Unknown";
|
String nameString = nameArrayString.length > i ? nameArrayString[i] : "Unknown";
|
||||||
nameList.add(name);
|
nameList.add(nameString);
|
||||||
|
|
||||||
// 色リストから次の色を取得
|
// 色リストから次の色を取得
|
||||||
int color = getNextColor();
|
int colorInt = getNextColor();
|
||||||
colorList.add(color);
|
colorList.add(colorInt);
|
||||||
|
|
||||||
// 地図にピンを追加
|
// 地図にピンを追加
|
||||||
addPinToMap(name, position, color);
|
addPinToMap(nameString, position, colorInt);
|
||||||
// スクロールビューに場所を追加
|
// スクロールビューに場所を追加
|
||||||
addLocationToScrollView(name, color);
|
addLocationToScrollView(nameString, colorInt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,10 +283,12 @@ public class Maps extends FragmentActivity implements OnMapReadyCallback, View.O
|
||||||
drawRoute(); // ルートを描画するメソッドを呼び出す
|
drawRoute(); // ルートを描画するメソッドを呼び出す
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e("Maps", "Error loading maps and names", e);
|
Log.e("Maps", "エラーが発生しました。原因は以下", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ルートを描画するメソッド
|
||||||
|
// Google マップの Directions API を使用してルート情報を取得し、ポリラインで描画
|
||||||
private void drawRoute() {
|
private void drawRoute() {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
|
@ -312,25 +305,27 @@ public class Maps extends FragmentActivity implements OnMapReadyCallback, View.O
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
urlBuilder.append("&mode=driving");
|
urlBuilder.append("&mode=driving");
|
||||||
urlBuilder.append("&key=").append(getString(R.string.maps_api_key));
|
//APiキーの設定
|
||||||
|
urlBuilder.append("&key=").append("AIzaSyBQ1Ak-I2NL5TP4K59ZI0VgzKk6HNZuusw");
|
||||||
|
|
||||||
String urlString = urlBuilder.toString();
|
String urlString = urlBuilder.toString();
|
||||||
Log.d("Maps", "Directions API URL: " + urlString);
|
Log.d("Maps", "Directions API URL: " + urlString);
|
||||||
|
|
||||||
|
// Directions APIにリクエストを送信してレスポンスを取得
|
||||||
URL url = new URL(urlString);
|
URL url = new URL(urlString);
|
||||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||||
conn.setRequestMethod("GET");
|
conn.setRequestMethod("GET");
|
||||||
InputStreamReader isr = new InputStreamReader(conn.getInputStream());
|
InputStreamReader isr = new InputStreamReader(conn.getInputStream());
|
||||||
BufferedReader br = new BufferedReader(isr);
|
BufferedReader br = new BufferedReader(isr);
|
||||||
StringBuilder jsonResults = new StringBuilder();
|
StringBuilder jsonResults = new StringBuilder();
|
||||||
String line;
|
String lineString;
|
||||||
while ((line = br.readLine()) != null) {
|
while ((lineString = br.readLine()) != null) {
|
||||||
jsonResults.append(line);
|
jsonResults.append(lineString);
|
||||||
}
|
}
|
||||||
br.close();
|
br.close();
|
||||||
|
|
||||||
Log.d("Maps", "API response: " + jsonResults.toString());
|
Log.d("Maps", "API response: " + jsonResults.toString());
|
||||||
|
// レスポンスからルート情報を取得してポリラインで描画
|
||||||
JsonObject jsonObject = new Gson().fromJson(jsonResults.toString(), JsonObject.class);
|
JsonObject jsonObject = new Gson().fromJson(jsonResults.toString(), JsonObject.class);
|
||||||
JsonArray routes = jsonObject.getAsJsonArray("routes");
|
JsonArray routes = jsonObject.getAsJsonArray("routes");
|
||||||
if (routes.size() > 0) {
|
if (routes.size() > 0) {
|
||||||
|
@ -343,36 +338,41 @@ public class Maps extends FragmentActivity implements OnMapReadyCallback, View.O
|
||||||
|
|
||||||
runOnUiThread(() -> mMap.addPolyline(new PolylineOptions().addAll(points).width(5).color(Color.BLUE)));
|
runOnUiThread(() -> mMap.addPolyline(new PolylineOptions().addAll(points).width(5).color(Color.BLUE)));
|
||||||
} else {
|
} else {
|
||||||
|
// ルートが見つからなかった場合のエラーメッセージを表示
|
||||||
JsonPrimitive errorMessage = jsonObject.getAsJsonPrimitive("error_message");
|
JsonPrimitive errorMessage = jsonObject.getAsJsonPrimitive("error_message");
|
||||||
if (errorMessage != null) {
|
if (errorMessage != null) {
|
||||||
Log.e("Maps", "Error: " + errorMessage.getAsString());
|
Log.e("Maps", "エラーが発生しました。原因は以下: " + errorMessage.getAsString());
|
||||||
} else {
|
} else {
|
||||||
Log.e("Maps", "No routes found and no error message provided");
|
Log.e("Maps", "原因不明のエラー");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e("Maps", "Error drawing route", e);
|
Log.e("Maps", "ルートの描画に失敗しました", e);
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// エンコードされた文字列から座標情報をデコードするためのメソッド
|
||||||
private List<LatLng> decodePoly(String encoded) {
|
private List<LatLng> decodePoly(String encoded) {
|
||||||
List<LatLng> poly = new ArrayList<>();
|
List<LatLng> poly = new ArrayList<>(); // 座標情報を格納するリスト
|
||||||
int index = 0, len = encoded.length();
|
int index = 0, len = encoded.length();// 文字列のインデックスと長さ
|
||||||
int lat = 0, lng = 0;
|
int latInt = 0, lng = 0; // 緯度と経度の初期値
|
||||||
|
|
||||||
|
// 文字列の長さに達するまで繰り返す
|
||||||
while (index < len) {
|
while (index < len) {
|
||||||
int b, shift = 0, result = 0;
|
int b, shift = 0, result = 0;
|
||||||
|
// バイト値を取得し、ビットシフトとOR演算を行って座標値を復元する
|
||||||
do {
|
do {
|
||||||
b = encoded.charAt(index++) - 63;
|
b = encoded.charAt(index++) - 63;
|
||||||
result |= (b & 0x1f) << shift;
|
result |= (b & 0x1f) << shift;
|
||||||
shift += 5;
|
shift += 5;
|
||||||
} while (b >= 0x20);
|
} while (b >= 0x20);
|
||||||
int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
|
int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
|
||||||
lat += dlat;
|
latInt += dlat;
|
||||||
|
|
||||||
shift = 0;
|
shift = 0;
|
||||||
result = 0;
|
result = 0;
|
||||||
|
// バイト値を取得し、ビットシフトとOR演算を行って座標値を復元する
|
||||||
do {
|
do {
|
||||||
b = encoded.charAt(index++) - 63;
|
b = encoded.charAt(index++) - 63;
|
||||||
result |= (b & 0x1f) << shift;
|
result |= (b & 0x1f) << shift;
|
||||||
|
@ -380,34 +380,35 @@ public class Maps extends FragmentActivity implements OnMapReadyCallback, View.O
|
||||||
} while (b >= 0x20);
|
} while (b >= 0x20);
|
||||||
int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
|
int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
|
||||||
lng += dlng;
|
lng += dlng;
|
||||||
|
// LatLngオブジェクトを作成してリストに追加する
|
||||||
LatLng p = new LatLng((((double) lat / 1E5)), (((double) lng / 1E5)));
|
LatLng p = new LatLng((((double) latInt / 1E5)), (((double) lng / 1E5)));
|
||||||
poly.add(p);
|
poly.add(p);
|
||||||
}
|
}
|
||||||
|
// 座標情報のリストを返す
|
||||||
return poly;
|
return poly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Colorクラスを使用して、与えられた色から色相値を計算するメソッド
|
||||||
private float getHueFromColor(int color) {
|
private float getHueFromColor(int color) {
|
||||||
float[] hsv = new float[3];
|
float[] hsv = new float[3];
|
||||||
Color.colorToHSV(color, hsv);
|
Color.colorToHSV(color, hsv);//整数の色値をHSV(色相、彩度、明度)の形式に変換し、色相値を取得します。
|
||||||
return hsv[0];
|
return hsv[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//mapにピンを追加するメソッド
|
||||||
private void addPinToMap(String locationName, LatLng position, int color) {
|
private void addPinToMap(String locationName, LatLng position, int color) {
|
||||||
Marker marker = mMap.addMarker(new MarkerOptions()
|
// マーカーオプションを作成し、位置、タイトル、色を設定する
|
||||||
.position(position)
|
Marker marker = mMap.addMarker(new MarkerOptions().position(position).title(locationName).icon(BitmapDescriptorFactory.defaultMarker(getHueFromColor(color))));
|
||||||
.title(locationName)
|
|
||||||
.icon(BitmapDescriptorFactory.defaultMarker(getHueFromColor(color)))
|
|
||||||
);
|
|
||||||
if (marker != null) {
|
if (marker != null) {
|
||||||
marker.setTag(locationName);
|
marker.setTag(locationName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// スクロールビューに位置情報を追加するメソッド
|
||||||
private void addLocationToScrollView(String locationName, int color) {
|
private void addLocationToScrollView(String locationName, int color) {
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
try {
|
try {
|
||||||
|
// テキストビューの作成
|
||||||
TextView textView = new TextView(this);
|
TextView textView = new TextView(this);
|
||||||
textView.setText(locationName);
|
textView.setText(locationName);
|
||||||
textView.setTextSize(20);
|
textView.setTextSize(20);
|
||||||
|
@ -416,7 +417,7 @@ public class Maps extends FragmentActivity implements OnMapReadyCallback, View.O
|
||||||
|
|
||||||
// テキストビューにクリックリスナーを追加
|
// テキストビューにクリックリスナーを追加
|
||||||
textView.setOnClickListener(v -> {
|
textView.setOnClickListener(v -> {
|
||||||
// 名前リストからインデックスを取得
|
// 名前リストから位置情報を取得
|
||||||
int index = nameList.indexOf(locationName);
|
int index = nameList.indexOf(locationName);
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
LatLng position = latLngList.get(index);
|
LatLng position = latLngList.get(index);
|
||||||
|
@ -425,15 +426,14 @@ public class Maps extends FragmentActivity implements OnMapReadyCallback, View.O
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 下線のビューの作成
|
||||||
View underline = new View(this);
|
View underline = new View(this);
|
||||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 3);
|
||||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
|
||||||
3
|
|
||||||
);
|
|
||||||
params.setMargins(0, 0, 0, 16);
|
params.setMargins(0, 0, 0, 16);
|
||||||
underline.setLayoutParams(params);
|
underline.setLayoutParams(params);
|
||||||
underline.setBackgroundColor(Color.BLACK);
|
underline.setBackgroundColor(Color.BLACK);
|
||||||
|
|
||||||
|
// テキストビューと下線のビューをスクロールビューに追加
|
||||||
locationsName.addView(textView);
|
locationsName.addView(textView);
|
||||||
locationsName.addView(underline);
|
locationsName.addView(underline);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -455,13 +455,20 @@ public class Maps extends FragmentActivity implements OnMapReadyCallback, View.O
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
//マーカーがクリックされた際の処理を行うメソッド
|
||||||
public boolean onMarkerClick(Marker marker) {
|
public boolean onMarkerClick(Marker marker) {
|
||||||
|
// マーカーから場所の名前を取得します。
|
||||||
String locationName = (String) marker.getTag();
|
String locationName = (String) marker.getTag();
|
||||||
|
// 場所の名前がnullではない場合に処理を実行します。
|
||||||
if (locationName != null) {
|
if (locationName != null) {
|
||||||
|
// マーカーのタイトルとして場所の名前を設定します。
|
||||||
marker.setTitle(locationName);
|
marker.setTitle(locationName);
|
||||||
|
// マーカーの情報ウィンドウを表示します。
|
||||||
marker.showInfoWindow();
|
marker.showInfoWindow();
|
||||||
}
|
}
|
||||||
|
// デフォルトの動作も実行するためにfalseを返します。
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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