2

My listener which automatically updates the listview, once the database change:

useradapter = new ArrayAdapter<User>(this,android.R.layout.simple_list_item_1, userArrayList);
myUserListView.setAdapter(useradapter);
Disposable d= new RoomWithRxJavaViewModel(this.getApplication()).getList()
            .concatMap(users1 -> Flowable.fromIterable(users1))
            .subscribeOn(Schedulers.computation())
            .observeOn(AndroidSchedulers.mainThread())
            .distinctUntilChanged()
            //.doOnComplete(() -> {useradapter.notifyDataSetChanged();/*userArrayList.clear();*/ } )
            .subscribe(allusers ->
                    {
                          userArrayList.add(allusers);
                           useradapter.notifyDataSetChanged();
                    }, e -> {
                Toast.makeText(this, "Error: " + e.getMessage(), Toast.LENGTH_LONG).show();
            }
);

My simple remove function:

Disposable ff = viewModel.delete(Integer.valueOf(pl.getText().toString()))
  .subscribe(() -> { //onSucess
    useradapter.clear();
    Toast.makeText(this, "deleted!!!!!!!!", Toast.LENGTH_LONG).show();
  }, //onError
    throwable -> {
    Toast.makeText(this, "Error!" + throwable.getMessage(), Toast.LENGTH_SHORT).show();
 }
);

Following issue: Sometimes, and i repeat only sometimes there is a flickering/blinking effect when deleting an item from the listview. Example: example

If you look closely u can see the flickering/blinking effect. e.g when i delete the item with the id 53,54 or 55

My question would be why that happens or rather why doesnt it happen always but just sometimes?

Things I already tried:

Setting android:cacheColorHint="#00000000" in my layout file. Adding myUserListView.setCacheColorHint(Color.TRANSPARENT); to my listview

Nummer Eins
  • 199
  • 1
  • 8

0 Answers0