mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-13 01:38:21 +00:00
fix sorting for backgrounds
This commit is contained in:
parent
21d6342968
commit
5c29001cca
9 changed files with 45 additions and 18 deletions
1
Habitica/assets/migrations/Habitica/7.sql
Normal file
1
Habitica/assets/migrations/Habitica/7.sql
Normal file
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE Customization ADD COLUMN customizationSetName varchar(255);
|
||||
|
|
@ -31,6 +31,7 @@
|
|||
<LinearLayout
|
||||
android:id="@+id/LL_header"
|
||||
android:layout_toRightOf="@id/IMG_ProfilePicture"
|
||||
android:layout_toEndOf="@id/IMG_ProfilePicture"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
|
|
@ -53,7 +54,7 @@
|
|||
<TextView
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_below="@id/LL_header"
|
||||
android:layout_below="@id/IMG_ProfilePicture"
|
||||
android:id="@+id/lvl_tv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="36dp"
|
||||
|
|
@ -64,7 +65,7 @@
|
|||
android:textSize="14sp"
|
||||
android:textColor="@color/textColorSecondaryDark"/>
|
||||
<LinearLayout
|
||||
android:layout_below="@id/LL_header"
|
||||
android:layout_below="@id/IMG_ProfilePicture"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
|||
|
|
@ -10,5 +10,5 @@ public class HabitDatabase {
|
|||
|
||||
public static final String NAME = "Habitica";
|
||||
|
||||
public static final int VERSION = 6;
|
||||
public static final int VERSION = 7;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ public class AvatarWithBarsViewModel implements View.OnClickListener {
|
|||
private HabitRPGUser userObject;
|
||||
private UserPicture userPicture;
|
||||
|
||||
private int cachedMaxHealth, cachedMaxExp, cachedMaxMana;
|
||||
|
||||
public AvatarWithBarsViewModel(Context context, View v) {
|
||||
this.context = context;
|
||||
|
||||
|
|
@ -119,13 +121,11 @@ public class AvatarWithBarsViewModel implements View.OnClickListener {
|
|||
drawable.getMinimumHeight());
|
||||
lvlText.setCompoundDrawables(drawable, null, null, null);
|
||||
|
||||
// binding.setClassShort(classShort);
|
||||
goldText.setText(String.valueOf(gp));
|
||||
silverText.setText(String.valueOf(sp));
|
||||
|
||||
goldText.setText(gp + "");
|
||||
silverText.setText(sp + "");
|
||||
|
||||
Double gems = new Double(user.getBalance() * 4);
|
||||
gemsText.setText(gems.intValue() + "");
|
||||
Double gems = user.getBalance() * 4;
|
||||
gemsText.setText(String.valueOf(gems.intValue()));
|
||||
}
|
||||
|
||||
public static void setHpBarData(ValueBarBinding valueBar, Stats stats, Context ctx) {
|
||||
|
|
@ -142,14 +142,29 @@ public class AvatarWithBarsViewModel implements View.OnClickListener {
|
|||
}
|
||||
|
||||
public void setHpBarData(float value, int valueMax){
|
||||
if (valueMax == 0) {
|
||||
valueMax = cachedMaxHealth;
|
||||
} else {
|
||||
cachedMaxHealth = valueMax;
|
||||
}
|
||||
setValueBar(hpBar, value, valueMax, context.getString(R.string.HP_default), context.getResources().getColor(R.color.hpColor), R.drawable.ic_header_heart);
|
||||
}
|
||||
|
||||
public void setXpBarData(float value, int valueMax){
|
||||
if (valueMax == 0) {
|
||||
valueMax = cachedMaxExp;
|
||||
} else {
|
||||
cachedMaxExp = valueMax;
|
||||
}
|
||||
setValueBar(xpBar, value, valueMax, context.getString(R.string.XP_default), context.getResources().getColor(R.color.xpColor), R.drawable.ic_header_exp);
|
||||
}
|
||||
|
||||
public void setMpBarData(float value, int valueMax){
|
||||
if (valueMax == 0) {
|
||||
valueMax = cachedMaxMana;
|
||||
} else {
|
||||
cachedMaxMana = valueMax;
|
||||
}
|
||||
setValueBar(mpBar, value, valueMax, context.getString(R.string.MP_default), context.getResources().getColor(R.color.mpColor), R.drawable.ic_header_magic);
|
||||
}
|
||||
|
||||
|
|
@ -173,9 +188,9 @@ public class AvatarWithBarsViewModel implements View.OnClickListener {
|
|||
}
|
||||
|
||||
public void onEvent(BoughtGemsEvent gemsEvent){
|
||||
Double gems = new Double(userObject.getBalance() * 4);
|
||||
Double gems = userObject.getBalance() * 4;
|
||||
gems += gemsEvent.NewGemsToAdd;
|
||||
gemsText.setText(gems.intValue() + "");
|
||||
gemsText.setText(String.valueOf(gems.intValue()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -48,9 +48,10 @@ public class CustomizationRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
|||
this.customizationList = new ArrayList<Object>();
|
||||
CustomizationSet lastSet = new CustomizationSet();
|
||||
for (Customization customization : newCustomizationList) {
|
||||
if (customization.getCustomizationSet() != null && !customization.getCustomizationSet().equals(lastSet.text)) {
|
||||
if (customization.getCustomizationSet() != null && !customization.getCustomizationSet().equals(lastSet.identifier)) {
|
||||
CustomizationSet set = new CustomizationSet();
|
||||
set.text = customization.getCustomizationSet();
|
||||
set.identifier = customization.getCustomizationSet();
|
||||
set.text = customization.getCustomizationSetName();
|
||||
set.price = customization.getSetPrice();
|
||||
set.hasPurchasable = !customization.isUsable();
|
||||
lastSet = set;
|
||||
|
|
@ -250,8 +251,7 @@ public class CustomizationRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
|||
|
||||
public void bind(CustomizationSet set) {
|
||||
this.set = set;
|
||||
String uppercasedSectionName = this.set.text.substring(0, 1).toUpperCase() + this.set.text.substring(1);
|
||||
this.label.setText(uppercasedSectionName);
|
||||
this.label.setText(set.text);
|
||||
if (set.hasPurchasable) {
|
||||
this.purchaseSetButton.setVisibility(View.VISIBLE);
|
||||
this.purchaseSetButton.setText(context.getString(R.string.purchase_set_button, set.price));
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import com.magicmicky.habitrpgwrapper.lib.models.Customization;
|
|||
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.Preferences;
|
||||
import com.raizlabs.android.dbflow.sql.builder.Condition;
|
||||
import com.raizlabs.android.dbflow.sql.language.OrderBy;
|
||||
import com.raizlabs.android.dbflow.sql.language.Select;
|
||||
import com.raizlabs.android.dbflow.sql.language.Where;
|
||||
|
||||
|
|
@ -95,7 +96,11 @@ public class AvatarCustomizationFragment extends BaseFragment {
|
|||
if (this.category != null) {
|
||||
select = select.and(Condition.column("category").eq(this.category));
|
||||
}
|
||||
select.orderBy(true, "customizationSet", "identifier");
|
||||
if (this.type.equals("background")) {
|
||||
select.orderBy(OrderBy.columns("customizationSetName").descending());
|
||||
} else {
|
||||
select.orderBy(true, "customizationSet");
|
||||
}
|
||||
|
||||
List<Customization> customizations = select.queryList();
|
||||
adapter.setCustomizationList(customizations);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public class Customization extends BaseModel {
|
|||
private String id;
|
||||
|
||||
@Column
|
||||
private String identifier, category, type, notes, customizationSet, text;
|
||||
private String identifier, category, type, notes, customizationSet, customizationSetName, text;
|
||||
|
||||
@Column
|
||||
private boolean purchased;
|
||||
|
|
@ -49,6 +49,7 @@ public class Customization extends BaseModel {
|
|||
public void setId(String id) {this.id = id;}
|
||||
public void setNotes(String notes) {this.notes = notes;}
|
||||
public void setCustomizationSet(String customizationSet) {this.customizationSet = customizationSet;}
|
||||
public void setCustomizationSetName(String customizationSetName) {this.customizationSetName = customizationSetName;}
|
||||
public void setText(String text) {this.text = text;}
|
||||
public void setPurchased(boolean purchased) {this.purchased = purchased;}
|
||||
public void setPrice(Integer price) {this.price = price;}
|
||||
|
|
@ -62,6 +63,7 @@ public class Customization extends BaseModel {
|
|||
public String getType() { return this.type; }
|
||||
public String getNotes() { return this.notes; }
|
||||
public String getCustomizationSet() { return this.customizationSet; }
|
||||
public String getCustomizationSetName() { return this.customizationSetName; }
|
||||
public String getText() { return this.text; }
|
||||
|
||||
@SuppressWarnings("RedundantIfStatement")
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ package com.magicmicky.habitrpgwrapper.lib.models;
|
|||
public class CustomizationSet {
|
||||
|
||||
public String text;
|
||||
public String identifier;
|
||||
public Integer price;
|
||||
public boolean hasPurchasable;
|
||||
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@ public class CustomizationDeserializer implements JsonDeserializer<List<Customiz
|
|||
if (setInfo.has("availableUntil")) {
|
||||
customization.setAvailableUntil(format.parse(setInfo.get("availableUntil").getAsString()));
|
||||
}
|
||||
customization.setCustomizationSetName(setInfo.get("text").getAsString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
@ -142,11 +143,12 @@ public class CustomizationDeserializer implements JsonDeserializer<List<Customiz
|
|||
if (customization == null) {
|
||||
customization = new Customization();
|
||||
customization.setCustomizationSet(setName);
|
||||
String readableSetName = setName.substring(13, 17) + "." + setName.substring(11, 13);
|
||||
customization.setCustomizationSetName(readableSetName);
|
||||
customization.setType("background");
|
||||
customization.setIdentifier(key);
|
||||
}
|
||||
|
||||
|
||||
customization.setText(entry.get("text").getAsString());
|
||||
customization.setNotes(entry.getAsJsonObject().get("notes").getAsString());
|
||||
customization.setPrice(7);
|
||||
|
|
|
|||
Loading…
Reference in a new issue