Firestore RecylerView Нет подключенного адаптера;ошибка пропуска макета - PullRequest
0 голосов
/ 20 февраля 2019

У меня есть 2 вида рециркуляции, в которых 1-й вид работает нормально, но во 2-м представлении я получаю сообщение об ошибке:

Адаптер не подключен;пропуск макета

Но через 5 минут данные отображаются.

Я гуглил, но не получил никакого результата.Ниже мой код.Может ли кто-нибудь помочь мне в этом.

открытый класс DashboardAdmin расширяет AppCompatActivity {

FirebaseFirestore database;
ProgressDialog mProgress;
ProgressBar progress_horizontal;

RecyclerView clmNameRecyclerView, visitCountRecyclerView;
ArrayList<User> clmNameArrayList;
ArrayList<DayCountGetterSetter> dayCountArrayList;
CLMNameRecyclerViewAdapter clmNameAdapter;
DayCountRecyclerViewAdapter dayCountRecyclerViewAdapter;   
LinearLayout clmNameRecyclerViewLayout, visitCountRecyclerViewLayout;
int listCount = 0;
int TestVariable = 0;



@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_dashboard_admin);

    progress_horizontal = findViewById(R.id.progress_horizontal);

    // Emp Name RecycleView
    clmNameRecyclerViewLayout = findViewById(R.id.clmNameRecyclerViewLayout);
    clmNameArrayList = new ArrayList<>();
    clmNameRecyclerView = findViewById(R.id.clmNameRecyclerView);
    clmNameRecyclerView.setHasFixedSize(true);
    clmNameRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    // Emp Name RecycleView

    // DayCount RecycleView
    visitCountRecyclerViewLayout = findViewById(R.id.visitCountRecyclerViewLayout);
    dayCountArrayList = new ArrayList<>();
    visitCountRecyclerView = findViewById(R.id.visitCountRecyclerView);
    visitCountRecyclerView.setHasFixedSize(true);
    visitCountRecyclerView.setLayoutManager(new LinearLayoutManager(this));

    dayCountRecyclerViewAdapter = new DayCountRecyclerViewAdapter(DashboardAdmin.this, dayCountArrayList);
    visitCountRecyclerView.setAdapter(dayCountRecyclerViewAdapter);
    // DayCount RecycleView

    if (clmNameArrayList.size() > 0)
        clmNameArrayList.clear();

    mProgress = new ProgressDialog(this);
    mProgress.setMessage(" Please wait...");
    mProgress.setCancelable(false);
    mProgress.show();

    database = FirebaseFirestore.getInstance();
    database.collection("UsersCollection")
            .whereEqualTo("earuserReportingManager", currentUser)
            .whereEqualTo("earuserType", "User")
            .whereEqualTo("earuserStatus", "Active")
            .orderBy("name")
            .get()
            .addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
                @Override
                public void onSuccess(QuerySnapshot queryDocumentSnapshots) {

                    for (QueryDocumentSnapshot documentSnapshot : queryDocumentSnapshots) {
                        listCount = listCount + 1;
                        User user = documentSnapshot.toObject(User.class);
                        clmNameArrayList.add(user);
                    }
                    clmNameAdapter = new CLMNameRecyclerViewAdapter(DashboardAdmin.this, clmNameArrayList);
                    clmNameRecyclerView.setAdapter(clmNameAdapter);
                    mProgress.dismiss();
                    clmNameRecyclerView.smoothScrollToPosition(clmNameArrayList.size());

                    if (clmNameArrayList.size() == 0) {
                        Toast.makeText(DashboardAdmin.this, "Oops... No visits available", Toast.LENGTH_LONG).show();
                    } else {
                        Toast.makeText(DashboardAdmin.this, String.valueOf(clmNameArrayList.size()), Toast.LENGTH_SHORT).show();
                        progress_horizontal.setMax(clmNameArrayList.size());
                        progress_horizontal.setProgress(0);
                        progress_horizontal.setVisibility(View.VISIBLE);
                        GetDayCount();
                        mProgress.dismiss();
                    }
                }

                private void GetDayCount() {

                    while (TestVariable < clmNameArrayList.size()) {
                        userId = clmNameArrayList.get(TestVariable).getUserName();
                        ProcessFirebaseData();
                        TestVariable++;
                    }

                    dayCountRecyclerViewAdapter.notifyDataSetChanged();

                }

                private void ProcessFirebaseData() {

                    listCount = 0;
                    if (dayCountArrayList.size() > 0)
                        dayCountArrayList.clear();

                    database.collection("VisitReportCollection")
                            .whereEqualTo("userId", userId)
                            .orderBy("createdDate", Query.Direction.DESCENDING)
                            .get()
                            .addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
                                @Override
                                public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
                                    for (QueryDocumentSnapshot documentSnapshot : queryDocumentSnapshots) {
                                        listCount = listCount + 1;
                                    }
                                    DayCountGetterSetter dayCountGetterSetter = new DayCountGetterSetter();
                                    dayCountGetterSetter.setDayCountMTD(listCount);
                                    dayCountGetterSetter.setDayCount1(listCount);
                                    dayCountGetterSetter.setDayCount2(listCount);
                                    dayCountGetterSetter.setDayCount3(listCount);
                                    dayCountGetterSetter.setDayCount4(listCount);
                                    dayCountGetterSetter.setDayCount5(listCount);
                                    dayCountGetterSetter.setDayCount6(listCount);
                                    dayCountGetterSetter.setDayCount7(listCount);
                                    dayCountArrayList.add(dayCountGetterSetter);
                                    progress_horizontal.setProgress(TestVariable);
                                }
                            })
                            .addOnFailureListener(new OnFailureListener() {
                                @Override
                                public void onFailure(@NonNull Exception e) {
                                    Log.d("FirebaseFailure", e.toString());
                                }
                            });
                }

            })
            .addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    Log.d("Dashboard", e.toString());
                }
            });

}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...