Uploaded image for project: 'Realm Java SDK'
  1. Realm Java SDK
  2. RJAVA-245

"Re-use RealmResults and RealmObjects" documentation example uses non-existent method

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Unknown 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

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: