murakumo_UUIDを何とかするの会 #21
|
@ -4,6 +4,7 @@
|
|||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
||||
<option name="modules">
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.example.oplogy;
|
|||
import androidx.room.Database;
|
||||
import androidx.room.RoomDatabase;
|
||||
|
||||
@Database(entities = {SetUpTable.class}, version = 2)
|
||||
@Database(entities = {SetUpTable.class}, version = 2, exportSchema = false)
|
||||
public abstract class AppDatabase extends RoomDatabase {
|
||||
// データベースにアクセスするためのメソッドを提供する
|
||||
public abstract SetUpTableDao setUpTableDao();
|
||||
|
|
|
@ -5,12 +5,12 @@ import java.util.List;
|
|||
|
||||
public class CreateUUID {
|
||||
|
||||
public static String generateUUID(List<String> classIdList ){
|
||||
public static int generateUUID(List<String> classIdList ){
|
||||
while (true){
|
||||
String uuid = String.valueOf((int)(Math.random()*100000));
|
||||
String uuid = String.valueOf((int)(Math.random() * 1000000));
|
||||
boolean isDuplicate = false;
|
||||
for(String classId : classIdList){
|
||||
if(Integer.parseInt(classId) == Integer.parseInt(uuid)){
|
||||
if(classId.equals(uuid)){
|
||||
//重複があればフラグを立て、ループを抜ける
|
||||
isDuplicate = true;
|
||||
break;
|
||||
|
@ -19,7 +19,9 @@ public class CreateUUID {
|
|||
//重複がなければ生成したUUIDを返す
|
||||
if (!isDuplicate) {
|
||||
//firestoreに挿入処理
|
||||
return uuid;
|
||||
//テスト用
|
||||
uuid="100";
|
||||
return Integer.parseInt(uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String classId = CreateUUID.generateUUID(classIdList);
|
||||
classId = CreateUUID.generateUUID(classIdList);
|
||||
Toast.makeText(MainActivity.this, "クラスID: " + classId, Toast.LENGTH_SHORT).show();
|
||||
Log .d("classIdList", classIdList.toString());
|
||||
|
||||
|
@ -292,4 +292,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume(){
|
||||
super.onResume();
|
||||
if (classId != 100000) {
|
||||
firestoreReception.getDocumentsByClassId(classId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user