I turn circular indeterminate progressBar to visible and then I run Thread, that can take few seconds (I tried AsyncTask, but it didn't work, probably because there is another AsyncTask running inside the method). However, the progressBar gets visible only just after the Thread is completed. How to make it visible before running the thread, so that the user can see, that something is happening?
Edit: The code is quite complicated, so it is not possible to attach it all without long description, however, I will try to attach important parts of the code
//this is the Thread class
private static final class LoadingMolecules extends Thread{
private Intent intent;
private ArrayList<Integer> groups;
Context context;
QuizProvider quizProvider;
public LoadingMolecules (Intent intent,ArrayList<Integer> groups, Context context ){
this.intent = intent;
this.groups = groups;
this.context = context;
}
@Override
public void run() {
quizProvider = new QuizProvider(groups, context);
//inside next method is the asyncTask
quizProvider.loadAllCompounds();
}
}
//there is the code running
progressBar.setVisibility(View.VISIBLE);
LoadingMolecules lm = new LoadingMolecules(intent, groups, this);
lm.start();
try {
lm.join();
}catch (InterruptedException ignore){
}
intent.putExtra("quizProvider", lm.quizProvider);
startActivity(intent);
finish();