Merge pull request #920 from kemirea/issue-911

don't show hourglass or gem count for other players. fixes #911.
This commit is contained in:
Phillip Thelen 2018-01-30 14:38:54 +01:00 committed by GitHub
commit 299bcdd60d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View file

@ -15,6 +15,7 @@ import com.habitrpg.android.habitica.events.commands.OpenGemPurchaseFragmentComm
import com.habitrpg.android.habitica.events.commands.OpenMenuItemCommand;
import com.habitrpg.android.habitica.models.Avatar;
import com.habitrpg.android.habitica.models.user.Stats;
import com.habitrpg.android.habitica.models.user.User;
import com.habitrpg.android.habitica.ui.fragments.NavigationDrawerFragment;
import com.habitrpg.android.habitica.ui.views.CurrencyViews;
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper;
@ -116,9 +117,11 @@ public class AvatarWithBarsViewModel {
setXpBarData(stats.getExp().floatValue(), stats.getToNextLevel());
setMpBarData(stats.getMp().floatValue(), stats.getMaxMP());
currencyView.setHourglasses(user.getHourglassCount());
currencyView.setGold(stats.getGp());
currencyView.setGems(user.getGemCount());
if (user instanceof User) {
currencyView.setHourglasses(user.getHourglassCount());
currencyView.setGems(user.getGemCount());
}
}
private void setHpBarData(float value, int valueMax) {

View file

@ -34,11 +34,13 @@ class CurrencyView : android.support.v7.widget.AppCompatTextView {
} catch (_: ArrayIndexOutOfBoundsException) {
true
}
visibility = GONE;
}
constructor(context: Context, currency: String, lightbackground: Boolean) : super(context) {
this.lightBackground = lightbackground
this.currency = currency
visibility = GONE;
}
private fun configureCurrency() {
@ -73,8 +75,10 @@ class CurrencyView : android.support.v7.widget.AppCompatTextView {
field = value
if (value != null) {
drawable = BitmapDrawable(resources, value)
this.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null)
val padding = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 6f, context.resources.displayMetrics).toInt()
this.setCompoundDrawablesWithIntrinsicBounds(drawable,
null, null, null)
val padding = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
6f, context.resources.displayMetrics).toInt()
compoundDrawablePadding = padding
this.gravity = Gravity.CENTER_VERTICAL
}
@ -113,6 +117,8 @@ class CurrencyView : android.support.v7.widget.AppCompatTextView {
private fun updateVisibility() {
if ("hourglasses" == this.currency) {
visibility = if ("0" == text) View.GONE else View.VISIBLE
} else {
visibility = View.VISIBLE;
}
}
}