Commit ea65c84d authored by fallenstardust's avatar fallenstardust

CallBack 卡片搜索

parent 9ed5afa2
...@@ -28,7 +28,7 @@ import ocgcore.LimitManager; ...@@ -28,7 +28,7 @@ import ocgcore.LimitManager;
import ocgcore.StringManager; import ocgcore.StringManager;
import ocgcore.data.Card; import ocgcore.data.Card;
public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoader.CallBack { public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoader.CallBack, CardSearcher.CallBack {
protected DrawerLayout mDrawerlayout; protected DrawerLayout mDrawerlayout;
protected RecyclerView mListView; protected RecyclerView mListView;
protected CardSearcher mCardSelector; protected CardSearcher mCardSelector;
...@@ -58,6 +58,7 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa ...@@ -58,6 +58,7 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
mCardLoader = new CardLoader(this); mCardLoader = new CardLoader(this);
mCardLoader.setCallBack(this); mCardLoader.setCallBack(this);
mCardSelector = new CardSearcher($(R.id.nav_view_list), mCardLoader); mCardSelector = new CardSearcher($(R.id.nav_view_list), mCardLoader);
mCardSelector.setCallBack(this);
} }
protected int getDimen(int id) { protected int getDimen(int id) {
......
...@@ -4,6 +4,7 @@ package cn.garymb.ygomobile.ui.cards; ...@@ -4,6 +4,7 @@ package cn.garymb.ygomobile.ui.cards;
import android.content.Context; import android.content.Context;
import android.graphics.Color; import android.graphics.Color;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.SparseArray;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
...@@ -21,13 +22,17 @@ import java.util.List; ...@@ -21,13 +22,17 @@ import java.util.List;
import cn.garymb.ygomobile.AppsSettings; import cn.garymb.ygomobile.AppsSettings;
import cn.garymb.ygomobile.lite.R; import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.loader.CardLoader;
import cn.garymb.ygomobile.loader.ICardLoader; import cn.garymb.ygomobile.loader.ICardLoader;
import cn.garymb.ygomobile.ui.activities.BaseActivity;
import cn.garymb.ygomobile.ui.adapters.SimpleSpinnerAdapter; import cn.garymb.ygomobile.ui.adapters.SimpleSpinnerAdapter;
import cn.garymb.ygomobile.ui.adapters.SimpleSpinnerItem; import cn.garymb.ygomobile.ui.adapters.SimpleSpinnerItem;
import cn.garymb.ygomobile.ui.plus.DialogPlus; import cn.garymb.ygomobile.ui.plus.DialogPlus;
import ocgcore.ConfigManager;
import ocgcore.DataManager; import ocgcore.DataManager;
import ocgcore.LimitManager; import ocgcore.LimitManager;
import ocgcore.StringManager; import ocgcore.StringManager;
import ocgcore.data.Card;
import ocgcore.data.CardSet; import ocgcore.data.CardSet;
import ocgcore.data.LimitList; import ocgcore.data.LimitList;
import ocgcore.enums.CardAttribute; import ocgcore.enums.CardAttribute;
...@@ -37,6 +42,8 @@ import ocgcore.enums.CardRace; ...@@ -37,6 +42,8 @@ import ocgcore.enums.CardRace;
import ocgcore.enums.CardType; import ocgcore.enums.CardType;
import ocgcore.enums.LimitType; import ocgcore.enums.LimitType;
import static cn.garymb.ygomobile.ui.cards.DeckManagerActivityImpl.Favorite;
public class CardSearcher implements View.OnClickListener { public class CardSearcher implements View.OnClickListener {
final String[] BtnVals = new String[9]; final String[] BtnVals = new String[9];
...@@ -61,6 +68,7 @@ public class CardSearcher implements View.OnClickListener { ...@@ -61,6 +68,7 @@ public class CardSearcher implements View.OnClickListener {
private EditText atkText; private EditText atkText;
private EditText defText; private EditText defText;
private Spinner pScale; private Spinner pScale;
private Button MyFavButton;
private Button LinkMarkerButton; private Button LinkMarkerButton;
private Button searchButton; private Button searchButton;
private Button resetButton; private Button resetButton;
...@@ -68,6 +76,16 @@ public class CardSearcher implements View.OnClickListener { ...@@ -68,6 +76,16 @@ public class CardSearcher implements View.OnClickListener {
private View layout_monster; private View layout_monster;
private ICardLoader dataLoader; private ICardLoader dataLoader;
private Context mContext; private Context mContext;
private CallBack mCallBack;
CardLoader mCardLoader;
public interface CallBack {
void onSearchResult(List<Card> Cards, boolean isHide);
}
public void setCallBack(CallBack callBack) {
mCallBack = callBack;
}
public CardSearcher(View view, ICardLoader dataLoader) { public CardSearcher(View view, ICardLoader dataLoader) {
this.view = view; this.view = view;
...@@ -93,13 +111,16 @@ public class CardSearcher implements View.OnClickListener { ...@@ -93,13 +111,16 @@ public class CardSearcher implements View.OnClickListener {
atkText = findViewById(R.id.edt_atk); atkText = findViewById(R.id.edt_atk);
defText = findViewById(R.id.edt_def); defText = findViewById(R.id.edt_def);
LinkMarkerButton = findViewById(R.id.btn_linkmarker); LinkMarkerButton = findViewById(R.id.btn_linkmarker);
MyFavButton = findViewById(R.id.btn_my_fav);
searchButton = findViewById(R.id.btn_search); searchButton = findViewById(R.id.btn_search);
resetButton = findViewById(R.id.btn_reset); resetButton = findViewById(R.id.btn_reset);
layout_monster = findViewById(R.id.layout_monster); layout_monster = findViewById(R.id.layout_monster);
pScale = findViewById(R.id.sp_scale); pScale = findViewById(R.id.sp_scale);
MyFavButton.setOnClickListener(this);
LinkMarkerButton.setOnClickListener(this); LinkMarkerButton.setOnClickListener(this);
searchButton.setOnClickListener(this); searchButton.setOnClickListener(this);
resetButton.setOnClickListener(this); resetButton.setOnClickListener(this);
mCardLoader = new CardLoader(mContext);
OnEditorActionListener searchListener = new OnEditorActionListener() { OnEditorActionListener searchListener = new OnEditorActionListener() {
@Override @Override
...@@ -117,6 +138,20 @@ public class CardSearcher implements View.OnClickListener { ...@@ -117,6 +138,20 @@ public class CardSearcher implements View.OnClickListener {
prefixWord.setOnEditorActionListener(searchListener); prefixWord.setOnEditorActionListener(searchListener);
suffixWord.setOnEditorActionListener(searchListener); suffixWord.setOnEditorActionListener(searchListener);
MyFavButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
SparseArray<Card> id = mCardLoader.readCards(ConfigManager.mLines, false);
Favorite.clear();
if (id != null) {
for (int i = 0; i < id.size(); i++)
Favorite.add(id.valueAt(i));
}
if (mCallBack != null)
mCallBack.onSearchResult(Favorite, false);
}
});
LinkMarkerButton.setOnClickListener(new OnClickListener() { LinkMarkerButton.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
......
...@@ -277,4 +277,5 @@ ...@@ -277,4 +277,5 @@
<string name="already_end">마지막</string> <string name="already_end">마지막</string>
<string name="tip_expansions_image">카드의 고화질 이미지가 없습니다.</string> <string name="tip_expansions_image">카드의 고화질 이미지가 없습니다.</string>
<string name="tip_return_to_duel">이미 돌아 가기 현재 게임</string> <string name="tip_return_to_duel">이미 돌아 가기 현재 게임</string>
<string name="my_favorites">즐겨 찾기★</string>
</resources> </resources>
...@@ -276,4 +276,5 @@ ...@@ -276,4 +276,5 @@
<string name="tip_redownload">重新下载?</string> <string name="tip_redownload">重新下载?</string>
<string name="tip_expansions_image">非自带卡片没有大图</string> <string name="tip_expansions_image">非自带卡片没有大图</string>
<string name="tip_return_to_duel">已回到当前游戏</string> <string name="tip_return_to_duel">已回到当前游戏</string>
<string name="my_favorites">我的收藏★</string>
</resources> </resources>
...@@ -279,4 +279,5 @@ ...@@ -279,4 +279,5 @@
<string name="tip_redownload">Redownload\?</string> <string name="tip_redownload">Redownload\?</string>
<string name="tip_expansions_image">no Large image for pre-released data</string> <string name="tip_expansions_image">no Large image for pre-released data</string>
<string name="tip_return_to_duel">Current game has been Returned</string> <string name="tip_return_to_duel">Current game has been Returned</string>
<string name="my_favorites">myFav★</string>
</resources> </resources>
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