Values are being sent nulls

Asked

Viewed 87 times

2

For some reason the arrays are being sent null in setListGrades, but inside the log shows the normal arrays. The API is being consumed correctly, so it is null when sending this method?

                    @Override
                    public void onNext(GradeModel grades) {

                        BigDecimal[] gradesList = new BigDecimal[grades.getReportLists().length];
                        Integer[] faultsList = new Integer[grades.getReportLists().length];
                        String[] classesList = new String[grades.getReportLists().length];

                        for (int i = 0; i < grades.getReportLists().length; i++) {
                            gradesList[i] = grades.getReportLists()[i].getGradesList();
                            faultsList[i] = grades.getReportLists()[i].getFaultList();
                            classesList[i] = grades.getReportLists()[i].getClassList();
                        }
                        Log.i(TAG, "caralhoooooo " + Arrays.asList(classesList) + Arrays.asList(gradesList) + Arrays.asList(faultsList));
                        mainPresenter.setListGrades(gradesList, faultsList, classesList);

                    }
                });
  • Put complete code and detailed error.

  • Hello, obg for interest. The complete code I can not because there are more than 30 classes and hundreds or thousands of lines. The model is a common model with gets and setters. There are no problems in other parts of the code. The only problem is that in this line mainPresenter.setListGrades(gradesList, faultsList, classesList); null values are being sent, and the log demonstrates that they are not null. What could be?

1 answer

1

Maybe if you were to do as below, it would solve:

List<BigDecimal> gradesList = new ArrayList<BigDecimal>();
List<Integer> faultsList = new ArrayList<Integer>();
List<String> classesList = new ArrayList<String>();

for (int i = 0; i < grades.getReportLists().length; i++) {
    gradesList.add(grades.getReportLists()[i].getGradesList());
    faultsList.add(grades.getReportLists()[i].getFaultList());
    classesList.add(grades.getReportLists()[i].getClassList());
 }
Log.i(TAG, "caralhoooooo " + Arrays.asList(classesList) + Arrays.asList(gradesList) + Arrays.asList(faultsList));
 mainPresenter.setListGrades(gradesList, faultsList, classesList);

or possibly

mainPresenter.setListGrades(gradesList.toArray(), faultsList.toArray(), classesList.toArray());

If there’s a problem, let us know and try to solve it another way

  • I tried option 1 where you use List instead of arrays and it’s the same. And option two cannot convert toArray pq are already arrays.

  • in this case, you need to mark breakpoints in your code and go debugging to see where it fails, possibly it should be the methods that are returning empty or God knows what may be, you need to debug to find the fault

  • I did that and found out that this line mainPresenter.setListGrades(gradesList, faultsList, classesList); is sending null values instead of arrays. This confuses me

Browser other questions tagged

You are not signed in. Login or sign up in order to post.