Lifecycle improvements

This commit is contained in:
Phillip Thelen 2021-06-21 12:21:55 +02:00
parent 395416825b
commit e6ca51c599
10 changed files with 29 additions and 23 deletions

View file

@ -146,7 +146,7 @@ android {
buildConfigField "String", "TESTING_LEVEL", "\"production\""
resConfigs "en", "bg", "de", "en-rGB", "es", "fr", "hr-rHR", "in", "it", "iw", "ja", "ko", "lt", "nl", "pl", "pt-rBR", "pt-rPT", "ru", "tr", "zh", "zh-rTW"
versionCode 2974
versionCode 2978
versionName "3.3"
}

View file

@ -13,6 +13,7 @@ import android.widget.TextView
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.widget.AppCompatCheckedTextView
import androidx.appcompat.widget.Toolbar
import androidx.lifecycle.lifecycleScope
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.components.UserComponent
import com.habitrpg.android.habitica.data.ChallengeRepository
@ -149,7 +150,7 @@ class ChallengeFormActivity : BaseActivity() {
savingInProgress = false
finish()
if (!editMode) {
GlobalScope.launch(context = Dispatchers.Main) {
lifecycleScope.launch(context = Dispatchers.Main) {
delay(500L)
MainNavigationController.navigate(ChallengesOverviewFragmentDirections.openChallengeDetail(challengeId ?: ""))
}

View file

@ -7,6 +7,7 @@ import android.view.*
import android.widget.*
import androidx.core.content.ContextCompat
import androidx.core.os.bundleOf
import androidx.lifecycle.lifecycleScope
import coil.load
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.components.UserComponent
@ -34,7 +35,6 @@ import com.habitrpg.android.habitica.ui.views.HabiticaSnackbar.SnackbarDisplayTy
import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaAlertDialog
import io.reactivex.rxjava3.core.Flowable
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import java.text.SimpleDateFormat
@ -176,7 +176,7 @@ class FullProfileActivity : BaseActivity() {
private fun showSendMessageToUserDialog() {
finish()
GlobalScope.launch(context = Dispatchers.Main) {
lifecycleScope.launch(context = Dispatchers.Main) {
delay(1000L)
MainNavigationController.navigate(R.id.inboxMessageListFragment, bundleOf(Pair("username", username), Pair("userID", userID)))
}

View file

@ -16,6 +16,7 @@ import androidx.core.content.edit
import androidx.core.os.bundleOf
import androidx.core.view.GravityCompat
import androidx.fragment.app.DialogFragment
import androidx.lifecycle.lifecycleScope
import com.habitrpg.android.habitica.HabiticaBaseApplication
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.data.ContentRepository
@ -209,7 +210,7 @@ class NavigationDrawerFragment : DialogFragment() {
}).subscribe( { pair ->
updateSeasonalMenuEntries(pair.first, pair.second)
seasonalShopJob?.cancel()
seasonalShopJob = GlobalScope.launch(Dispatchers.Main) {
seasonalShopJob = lifecycleScope.launch(Dispatchers.Main) {
val gearEvent = pair.first.events.firstOrNull { it.gear }
while (gearEvent?.end?.after(Date()) == true || pair.second.isNotEmpty()) {
updateSeasonalMenuEntries(pair.first, pair.second)

View file

@ -9,6 +9,7 @@ import android.view.View
import android.view.ViewGroup
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.content.ContextCompat
import androidx.lifecycle.lifecycleScope
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.components.UserComponent
import com.habitrpg.android.habitica.databinding.FragmentSkillsBinding
@ -26,8 +27,6 @@ import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
import com.habitrpg.android.habitica.ui.views.HabiticaSnackbar
import com.habitrpg.android.habitica.ui.views.HabiticaSnackbar.Companion.showSnackbar
import io.reactivex.rxjava3.core.Flowable
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
@ -110,6 +109,7 @@ class SkillsFragment : BaseMainFragment<FragmentSkillsBinding>() {
}
private fun displaySkillResult(usedSkill: Skill?, response: SkillResponse) {
if (!isAdded) return
adapter?.mana = response.user?.stats?.mp ?: 0.0
val activity = activity ?: return
if ("special" == usedSkill?.habitClass) {
@ -124,15 +124,14 @@ class SkillsFragment : BaseMainFragment<FragmentSkillsBinding>() {
}
}
if (response.damage > 0) {
context?.let {
GlobalScope.launch(context = Dispatchers.Main) {
delay(2000L)
showSnackbar(activity.snackbarContainer, null,
context?.getString(R.string.caused_damage),
BitmapDrawable(resources, HabiticaIconsHelper.imageOfDamage()),
ContextCompat.getColor(it, R.color.green_10), "+%.01f".format(response.damage),
HabiticaSnackbar.SnackbarDisplayType.SUCCESS)
}
lifecycleScope.launch {
delay(2000L)
if (!isAdded) return@launch
showSnackbar(activity.snackbarContainer, null,
context?.getString(R.string.caused_damage),
BitmapDrawable(resources, HabiticaIconsHelper.imageOfDamage()),
ContextCompat.getColor(activity, R.color.green_10), "+%.01f".format(response.damage),
HabiticaSnackbar.SnackbarDisplayType.SUCCESS)
}
}
compositeSubscription.add(userRepository.retrieveUser(false).subscribe({ }, RxErrorHandler.handleEmptyError()))

View file

@ -8,6 +8,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.activity.result.contract.ActivityResultContracts
import androidx.lifecycle.lifecycleScope
import com.habitrpg.android.habitica.MainNavDirections
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.components.UserComponent
@ -157,7 +158,7 @@ class GuildDetailFragment : BaseFragment<FragmentGuildDetailBinding>() {
val context = context
if (context != null) {
var groupChallenges = getGroupChallenges()
GlobalScope.launch(Dispatchers.Main) {
lifecycleScope.launch(Dispatchers.Main) {
delay(500)
if (groupChallenges.isNotEmpty()) {
val alert = HabiticaAlertDialog(context)

View file

@ -9,6 +9,7 @@ import android.widget.TextView
import androidx.appcompat.widget.AppCompatEditText
import androidx.core.content.ContextCompat
import androidx.core.os.bundleOf
import androidx.lifecycle.lifecycleScope
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.components.UserComponent
import com.habitrpg.android.habitica.data.InventoryRepository
@ -135,7 +136,7 @@ class PartyDetailFragment : BaseFragment<FragmentPartyDetailBinding>() {
binding?.newQuestButton?.visibility = View.GONE
binding?.questDetailButton?.visibility = View.VISIBLE
binding?.questImageWrapper?.visibility = View.VISIBLE
GlobalScope.launch(Dispatchers.Main) {
lifecycleScope.launch(Dispatchers.Main) {
delay(500)
inventoryRepository.getQuestContent(party.quest?.key ?: "")
.subscribe({ this@PartyDetailFragment.updateQuestContent(it) }, RxErrorHandler.handleEmptyError())
@ -355,8 +356,8 @@ class PartyDetailFragment : BaseFragment<FragmentPartyDetailBinding>() {
internal fun leaveParty() {
val context = context
if (context != null) {
var groupChallenges = getGroupChallenges()
GlobalScope.launch(Dispatchers.Main) {
val groupChallenges = getGroupChallenges()
lifecycleScope.launch(Dispatchers.Main) {
delay(500)
if (groupChallenges.isNotEmpty()) {
val alert = HabiticaAlertDialog(context)

View file

@ -8,7 +8,6 @@ import android.text.SpannableString
import android.text.Spanned
import android.text.method.LinkMovementMethod
import android.widget.TextView
import androidx.core.content.ContextCompat.startActivity
import com.habitrpg.android.habitica.BuildConfig
import com.habitrpg.android.habitica.extensions.handleUrlClicks
import com.habitrpg.android.habitica.helpers.RxErrorHandler

View file

@ -17,6 +17,11 @@ class AnalyticsManagerImpl(context: Context): AnalyticsManager {
}
override fun logException(t: Throwable) {
if (t is org.solovyev.android.checkout.BillingException) {
if (t.response == org.solovyev.android.checkout.ResponseCodes.USER_CANCELED) {
return
}
}
FirebaseCrashlytics.getInstance().recordException(t)
}

View file

@ -1,2 +1 @@
This latest update improves the use of certain skills. Now we will display how much damage you do to a boss right when you use a skill like Brutal Smash. The list of tasks that displays when you use a skill will only show viable tasks as well now. Weve also made some improvements to the mini notifications you receive when getting an item or level up, clarified the reason given for equipment being locked, and fixed a few pesky bugs in the process. Hope you enjoy!
In this update, weve improved more of our notifications so they bring you to the relevant screen when tapped. When customizing your avatar, youll be able to see your avatar updating in real time as you select different options. You can also see your current Gems when gifting Gems from your balance now. We've fixed a few bugs too, including one where tasks wouldnt load when the app is left running in the background for awhile, and another where Dailies wouldnt filter properly on launch.