Merge pull request 'ルート作成画面の遷移時にformに送られた人数が足りてない場合、警告のダイアログを出すように変更' (#9) from murakumo_setupの情報をroomに保存し隊 into master
Reviewed-on: #9
This commit is contained in:
commit
fc25e35a77
|
@ -11,6 +11,7 @@ import com.google.firebase.firestore.QueryDocumentSnapshot;
|
||||||
import com.google.firebase.firestore.QuerySnapshot;
|
import com.google.firebase.firestore.QuerySnapshot;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -63,19 +64,19 @@ public class FirestoreReception {
|
||||||
for(MyDataClass data :myDataList){
|
for(MyDataClass data :myDataList){
|
||||||
Log.i("FirestoreReceptiond", "data: " + data.toString());
|
Log.i("FirestoreReceptiond", "data: " + data.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log.w("FirestoreReceptiond", "Error getting documents.", task.getException());
|
Log.w("FirestoreReceptiond", "Error getting documents.", task.getException());
|
||||||
}
|
}
|
||||||
|
Log.i("FirestoreReceptiond", "data: " + myDataList.size());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//Dataのリストのサイズを返す
|
||||||
public int getMyDataListSize(){
|
public int getMyDataListSize(){
|
||||||
return myDataList.size();
|
return myDataList.size();
|
||||||
}
|
}
|
||||||
|
//Dataのリストを返す
|
||||||
public List<MyDataClass> getMyDataList(){
|
public List<MyDataClass> getMyDataList(){
|
||||||
return myDataList;
|
return myDataList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,14 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.room.Room;
|
||||||
|
|
||||||
import com.google.firebase.firestore.FirebaseFirestore;
|
import com.google.firebase.firestore.FirebaseFirestore;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
|
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
|
||||||
|
|
||||||
|
@ -69,7 +73,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
|
|
||||||
firestoreReception.getDocumentsByClassId(100);
|
firestoreReception.getDocumentsByClassId(100);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,10 +95,48 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
// ルート作成のクリック処理
|
// ルート作成のクリック処理
|
||||||
if(view == root){
|
if(view == root){
|
||||||
imageRoot.setImageResource(R.drawable.pin);
|
imageRoot.setImageResource(R.drawable.pin);
|
||||||
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
|
||||||
|
CountDownLatch latch = new CountDownLatch(2);
|
||||||
|
|
||||||
|
executor.execute(() -> {
|
||||||
|
AppDatabase db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "SetUpTable").build();
|
||||||
|
SetUpTableDao setUpTableDao = db.setUpTableDao();
|
||||||
|
|
||||||
|
Log.d("MainActivity", "db" + setUpTableDao.getAll());
|
||||||
|
|
||||||
|
int totalStudent = setUpTableDao.getTotalStudent();
|
||||||
|
int myDataListSize = firestoreReception.getMyDataListSize();
|
||||||
|
|
||||||
|
runOnUiThread(() -> {
|
||||||
|
if (totalStudent != myDataListSize) {
|
||||||
|
showRouteCreationDialog(latch);
|
||||||
|
} else {
|
||||||
|
latch.countDown();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
executor.execute(() -> {
|
||||||
List<MyDataClass> myDataList = firestoreReception.getMyDataList();
|
List<MyDataClass> myDataList = firestoreReception.getMyDataList();
|
||||||
CreateRoot createRoot = new CreateRoot(MainActivity.this);
|
CreateRoot createRoot = new CreateRoot(MainActivity.this);
|
||||||
createRoot.receiveData(myDataList);
|
createRoot.receiveData(myDataList);
|
||||||
|
latch.countDown();
|
||||||
|
});
|
||||||
|
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
latch.await(); // Both tasks must call countDown() before this returns
|
||||||
|
runOnUiThread(() -> {
|
||||||
|
Intent toRoot = new Intent(MainActivity.this, Maps.class);
|
||||||
|
startActivity(toRoot);
|
||||||
|
});
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
|
||||||
|
executor.shutdown();
|
||||||
}
|
}
|
||||||
// 提出状況のクリック処理
|
// 提出状況のクリック処理
|
||||||
if(view == submission){
|
if(view == submission){
|
||||||
|
@ -103,7 +144,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
startActivity(toSubmission);
|
startActivity(toSubmission);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showUUIDYesNoDialog() {
|
private void showUUIDYesNoDialog() {
|
||||||
//ダイアログの表示
|
//ダイアログの表示
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
@ -127,4 +167,23 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
});
|
});
|
||||||
builder.show();
|
builder.show();
|
||||||
}
|
}
|
||||||
|
//ルート作成のダイアログ
|
||||||
|
private void showRouteCreationDialog(CountDownLatch latch) {
|
||||||
|
new AlertDialog.Builder(MainActivity.this)
|
||||||
|
.setTitle("警告")
|
||||||
|
.setMessage("人数が足りてませんがそれでもルート作成を行いますか?")
|
||||||
|
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
latch.countDown();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.show();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -178,6 +178,8 @@ public class SetUpActivity extends FragmentActivity
|
||||||
showTimePickerDialog();
|
showTimePickerDialog();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//リセットボタンの処理
|
||||||
|
|
||||||
reset.setOnClickListener(v -> { //テキストとラジオボタンの選択を消去
|
reset.setOnClickListener(v -> { //テキストとラジオボタンの選択を消去
|
||||||
setTeacherName.setText("");
|
setTeacherName.setText("");
|
||||||
setStartPoint.setText("");
|
setStartPoint.setText("");
|
||||||
|
@ -189,6 +191,13 @@ public class SetUpActivity extends FragmentActivity
|
||||||
setStartBreakTime.setText("");
|
setStartBreakTime.setText("");
|
||||||
setEndBreakTime.setText("");
|
setEndBreakTime.setText("");
|
||||||
setTotalStudent.setText("");
|
setTotalStudent.setText("");
|
||||||
|
|
||||||
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
executor.execute(() -> {
|
||||||
|
AppDatabase db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "SetUpTable").build();
|
||||||
|
SetUpTableDao setUpTableDao = db.setUpTableDao();
|
||||||
|
setUpTableDao.deleteAll();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
package com.example.oplogy;
|
package com.example.oplogy;
|
||||||
|
|
||||||
import androidx.room.Dao;
|
import androidx.room.Dao;
|
||||||
import androidx.room.Insert;
|
import androidx.room.Insert;
|
||||||
import androidx.room.Query;
|
import androidx.room.Query;
|
||||||
import androidx.room.Update;
|
import androidx.room.Update;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
public interface SetUpTableDao {
|
public interface SetUpTableDao {
|
||||||
@Insert
|
@Insert
|
||||||
|
@ -13,20 +14,22 @@ public interface SetUpTableDao {
|
||||||
@Update
|
@Update
|
||||||
void update(SetUpTable setUpTable);
|
void update(SetUpTable setUpTable);
|
||||||
//名前が一致しているかの確認
|
//名前が一致しているかの確認
|
||||||
|
|
||||||
|
//削除処理
|
||||||
|
@Query("DELETE FROM SetUpTable")
|
||||||
|
void deleteAll();
|
||||||
|
//全件取得
|
||||||
|
@Query("SELECT * FROM SetUpTable")
|
||||||
|
List<SetUpTable> getAll();
|
||||||
|
|
||||||
@Query("SELECT * FROM SetUpTable WHERE teacherName = :name LIMIT 1")
|
@Query("SELECT * FROM SetUpTable WHERE teacherName = :name LIMIT 1")
|
||||||
SetUpTable findByName(String name);
|
SetUpTable findByName(String name);
|
||||||
|
|
||||||
|
@Query("SELECT totalStudent FROM SetUpTable")
|
||||||
|
int getTotalStudent();
|
||||||
//開始時間と終了時間の取得
|
//開始時間と終了時間の取得
|
||||||
@Query("SELECT startTime FROM SetUpTable")
|
@Query("SELECT startTime FROM SetUpTable")
|
||||||
String getStartTime();
|
String getStartTime();
|
||||||
@Query("SELECT endTime FROM SetUpTable")
|
@Query("SELECT endTime FROM SetUpTable")
|
||||||
String getEndTime();
|
String getEndTime();
|
||||||
//インターバル時間の取得
|
|
||||||
@Query("SELECT intervalTime FROM SetUpTable")
|
|
||||||
String getIntervalTime();
|
|
||||||
//休憩開始時間の取得
|
|
||||||
@Query("SELECT startBreakTime FROM SetUpTable")
|
|
||||||
String getStartBreakTime();
|
|
||||||
//休憩終了時間の取得
|
|
||||||
@Query("SELECT endBreakTime FROM SetUpTable")
|
|
||||||
String getEndBreakTime();
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user