murakumo_修正パッチその2 #18
|
@ -4,8 +4,6 @@
|
||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="testRunner" value="GRADLE" />
|
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="jbr-17" />
|
<option name="gradleJvm" value="jbr-17" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
|
@ -14,6 +12,7 @@
|
||||||
<option value="$PROJECT_DIR$/app" />
|
<option value="$PROJECT_DIR$/app" />
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
|
<option name="resolveExternalAnnotations" value="false" />
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
|
|
@ -15,6 +15,7 @@ import androidx.room.Room;
|
||||||
|
|
||||||
import com.google.firebase.firestore.FirebaseFirestore;
|
import com.google.firebase.firestore.FirebaseFirestore;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
@ -222,6 +223,50 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Main
|
||||||
|
private ArrayList<SubmissionStudent> getSubmissionStudents() {
|
||||||
|
ArrayList<SubmissionStudent> submissionStudents = new ArrayList<>();
|
||||||
|
List<MyDataClass> myDataList = firestoreReception.getMyDataList();
|
||||||
|
|
||||||
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
|
||||||
|
executor.execute(() -> {
|
||||||
|
// 1. Roomデータベースから全生徒数を取得
|
||||||
|
AppDatabase db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "SetUpTable").build();
|
||||||
|
SetUpTableDao setUpTableDao = db.setUpTableDao();
|
||||||
|
int totalStudent = setUpTableDao.getTotalStudent();
|
||||||
|
// 2. Firestoreから生徒番号のリストを取得
|
||||||
|
ArrayList<Integer> firestoreStudentNumbers = new ArrayList<>();
|
||||||
|
for (MyDataClass myData : myDataList) {
|
||||||
|
int studentNumber = myData.getStudentNumber();
|
||||||
|
firestoreStudentNumbers.add(studentNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. SubmissionStudentオブジェクトのリストを作成
|
||||||
|
for (int i = 1; i <= totalStudent; i++) {
|
||||||
|
boolean submitted = firestoreStudentNumbers.contains(i);
|
||||||
|
submissionStudents.add(new SubmissionStudent(i, submitted));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. データベース操作が完了したことを通知
|
||||||
|
latch.countDown();
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
// データベース操作が完了するのを待つ
|
||||||
|
latch.await();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
executor.shutdown();
|
||||||
|
|
||||||
|
// SubmissionStudentオブジェクトのリストを返す
|
||||||
|
return submissionStudents;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
|
|
@ -1,14 +1,58 @@
|
||||||
package com.example.oplogy;
|
//package com.example.oplogy;
|
||||||
|
//
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
//import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
//import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import android.os.Bundle;
|
//import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
//
|
||||||
public class SubmissionActivity extends AppCompatActivity {
|
//import android.os.Bundle;
|
||||||
|
//import android.widget.ImageView;
|
||||||
@Override
|
//
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
//import com.example.oplogy.databinding.SubmissionBinding;
|
||||||
super.onCreate(savedInstanceState);
|
//
|
||||||
setContentView(R.layout.submission);
|
//import java.util.ArrayList;
|
||||||
}
|
//import java.util.List;
|
||||||
}
|
//
|
||||||
|
//public class SubmissionActivity extends AppCompatActivity {
|
||||||
|
// private RecyclerView recyclerView;
|
||||||
|
// private SubmissionAdapter submissionAdapter;
|
||||||
|
// private List<SubmissionStudent> students = new ArrayList<>();
|
||||||
|
// ArrayList<Integer> studentNumbers = new ArrayList<>();
|
||||||
|
// private int totalStudent = 10;
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
// super.onCreate(savedInstanceState);
|
||||||
|
// setContentView(R.layout.submission);
|
||||||
|
//
|
||||||
|
// // 戻るボタンの処理
|
||||||
|
// ImageView backButton = findViewById(R.id.BackMain_fromSubmission);
|
||||||
|
// backButton.setOnClickListener(v -> {
|
||||||
|
// finish();
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// // インテントから提出状況の生徒の数を取得
|
||||||
|
// studentNumbers=getIntent().getIntegerArrayListExtra("submissionStudents");
|
||||||
|
//
|
||||||
|
// recyclerView = findViewById(R.id.recyclerView);
|
||||||
|
// recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||||
|
// submissionAdapter = new SubmissionAdapter(students);
|
||||||
|
// recyclerView.setAdapter(submissionAdapter);
|
||||||
|
//
|
||||||
|
// // 生徒のリストを取得
|
||||||
|
// fetchStudents();
|
||||||
|
// }
|
||||||
|
// private void fetchStudents() {
|
||||||
|
// // インテントから生徒のリストを取得
|
||||||
|
// ArrayList<SubmissionStudent> submissionStudents = getIntent().getParcelableArrayListExtra("submissionStudents");
|
||||||
|
//
|
||||||
|
// // 生徒のリストを反復処理し、それをRecyclerViewに表示
|
||||||
|
// for (SubmissionStudent student : submissionStudents) {
|
||||||
|
// students.add(student);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // データが変更されたことをアダプターに通知
|
||||||
|
// submissionAdapter.notifyDataSetChanged();
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
|
62
app/src/main/java/com/example/oplogy/SubmissionAdapter.java
Normal file
62
app/src/main/java/com/example/oplogy/SubmissionAdapter.java
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
//package com.example.oplogy;
|
||||||
|
//
|
||||||
|
//import android.graphics.Color;
|
||||||
|
//import android.view.LayoutInflater;
|
||||||
|
//import android.view.View;
|
||||||
|
//import android.view.ViewGroup;
|
||||||
|
//import android.widget.TextView;
|
||||||
|
//import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
//import java.util.List;
|
||||||
|
//
|
||||||
|
//public class SubmissionAdapter extends RecyclerView.Adapter<SubmissionAdapter.StudentViewHolder> {
|
||||||
|
//
|
||||||
|
// private List<SubmissionStudent> students;
|
||||||
|
//
|
||||||
|
// public static class StudentViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
// public TextView studentNumberTextView;
|
||||||
|
// public TextView statusTextView;
|
||||||
|
//
|
||||||
|
// public StudentViewHolder(View view) {
|
||||||
|
// super(view);
|
||||||
|
// // レイアウトファイルのTextViewを取得
|
||||||
|
// studentNumberTextView = view.findViewById(R.id.studentNumberTextView);
|
||||||
|
// statusTextView = view.findViewById(R.id.statusTextView);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public SubmissionAdapter(List<SubmissionStudent> students) {
|
||||||
|
// this.students = students;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public StudentViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
|
// View view = LayoutInflater.from(parent.getContext())
|
||||||
|
// .inflate(R.layout.row_submission, parent, false);
|
||||||
|
// return new StudentViewHolder(view);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void onBindViewHolder(StudentViewHolder holder, int position) {
|
||||||
|
// SubmissionStudent student = students.get(position);
|
||||||
|
// holder.studentNumberTextView.setText(String.valueOf(student.getStudentNumber()));
|
||||||
|
// // 提出済みかどうかで表示を変える
|
||||||
|
// if (student.isSubmitted()) {
|
||||||
|
// holder.statusTextView.setText("提出済み");
|
||||||
|
// holder.statusTextView.setBackgroundColor(Color.BLACK);
|
||||||
|
// holder.statusTextView.setTextColor(Color.WHITE);
|
||||||
|
// holder.studentNumberTextView.setBackgroundColor(Color.BLACK);
|
||||||
|
// holder.studentNumberTextView.setTextColor(Color.WHITE);
|
||||||
|
// } else {
|
||||||
|
// holder.statusTextView.setText("未提出");
|
||||||
|
// holder.statusTextView.setBackgroundColor(Color.RED);
|
||||||
|
// holder.statusTextView.setTextColor(Color.WHITE);
|
||||||
|
// holder.studentNumberTextView.setBackgroundColor(Color.RED);
|
||||||
|
// holder.studentNumberTextView.setTextColor(Color.WHITE);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public int getItemCount() {
|
||||||
|
// return students.size();
|
||||||
|
// }
|
||||||
|
//}
|
49
app/src/main/java/com/example/oplogy/SubmissionStudent.java
Normal file
49
app/src/main/java/com/example/oplogy/SubmissionStudent.java
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
//package com.example.oplogy;
|
||||||
|
//import android.os.Parcel;
|
||||||
|
//import android.os.Parcelable;
|
||||||
|
//
|
||||||
|
//public class SubmissionStudent implements Parcelable {
|
||||||
|
// private int studentNumber;
|
||||||
|
// private boolean submitted;
|
||||||
|
//
|
||||||
|
// public SubmissionStudent(int studentNumber, boolean submitted) {
|
||||||
|
// this.studentNumber = studentNumber;
|
||||||
|
// this.submitted = submitted;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// protected SubmissionStudent(Parcel in) {
|
||||||
|
// studentNumber = in.readInt();
|
||||||
|
// submitted = in.readByte() != 0;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public static final Creator<SubmissionStudent> CREATOR = new Creator<SubmissionStudent>() {
|
||||||
|
// @Override
|
||||||
|
// public SubmissionStudent createFromParcel(Parcel in) {
|
||||||
|
// return new SubmissionStudent(in);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public SubmissionStudent[] newArray(int size) {
|
||||||
|
// return new SubmissionStudent[size];
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// public int getStudentNumber() {
|
||||||
|
// return studentNumber;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public boolean isSubmitted() {
|
||||||
|
// return submitted;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public int describeContents() {
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void writeToParcel(Parcel parcel, int i) {
|
||||||
|
// parcel.writeInt(studentNumber);
|
||||||
|
// parcel.writeByte((byte) (submitted ? 1 : 0));
|
||||||
|
// }
|
||||||
|
//}
|
Loading…
Reference in New Issue
Block a user