mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-18 03:39:00 +00:00
Correct display of owned pets
This commit is contained in:
parent
8706003c27
commit
7fe99b80ec
2 changed files with 22 additions and 25 deletions
|
|
@ -99,13 +99,17 @@ public class PetDetailRecyclerAdapter extends RecyclerView.Adapter<PetDetailRecy
|
|||
itemView.setOnClickListener(this);
|
||||
}
|
||||
|
||||
public Boolean isOwned() {
|
||||
public int getOwnedStatus() {
|
||||
if (ownedMapping != null && animal != null) {
|
||||
if (ownedMapping.containsKey(animal.getKey()) && ownedMapping.get(animal.getKey()) != 0) {
|
||||
return true;
|
||||
if (ownedMapping.containsKey(animal.getKey())) {
|
||||
return ownedMapping.get(animal.getKey());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean isOwned() {
|
||||
return this.getOwnedStatus() > 0;
|
||||
}
|
||||
|
||||
public Boolean isMountOwned() {
|
||||
|
|
@ -125,7 +129,7 @@ public class PetDetailRecyclerAdapter extends RecyclerView.Adapter<PetDetailRecy
|
|||
this.titleView.setText(item.getColorText());
|
||||
this.trainedProgressbar.setVisibility(View.VISIBLE);
|
||||
this.imageView.setAlpha(1.0f);
|
||||
if (this.isOwned()) {
|
||||
if (this.getOwnedStatus() > 0) {
|
||||
if (this.isMountOwned()) {
|
||||
this.trainedProgressbar.setVisibility(View.GONE);
|
||||
} else {
|
||||
|
|
@ -134,7 +138,11 @@ public class PetDetailRecyclerAdapter extends RecyclerView.Adapter<PetDetailRecy
|
|||
DataBindingUtils.loadImage(this.imageView, "Pet-" + itemType + "-" + item.getColor());
|
||||
} else {
|
||||
this.trainedProgressbar.setVisibility(View.GONE);
|
||||
DataBindingUtils.loadImage(this.imageView, "PixelPaw");
|
||||
if (this.getOwnedStatus() == 0) {
|
||||
DataBindingUtils.loadImage(this.imageView, "PixelPaw");
|
||||
} else {
|
||||
DataBindingUtils.loadImage(this.imageView, "Pet-" + itemType + "-" + item.getColor());
|
||||
}
|
||||
this.imageView.setAlpha(0.4f);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,7 @@ package com.habitrpg.android.habitica.ui.fragments.inventory;
|
|||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
@ -14,24 +11,15 @@ import android.widget.TextView;
|
|||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.events.ContentReloadedEvent;
|
||||
import com.habitrpg.android.habitica.events.ReloadContentEvent;
|
||||
import com.habitrpg.android.habitica.ui.DividerItemDecoration;
|
||||
import com.habitrpg.android.habitica.ui.activities.MainActivity;
|
||||
import com.habitrpg.android.habitica.ui.adapter.inventory.ItemRecyclerAdapter;
|
||||
import com.habitrpg.android.habitica.ui.adapter.inventory.StableRecyclerAdapter;
|
||||
import com.habitrpg.android.habitica.ui.fragments.BaseFragment;
|
||||
import com.habitrpg.android.habitica.ui.helpers.MarginDecoration;
|
||||
import com.habitrpg.android.habitica.ui.helpers.RecyclerViewEmptySupport;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.inventory.Animal;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.inventory.Egg;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.inventory.Food;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.inventory.HatchingPotion;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.inventory.Item;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.inventory.Mount;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.inventory.Pet;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.inventory.QuestContent;
|
||||
import com.raizlabs.android.dbflow.sql.builder.Condition;
|
||||
import com.raizlabs.android.dbflow.sql.language.From;
|
||||
import com.raizlabs.android.dbflow.sql.language.Select;
|
||||
import com.raizlabs.android.dbflow.sql.language.Where;
|
||||
|
||||
|
|
@ -39,13 +27,10 @@ import org.greenrobot.eventbus.EventBus;
|
|||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
import rx.Observable;
|
||||
|
||||
public class StableRecyclerFragment extends BaseFragment {
|
||||
@Bind(R.id.recyclerView)
|
||||
|
|
@ -74,8 +59,6 @@ public class StableRecyclerFragment extends BaseFragment {
|
|||
recyclerView.setEmptyView(emptyView);
|
||||
emptyView.setText(getString(R.string.empty_items, itemTypeText));
|
||||
|
||||
android.support.v4.app.FragmentActivity context = getActivity();
|
||||
|
||||
layoutManager = new GridLayoutManager(getActivity(), 2);
|
||||
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
|
||||
@Override
|
||||
|
|
@ -177,7 +160,10 @@ public class StableRecyclerFragment extends BaseFragment {
|
|||
}
|
||||
switch (itemType) {
|
||||
case "pets":
|
||||
if (user.getItems().getPets() != null && user.getItems().getPets().containsKey(animal.getKey()) && user.getItems().getPets().get(animal.getKey()) != null) {
|
||||
if (user.getItems().getPets() != null
|
||||
&& user.getItems().getPets().containsKey(animal.getKey())
|
||||
&& user.getItems().getPets().get(animal.getKey()) != null
|
||||
&& user.getItems().getPets().get(animal.getKey()) > 0) {
|
||||
if (lastAnimal.getNumberOwned() == 0) {
|
||||
lastAnimal.setColor(animal.getColor());
|
||||
}
|
||||
|
|
@ -185,7 +171,10 @@ public class StableRecyclerFragment extends BaseFragment {
|
|||
}
|
||||
break;
|
||||
case "mounts":
|
||||
if (user.getItems().getMounts() != null && user.getItems().getMounts().containsKey(animal.getKey()) && user.getItems().getMounts().get(animal.getKey()) != null) {
|
||||
if (user.getItems().getMounts() != null
|
||||
&& user.getItems().getMounts().containsKey(animal.getKey())
|
||||
&& user.getItems().getMounts().get(animal.getKey()) != null
|
||||
&& user.getItems().getMounts().get(animal.getKey())) {
|
||||
if (lastAnimal.getNumberOwned() == 0) {
|
||||
lastAnimal.setColor(animal.getColor());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue