mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-19 12:18:59 +00:00
Add dialog for gear
This commit is contained in:
parent
e455677da9
commit
c551ed85e7
6 changed files with 194 additions and 12 deletions
103
Habitica/res/layout/dialog_purchase_content_gear.xml
Normal file
103
Habitica/res/layout/dialog_purchase_content_gear.xml
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="@dimen/shopitem_dialog_content_inset"
|
||||
android:paddingRight="@dimen/shopitem_dialog_content_inset"
|
||||
android:gravity="center_horizontal"
|
||||
tools:parentTag="LinearLayout"
|
||||
tools:orientation="vertical">
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="@dimen/shopitem_image_size"
|
||||
android:layout_height="@dimen/shopitem_image_size" />
|
||||
<TextView
|
||||
android:id="@id/titleTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Headline"
|
||||
tools:text="This is the Title"
|
||||
android:gravity="center"
|
||||
android:layout_marginTop="14dp"
|
||||
android:layout_marginBottom="4dp"/>
|
||||
<TextView
|
||||
android:id="@id/notesTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Body2"
|
||||
android:textColor="@color/black_50_alpha"
|
||||
tools:text="These are the notes"
|
||||
android:gravity="center"/>
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp">
|
||||
<TableRow
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
>
|
||||
<TextView
|
||||
android:id="@+id/str_label"
|
||||
android:text="@string/str_abbrv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="12dp"/>
|
||||
<TextView
|
||||
android:id="@+id/str_value"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="+6"
|
||||
android:layout_marginRight="16dp"
|
||||
android:textColor="@color/good_50"/>
|
||||
<TextView
|
||||
android:id="@+id/per_label"
|
||||
android:text="@string/per_abbrv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="12dp"/>
|
||||
<TextView
|
||||
android:id="@+id/per_value"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="+6"
|
||||
android:layout_marginRight="16dp"
|
||||
android:textColor="@color/good_50"/>
|
||||
</TableRow>
|
||||
<TableRow
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
<TextView
|
||||
android:id="@+id/con_label"
|
||||
android:text="@string/con_abbrv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="12dp"/>
|
||||
<TextView
|
||||
android:id="@+id/con_value"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="+6"
|
||||
android:layout_marginRight="16dp"
|
||||
android:textColor="@color/good_50"/>
|
||||
<TextView
|
||||
android:id="@+id/int_label"
|
||||
android:text="@string/int_abbrv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="12dp"/>
|
||||
<TextView
|
||||
android:id="@+id/int_value"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="+6"
|
||||
android:layout_marginRight="16dp"
|
||||
android:textColor="@color/good_50"/>
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
</merge>
|
||||
|
|
@ -640,4 +640,8 @@
|
|||
<string name="experience_reward" formatted="false">%d Experience points</string>
|
||||
<string name="gold_reward" formatted="false">%d Gold</string>
|
||||
<string name="quest_owner_rewards">Quest Owner Rewards</string>
|
||||
<string name="str_abbrv">Str:</string>
|
||||
<string name="per_abbrv">Per:</string>
|
||||
<string name="int_abbrv">Int:</string>
|
||||
<string name="con_abbrv">Con:</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ public class Equipment extends RealmObject {
|
|||
public String index;
|
||||
public String text;
|
||||
public String notes;
|
||||
public float con, str, per;
|
||||
public int con, str, per;
|
||||
@SerializedName("int")
|
||||
public float _int;
|
||||
public int _int;
|
||||
public Boolean owned;
|
||||
|
||||
public Equipment() {
|
||||
|
|
@ -89,35 +89,35 @@ public class Equipment extends RealmObject {
|
|||
this.notes = notes;
|
||||
}
|
||||
|
||||
public float getCon() {
|
||||
public int getCon() {
|
||||
return con;
|
||||
}
|
||||
|
||||
public void setCon(float con) {
|
||||
public void setCon(int con) {
|
||||
this.con = con;
|
||||
}
|
||||
|
||||
public float getStr() {
|
||||
public int getStr() {
|
||||
return str;
|
||||
}
|
||||
|
||||
public void setStr(float str) {
|
||||
public void setStr(int str) {
|
||||
this.str = str;
|
||||
}
|
||||
|
||||
public float getPer() {
|
||||
public int getPer() {
|
||||
return per;
|
||||
}
|
||||
|
||||
public void setPer(float per) {
|
||||
public void setPer(int per) {
|
||||
this.per = per;
|
||||
}
|
||||
|
||||
public float get_int() {
|
||||
public int get_int() {
|
||||
return _int;
|
||||
}
|
||||
|
||||
public void set_int(float _int) {
|
||||
public void set_int(int _int) {
|
||||
this._int = _int;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ public class ShopItem {
|
|||
}
|
||||
|
||||
public boolean isTypeGear() {
|
||||
return false;
|
||||
return "gear".equals(purchaseType);
|
||||
}
|
||||
|
||||
public boolean isTypeAnimal() {
|
||||
|
|
|
|||
|
|
@ -147,7 +147,10 @@ public class PurchaseDialog extends AlertDialog {
|
|||
contentView = new PurchaseDialogItemContent(getContext());
|
||||
} else if (shopItem.isTypeQuest()) {
|
||||
contentView = new PurchaseDialogQuestContent(getContext());
|
||||
inventoryRepository.getQuestContent(item.getKey()).first().subscribe(((PurchaseDialogQuestContent)contentView)::setQuestContent, RxErrorHandler.handleEmptyError());
|
||||
inventoryRepository.getQuestContent(item.getKey()).first().subscribe(((PurchaseDialogQuestContent) contentView)::setQuestContent, RxErrorHandler.handleEmptyError());
|
||||
} else if (shopItem.isTypeGear()) {
|
||||
contentView = new PurchaseDialogGearContent(getContext());
|
||||
inventoryRepository.getEquipment(item.getKey()).first().subscribe(((PurchaseDialogGearContent) contentView)::setEquipment, RxErrorHandler.handleEmptyError());
|
||||
} else if ("gems".equals(shopItem.purchaseType)) {
|
||||
contentView = new PurchaseDialogGemsContent(getContext());
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,72 @@
|
|||
package com.habitrpg.android.habitica.ui.views.shops;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.models.inventory.Equipment;
|
||||
import com.habitrpg.android.habitica.models.shops.ShopItem;
|
||||
import com.habitrpg.android.habitica.models.user.Gear;
|
||||
|
||||
import butterknife.BindView;
|
||||
|
||||
class PurchaseDialogGearContent extends PurchaseDialogContent {
|
||||
|
||||
|
||||
@BindView(R.id.notesTextView)
|
||||
TextView notesTextView;
|
||||
@BindView(R.id.str_label)
|
||||
TextView strLabel;
|
||||
@BindView(R.id.str_value)
|
||||
TextView strValueTextView;
|
||||
@BindView(R.id.per_label)
|
||||
TextView perLabel;
|
||||
@BindView(R.id.per_value)
|
||||
TextView perValueTextView;
|
||||
@BindView(R.id.con_label)
|
||||
TextView conLabel;
|
||||
@BindView(R.id.con_value)
|
||||
TextView conValueTextView;
|
||||
@BindView(R.id.int_label)
|
||||
TextView intLabel;
|
||||
@BindView(R.id.int_value)
|
||||
TextView intValueTextView;
|
||||
|
||||
public PurchaseDialogGearContent(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public PurchaseDialogGearContent(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getViewId() {
|
||||
return R.layout.dialog_purchase_content_gear;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem(ShopItem item) {
|
||||
super.setItem(item);
|
||||
notesTextView.setText(item.getNotes());
|
||||
}
|
||||
|
||||
public void setEquipment(Equipment equipment) {
|
||||
configureFieldsForValue(strLabel, strValueTextView, equipment.str);
|
||||
configureFieldsForValue(perLabel, perValueTextView, equipment.per);
|
||||
configureFieldsForValue(conLabel, conValueTextView, equipment.con);
|
||||
configureFieldsForValue(intLabel, intValueTextView, equipment._int);
|
||||
}
|
||||
|
||||
private void configureFieldsForValue(TextView labelView, TextView valueTextView, int value) {
|
||||
valueTextView.setText("+"+value);
|
||||
if (value == 0) {
|
||||
labelView.setTextColor(ContextCompat.getColor(getContext(), R.color.gray_400));
|
||||
valueTextView.setTextColor(ContextCompat.getColor(getContext(), R.color.gray_400));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue