Skip to content

Commit

Permalink
Merge pull request #198 from AEFeinstein/foreign-names
Browse files Browse the repository at this point in the history
Foreign names
  • Loading branch information
AEFeinstein authored May 2, 2017
2 parents a3211e1 + b5853c7 commit 1719f16
Show file tree
Hide file tree
Showing 19 changed files with 3,285 additions and 2,812 deletions.
4 changes: 2 additions & 2 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ dependencies {
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:gridlayout-v7:25.3.1'
compile 'com.github.woxthebox:draglistview:1.4.2' // This includes support recyclerview
compile 'com.github.woxthebox:draglistview:1.4.3' // This includes support recyclerview
compile 'org.jetbrains:annotations:13.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.afollestad.material-dialogs:core:0.9.4.1'
compile 'com.afollestad.material-dialogs:core:0.9.4.4'
compile 'com.jpardogo.materialtabstrip:library:1.1.1'
compile 'com.code-troopers.betterpickers:library:3.1.0'
compile 'com.github.machinarius:preferencefragment:0.1.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class PrefixedFieldNamingStrategy implements FieldNamingStrategy {

/** The prefix to be match on the field's name */
protected String mPrefix;
private String mPrefix;

/**
* Create a PrefixedFieldNamingStrategy object that check for a prefix on the field's name,
Expand Down Expand Up @@ -41,7 +41,7 @@ public String translateName(final Field f) {
* @param s the string to transform.
* @return A string with a lowercase first letter
*/
public static String lowercaseFirstLetter(String s)
private static String lowercaseFirstLetter(String s)
{
if(s.length() > 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,11 @@ public void setInfoFromID(final long id) {
float p = cCardById.getFloat(cCardById.getColumnIndex(CardDbAdapter.KEY_POWER));
float t = cCardById.getFloat(cCardById.getColumnIndex(CardDbAdapter.KEY_TOUGHNESS));
if (loyalty != CardDbAdapter.NO_ONE_CARES) {
mPowTouTextView.setText(Integer.valueOf(loyalty).toString());
if (loyalty == CardDbAdapter.X) {
mPowTouTextView.setText("X");
} else {
mPowTouTextView.setText(Integer.valueOf(loyalty).toString());
}
} else if (p != CardDbAdapter.NO_ONE_CARES && t != CardDbAdapter.NO_ONE_CARES) {

String powTouStr = "";
Expand All @@ -546,6 +550,8 @@ else if (p == CardDbAdapter.SEVEN_MINUS_STAR)
powTouStr += "7-*";
else if (p == CardDbAdapter.STAR_SQUARED)
powTouStr += "*^2";
else if (p == CardDbAdapter.X)
powTouStr += "X";
else {
if (p == (int) p) {
powTouStr += (int) p;
Expand All @@ -566,6 +572,8 @@ else if (t == CardDbAdapter.SEVEN_MINUS_STAR)
powTouStr += "7-*";
else if (t == CardDbAdapter.STAR_SQUARED)
powTouStr += "*^2";
else if (t == CardDbAdapter.X)
powTouStr += "X";
else {
if (t == (int) t) {
powTouStr += (int) t;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@
public class DecklistFragment extends FamiliarFragment {

/* UI Elements */
public AutoCompleteTextView mNameField;
public EditText mNumberField;
private AutoCompleteTextView mNameField;
private EditText mNumberField;
public TextView mDeckName;
public TextView mDeckCards;
public TextView mDeckPrice;
private TextView mDeckCards;
private TextView mDeckPrice;

/* Decklist and adapters */
public ListView decklistView;
private ListView decklistView;
public ArrayList<CompressedDecklistInfo> mCompressedDecklist;
public DecklistArrayAdapter mDecklistAdapter;
public ComparatorChain mDecklistChain;
private ComparatorChain<CompressedDecklistInfo> mDecklistChain;

public static final String AUTOSAVE_NAME = "autosave";
public String mCurrentDeck = "";
Expand Down Expand Up @@ -265,7 +265,7 @@ private void addCardToDeck(boolean isSideboard) {
mCompressedDecklist.add(new CompressedDecklistInfo(card, isSideboard));
}

/* Sort the decklist */;
/* Sort the decklist */
Collections.sort(mCompressedDecklist, mDecklistChain);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,9 @@ private SearchCriteria parseForm() {
case "*^2":
pow = CardDbAdapter.STAR_SQUARED;
break;
case "X":
pow = CardDbAdapter.X;
break;
}
}
searchCriteria.powChoice = pow;
Expand All @@ -649,6 +652,9 @@ private SearchCriteria parseForm() {
case "*^2":
tou = CardDbAdapter.STAR_SQUARED;
break;
case "X":
tou = CardDbAdapter.X;
break;
}
}
searchCriteria.touChoice = tou;
Expand Down Expand Up @@ -817,6 +823,8 @@ else if (p == CardDbAdapter.SEVEN_MINUS_STAR)
mPowChoice.setSelection(ptList.indexOf("7-*"));
else if (p == CardDbAdapter.STAR_SQUARED)
mPowChoice.setSelection(ptList.indexOf("*^2"));
else if (p == CardDbAdapter.X)
mPowChoice.setSelection(ptList.indexOf("X"));
else {
if (p == (int) p) {
mPowChoice.setSelection(ptList.indexOf(((int) p) + ""));
Expand All @@ -838,6 +846,8 @@ else if (t == CardDbAdapter.SEVEN_MINUS_STAR)
mTouChoice.setSelection(ptList.indexOf("7-*"));
else if (t == CardDbAdapter.STAR_SQUARED)
mTouChoice.setSelection(ptList.indexOf("*^2"));
else if (t == CardDbAdapter.X)
mTouChoice.setSelection(ptList.indexOf("X"));
else {
if (t == (int) t) {
mTouChoice.setSelection(ptList.indexOf(((int) t) + ""));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,8 @@ else if (p == CardDbAdapter.SEVEN_MINUS_STAR)
pow = "7-*";
else if (p == CardDbAdapter.STAR_SQUARED)
pow = "*^2";
else if (p == CardDbAdapter.X)
pow = "X";
else {
if (p == (int) p) {
pow = Integer.valueOf((int) p).toString();
Expand Down Expand Up @@ -752,6 +754,8 @@ else if (t == CardDbAdapter.SEVEN_MINUS_STAR)
tou = "7-*";
else if (t == CardDbAdapter.STAR_SQUARED)
tou = "*^2";
else if (t == CardDbAdapter.X)
tou = "X";
else {
if (t == (int) t) {
tou = Integer.valueOf((int) t).toString();
Expand All @@ -768,7 +772,10 @@ else if (t == CardDbAdapter.STAR_SQUARED)
/* Show the loyalty, if the card has any (traitor...) */
float loyalty = info.mCard.mLoyalty;
if (loyalty != -1 && loyalty != CardDbAdapter.NO_ONE_CARES) {
if (loyalty == (int) loyalty) {

if (loyalty == CardDbAdapter.X) {
((TextView) convertView.findViewById(R.id.cardt)).setText("X");
} else if (loyalty == (int) loyalty) {
((TextView) convertView.findViewById(R.id.cardt)).setText(Integer.toString((int) loyalty));
} else {
((TextView) convertView.findViewById(R.id.cardt)).setText(Float.toString(loyalty));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import com.gelakinetic.mtgfam.helpers.DecklistHelpers.CompressedDecklistInfo;

import org.apache.commons.collections4.comparators.ComparatorChain;

import java.util.ArrayList;
import java.util.Comparator;

Expand Down Expand Up @@ -89,25 +87,18 @@ public int getTotalNumber() {

}

public static ComparatorChain<CompressedCardInfo> getComparatorWithName(Comparator<CompressedCardInfo> comparator) {
ComparatorChain<CompressedCardInfo> chain = new ComparatorChain<>();
chain.addComparator(comparator);
chain.addComparator(new CardComparatorName());
return chain;
}

/* Comparator based on name */
public static class CardComparatorName implements Comparator<CompressedCardInfo> {
public static class CardComparatorName implements Comparator<CompressedDecklistInfo> {
@Override
public int compare(CompressedCardInfo card1, CompressedCardInfo card2) {
public int compare(CompressedDecklistInfo card1, CompressedDecklistInfo card2) {
return card1.mCard.mName.compareTo(card2.mCard.mName);
}
}

/* Comparator based on CMC */
public static class CardComparatorCMC implements Comparator<CompressedCardInfo> {
public static class CardComparatorCMC implements Comparator<CompressedDecklistInfo> {
@Override
public int compare(CompressedCardInfo card1, CompressedCardInfo card2) {
public int compare(CompressedDecklistInfo card1, CompressedDecklistInfo card2) {
if (card1.mCard.mCmc == card2.mCard.mCmc) {
return 0;
} else if (card1.mCard.mCmc > card2.mCard.mCmc) {
Expand All @@ -118,7 +109,7 @@ public int compare(CompressedCardInfo card1, CompressedCardInfo card2) {
}

/* Comparator based on color */
public static class CardComparatorColor implements Comparator<CompressedCardInfo> {
public static class CardComparatorColor implements Comparator<CompressedDecklistInfo> {

private static final String colors = "WUBRG";
private static final String nonColors = "LAC";
Expand All @@ -144,7 +135,7 @@ private String getColors(String c) {
}

@Override
public int compare(CompressedCardInfo card1, CompressedCardInfo card2) {
public int compare(CompressedDecklistInfo card1, CompressedDecklistInfo card2) {
String cardColors1 = getColors(card1.mCard.mColor);
String cardColors2 = getColors(card2.mCard.mColor);
int priority1;
Expand Down Expand Up @@ -196,13 +187,13 @@ public int compare(CompressedDecklistInfo card1, CompressedDecklistInfo card2) {

/* Comparator based on card supertype
* must pass an array of types in the order you wish to sort */
public static class CardComparatorSupertype implements Comparator<CompressedCardInfo> {
public static class CardComparatorSupertype implements Comparator<CompressedDecklistInfo> {
final String[] mTypes;
public CardComparatorSupertype(String[] superTypes) {
mTypes = superTypes;
}
@Override
public int compare(CompressedCardInfo card1, CompressedCardInfo card2) {
public int compare(CompressedDecklistInfo card1, CompressedDecklistInfo card2) {
String card1Type = card1.mCard.mType;
String card2Type = card2.mCard.mType;
for (String type : mTypes) {
Expand Down Expand Up @@ -290,7 +281,7 @@ public int compare(CompressedCardInfo card1, CompressedCardInfo card2) {
}

/* Comparator based on first set of a card */
public static class CardComparatorSet implements Comparator<CompressedCardInfo> {
private static class CardComparatorSet implements Comparator<CompressedCardInfo> {
@Override
public int compare(CompressedCardInfo card1, CompressedCardInfo card2) {
return card1.mInfo.get(0).mSet.compareTo(card2.mInfo.get(0).mSet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ else if (p == CardDbAdapter.SEVEN_MINUS_STAR)
pow = "7-*";
else if (p == CardDbAdapter.STAR_SQUARED)
pow = "*^2";
else if (p == CardDbAdapter.X)
pow = "X";
else {
if (p == (int) p) {
pow = Integer.valueOf((int) p).toString();
Expand All @@ -215,6 +217,8 @@ else if (t == CardDbAdapter.SEVEN_MINUS_STAR)
tou = "7-*";
else if (t == CardDbAdapter.STAR_SQUARED)
tou = "*^2";
else if (t == CardDbAdapter.X)
tou = "X";
else {
if (t == (int) t) {
tou = Integer.valueOf((int) t).toString();
Expand All @@ -229,10 +233,12 @@ else if (t == CardDbAdapter.STAR_SQUARED)
float l = cursor.getFloat(cursor.getColumnIndex(mFrom[i]));
if (l != CardDbAdapter.NO_ONE_CARES) {
hideLoyalty = false;
if (l == (int) l) {
textField.setText(Integer.toString((int) l));
if (l == CardDbAdapter.X) {
((TextView) textField.findViewById(R.id.cardt)).setText("X");
} else if (l == (int) l) {
((TextView) textField.findViewById(R.id.cardt)).setText(Integer.toString((int) l));
} else {
textField.setText(Float.toString(l));
((TextView) textField.findViewById(R.id.cardt)).setText(Float.toString(l));
}
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
public class CardDbAdapter {

/* Database version. Must be incremented whenever datagz is updated */
public static final int DATABASE_VERSION = 79;
public static final int DATABASE_VERSION = 80;

/* The name of the database */
public static final String DATABASE_NAME = "data";
Expand Down Expand Up @@ -286,6 +286,7 @@ public class CardDbAdapter {
public static final int SEVEN_MINUS_STAR = -1003;
public static final int STAR_SQUARED = -1004;
public static final int NO_ONE_CARES = -1005;
public static final int X = -1006;

/* The options for printings for a query */
public static final int MOST_RECENT_PRINTING = 0;
Expand Down
Loading

0 comments on commit 1719f16

Please sign in to comment.