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:
parent
3a8d96346b
commit
3756a1fd20
31 changed files with 1064 additions and 542 deletions
|
@ -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))
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue