What its supposed to do is after getting ProgramTracker size it checks if there is still an unfinished Exercise inside ProgramTracker and if it detects an unfinished exercise it changes the falseDetected which is false to true and then goes to my else statement which it should show my viewKonfetti.
private void checkIfCurrentWeekProgramComplete() {
currentWeek = programTrackers.get(0).getWeek();
DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference("ProgramTracker")
.child(GlobalUser.getmUser().getiD())
.child(programTrackers.get(0).getProgramId());
databaseReference.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
ProgramTracker programTracker = dataSnapshot.getValue(ProgramTracker.class);
if (programTracker.getProgramExerciseWeek() == currentWeek) {
programTrackers.add(programTracker);
if (programTrackers.size() == programTrackers.size()) {
for (int i = 0; i < programTrackers.size(); i++) {
if (!programTrackers.get(i).isProgramExerciseFinished()) {
falseDetected = true;
}
}
if (falseDetected) {
finish();
} else {
//meaning this week for the current program is done
viewKonfetti = findViewById(R.id.viewKonfetti);
viewKonfetti.build()
.addColors(Color.YELLOW, Color.GREEN, Color.MAGENTA)
.setDirection(0.0, 359.0)
.setDirection(0.0, 359.0)
.setSpeed(1f, 5f)
.setFadeOutEnabled(true)
.setTimeToLive(2000L)
.addShapes(Shape.RECT, Shape.CIRCLE)
.addSizes(new Size(12, 5))
.setPosition(-50f, viewKonfetti.getWidth() + 50f, -50f, -50f)
.streamFor(300, 5000L);
FragmentManager fm = getFragmentManager();
InputWeightDialog weightDialog = new InputWeightDialog();
weightDialog.show(fm, "fragment_input_weight");
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire