mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
Added info about found quest items in a snackbar
When user finds an item as a result, the information is displayed in the same way, as for other found items. If he/she finds both — quest item and some other treasure both are displayed in the same dialog. Three subsequent notifications would be quite unhandy and also it seemed easier to be accomplished this way.
This commit is contained in:
parent
2da5d82212
commit
da9e44231a
5 changed files with 16 additions and 5 deletions
|
|
@ -76,6 +76,7 @@ class TaskRepositoryImpl(localRepository: TaskLocalRepository, apiClient: ApiCli
|
|||
result.goldDelta = localData.gp - (stats?.gp ?: 0.0)
|
||||
result.hasLeveledUp = localData.lvl > stats?.lvl ?: 0
|
||||
result.questDamage = localData._tmp?.quest?.progressDelta
|
||||
result.questItemsFound = localData._tmp?.quest?.collection
|
||||
result.drop = localData._tmp?.drop
|
||||
notifyFunc?.invoke(result)
|
||||
|
||||
|
|
@ -108,6 +109,7 @@ class TaskRepositoryImpl(localRepository: TaskLocalRepository, apiClient: ApiCli
|
|||
result.goldDelta = res.gp - (stats?.gp ?: 0.0)
|
||||
result.hasLeveledUp = res.lvl > stats?.lvl ?: 0
|
||||
result.questDamage = res._tmp?.quest?.progressDelta
|
||||
result.questItemsFound = res._tmp?.quest?.collection
|
||||
result.drop = res._tmp?.drop
|
||||
if (localData == null) {
|
||||
notifyFunc?.invoke(result)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.habitrpg.android.habitica.helpers.SoundManager
|
|||
import com.habitrpg.android.habitica.models.responses.TaskScoringResult
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaSnackbar
|
||||
import io.reactivex.Flowable
|
||||
import java.lang.StringBuilder
|
||||
import javax.inject.Inject
|
||||
|
||||
class DisplayItemDropUseCase @Inject
|
||||
|
|
@ -17,11 +18,18 @@ constructor(private val soundManager: SoundManager, threadExecutor: ThreadExecut
|
|||
override fun buildUseCaseObservable(requestValues: RequestValues): Flowable<Void> {
|
||||
return Flowable.defer {
|
||||
val data = requestValues.data
|
||||
var snackbarText = StringBuilder(data?.drop?.dialog ?: "")
|
||||
|
||||
if (data?.drop != null) {
|
||||
if (data?.questItemsFound ?: 0 > 0 && requestValues.showQuestItems) {
|
||||
if (snackbarText.isNotEmpty())
|
||||
snackbarText.append('\n')
|
||||
snackbarText.append("+${data!!.questItemsFound} quest items")
|
||||
}
|
||||
|
||||
if (snackbarText.isNotEmpty()) {
|
||||
Handler().postDelayed({
|
||||
HabiticaSnackbar.showSnackbar(requestValues.snackbarTargetView,
|
||||
data.drop?.dialog, HabiticaSnackbar.SnackbarDisplayType.DROP)
|
||||
snackbarText, HabiticaSnackbar.SnackbarDisplayType.DROP)
|
||||
soundManager.loadAndPlayAudio(SoundManager.SoundItemDrop)
|
||||
}, 3000L)
|
||||
}
|
||||
|
|
@ -30,5 +38,5 @@ constructor(private val soundManager: SoundManager, threadExecutor: ThreadExecut
|
|||
}
|
||||
}
|
||||
|
||||
class RequestValues(val data: TaskScoringResult?, val context: AppCompatActivity, val snackbarTargetView: ViewGroup) : UseCase.RequestValues
|
||||
class RequestValues(val data: TaskScoringResult?, val context: AppCompatActivity, val snackbarTargetView: ViewGroup, val showQuestItems: Boolean) : UseCase.RequestValues
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ class TaskDirectionDataTemp {
|
|||
|
||||
class TaskDirectionDataQuest {
|
||||
var progressDelta: Double = 0.0
|
||||
var collection: Int = 0
|
||||
}
|
||||
|
||||
class TaskDirectionDataDrop {
|
||||
|
|
|
|||
|
|
@ -9,4 +9,5 @@ class TaskScoringResult {
|
|||
var manaDelta: Double? = null
|
||||
var hasLeveledUp: Boolean = false
|
||||
var questDamage: Double? = null
|
||||
var questItemsFound: Int? = null
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,6 @@ import io.realm.Realm
|
|||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import java.util.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.inject.Inject
|
||||
|
||||
open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
|
||||
|
|
@ -500,7 +499,7 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
|
|||
.subscribe(Consumer { }, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
|
||||
compositeSubscription.add(displayItemDropUseCase.observable(DisplayItemDropUseCase.RequestValues(data, this, snackbarContainer))
|
||||
compositeSubscription.add(displayItemDropUseCase.observable(DisplayItemDropUseCase.RequestValues(data, this, snackbarContainer, userIsOnQuest))
|
||||
.subscribe(Consumer { }, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue