型をStringからIntegerに変更
This commit is contained in:
parent
97ce89789b
commit
845557220d
|
@ -5,12 +5,12 @@ import java.util.List;
|
||||||
|
|
||||||
public class CreateUUID {
|
public class CreateUUID {
|
||||||
|
|
||||||
public static int generateUUID(List<String> classIdList ){
|
public static int generateUUID(List<Integer> classIdList ){
|
||||||
while (true){
|
while (true){
|
||||||
String uuid = String.valueOf((int)(Math.random() * 1000000));
|
int uuid = (int)(Math.random() * 1000000);
|
||||||
boolean isDuplicate = false;
|
boolean isDuplicate = false;
|
||||||
for(String classId : classIdList){
|
for(int classId : classIdList){
|
||||||
if(classId.equals(uuid)){
|
if(classId==uuid){
|
||||||
//重複があればフラグを立て、ループを抜ける
|
//重複があればフラグを立て、ループを抜ける
|
||||||
isDuplicate = true;
|
isDuplicate = true;
|
||||||
break;
|
break;
|
||||||
|
@ -19,9 +19,11 @@ public class CreateUUID {
|
||||||
//重複がなければ生成したUUIDを返す
|
//重複がなければ生成したUUIDを返す
|
||||||
if (!isDuplicate) {
|
if (!isDuplicate) {
|
||||||
//firestoreに挿入処理
|
//firestoreに挿入処理
|
||||||
|
InsertClassIdforFirebase insertClassIdforFirebase = new InsertClassIdforFirebase();
|
||||||
|
insertClassIdforFirebase.insertClassId(uuid);
|
||||||
//テスト用
|
//テスト用
|
||||||
uuid="100";
|
uuid=100;
|
||||||
return Integer.parseInt(uuid);
|
return uuid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,14 +17,14 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
public class FirestoreReception_classIdDatabase {
|
public class FirestoreReception_classIdDatabase {
|
||||||
private FirebaseFirestore db;
|
private FirebaseFirestore db;
|
||||||
private List<String> classIdList= new ArrayList<>();
|
private List<Integer> classIdList= new ArrayList<>();
|
||||||
|
|
||||||
public FirestoreReception_classIdDatabase() {
|
public FirestoreReception_classIdDatabase() {
|
||||||
db = FirebaseFirestore.getInstance();
|
db = FirebaseFirestore.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<String> getAllDocumentsFromClassIdDatabase() {
|
public List<Integer> getAllDocumentsFromClassIdDatabase() {
|
||||||
db.collection("classId_Database")
|
db.collection("classId_Database")
|
||||||
.get()
|
.get()
|
||||||
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
|
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
|
||||||
|
@ -34,7 +34,7 @@ public class FirestoreReception_classIdDatabase {
|
||||||
for (QueryDocumentSnapshot document : task.getResult()) {
|
for (QueryDocumentSnapshot document : task.getResult()) {
|
||||||
Log.d("結果", document.getId() + " => " + document.getData());
|
Log.d("結果", document.getId() + " => " + document.getData());
|
||||||
//データをListに追加
|
//データをListに追加
|
||||||
classIdList.add((String) document.get("classId"));
|
classIdList.add(((Long) document.get("classId")).intValue());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.d("結果", "Error getting documents: ", task.getException());
|
Log.d("結果", "Error getting documents: ", task.getException());
|
||||||
|
@ -45,7 +45,7 @@ public class FirestoreReception_classIdDatabase {
|
||||||
return classIdList;
|
return classIdList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getClassIdList() {
|
public List<Integer> getClassIdList() {
|
||||||
return classIdList;
|
return classIdList;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -162,7 +162,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
//UUIDを表示するかのダイアログ
|
//UUIDを表示するかのダイアログ
|
||||||
private void showUUIDYesNoDialog() {
|
private void showUUIDYesNoDialog() {
|
||||||
firestoreReception_classIdDatabase = new FirestoreReception_classIdDatabase();
|
firestoreReception_classIdDatabase = new FirestoreReception_classIdDatabase();
|
||||||
List<String> classIdList = firestoreReception_classIdDatabase.getAllDocumentsFromClassIdDatabase();
|
List<Integer> classIdList = firestoreReception_classIdDatabase.getAllDocumentsFromClassIdDatabase();
|
||||||
|
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user