Commit 4aedbb45 authored by qq247321453's avatar qq247321453

支持现实不存在的卡片

parent 0474dbee
......@@ -23,14 +23,17 @@ android {
}
productFlavors {
cn {
buildConfigField 'String', 'URL_DONATE', '"https://afdian.net/@ygomobile"'
manifestPlaceholders = [APP_ID: "0b6f110306"]
}
en {
applicationIdSuffix ".EN"
buildConfigField 'String', 'URL_DONATE', '"https://www.paypal.me/ygomobile1"'
manifestPlaceholders = [APP_ID: "9c66525dfa"]
}
ko {
applicationIdSuffix ".KO"
buildConfigField 'String', 'URL_DONATE', '"https://www.paypal.me/ygomobile1"'
manifestPlaceholders = [APP_ID: "0488398d8a"]
}
}
......
......@@ -142,10 +142,8 @@ public interface Constants {
int DECK_SIDE_MAX = 15;
int DECK_EXTRA_COUNT = (DECK_SIDE_MAX / DECK_WIDTH_COUNT * DECK_WIDTH_COUNT < DECK_SIDE_MAX) ? DECK_WIDTH_COUNT * 2 : DECK_WIDTH_COUNT;
int DECK_SIDE_COUNT = DECK_EXTRA_COUNT;
String URL_DONATE_CN= "https://afdian.net/@ygomobile";
String URL_DONATE= "https://www.paypal.me/ygomobile1";
String URL_HELP = "http://note.youdao.com/noteshare?id=8ae2dc824b7dc04a95a4665a938e2251";
String URL_MASTERRULE_CN = "https://ocg-rule.readthedocs.io/zh_CN/master/";
String URL_MASTER_RULE_CN = "https://ocg-rule.readthedocs.io/zh_CN/master/";
String WIKI_SEARCH_URL = "https://www.ourocg.cn/S.aspx?key=";
String SERVER_FILE = "server_list.xml";
......
......@@ -104,7 +104,7 @@ public class GameUriManager {
}
private File getDeckFile(File dir, String name) {
File file = new File(dir, name + ".ydk");
File file = new File(dir, name);
if (file.exists()) {
for (int i = 2; i < 10; i++) {
file = new File(dir, name + "(" + i + ").ydk");
......@@ -158,7 +158,7 @@ public class GameUriManager {
File local;
if (name.toLowerCase(Locale.US).endsWith(".ydk")) {
File dir = Constants.COPY_YDK_FILE ? new File(AppsSettings.get().getDeckDir()) : new File(getActivity().getApplicationInfo().dataDir, "cache");
local = getDeckFile(dir, name);
local = getDeckFile(dir, getPathName(path, true));
} else if (name.toLowerCase(Locale.US).endsWith(".ypk")) {
local = new File(AppsSettings.get().getExpansionsPath(), name);
} else if (name.toLowerCase(Locale.US).endsWith(".yrp")) {
......
package cn.garymb.ygomobile.ui.activities;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.RecyclerView;
import cn.garymb.ygomobile.lite.R;
public class DebugActivity extends BaseActivity {
private RecyclerView rv_list;
private Toolbar toolbar;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.debug_activity);
initView();
}
private void initView() {
rv_list=$(R.id.rv_list);
toolbar=$(R.id.toolbar);
setSupportActionBar(toolbar);
enableBackHome();
}
}
......@@ -32,7 +32,6 @@ public class CardListAdapter extends BaseRecyclerAdapterPlus<Card, ViewHolder> i
private boolean mItemBg;
private ImageLoader imageLoader;
private boolean mEnableSwipe = false;
private BaseActivity mContext;
public CardListAdapter(Context context, ImageLoader imageLoader) {
super(context);
......@@ -103,10 +102,7 @@ public class CardListAdapter extends BaseRecyclerAdapterPlus<Card, ViewHolder> i
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
Log.e("Cardlist","num"+position);
Card item = getItem(position);
if (item==null)
return;
imageLoader.bindImage(holder.cardImage, item.Code);
holder.cardName.setText(item.Name);
if (item.isType(CardType.Monster)) {
......
......@@ -50,7 +50,7 @@ public class CardSearchActivity extends BaseActivity implements CardLoader.CallB
public static final String SEARCH_MESSAGE = "searchMessage";
protected DrawerLayout mDrawerlayout;
protected CardSearcher mCardSelector;
protected CardListAdapter mCardListAdapater;
protected CardListAdapter mCardListAdapter;
protected CardLoader mCardLoader;
protected boolean isLoad = false;
protected StringManager mStringManager = DataManager.get().getStringManager();
......@@ -79,10 +79,10 @@ public class CardSearchActivity extends BaseActivity implements CardLoader.CallB
mDrawerlayout = $(R.id.drawer_layout);
mImageLoader = ImageLoader.get(this);
mListView = $(R.id.list_cards);
mCardListAdapater = new CardListAdapter(this, mImageLoader);
mCardListAdapater.setItemBg(true);
mCardListAdapter = new CardListAdapter(this, mImageLoader);
mCardListAdapter.setItemBg(true);
mListView.setLayoutManager(new FastScrollLinearLayoutManager(this));
mListView.setAdapter(mCardListAdapater);
mListView.setAdapter(mCardListAdapter);
Button btn_search = $(R.id.btn_search);
btn_search.setOnClickListener((v) -> showSearch(true));
/*
......@@ -144,7 +144,7 @@ public class CardSearchActivity extends BaseActivity implements CardLoader.CallB
mListView.addOnItemTouchListener(new RecyclerViewItemListener(mListView, new RecyclerViewItemListener.OnItemListener() {
@Override
public void onItemClick(View view, int pos) {
onCardClick(pos, mCardListAdapater);
onCardClick(pos, mCardListAdapter);
}
@Override
......@@ -206,9 +206,9 @@ public class CardSearchActivity extends BaseActivity implements CardLoader.CallB
@Override
public void onSearchResult(List<Card> cardInfos, boolean isHide) {
// Log.d("kk", "find " + (cardInfos == null ? -1 : cardInfos.size()));
mCardListAdapater.set(cardInfos);
mCardListAdapter.set(cardInfos);
mResult_count.setText(String.valueOf(cardInfos.size()));
mCardListAdapater.notifyDataSetChanged();
mCardListAdapter.notifyDataSetChanged();
if (cardInfos.size() > 0) {
mListView.smoothScrollToPosition(0);
}
......@@ -236,7 +236,7 @@ public class CardSearchActivity extends BaseActivity implements CardLoader.CallB
if (mDrawerlayout.isDrawerOpen(Constants.CARD_SEARCH_GRAVITY)) {
mDrawerlayout.closeDrawer(Constants.CARD_SEARCH_GRAVITY);
}
mCardListAdapater.setLimitList(limitList);
mCardListAdapter.setLimitList(limitList);
}
@Override
......
package cn.garymb.ygomobile.ui.cards.deck;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.recyclerview.widget.RecyclerView;
import cn.garymb.ygomobile.Constants;
import cn.garymb.ygomobile.bean.DeckInfo;
import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.loader.ImageLoader;
import ocgcore.data.Card;
import ocgcore.data.LimitList;
import ocgcore.enums.LimitType;
public class DeckAdapater2 extends RecyclerView.Adapter<DeckViewHolder> {
private final ImageLoader mImageLoader;
private final DeckInfo mDeck;
private LimitList mLimitList;
private ImageTop mImageTop;
private final LabelInfo mLabelInfo;
private Context mContext;
private LayoutInflater mLayoutInflater;
public final static int MainLabel = 0;
public final static int MainStart = MainLabel + 1;
public final static int MainEnd = MainStart + Constants.DECK_MAIN_MAX - 1;
public final static int ExtraLabel = MainEnd + 1;
public final static int ExtraStart = ExtraLabel + 1;
public final static int ExtraEnd = ExtraStart + Constants.DECK_EXTRA_MAX - 1;
public final static int SideLabel = ExtraEnd + 1;
public final static int SideStart = SideLabel + 1;
public final static int SideEnd = SideStart + Constants.DECK_SIDE_MAX - 1;
private int cardWidth, cardHeight;
public DeckAdapater2(Context context, int width, int height) {
mContext = context;
cardWidth = width;
cardHeight = height;
mLayoutInflater = LayoutInflater.from(context);
mImageLoader = ImageLoader.get(context);
mDeck = new DeckInfo();
mLabelInfo = new LabelInfo(context);
}
public Context getContext() {
return mContext;
}
public void updateDeck(DeckInfo deck) {
mDeck.update(deck);
mLabelInfo.update(deck);
}
public void setLimitList(LimitList limitList) {
mLimitList = limitList;
}
public ImageTop getImageTop() {
if (mImageTop == null) {
mImageTop = new ImageTop(getContext());
}
return mImageTop;
}
public boolean isLabel(int pos) {
return pos == ExtraLabel || pos == MainLabel || pos == SideLabel;
}
@Override
public DeckViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = mLayoutInflater.inflate(R.layout.item_deck_card2, parent, false);
return new DeckViewHolder(view);
}
@Override
public int getItemCount() {
return Constants.DECK_EXTRA_MAX + Constants.DECK_MAIN_MAX + Constants.DECK_SIDE_MAX + 3;
}
@Override
public void onBindViewHolder(DeckViewHolder holder, int position) {
if (position == ExtraLabel) {
//61 62-76
holder.setText(mLabelInfo.getExtraString());
} else if (position == MainLabel) {
//0 1-60
holder.setText(mLabelInfo.getMainString());
} else if (position == SideLabel) {
//77 78-92
holder.setText(mLabelInfo.getSideString());
} else {
holder.setSize(cardWidth, cardHeight);
Card card = null;
if (inMain(position)) {
card = mDeck.getMainCard(getMainIndex(position));
} else if (inExtra(position)) {
card = mDeck.getExtraCard(getExtraIndex(position));
} else if (inSide(position)) {
card = mDeck.getSideCard(getSideIndex(position));
}
if (card == null) {
holder.showEmpty();
} else {
holder.showImage();
if (mLimitList != null) {
if (mLimitList.check(card, LimitType.Forbidden)) {
holder.setRightImage(getImageTop().forbidden);
} else if (mLimitList.check(card, LimitType.Limit)) {
holder.setRightImage(getImageTop().limit);
} else if (mLimitList.check(card, LimitType.SemiLimit)) {
holder.setRightImage(getImageTop().semiLimit);
} else {
holder.setRightImage(null);
}
} else {
holder.setRightImage(null);
}
mImageLoader.bindImage(holder.cardImage, card.Code);
}
}
}
private int getMainIndex(int pos) {
return pos - MainStart;
}
private int getExtraIndex(int pos) {
return pos - ExtraStart;
}
private int getSideIndex(int pos) {
return pos - SideStart;
}
private boolean inMain(int pos) {
return pos >= MainStart && pos <= MainEnd;
}
private boolean inExtra(int pos) {
return pos >= ExtraStart && pos <= ExtraEnd;
}
private boolean inSide(int pos) {
return pos >= SideStart && pos <= SideEnd;
}
}
class DeckData {
}
package cn.garymb.ygomobile.ui.cards.deck;
import android.content.Context;
import androidx.recyclerview.widget.GridLayoutManager;
public class DeckLayoutManager2 extends GridLayoutManager {
private static final int DEF_LINE_COUNT = 10;
private static final int DEF_LINE_MAX_COUNT = 15;
public DeckLayoutManager2(Context context, int span) {
super(context, span);
setSpanSizeLookup(new SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
if (DeckItemUtils.isLabel(position)) {
return getChildCount();
}
return 1;
}
});
}
}
......@@ -244,7 +244,7 @@ public class FileActivity extends BaseActivity implements AdapterView.OnItemClic
} else {
mFileAdapter.setPath(mFileOpenInfo.getDefPath());
}
mFileAdapter.setFilefilter(mFileOpenInfo.getFileFilter());
mFileAdapter.setFileFilter(mFileOpenInfo.getFileFilter());
mFileAdapter.setOnlyFolder(mFileOpenInfo.getType() == FileOpenType.SelectFolder);
mFileAdapter.loadFiles();
}
......
......@@ -42,17 +42,17 @@ class FileAdapter extends BaseAdapterPlus<File> {
public FileAdapter(Context context) {
super(context);
rootPath = getRootPath();
try {
rootPath = Environment.getExternalStorageDirectory().getAbsolutePath();
} catch (Exception e) {
rootPath = "/";
}
}
public void setOnPathChangedListener(OnPathChangedListener onPathChangedListener) {
mOnPathChangedListener = onPathChangedListener;
}
private String getRootPath() {
return "/";
}
public File getCurPath() {
return mCurPath;
}
......@@ -101,7 +101,7 @@ class FileAdapter extends BaseAdapterPlus<File> {
mShowHide = showHide;
}
public void setFilefilter(String filefilter) {
public void setFileFilter(String filefilter) {
mFilefilter = filefilter;
}
......
......@@ -92,8 +92,6 @@ import ocgcore.CardManager;
import ocgcore.data.Card;
import static cn.garymb.ygomobile.Constants.ASSET_SERVER_LIST;
import static cn.garymb.ygomobile.Constants.URL_DONATE;
import static cn.garymb.ygomobile.Constants.URL_DONATE_CN;
public abstract class HomeActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener, OnDuelAssistantListener {
......@@ -296,13 +294,8 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
switch (id) {
case R.id.nav_webpage: {
String url;
if (BuildConfig.APPLICATION_ID == "cn.garymb.ygomobile.EN" || BuildConfig.APPLICATION_ID == "cn.garymb.ygomobile.KO") {
url = URL_DONATE;
} else {
url = URL_DONATE_CN;
}
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
intent.setData(Uri.parse(BuildConfig.URL_DONATE));
startActivity(intent);
}
break;
......@@ -352,7 +345,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
Button btnTutorial = viewDialog.findViewById(R.id.tutorial);
btnMasterRule.setOnClickListener((v) -> {
WebActivity.open(this, getString(R.string.masterrule), Constants.URL_MASTERRULE_CN);
WebActivity.open(this, getString(R.string.masterrule), Constants.URL_MASTER_RULE_CN);
dialog.dismiss();
});
btnTutorial.setOnClickListener((v) -> {
......
......@@ -22,7 +22,6 @@ import cn.garymb.ygomobile.AppsSettings;
import cn.garymb.ygomobile.Constants;
import cn.garymb.ygomobile.GameUriManager;
import cn.garymb.ygomobile.YGOStarter;
import cn.garymb.ygomobile.core.IrrlichtBridge;
import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.ui.activities.WebActivity;
import cn.garymb.ygomobile.ui.plus.DialogPlus;
......@@ -106,7 +105,7 @@ public class MainActivity extends HomeActivity {
Button btnTutorial = viewDialog.findViewById(R.id.tutorial);
btnMasterRule.setOnClickListener((v) -> {
WebActivity.open(this, getString(R.string.masterrule), Constants.URL_MASTERRULE_CN);
WebActivity.open(this, getString(R.string.masterrule), Constants.URL_MASTER_RULE_CN);
dialog.dismiss();
});
btnTutorial.setOnClickListener((v) -> {
......
......@@ -110,7 +110,13 @@ public class CardManager {
}
public Card getCard(int code) {
return cardDataHashMap.get(Integer.valueOf(code));
Card card = cardDataHashMap.get(code);
if(card == null){
card = new Card(code);
cardDataHashMap.put(code, new Card(code));
return card;
}
return card;
}
public int getCount() {
......
......@@ -35,6 +35,7 @@ public class Card extends CardData implements Parcelable {
public Card(int code) {
super(code);
this.Name = "Unknown";
}
public Card(CardData cardData) {
......
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