having issues displaying to a textview from firestore db due to asynchronous process
I have tried to notify the textviews but they are not bound by any thread apparently
The displayed data can be logged to console but is not displayed to the textview
I would have used notifyDataSetChanged() but it only exists for the recyclerview to update its content
If notifyall() or notify() is used there is a thread error showing the elements were bound the thread
package com.example.schedule;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.firestore.QueryDocumentSnapshot;
import com.google.firebase.firestore.QuerySnapshot;
public class ScheduleDetails extends AppCompatActivity implements View.OnClickListener {
Button backbutton;
TextView schedName;
TextView textDesc;
TextView textDte;
TextView textTime;
private FirebaseAuth mAuth;
@Override
protected void onStart() {
super.onStart();
mAuth = FirebaseAuth.getInstance();
final FirebaseUser currentUser = mAuth.getCurrentUser();
final FirebaseFirestore db = FirebaseFirestore.getInstance();
schedName = findViewById(R.id.schedName);
schedName.setText(getIntent().getStringExtra("text"));
final String sched = getIntent().getStringExtra("text");
db.collection("Schedules")
.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (QueryDocumentSnapshot document : task.getResult()) {
if (document.get("Owner").toString().equals(currentUser.getUid())) {
if(document.get("Schedule").toString().equals(sched)){
System.out.println(document.get("Schedule Description").toString());
System.out.println(document.get("Schedule Description").toString());
System.out.println(document.get("Schedule Description").toString());
System.out.println(document.get("Schedule Description").toString());
System.out.println(document.get("Schedule Description").toString());
System.out.println(document.get("Schedule Description").toString());
System.out.println(document.get("Schedule Description").toString());
System.out.println(document.get("Schedule Description").toString());
textDesc.setText(document.get("Schedule Description").toString());
//textDesc.notify();
//Log.d("",document.get("Schedule Description").toString());
//textDte.notify();
textDte.setText(document.get("Schedule Date").toString());
//textTime.notify();
textTime.setText(document.get("Schedule Time").toString());
}
}
}
}else {
Log.w("My Contenet", "Error getting your schedules.", task.getException());
}
}
});
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_schedule_details);
backbutton = findViewById(R.id.buttonback);
backbutton.setOnClickListener(this);
}
@Override
public void onClick(View view) {
Intent intent = new Intent(this, Navigator.class);
startActivity(intent);
}
}
Expect textview to display details of the schedule