parse-community/ParseLiveQuery-Android

Is there a problem with my code? But why can't it be implemented?

CollinsWalker opened this issue · 1 comments

ParseLiveQueryClient parseLiveQueryClient = ParseLiveQueryClient.Factory.getClient();
        //mPosts.clear();
        ParseQuery<Post> query = ParseQuery.getQuery(Post.class);
        // Connect to Parse server
        SubscriptionHandling<Post> subscriptionHandling = parseLiveQueryClient.subscribe(query);
        // Listen for CREATE events
        subscriptionHandling.handleEvent(SubscriptionHandling.Event.CREATE, new SubscriptionHandling.HandleEventCallback<Post>() {
            @Override
            public void onEvent(ParseQuery<Post> query, Post object) {
                mPosts.add(0, object);
                Handler handler = new Handler(Looper.getMainLooper());
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        adapter.notifyDataSetChanged();
                        recyclerView.scrollToPosition(0);
                    }
                });
            }
        });

Is there a problem with my code? But why can't it be implemented?

Hello, could you provide a bit more information about your issue?
What is not working?