mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
Merge origin/master
This commit is contained in:
commit
666308bd67
6 changed files with 145 additions and 152 deletions
|
@ -37,7 +37,7 @@
|
|||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" pref="1" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="panelControl" pref="654" max="32767" attributes="0"/>
|
||||
<Component id="panelControl" max="32767" attributes="0"/>
|
||||
<Component id="panelCardArea" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
|
@ -105,7 +105,7 @@
|
|||
<Component id="lblLandCount" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblCreatureCount" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblSorceryCount" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblInstantCount" alignment="3" min="-2" pref="-17" max="-2" attributes="0"/>
|
||||
<Component id="lblInstantCount" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblEnchantmentCount" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="chkPiles" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
|
@ -127,7 +127,7 @@
|
|||
<Property name="text" type="java.lang.String" value="999"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Number of all cards in this area."/>
|
||||
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
|
||||
<Color id="Standardcursor"/>
|
||||
<Color id="Default Cursor"/>
|
||||
</Property>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="inheritsPopupMenu" type="boolean" value="false"/>
|
||||
|
@ -145,7 +145,7 @@
|
|||
<Property name="toolTipText" type="java.lang.String" value="Number of lands."/>
|
||||
<Property name="verticalAlignment" type="int" value="1"/>
|
||||
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
|
||||
<Color id="Standardcursor"/>
|
||||
<Color id="Default Cursor"/>
|
||||
</Property>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="inheritsPopupMenu" type="boolean" value="false"/>
|
||||
|
@ -163,7 +163,7 @@
|
|||
<Property name="toolTipText" type="java.lang.String" value="Number of creatures."/>
|
||||
<Property name="verticalAlignment" type="int" value="1"/>
|
||||
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
|
||||
<Color id="Standardcursor"/>
|
||||
<Color id="Default Cursor"/>
|
||||
</Property>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="inheritsPopupMenu" type="boolean" value="false"/>
|
||||
|
@ -181,7 +181,7 @@
|
|||
<Property name="toolTipText" type="java.lang.String" value="Number of sorceries."/>
|
||||
<Property name="verticalAlignment" type="int" value="1"/>
|
||||
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
|
||||
<Color id="Standardcursor"/>
|
||||
<Color id="Default Cursor"/>
|
||||
</Property>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="inheritsPopupMenu" type="boolean" value="false"/>
|
||||
|
@ -199,7 +199,7 @@
|
|||
<Property name="toolTipText" type="java.lang.String" value="Number of instants."/>
|
||||
<Property name="verticalAlignment" type="int" value="1"/>
|
||||
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
|
||||
<Color id="Standardcursor"/>
|
||||
<Color id="Default Cursor"/>
|
||||
</Property>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="inheritsPopupMenu" type="boolean" value="false"/>
|
||||
|
@ -217,7 +217,7 @@
|
|||
<Property name="toolTipText" type="java.lang.String" value="Number of enchantments."/>
|
||||
<Property name="verticalAlignment" type="int" value="1"/>
|
||||
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
|
||||
<Color id="Standardcursor"/>
|
||||
<Color id="Default Cursor"/>
|
||||
</Property>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="inheritsPopupMenu" type="boolean" value="false"/>
|
||||
|
|
|
@ -44,7 +44,10 @@ import java.awt.event.MouseListener;
|
|||
import java.beans.Beans;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JTable;
|
||||
|
@ -86,6 +89,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
|||
protected CardEventSource cardEventSource = new CardEventSource();
|
||||
private Dimension cardDimension;
|
||||
private CardsView cards;
|
||||
private Map<UUID, MageCard> mageCards = new LinkedHashMap<>();
|
||||
protected BigCard bigCard;
|
||||
protected UUID gameId;
|
||||
private SortSetting sortSetting;
|
||||
|
@ -123,6 +127,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
|||
((CardPanel)comp).cleanUp();
|
||||
}
|
||||
}
|
||||
mageCards.clear();
|
||||
cardArea.removeAll();
|
||||
this.bigCard = null;
|
||||
|
||||
|
@ -276,102 +281,115 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
|||
int numColumns = maxWidth / Config.dimensions.frameWidth;
|
||||
int curColumn = 0;
|
||||
int curRow = 0;
|
||||
int landCount = 0;
|
||||
int creatureCount = 0;
|
||||
int sorceryCount = 0;
|
||||
int instantCount = 0;
|
||||
int enchantmentCount = 0;
|
||||
//FIXME: why we remove all cards? for performance it's better to merge changes
|
||||
// as it is already done in ListView
|
||||
cardArea.removeAll();
|
||||
int maxRow = 0;
|
||||
int maxColumn = 0;
|
||||
Comparator<CardView> comparator = null;
|
||||
Map<UUID, MageCard> oldMageCards = mageCards;
|
||||
mageCards = new LinkedHashMap<>();
|
||||
|
||||
//Find card view
|
||||
for(UUID uuid : cards.keySet()){
|
||||
if(oldMageCards.containsKey(uuid)){
|
||||
mageCards.put(uuid, oldMageCards.get(uuid));
|
||||
oldMageCards.remove(uuid);
|
||||
}
|
||||
else{
|
||||
mageCards.put(uuid, addCard(cards.get(uuid), bigCard, gameId));
|
||||
}
|
||||
}
|
||||
//Remove unused cards
|
||||
for(MageCard card : oldMageCards.values()){
|
||||
cardArea.remove(card);
|
||||
}
|
||||
|
||||
if (cards != null && cards.size() > 0) {
|
||||
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
List<CardView> sortedCards = new ArrayList<>(cards.values());
|
||||
switch (sortSetting.getSortBy()) {
|
||||
case NAME:
|
||||
Collections.sort(sortedCards, new CardViewNameComparator());
|
||||
comparator = new CardViewNameComparator();
|
||||
break;
|
||||
case RARITY:
|
||||
Collections.sort(sortedCards, new CardViewRarityComparator());
|
||||
comparator = new CardViewRarityComparator();
|
||||
break;
|
||||
case COLOR:
|
||||
Collections.sort(sortedCards, new CardViewColorComparator());
|
||||
comparator = new CardViewColorComparator();
|
||||
break;
|
||||
case COLOR_DETAILED:
|
||||
Collections.sort(sortedCards, new CardViewColorDetailedComparator());
|
||||
comparator = new CardViewColorDetailedComparator();
|
||||
break;
|
||||
case CASTING_COST:
|
||||
Collections.sort(sortedCards, new CardViewCostComparator());
|
||||
comparator = new CardViewCostComparator();
|
||||
break;
|
||||
}
|
||||
if(comparator != null){
|
||||
Collections.sort(sortedCards, new CardViewNameComparator());
|
||||
Collections.sort(sortedCards, comparator);
|
||||
}
|
||||
CardView lastCard = null;
|
||||
for (CardView card: sortedCards) {
|
||||
if (sortSetting.isPilesToggle()) {
|
||||
if (lastCard == null) {
|
||||
lastCard = card;
|
||||
}
|
||||
switch (sortSetting.getSortBy()) {
|
||||
case NAME:
|
||||
if (!card.getName().equals(lastCard.getName())) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case RARITY:
|
||||
if (!card.getRarity().equals(lastCard.getRarity())) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case COLOR:
|
||||
if (card.getColor().compareTo(lastCard.getColor()) != 0) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case COLOR_DETAILED:
|
||||
if (card.getColor().hashCode() != lastCard.getColor().hashCode()) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case CASTING_COST:
|
||||
if (card.getConvertedManaCost() != lastCard.getConvertedManaCost()) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
if(comparator != null){
|
||||
if(comparator.compare(card, lastCard) > 0){
|
||||
curColumn++;
|
||||
maxRow = Math.max(maxRow, curRow);
|
||||
curRow = 0;
|
||||
}
|
||||
}
|
||||
rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20);
|
||||
addCard(card, bigCard, gameId, rectangle);
|
||||
setCardBounds(mageCards.get(card.getId()), rectangle);
|
||||
|
||||
curRow++;
|
||||
lastCard = card;
|
||||
} else {
|
||||
rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20);
|
||||
addCard(card, bigCard, gameId, rectangle);
|
||||
setCardBounds(mageCards.get(card.getId()), rectangle);
|
||||
curColumn++;
|
||||
if (curColumn == numColumns) {
|
||||
maxColumn = Math.max(maxColumn, curColumn);
|
||||
curColumn = 0;
|
||||
curRow++;
|
||||
}
|
||||
}
|
||||
if (card.getCardTypes().contains(CardType.LAND)) {
|
||||
landCount++;
|
||||
}
|
||||
if (card.getCardTypes().contains(CardType.CREATURE)) {
|
||||
creatureCount++;
|
||||
}
|
||||
if (card.getCardTypes().contains(CardType.SORCERY)) {
|
||||
sorceryCount++;
|
||||
}
|
||||
if (card.getCardTypes().contains(CardType.INSTANT)) {
|
||||
instantCount++;
|
||||
}
|
||||
if (card.getCardTypes().contains(CardType.ENCHANTMENT)) {
|
||||
enchantmentCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
maxRow = Math.max(maxRow, curRow);
|
||||
maxColumn = Math.max(maxColumn, curColumn);
|
||||
updateCounts();
|
||||
cardArea.setPreferredSize(new Dimension((maxColumn+1) * Config.dimensions.frameWidth, Config.dimensions.frameHeight + maxRow*20));
|
||||
cardArea.revalidate();
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
private void updateCounts(){
|
||||
int landCount = 0;
|
||||
int creatureCount = 0;
|
||||
int sorceryCount = 0;
|
||||
int instantCount = 0;
|
||||
int enchantmentCount = 0;
|
||||
for (CardView card: cards.values()) {
|
||||
if (card.getCardTypes().contains(CardType.LAND)) {
|
||||
landCount++;
|
||||
}
|
||||
if (card.getCardTypes().contains(CardType.CREATURE)) {
|
||||
creatureCount++;
|
||||
}
|
||||
if (card.getCardTypes().contains(CardType.SORCERY)) {
|
||||
sorceryCount++;
|
||||
}
|
||||
if (card.getCardTypes().contains(CardType.INSTANT)) {
|
||||
instantCount++;
|
||||
}
|
||||
if (card.getCardTypes().contains(CardType.ENCHANTMENT)) {
|
||||
enchantmentCount++;
|
||||
}
|
||||
}
|
||||
|
||||
int count = cards != null ? cards.size() : 0;
|
||||
this.lblCount.setText(Integer.toString(count));
|
||||
this.lblCreatureCount.setText(Integer.toString(creatureCount));
|
||||
|
@ -379,24 +397,24 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
|||
this.lblSorceryCount.setText(Integer.toString(sorceryCount));
|
||||
this.lblInstantCount.setText(Integer.toString(instantCount));
|
||||
this.lblEnchantmentCount.setText(Integer.toString(enchantmentCount));
|
||||
cardArea.setPreferredSize(new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight + 200));
|
||||
cardArea.revalidate();
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle) {
|
||||
private MageCard addCard(CardView card, BigCard bigCard, UUID gameId) {
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
}
|
||||
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, cardDimension, gameId, true);
|
||||
cardImg.setBounds(rectangle);
|
||||
cardArea.add(cardImg);
|
||||
cardArea.moveToFront(cardImg);
|
||||
cardImg.update(card);
|
||||
cardImg.addMouseListener(this);
|
||||
cardImg.setCardBounds(rectangle.x, rectangle.y, Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
return cardImg;
|
||||
}
|
||||
|
||||
|
||||
private void setCardBounds(MageCard card, Rectangle rectangle) {
|
||||
card.setBounds(rectangle);
|
||||
card.setCardBounds(rectangle.x, rectangle.y, Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
cardArea.moveToFront(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -437,7 +455,6 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
|||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
java.awt.GridBagConstraints gridBagConstraints;
|
||||
|
||||
bgView = new javax.swing.ButtonGroup();
|
||||
panelControl = new javax.swing.JPanel();
|
||||
|
@ -615,7 +632,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
|||
.addComponent(lblLandCount)
|
||||
.addComponent(lblCreatureCount)
|
||||
.addComponent(lblSorceryCount)
|
||||
.addComponent(lblInstantCount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblInstantCount)
|
||||
.addComponent(lblEnchantmentCount)
|
||||
.addComponent(chkPiles))
|
||||
.addComponent(cbSortBy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
|
@ -636,7 +653,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
|||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(1, 1, 1)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(panelControl, javax.swing.GroupLayout.DEFAULT_SIZE, 654, Short.MAX_VALUE)
|
||||
.addComponent(panelControl, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(panelCardArea)))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
|
|
|
@ -39,13 +39,7 @@ public class CardViewColorComparator implements Comparator<CardView> {
|
|||
|
||||
@Override
|
||||
public int compare(CardView o1, CardView o2) {
|
||||
int val = o1.getColor().compareTo(o2.getColor());
|
||||
if (val == 0) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
else {
|
||||
return val;
|
||||
}
|
||||
return o1.getColor().compareTo(o2.getColor());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,51 +1,45 @@
|
|||
/*
|
||||
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.client.util;
|
||||
|
||||
import java.util.Comparator;
|
||||
import mage.view.CardView;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class CardViewColorDetailedComparator implements Comparator<CardView> {
|
||||
|
||||
@Override
|
||||
public int compare(CardView o1, CardView o2) {
|
||||
int val = o1.getColor().hashCode() - o2.getColor().hashCode();
|
||||
if (val == 0) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.client.util;
|
||||
|
||||
import java.util.Comparator;
|
||||
import mage.view.CardView;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class CardViewColorDetailedComparator implements Comparator<CardView> {
|
||||
|
||||
@Override
|
||||
public int compare(CardView o1, CardView o2) {
|
||||
return o1.getColor().hashCode() - o2.getColor().hashCode();
|
||||
}
|
||||
|
||||
}
|
|
@ -39,13 +39,7 @@ public class CardViewCostComparator implements Comparator<CardView> {
|
|||
|
||||
@Override
|
||||
public int compare(CardView o1, CardView o2) {
|
||||
int val = Integer.valueOf(o1.getConvertedManaCost()).compareTo(Integer.valueOf(o2.getConvertedManaCost()));
|
||||
if (val == 0) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
else {
|
||||
return val;
|
||||
}
|
||||
return Integer.valueOf(o1.getConvertedManaCost()).compareTo(Integer.valueOf(o2.getConvertedManaCost()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,13 +39,7 @@ public class CardViewRarityComparator implements Comparator<CardView> {
|
|||
|
||||
@Override
|
||||
public int compare(CardView o1, CardView o2) {
|
||||
int val = o1.getRarity().compareTo(o2.getRarity());
|
||||
if (val == 0) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
else {
|
||||
return val;
|
||||
}
|
||||
return o1.getRarity().compareTo(o2.getRarity());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue