Feed

Feeds are 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 will be able to create posts on any group that they are a member of and any user that they can find.

There is also a global feed which is an aggregate of all the posts in a user's feeds.

Feed management methods are all contained in a EkoFeedRepository class.

Create Repository

val feedRepository = EkoClient.newFeedRepository()

Query User Feed

You can get any user's feed by calling the method below with the userId:

Enum Types

EkoUserFeedSortOption

EkoUserFeedSortOption.LAST_CREATED
EkoUserFeedSortOption.FIRST_CREATED
feedRepository.getUserFeed("user1")
.build()
.query()
.doOnNext {
//Do Action
}
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe()

There is also a quick easy method to get your own feed:

feedRepository.getMyFeed()
.sortBy(EkoUserFeedSortOption.LAST_CREATED)
.build()
.query()
.doOnNext {
//Do Action
}
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe()

Note. By default of sortBy is LAST_CREATED so you can skip .sortBy in builder

Query Group Feed

You can get any group's feed by calling the method below with the communityId:

Enum Types

EkoCommunityFeedSortOption

EkoCommunityFeedSortOption.LAST_CREATED
feedRepository.getCommunityFeed("community1")
.sortBy(EkoCommunityFeedSortOption.LAST_CREATED)
.build()
.query()
.doOnNext {
//Do Action
}
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe()

Query Global Feed

You can retreive your global feed by calling the following method:

feedRepository.getGlobalFeed()
.doOnNext {
//Do Action
}
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe()

Posts

A feed is made up of a collection of posts. Users will be able to generate different types of posts as well as be able to react and comment on posts.

EkoImage

When you want to parse EkoImage object you can upload image uri or id by use EkoClient.newFileRepository() the following:

val files = mutableListOf<EkoImage>()
EkoClient.newFileRepository()
.uploadImage(:uri)
.build()
.transfer()
.doOnNext {
when (it) {
is EkoUploadResult.COMPLETE -> {
files.add(it.image)
}
is EkoUploadResult.PROGRESS -> {
// do something
}
is EkoUploadResult.ERROR, EkoUploadResult.CANCELLED -> {
// do something
}
}
}
.subscribeOn(Schedulers.io())
.subscribe()

EkoFile

When you want to parse EkoFile object you can upload file uri or id by use EkoClient.newFileRepository() the following:

val files = mutableListOf<EkoFile>()
EkoClient.newFileRepository()
.uploadFile(:uri)
.build()
.transfer()
.doOnNext {
when (it) {
is EkoUploadResult.COMPLETE -> {
files.add(it.file)
}
is EkoUploadResult.PROGRESS -> {
// do something
}
is EkoUploadResult.ERROR, EkoUploadResult.CANCELLED -> {
// do something
}
}
}
.subscribeOn(Schedulers.io())
.subscribe()

Create a Text Post

When creating a text post, calling the following method:

feedRepository.createPost()
.targetUser("user1")
.text("hello!")
.build()
.post()
.doOnSuccess {
//Do Action
}
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe()

Create an Image Post

feedRepository.createPost()
.targetUser("user1")
.image(*files.toTypedArray())
.build()
.post()
.doOnSuccess {
//Do Action
}
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe()

Create a File Post

feedRepository.createPost()
.targetUser("user1")
.file(*files.toTypedArray())
.build()
.post()
.doOnSuccess {
//Do Action
}
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe()

Note. A post can consist of either a list of images or a list of files but noth both.

Get Post

You can use the getPost(:postId) method in order to get a single post:

feedRepository.getPost("post123")
.doOnNext {
//Do Action
}
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe()

Delete Post

feedRepository.deletePost("post123")
.doOnComplete {
//Do Action
}
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe()

Note. Only the post owner or an admin will be able to delete a post.

Update Post

If you prefer update post. you have to use EkoPost that you are recieved for update post and check data type the following:

val item: EkoPost.Data = post.getData()
if (item is EkoPost.Data.TEXT) {
item.edit()
.text("hello!")
.build()
.apply()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe()
}

Add Reaction

You can add a reaction to a post by use EkoPost that you are recieved and calling the following method:

post.react()
.addReaction("like")
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe()

Remove Reaction

You can remove a reaction to a post by use EkoPost that you are recieved and calling the following method:

post.react()
.removeReaction("like")
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe()

Add Comment

You can use EkoPost that you are recieved for add a comment to a post using our Comment feature:

post.comment()
.with()
.text("comment!")
.build()
.send()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doOnSuccess {
//Do Action
}
.subscribe()

Reply Comment

You can use EkoPost that you are recieved for reply a comment to a post using our Comment feature:

post.comment()
.parentId("parentId")
.with()
.text("reply comment!")
.build()
.send()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doOnSuccess {
//Do Action
}
.subscribe()

See more on Comments

Flag Post

You can use EkoPost that you are recieved for flag a post as inappropriate using the following method:

post.report()
.flag()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doOnComplete {
//Do Action
}
.subscribe()

Check for isFlaggedByMe

You can use EkoPost that you are recieved for get status flag the following:

val result = post.isFlaggedByMe()

Unflag Post

You can use EkoPost that you are recieved for unflag a post the following method:

post.report()
.unflag()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doOnComplete {
//Do Action
}
.subscribe()