Код: Выделить всё
Log.d("ıd check",subCatId+catId);
database.getReference().child("categories").child(catId)
.child("subCategories").child(subCatId)
.child("questions").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
if (snapshot.exists()) {
Log.d("exixtance","DOES EXİSTS");
timer.start();
for (DataSnapshot dataSnapshot : snapshot.getChildren()) {
prossesdata(dataSnapshot);
loadingdialog.dismiss();
}
if (list.size() > 0) {
for (int i = 0; i < 4; i++) {
binding.optioncontainer.getChildAt(i).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
checkAnswer((Button) v);
}
});
}
playAnimation(binding.question, 0, list.get(position).getQuestion());
binding.buttonnext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
enableOptions(true);
position++;
if (position == list.size()) {
timer.cancel();
Intent intent = new Intent(QuestionActivity.this, ScoreActivity.class);
long totaltime = questionTime * 60 * 100;
intent.putExtra("timetaken", totaltime - timeLeft);
intent.putExtra("correct", correctAnswer);
intent.putExtra("wrong", wrongAnswer);
intent.putExtra("totalquestion", list.size());
startActivity(intent);
finish();
return;
}
count = 0;
playAnimation(binding.question, 0, list.get(position).getQuestion());
}
});
binding.buttonsubmit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(QuestionActivity.this, ScoreActivity.class);
long totaltime = questionTime * 60 * 100;
intent.putExtra("timetaken", totaltime - timeLeft);
intent.putExtra("correct", correctAnswer);
intent.putExtra("wrong", wrongAnswer);
intent.putExtra("totalquestion", list.size());
startActivity(intent);
}
});
}
} else {
Toast.makeText(QuestionActivity.this, ""+list.size(), Toast.LENGTH_SHORT).show();
loadingdialog.dismiss();
}
}
Как решить эту проблему и заставить работать первую часть? Снимок не существует, поэтому я не могу выполнить условие if.
Я добавил журнал, и вот результат:
2024-10-06 17:39:26.060 23619-23619 я проверил com.example.quiztime D -O8IX4259O4p5Ko_uh4e-O8GtSPIwhXwbPfYy0Bc
А это моя база данных реального времени:
-O8GtSPIwhXwbPfYy0Bc
categoryImage
:
"https://firebasestorage.googleapis.com/ ... pot.com/o/ CategoryImage%2F1727950867993?alt=media&token=44da-1e8e-4188-8f81-b7b81d056125"
Имя категории
:
"almanca "
Подкатегории
-O8HS_G7EjfqXDUij4El
Имя категории
:
"a1 almanca"
вопросы
-O8IX4259O4p5Ko_uh4e
название категории
:
"a2 almanca
Подробнее здесь: https://stackoverflow.com/questions/790 ... esnt-exist