Add EventHub, add fav, reblog events, improve timelines (#562)

* Add AppStore, add fav, reblog events

* Add events, add handling to Timeline

* Add event handling to Notifications

* Mostly finish events

* Fix unsubscribing

* Cleanup timeline

* Fix newStatusEvent in thread, fix deleteEvent

* Insert new toots only in specific timelines

* Add missing else

* Rename AppStore to EventHub

* Fix tests

* Use DiffUtils for timeline

* Fix empty timeline bug. Improve loading placeholder

* Fix AsyncListDiff, loading indicator, "load more"

* Timeline fixes & improvements.

Fix infinite loading. Remove spinner correctly.
Don't refresh timeline without need.
This commit is contained in:
Ivan Kupalov 2018-05-27 11:22:12 +03:00 committed by GitHub
commit 3756a1fd20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 1064 additions and 542 deletions

View file

@ -15,11 +15,12 @@
package com.keylesspalace.tusky.network
import android.content.Intent
import android.support.v4.content.LocalBroadcastManager
import com.keylesspalace.tusky.appstore.EventHub
import com.keylesspalace.tusky.appstore.BlockEvent
import com.keylesspalace.tusky.appstore.MuteEvent
import com.keylesspalace.tusky.appstore.StatusDeletedEvent
import com.keylesspalace.tusky.entity.Relationship
import com.keylesspalace.tusky.entity.Status
import com.keylesspalace.tusky.receiver.TimelineReceiver
import okhttp3.ResponseBody
import retrofit2.Call
import retrofit2.Callback
@ -39,7 +40,7 @@ interface TimelineCases {
class TimelineCasesImpl(
private val mastodonApi: MastodonApi,
private val broadcastManager: LocalBroadcastManager
private val eventHub: EventHub
) : TimelineCases {
override fun reblogWithCallback(status: Status, reblog: Boolean, callback: Callback<Status>) {
val id = status.actionableId
@ -70,9 +71,7 @@ class TimelineCasesImpl(
override fun onFailure(call: Call<Relationship>, t: Throwable) {}
})
val intent = Intent(TimelineReceiver.Types.MUTE_ACCOUNT)
intent.putExtra("id", id)
broadcastManager.sendBroadcast(intent)
eventHub.dispatch(MuteEvent(id))
}
override fun block(id: String) {
@ -82,9 +81,8 @@ class TimelineCasesImpl(
override fun onFailure(call: Call<Relationship>, t: Throwable) {}
})
val intent = Intent(TimelineReceiver.Types.BLOCK_ACCOUNT)
intent.putExtra("id", id)
broadcastManager.sendBroadcast(intent)
eventHub.dispatch(BlockEvent(id))
}
override fun delete(id: String) {
@ -94,6 +92,7 @@ class TimelineCasesImpl(
override fun onFailure(call: Call<ResponseBody>, t: Throwable) {}
})
eventHub.dispatch(StatusDeletedEvent(id))
}
}