-
Type: Task
-
Resolution: Unresolved
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
In https://realm.io/docs/java/latest/#reuse-realmresults-realmobjects
public class MyActivity extends Activity { private Realm realm; private RealmResults<Person> allPersons; private RealmChangeListener realmListener = new RealmChangeListener() { @Override public void onChange(Realm realm) { //// <-- if RealmChangeListener is raw, this is Object // Just redraw the views. `allPersons` already contain the // latest data. invalidateView(); } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); realm = Realm.getDefaultInstance(); realm.addRealmChangeListener(listener); //// <-- it's called "addChangeListener"! allPerson = realm.where(Person.class).findAll(); // Create the "live" query result setupViews(); // Initial setup of views invalidateView(); // Redraw views with data } // ... }
Also, why use Realm notification here instead of adding change listener to results? Just wondering