Skip to content

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

Closed
@CollinsWalker

Description

@CollinsWalker
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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions