Commit 0eb9fc31 authored by qq247321453's avatar qq247321453

CardKeyWord搜索

parent 7a92d476
...@@ -6,11 +6,11 @@ import android.util.Log; ...@@ -6,11 +6,11 @@ import android.util.Log;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import cn.garymb.ygomobile.core.IrrlichtBridge;
import ocgcore.DataManager; import ocgcore.DataManager;
import ocgcore.data.Card; import ocgcore.data.Card;
public class CardKeyWord { public class CardKeyWord {
private static final String TAG = "CardKeyWord";
private final String word; private final String word;
private final List<ICardFilter> filterList = new ArrayList<>(); private final List<ICardFilter> filterList = new ArrayList<>();
private final boolean empty; private final boolean empty;
...@@ -42,15 +42,8 @@ public class CardKeyWord { ...@@ -42,15 +42,8 @@ public class CardKeyWord {
w = w.substring(1); w = w.substring(1);
} }
} }
if (!onlyText) { Log.d(TAG, "filter:word=" + w + ", exclude=" + exclude + ", onlyText=" + onlyText);
long setcode = DataManager.get().getStringManager().getSetCode(w); filterList.add(new NameFilter(w, exclude, onlyText));
if (setcode != 0) {
//如果是系列名
filterList.add(new SetcodeFilter(setcode, exclude));
}
}
// Log.d(IrrlichtBridge.TAG, "filter:word=" + w + ", exclude=" + exclude + ", onlyText=" + onlyText);
filterList.add(new NameFilter(w, exclude));
} }
} }
} }
...@@ -76,37 +69,25 @@ public class CardKeyWord { ...@@ -76,37 +69,25 @@ public class CardKeyWord {
private static class NameFilter implements ICardFilter { private static class NameFilter implements ICardFilter {
private final boolean exclude; private final boolean exclude;
private final String word; private final String word;
private final long setcode;
public NameFilter(String word, boolean exclude) { //包含系列,或者包含名字、描述
public NameFilter(String word, boolean exclude, boolean onlyText) {
this.setcode = onlyText ? 0 : DataManager.get().getStringManager().getSetCode(word);
this.exclude = exclude; this.exclude = exclude;
this.word = word; this.word = word;
if(this.setcode > 0){
Log.d(TAG, "filter:setcode=" + setcode + ", exclude=" + exclude + ", word=" + word);
} }
@Override
public boolean isValid(Card card) {
if (exclude) {
return !card.Name.contains(word);
} else {
return card.Name.contains(word);
}
}
}
private static class SetcodeFilter implements ICardFilter {
private final boolean exclude;
private final long setcode;
public SetcodeFilter(long setcode, boolean exclude) {
this.exclude = exclude;
this.setcode = setcode;
} }
@Override @Override
public boolean isValid(Card card) { public boolean isValid(Card card) {
boolean ret = (setcode != 0 && card.isSetCode(setcode)) || card.containsName(word) || card.containsDesc(word);
if (exclude) { if (exclude) {
return !card.isSetCode(setcode); return !ret;
} else { } else {
return card.isSetCode(setcode); return ret;
} }
} }
} }
......
...@@ -117,14 +117,14 @@ public class ImageLoader implements Closeable { ...@@ -117,14 +117,14 @@ public class ImageLoader implements Closeable {
private void bind(final byte[] data, String name, ImageView imageview, Drawable pre, int[] size) { private void bind(final byte[] data, String name, ImageView imageview, Drawable pre, int[] size) {
if (BuildConfig.DEBUG_MODE) { if (BuildConfig.DEBUG_MODE) {
Log.d(TAG, "bind data:" + name + ", size=" + (size == null ? "null" : size[0] + "x" + size[1])); Log.v(TAG, "bind data:" + name + ", size=" + (size == null ? "null" : size[0] + "x" + size[1]));
} }
bindT(data, name, imageview, pre, size); bindT(data, name, imageview, pre, size);
} }
private void bind(final Uri uri, String name, ImageView imageview, Drawable pre, int[] size) { private void bind(final Uri uri, String name, ImageView imageview, Drawable pre, int[] size) {
if (BuildConfig.DEBUG_MODE) { if (BuildConfig.DEBUG_MODE) {
Log.d(TAG, "bind uri:" + name + ", size=" + (size == null ? "null" : size[0] + "x" + size[1])); Log.v(TAG, "bind uri:" + name + ", size=" + (size == null ? "null" : size[0] + "x" + size[1]));
} }
bindT(uri, name, imageview, pre, size); bindT(uri, name, imageview, pre, size);
} }
...@@ -169,7 +169,7 @@ public class ImageLoader implements Closeable { ...@@ -169,7 +169,7 @@ public class ImageLoader implements Closeable {
private void bind(final File file, ImageView imageview, Drawable pre, int[] size) { private void bind(final File file, ImageView imageview, Drawable pre, int[] size) {
if (BuildConfig.DEBUG_MODE) { if (BuildConfig.DEBUG_MODE) {
Log.d(TAG, "bind file:" + file.getPath() + ", size=" + (size == null ? "null" : size[0] + "x" + size[1])); Log.v(TAG, "bind file:" + file.getPath() + ", size=" + (size == null ? "null" : size[0] + "x" + size[1]));
} }
try { try {
DrawableTypeRequest<File> resource = with(imageview.getContext()).load(file); DrawableTypeRequest<File> resource = with(imageview.getContext()).load(file);
...@@ -239,7 +239,7 @@ public class ImageLoader implements Closeable { ...@@ -239,7 +239,7 @@ public class ImageLoader implements Closeable {
public void bindImage(ImageView imageview, long code, Drawable pre, int[] size) { public void bindImage(ImageView imageview, long code, Drawable pre, int[] size) {
if (BuildConfig.DEBUG_MODE) { if (BuildConfig.DEBUG_MODE) {
Log.d(TAG, "bind image:" + code + ", size=" + (size == null ? "null" : size[0] + "x" + size[1])); Log.v(TAG, "bind image:" + code + ", size=" + (size == null ? "null" : size[0] + "x" + size[1]));
} }
String name = Constants.CORE_IMAGE_PATH + "/" + code; String name = Constants.CORE_IMAGE_PATH + "/" + code;
String name_ex = Constants.CORE_EXPANSIONS_IMAGE_PATH + "/" + code; String name_ex = Constants.CORE_EXPANSIONS_IMAGE_PATH + "/" + code;
......
...@@ -92,7 +92,7 @@ public class CardDetailRandom { ...@@ -92,7 +92,7 @@ public class CardDetailRandom {
public static CardDetailRandom genRandomCardDetail(Context context, ImageLoader imageLoader, Card cardInfo) { public static CardDetailRandom genRandomCardDetail(Context context, ImageLoader imageLoader, Card cardInfo) {
if (cardInfo == null) return null; if (cardInfo == null) return null;
CardDetailRandom cardDetailRandom = new CardDetailRandom(context, cardInfo); CardDetailRandom cardDetailRandom = new CardDetailRandom(context, cardInfo);
cardDetailRandom.bindCardImage(imageLoader, cardInfo.Alias != 0 ? cardInfo.Alias : cardInfo.Code); cardDetailRandom.bindCardImage(imageLoader, cardInfo.Code);
sCardDetailRandom = cardDetailRandom; sCardDetailRandom = cardDetailRandom;
return cardDetailRandom; return cardDetailRandom;
} }
......
...@@ -139,6 +139,14 @@ public class Card extends CardData implements Parcelable { ...@@ -139,6 +139,14 @@ public class Card extends CardData implements Parcelable {
return c.Code == this.Code || c.Alias == this.Code || c.Code == this.Alias; return c.Code == this.Code || c.Alias == this.Code || c.Code == this.Alias;
} }
public boolean containsName(String key){
return Name != null && Name.contains(key);
}
public boolean containsDesc(String key){
return Desc != null && Desc.contains(key);
}
@NonNull @NonNull
@Override @Override
public String toString() { public String toString() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment