package net.lacolaco.smileessence.twitter.task import net.lacolaco.smileessence.data.Account import net.lacolaco.smileessence.entity.Tweet import twitter4j.TwitterException class Timelines { class HomeTimelineTask // --------------------------- CONSTRUCTORS --------------------------- ( // ------------------------------ FIELDS ------------------------------ private val account: Account) : TimelineTask() { // ------------------------ OVERRIDE METHODS ------------------------ @Throws(TwitterException::class) override fun doInBackground(): List { return Tweet.fromTwitter(account.twitter.timelines().getHomeTimeline(paging), account.userId) } } class MentionsTimelineTask // --------------------------- CONSTRUCTORS --------------------------- ( // ------------------------------ FIELDS ------------------------------ private val account: Account) : TimelineTask() { // ------------------------ OVERRIDE METHODS ------------------------ @Throws(TwitterException::class) override fun doInBackground(): List { return Tweet.fromTwitter(account.twitter.timelines().getMentionsTimeline(paging), account.userId) } } class UserTimelineTask // --------------------------- CONSTRUCTORS --------------------------- (private val account: Account, // ------------------------------ FIELDS ------------------------------ private val userID: Long) : TimelineTask() { // ------------------------ OVERRIDE METHODS ------------------------ @Throws(TwitterException::class) override fun doInBackground(): List { return Tweet.fromTwitter(account.twitter.timelines().getUserTimeline(userID, paging), account.userId) } } class UserListStatusesTask // --------------------------- CONSTRUCTORS --------------------------- ( // ------------------------------ FIELDS ------------------------------ private val account: Account, private val listFullName: String) : TimelineTask() { // ------------------------ OVERRIDE METHODS ------------------------ @Throws(TwitterException::class) override fun doInBackground(): List { val strings = listFullName.split("/".toRegex()).dropLastWhile({ it.isEmpty() }).toTypedArray() return Tweet.fromTwitter(account.twitter.list().getUserListStatuses(strings[0], strings[1], paging), account.userId) } } }