I have a question regarding clearing recyclerview after few seconds in android. I tried doing this in a Thread but it didn't work for me. I used this code
public void cleardbView()
{
final Thread countdown = new Thread() {
@Override
public void run() {
try {
Thread.sleep(15000);
runOnUiThread(new Runnable() {
@Override
public void run() {
recyclerView = (RecyclerView) findViewById(R.id.dbView);
arrayList.clear();
layoutManager = new LinearLayoutManager(MainActivity.this);
return;
}
});
} catch (InterruptedException e) {
}
return;
}
};
countdown.start();
}
I am using this code in the section where I am adding data. The method is too big with all the conditions so I will put here only pseudo code(I tried to simplify it as much as I could :D )
if(conditions)
{
insertData();
}
if(inserted)
{
cleardbView();
}