Commit 83b7460f authored by Eugene Shapovalov's avatar Eugene Shapovalov 💬

Implement user activity assigned badges.

parent 2f19b07c
......@@ -131,7 +131,7 @@ dependencies {
implementation("ru.noties:markwon:$markwonVersion")
implementation("ru.noties:markwon-image-loader:$markwonVersion")
//Bottom navigation bar
implementation("com.aurelhubert:ahbottomnavigation:2.1.0")
implementation("com.aurelhubert:ahbottomnavigation:2.3.4")
//Lottie
implementation("com.airbnb.android:lottie:2.5.1")
//Date
......
......@@ -380,18 +380,18 @@ interface GitlabApi {
@Query("scope") scope: MergeRequestScope = MergeRequestScope.ASSIGNED_TO_ME,
@Query("state") state: MergeRequestState = MergeRequestState.OPENED,
@Query("per_page") pageSize: Int = 1
): Single<Result<Unit>>
): Single<Result<Void>>
@HEAD("$API_PATH/issues")
fun getMyAssignedIssueHeaders(
@Query("scope") scope: IssueScope = IssueScope.ASSIGNED_BY_ME,
@Query("state") state: IssueState = IssueState.OPENED,
@Query("per_page") pageSize: Int = 1
): Single<Result<Unit>>
): Single<Result<Void>>
@HEAD("$API_PATH/todos")
fun getMyAssignedTodoHeaders(
@Query("state") state: TodoState = TodoState.PENDING,
@Query("per_page") pageSize: Int = 1
): Single<Result<Unit>>
): Single<Result<Void>>
}
\ No newline at end of file
package ru.terrakok.gitlabclient.presentation.main
import com.arellomobile.mvp.InjectViewState
import io.reactivex.Single
import io.reactivex.functions.Function3
import ru.terrakok.gitlabclient.model.interactor.issue.IssueInteractor
import ru.terrakok.gitlabclient.model.interactor.mergerequest.MergeRequestInteractor
import ru.terrakok.gitlabclient.model.interactor.todo.TodoInteractor
import ru.terrakok.gitlabclient.presentation.global.BasePresenter
import javax.inject.Inject
/**
* Created by Eugene Shapovalov (@CraggyHaggy) on 20.05.19.
*/
@InjectViewState
class MainPresenter @Inject constructor(
private val issueInteractor: IssueInteractor,
private val mergeRequestInteractor: MergeRequestInteractor,
private val todoInteractor: TodoInteractor
) : BasePresenter<MainView>() {
override fun onFirstViewAttach() {
super.onFirstViewAttach()
Single
.zip(
issueInteractor.getMyAssignedIssueCount(),
mergeRequestInteractor.getMyAssignedMergeRequestCount(),
todoInteractor.getMyAssignedTodoCount(),
Function3<Int, Int, Int, Triple<Int, Int, Int>> { issueCount, mergeRequestCount, todoCount ->
Triple(issueCount, mergeRequestCount, todoCount)
}
)
.subscribe(
{ viewState.setAssignedNotifications(it.first, it.second, it.third) },
{
// TODO: user activity badges (Maybe we can retry this request, until it finishes correctly?).
}
)
.connect()
}
}
\ No newline at end of file
package ru.terrakok.gitlabclient.presentation.main
import com.arellomobile.mvp.MvpView
import com.arellomobile.mvp.viewstate.strategy.OneExecutionStateStrategy
import com.arellomobile.mvp.viewstate.strategy.StateStrategyType
/**
* Created by Eugene Shapovalov (@CraggyHaggy) on 20.05.19.
*/
@StateStrategyType(OneExecutionStateStrategy::class)
interface MainView : MvpView {
fun setAssignedNotifications(issueCount: Int, mergeRequestCount: Int, todoCount: Int)
}
\ No newline at end of file
package ru.terrakok.gitlabclient.ui.main
import android.os.Bundle
import androidx.annotation.ColorRes
import androidx.core.content.ContextCompat
import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter
import com.aurelhubert.ahbottomnavigation.AHBottomNavigationAdapter
import com.aurelhubert.ahbottomnavigation.notification.AHNotification
import kotlinx.android.synthetic.main.fragment_main.*
import ru.terrakok.cicerone.android.support.SupportAppScreen
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.Screens
import ru.terrakok.gitlabclient.extension.color
import ru.terrakok.gitlabclient.presentation.main.MainPresenter
import ru.terrakok.gitlabclient.presentation.main.MainView
import ru.terrakok.gitlabclient.ui.global.BaseFragment
/**
* @author Konstantin Tskhovrebov (aka terrakok). Date: 02.04.17
*/
class MainFragment : BaseFragment() {
class MainFragment : BaseFragment(), MainView {
override val layoutRes = R.layout.fragment_main
private val currentTabFragment: BaseFragment?
get() = childFragmentManager.fragments.firstOrNull { !it.isHidden } as? BaseFragment
@InjectPresenter
lateinit var presenter: MainPresenter
@ProvidePresenter
fun providePresenter(): MainPresenter = scope.getInstance(MainPresenter::class.java)
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
......@@ -78,6 +91,20 @@ class MainFragment : BaseFragment() {
currentTabFragment?.onBackPressed()
}
override fun setAssignedNotifications(issueCount: Int, mergeRequestCount: Int, todoCount: Int) {
with(bottomBar) {
setNotification(buildBottomBarNotification(R.color.fruit_salad, issueCount), 1)
setNotification(buildBottomBarNotification(R.color.brandy_punch, mergeRequestCount), 2)
setNotification(buildBottomBarNotification(R.color.mariner, todoCount), 3)
}
}
private fun buildBottomBarNotification(@ColorRes backgroundColor: Int, count: Int) =
AHNotification.Builder()
.setBackgroundColor(ContextCompat.getColor(requireContext(), backgroundColor))
.setText(count.toString())
.build()
companion object {
private val eventsTab = Screens.MyEvents
private val issuesTab = Screens.MyIssuesContainer
......
......@@ -19,12 +19,15 @@
<color name="green">#5AC54F</color>
<color name="lightGreen">#EEF9ED</color>
<color name="fruit_salad">#50A164</color>
<color name="red">#F23117</color>
<color name="lightRed">#FDEAE7</color>
<color name="brandy_punch">#D88138</color>
<color name="blue">#17d1f2</color>
<color name="lightBlue">#e7fafd</color>
<color name="mariner">#397BCE</color>
<color name="beige">#fff8e1</color>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment