I am having this problem even though I used async in Realm. The lag is very noticeable. Is there something wrong with how I code it? This is my code:
RealmConfiguration configuration = new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.build();
realm = Realm.getInstance(configuration);
itemCategoryName = getIntent().getExtras().getString("category", "");
itemCategoryName = itemCategoryName.toLowerCase();
shopItemList = new ArrayList<>();
shopItemAdapter = new ShopItemAdapter(this, shopItemList);
recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
recyclerView.setAdapter(shopItemAdapter);
realm.where(ShopItem.class).contains("category", itemCategoryName, Case.INSENSITIVE).findAllAsync()
.addChangeListener(new RealmChangeListener<RealmResults<ShopItem>>() {
@Override
public void onChange(RealmResults<ShopItem> shopItems) {
shopItemList.addAll(shopItems);
shopItemAdapter.notifyDataSetChanged();
}
});