Feed & Timeline
Let users react to messages, posts, and comments, which are visible to others.
Feed is a new way for users to create content on various areas of the SDK. Currently, users and groups can have feeds. Each feed consists of a collection of posts. Users can create posts on any groups that they are a member of and any user that they can find.
There are 3 types of feeds:
  1. 1.
    User Feed This is a collection of posts for a user's timeline.
  2. 2.
    Group Feed This is a collection of posts from members of the group or community.
  3. 3.
    Global Feed This is an aggregate of both User and Group feeds.

Query User Feed

You can get any user's feed by calling the method below with the userId:
1
AmitySocialClient.newFeedRepository()
2
.getUserFeed(userId)
3
.includeDeleted(Boolean)
4
.build()
5
.query()
6
.subscribeOn(Schedulers.io())
7
.observeOn(AndroidSchedulers.mainThread())
8
.doOnNext {
9
// PagedList<AmityPost>
10
}.doOnError {
11
// handle error
12
}.subscribe()
Copied!

Query Group Feed

You can get any group's feed by calling the method below with the communityId:
1
AmitySocialClient.newFeedRepository()
2
.getCommunityFeed(communityId)
3
.feedType(AmityFeedType)
4
.includeDeleted(Boolean)
5
.build()
6
.query()
7
.subscribeOn(Schedulers.io())
8
.observeOn(AndroidSchedulers.mainThread())
9
.doOnNext {
10
// PagedList<AmityPost>
11
}.doOnError {
12
// handle error
13
}.subscribe()
Copied!

Query Global Feed

You can retrieve your global feed by calling the following method:
1
AmitySocialClient.newFeedRepository()
2
.getGlobalFeed()
3
.build()
4
.query()
5
.subscribeOn(Schedulers.io())
6
.observeOn(AndroidSchedulers.mainThread())
7
.doOnNext {
8
// PagedList<AmityPost>
9
}.doOnError {
10
// handle error
11
}.subscribe()
Copied!

Implementing feed pagination

Whether you're querying a user, group, or global feed, a maximum of 15 posts in each page will be returned. Pagination in Android uses the Paging2 library. It will automatically handle the loading of the next page when the user scrolls the list based on PagingSource logic.
Last modified 2mo ago