Commit 1cb563a4 authored by fallenstardust's avatar fallenstardust
parents 3c20e61f 0e4babd2
......@@ -131,20 +131,17 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
ILogger* logger = device->getLogger();
// logger->setLogLevel(ELL_WARNING);
isPSEnabled = options->isPendulumScaleEnabled();
dataManager.FileSystem = device->getFileSystem();
((CIrrDeviceAndroid*)device)->onAppCmd = onHandleAndroidCommand;
xScale = android::getXScale(app);
yScale = android::getYScale(app);
char log_scale[256] = {0};
sprintf(log_scale, "xScale = %f, yScale = %f", xScale, yScale);
Printer::log(log_scale);
ALOGD("xScale = %f, yScale = %f", xScale, yScale);
//io::path databaseDir = options->getDBDir();
io::path workingDir = options->getWorkDir();
char log_working[256] = {0};
sprintf(log_working, "workingDir= %s", workingDir.c_str());
Printer::log(log_working);
ALOGD("workingDir= %s", workingDir.c_str());
dataManager.FileSystem->changeWorkingDirectoryTo(workingDir);
/* Your media must be somewhere inside the assets folder. The assets folder is the root for the file system.
......@@ -201,9 +198,7 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
} else {
isNPOTSupported = ((COGLES1Driver *) driver)->queryOpenGLFeature(COGLES1ExtensionHandler::IRR_OES_texture_npot);
}
char log_npot[256];
sprintf(log_npot, "isNPOTSupported = %d", isNPOTSupported);
Printer::log(log_npot);
ALOGD("isNPOTSupported = %d", isNPOTSupported);
if (isNPOTSupported) {
if (quality == 1) {
driver->setTextureCreationFlag(irr::video::ETCF_CREATE_MIP_MAPS, false);
......@@ -1301,14 +1296,14 @@ void Game::MainLoop() {
if (!driver->queryFeature(video::EVDF_PIXEL_SHADER_1_1) &&
!driver->queryFeature(video::EVDF_ARB_FRAGMENT_PROGRAM_1))
{
Printer::log("WARNING: Pixel shaders disabled "
ALOGD("WARNING: Pixel shaders disabled "
"because of missing driver/hardware support.");
psFileName = "";
}
if (!driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1) &&
!driver->queryFeature(video::EVDF_ARB_VERTEX_PROGRAM_1))
{
Printer::log("WARNING: Vertex shaders disabled "
ALOGD("WARNING: Vertex shaders disabled "
"because of missing driver/hardware support.");
solidvsFileName = "";
TACvsFileName = "";
......@@ -1316,7 +1311,6 @@ void Game::MainLoop() {
}
video::IGPUProgrammingServices* gpu = driver->getGPUProgrammingServices();
if (gpu) {
char log_custom_shader[1024];
const video::E_GPU_SHADING_LANGUAGE shadingLanguage = video::EGSL_DEFAULT;
ogles2Solid = gpu->addHighLevelShaderMaterialFromFiles(
psFileName, "vertexMain", video::EVST_VS_1_1,
......@@ -1330,12 +1324,9 @@ void Game::MainLoop() {
psFileName, "vertexMain", video::EVST_VS_1_1,
blendvsFileName, "pixelMain", video::EPST_PS_1_1,
&customShadersCallback, video::EMT_ONETEXTURE_BLEND, 0 , shadingLanguage);
sprintf(log_custom_shader, "ogles2Sold = %d", ogles2Solid);
Printer::log(log_custom_shader);
sprintf(log_custom_shader, "ogles2BlendTexture = %d", ogles2BlendTexture);
Printer::log(log_custom_shader);
sprintf(log_custom_shader, "ogles2TrasparentAlpha = %d", ogles2TrasparentAlpha);
Printer::log(log_custom_shader);
ALOGD("ogles2Sold = %d", ogles2Solid);
ALOGD("ogles2BlendTexture = %d", ogles2BlendTexture);
ALOGD("ogles2TrasparentAlpha = %d", ogles2TrasparentAlpha);
}
}
matManager.mCard.MaterialType = (video::E_MATERIAL_TYPE)ogles2BlendTexture;
......
......@@ -41,7 +41,6 @@ int GetListBoxIndex(IGUIListBox* listbox, const wchar_t * target){
}
void android_main(ANDROID_APP app) {
app->inputPollSource.process = android::process_input;
app_dummy();
#else
int main(int argc, char* argv[]) {
#endif
......
......@@ -85,6 +85,8 @@ private:
bool musicEnabled = false;
};
//extern SoundManager soundManager;
}
#endif //SOUNDMANAGER_H
\ No newline at end of file
......@@ -9,7 +9,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.android.tools.build:gradle:7.0.3'
classpath 'com.android.tools.build:gradle-experimental:0.11.1'
//classpath 'me.tatarka:gradle-retrolambda:3.2.5'
}
......
......@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
......@@ -186,6 +186,8 @@ static void* join_game_thread(void* param) {
ygo::mainGame->gMutex.unlock();
return NULL;
}
//auto exit when join game by mycard.
exit_on_return = true;
irr::android::YGOGameOptions options = irr::android::YGOGameOptions(param);
irr::SEvent event;
......
......@@ -77,10 +77,10 @@ android {
exclude 'META-INF/LICENSE'
exclude 'META-INF/rxjava.properties'
}
aaptOptions {
noCompress 'dll', "config"
androidResources {
noCompress 'dll', 'config'
}
// buildToolsVersion '28.0.3'
// buildToolsVersion '28.0.3'
}
repositories {
......
......@@ -177,7 +177,8 @@
android:configChanges="orientation|keyboardHidden|navigation|screenSize"
android:launchMode="singleTop"
android:theme="@style/AppTheme.Mycard"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize" />
android:windowSoftInputMode="stateAlwaysHidden|adjustResize"/>
<activity
android:name="cn.garymb.ygomobile.ui.mycard.mcchat.McchatActivity"
android:label="@string/app_name"
......
......@@ -113,8 +113,8 @@ public class GameUriManager {
}
return new File(dir, "tmp_" + System.currentTimeMillis() + ".ydk");
} else {
IOUtils.createFolder(dir);
file=new File(dir,name+".ydk");
IOUtils.createFolder(dir);
file = new File(dir, name + ".ydk");
}
return file;
}
......@@ -197,7 +197,6 @@ public class GameUriManager {
}
private void doUri(Uri uri) {
Intent startSeting = new Intent(activity, SettingsActivity.class);
if ("file".equals(uri.getScheme()) || "content".equals(uri.getScheme())) {
File file = toLocalFile(uri);
......
......@@ -6,48 +6,39 @@ import cn.garymb.ygomobile.bean.TextSelect;
public class DeckFile extends TextSelect {
private String name;
private String path;
private Long date;
private final File path;
private final String fullName;
public DeckFile(String path) {
this.path = path;
name = new File(path).getName();
int end = name.lastIndexOf(".");
if (end != -1)
name = name.substring(0, end);
super.setName(name);
setObject(this);
this(new File(path));
}
public DeckFile(File file) {
path = file.getAbsolutePath();
name = file.getName();
name = name.substring(0, name.lastIndexOf("."));
date = file.lastModified();
path = file;
fullName = file.getName();
String name = fullName;
int index = name.lastIndexOf(".");
if(index > 0) {
name = name.substring(0, index);
}
super.setName(name);
setObject(this);
}
public String getName() {
return name;
}
public String getFileName(){
return new File(path).getName();
public String getFileName() {
return fullName;
}
public void setName(String name) {
this.name = name;
public File getPathFile() {
return path;
}
public String getPath() {
return path;
return path.getAbsolutePath();
}
public void setPath(String path) {
this.path = path;
public Long getDate() {
return path.lastModified();
}
public Long getDate() { return date; }
}
......@@ -3,8 +3,11 @@ package cn.garymb.ygomobile.loader;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import ocgcore.DataManager;
import ocgcore.data.Card;
......@@ -72,10 +75,10 @@ public class CardKeyWord {
private final long setcode;
//包含系列,或者包含名字、描述
public NameFilter(String word, boolean exclude, boolean onlyText) {
public NameFilter(@NonNull String word, boolean exclude, boolean onlyText) {
this.setcode = onlyText ? 0 : DataManager.get().getStringManager().getSetCode(word);
this.exclude = exclude;
this.word = word;
this.word = word.toLowerCase(Locale.US);
if(this.setcode > 0){
Log.d(TAG, "filter:setcode=" + setcode + ", exclude=" + exclude + ", word=" + word);
}
......
......@@ -29,7 +29,6 @@ import ocgcore.enums.LimitType;
public class CardLoader implements ICardSearcher {
private final LimitManager mLimitManager;
private final CardManager mCardManager;
private final StringManager mStringManager;
private final Context context;
private CallBack mCallBack;
private LimitList mLimitList;
......@@ -50,7 +49,6 @@ public class CardLoader implements ICardSearcher {
this.context = context;
mLimitManager = DataManager.get().getLimitManager();
mCardManager = DataManager.get().getCardManager();
mStringManager = DataManager.get().getStringManager();
mLimitList = mLimitManager.getTopLimit();
}
......
......@@ -68,7 +68,7 @@ public class ImageLoader implements Closeable {
private final boolean useCache;
private static final String TAG = ImageLoader.class.getSimpleName();
private final Map<String, ZipFile> zipFileCache = new ConcurrentHashMap<>();
private final Map<Long, Cache> zipDataCache = new ConcurrentHashMap<>();
private final Map<Long, ImageLoader.Cache> zipDataCache = new ConcurrentHashMap<>();
private ZipFile mDefaultZipFile;
private File mPicsFile;
......@@ -182,7 +182,7 @@ public class ImageLoader implements Closeable {
try {
RequestBuilder<Drawable> resource = GlideCompat.with(imageview.getContext()).load(file);
setDefaults(resource,
new MediaStoreSignature("image/*", file.lastModified(), Type.origin.getId()),
new MediaStoreSignature("image/*", file.lastModified(), ImageLoader.Type.origin.getId()),
pre, type);
resource.into(imageview);
} catch (Exception e) {
......
package cn.garymb.ygomobile.ui.adapters;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.tubb.smrv.SwipeHorizontalMenuLayout;
import org.greenrobot.eventbus.EventBus;
......@@ -63,6 +66,14 @@ public class CardListAdapter extends BaseRecyclerAdapterPlus<Card, ViewHolder> i
return false;
}
public void notifyItemChanged(Card card) {
for (int i = 0; i < getItemCount(); i++) {
if (getCard(i).Code == card.Code) {
notifyItemChanged(i);
}
}
}
public void hideMenu(View view) {
if (view == null) {
view = mShowMenuView;
......@@ -88,6 +99,7 @@ public class CardListAdapter extends BaseRecyclerAdapterPlus<Card, ViewHolder> i
}
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = inflate(R.layout.item_search_card_swipe, parent, false);
......@@ -100,8 +112,8 @@ public class CardListAdapter extends BaseRecyclerAdapterPlus<Card, ViewHolder> i
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
Card item = getItem(position);
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
Card item = getCard(position);
if(item == null){
return;
}
......
package cn.garymb.ygomobile.ui.adapters;
import androidx.annotation.NonNull;
public class SimpleSpinnerItem {
public long value;
public String text;
public Object tag;
public transient Object tag;
public SimpleSpinnerItem(long value, String text) {
this.value = value;
......@@ -20,8 +22,9 @@ public class SimpleSpinnerItem {
return this;
}
@NonNull
@Override
public String toString() {
return text;
return "" + text;
}
}
......@@ -107,6 +107,9 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
ll_bar.setVisibility(View.GONE);
imageLoader.bindImage(photoView, msg.arg1, ImageLoader.Type.origin);
imageLoader.bindImage(cardImage, msg.arg1, ImageLoader.Type.middle);
if(mListener != null){
mListener.onImageUpdate(mCardInfo);
}
break;
case TYPE_DOWNLOAD_CARD_IMAGE_ING:
tv_loading.setText(msg.arg1 + "%");
......@@ -128,32 +131,32 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
public CardDetail(BaseActivity context, ImageLoader imageLoader, StringManager stringManager) {
super(context.getLayoutInflater().inflate(R.layout.dialog_cardinfo, null));
mContext = context;
cardImage = bind(R.id.card_image);
cardImage = findViewById(R.id.card_image);
this.imageLoader = imageLoader;
mStringManager = stringManager;
name = bind(R.id.text_name);
desc = bind(R.id.text_desc);
close = bind(R.id.btn_close);
cardCode = bind(R.id.card_code);
level = bind(R.id.card_level);
linkArrow = bind(R.id.detail_link_arrows);
type = bind(R.id.card_type);
View faq = bind(R.id.btn_faq);
cardAtk = bind(R.id.card_atk);
cardDef = bind(R.id.card_def);
atkdefView = bind(R.id.layout_atkdef2);
mImageFav = bind(R.id.image_fav);
monsterLayout = bind(R.id.layout_monster);
layoutDetailPScale = bind(R.id.detail_p_scale);
detailCardScale = bind(R.id.detail_cardscale);
race = bind(R.id.card_race);
setName = bind(R.id.card_setname);
addMain = bind(R.id.btn_add_main);
addSide = bind(R.id.btn_add_side);
otView = bind(R.id.card_ot);
attrView = bind(R.id.card_attribute);
lbSetCode = bind(R.id.label_setcode);
name = findViewById(R.id.text_name);
desc = findViewById(R.id.text_desc);
close = findViewById(R.id.btn_close);
cardCode = findViewById(R.id.card_code);
level = findViewById(R.id.card_level);
linkArrow = findViewById(R.id.detail_link_arrows);
type = findViewById(R.id.card_type);
View faq = findViewById(R.id.btn_faq);
cardAtk = findViewById(R.id.card_atk);
cardDef = findViewById(R.id.card_def);
atkdefView = findViewById(R.id.layout_atkdef2);
mImageFav = findViewById(R.id.image_fav);
monsterLayout = findViewById(R.id.layout_monster);
layoutDetailPScale = findViewById(R.id.detail_p_scale);
detailCardScale = findViewById(R.id.detail_cardscale);
race = findViewById(R.id.card_race);
setName = findViewById(R.id.card_setname);
addMain = findViewById(R.id.btn_add_main);
addSide = findViewById(R.id.btn_add_side);
otView = findViewById(R.id.card_ot);
attrView = findViewById(R.id.card_attribute);
lbSetCode = findViewById(R.id.label_setcode);
cardManager = DataManager.get().getCardManager();
close.setOnClickListener((v) -> {
if (mListener != null) {
......@@ -187,10 +190,10 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
mListener.onOpenUrl(cardInfo);
}
});
bind(R.id.lastone).setOnClickListener((v) -> {
findViewById(R.id.lastone).setOnClickListener((v) -> {
onPreCard();
});
bind(R.id.nextone).setOnClickListener((v) -> {
findViewById(R.id.nextone).setOnClickListener((v) -> {
onNextCard();
});
mImageFav.setOnClickListener((v) -> {
......@@ -532,9 +535,6 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
}
}
private <T extends View> T bind(int id) {
return (T) findViewById(id);
}
public interface OnFavoriteChangedListener {
void onFavoriteChange(Card card, boolean favorite);
......@@ -547,6 +547,10 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
void onAddSideCard(Card cardInfo);
void onImageUpdate(Card cardInfo);
void onClose();
}
......@@ -563,6 +567,11 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
public void onClose() {
}
@Override
public void onImageUpdate(Card cardInfo) {
}
@Override
public void onAddSideCard(Card cardInfo) {
......
......@@ -291,6 +291,11 @@ public class CardSearchActivity extends BaseActivity implements CardLoader.CallB
WebActivity.openFAQ(getContext(), cardInfo);
}
@Override
public void onImageUpdate(Card cardInfo) {
mCardListAdapter.notifyItemChanged(cardInfo);
}
@Override
public void onClose() {
mDialog.dismiss();
......
......@@ -120,6 +120,7 @@ public class CardSearcher implements View.OnClickListener {
resetButton.setOnClickListener(this);
mCardLoader = dataLoader;
// setCodeSpinner.setFirstIndex(1);
OnEditorActionListener searchListener = (v, actionId, event) -> {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
......
......@@ -38,7 +38,6 @@ import com.feihua.dialogutils.util.DialogUtils;
import com.nightonke.boommenu.BoomButtons.BoomButton;
import com.nightonke.boommenu.BoomButtons.TextOutsideCircleButton;
import com.nightonke.boommenu.BoomMenuButton;
import com.ourygo.assistant.service.DuelAssistantService;
import com.ourygo.assistant.util.DuelAssistantManagement;
import org.greenrobot.eventbus.EventBus;
......@@ -420,6 +419,12 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
WebActivity.openFAQ(getContext(), cardInfo);
}
@Override
public void onImageUpdate(Card cardInfo) {
mDeckAdapater.notifyItemChanged(cardInfo);
mCardListAdapter.notifyItemChanged(cardInfo);
}
@Override
public void onClose() {
mDialog.dismiss();
......@@ -1117,7 +1122,7 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
@Override
public void onDeckSelect(DeckFile deckFile) {
loadDeckFromFile(new File(deckFile.getPath()));
loadDeckFromFile(deckFile.getPathFile());
}
@Override
......@@ -1127,7 +1132,7 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
return;
String currentDeckPath = deck.getAbsolutePath();
for (DeckFile deckFile : deckFileList) {
if (deckFile.getPath().equals(currentDeckPath)) {
if (TextUtils.equals(deckFile.getPath(), currentDeckPath)) {
List<File> files = getYdkFiles();
File file = null;
if (files != null && files.size() > 0) {
......@@ -1145,10 +1150,14 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
@Override
public void onDeckMove(List<DeckFile> deckFileList, DeckType toDeckType) {
String currentDeckPath = mDeckAdapater.getYdkFile().getAbsolutePath();
File ydk = mDeckAdapater.getYdkFile();
if(ydk == null){
return;
}
String currentDeckPath = ydk.getPath();
for (DeckFile deckFile : deckFileList) {
if (deckFile.getPath().equals(currentDeckPath)) {
loadDeckFromFile(new File(toDeckType.getPath(), deckFile.getName() + ".ydk"));
if (TextUtils.equals(currentDeckPath, deckFile.getPath())) {
loadDeckFromFile(new File(toDeckType.getPath(), deckFile.getFileName()));
return;
}
}
......@@ -1156,10 +1165,14 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
@Override
public void onDeckCopy(List<DeckFile> deckFileList, DeckType toDeckType) {
String currentDeckPath = mDeckAdapater.getYdkFile().getAbsolutePath();
File ydk = mDeckAdapater.getYdkFile();
if(ydk == null){
return;
}
String currentDeckPath = ydk.getPath();
for (DeckFile deckFile : deckFileList) {
if (deckFile.getPath().equals(currentDeckPath)) {
loadDeckFromFile(new File(toDeckType.getPath(), deckFile.getName() + ".ydk"));
if (TextUtils.equals(currentDeckPath, deckFile.getPath())) {
loadDeckFromFile(new File(toDeckType.getPath(), deckFile.getFileName()));
return;
}
}
......
......@@ -9,6 +9,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import java.io.File;
......@@ -189,7 +190,7 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
}
@Override
public Card getCard(int posotion) {
public @Nullable Card getCard(int posotion) {
int count = mMainCount;
int index = 0;
if (posotion < count) {
......@@ -388,7 +389,7 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
return mLimitList;
}
public File getYdkFile(){
public @Nullable File getYdkFile(){
if(mDeckInfo != null){
return mDeckInfo.source;
}
......@@ -477,6 +478,16 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
mItems.add(deckItem);
}
public void notifyItemChanged(Card card){
for (int i = 0; i < getItemCount(); i++) {
DeckItem item = getItem(i);
Card c = item.getCardInfo();
if (c != null && c.Code == card.Code) {
notifyItemChanged(i);
}
}
}
public void addItem(int pos, DeckItem deckItem) {
if (deckItem.getCardInfo() != null) {
if (pos >= DeckItem.MainStart && pos <= DeckItem.MainEnd) {
......
......@@ -142,12 +142,15 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
};
//x5内核初始化接口
QbSdk.initX5Environment(this, cb);
if (!Constants.ACTION_OPEN_GAME.equals(getIntent().getAction())) {
Log.d(Constants.TAG, "start check update");
//check update
Beta.checkUpgrade(false, false);
} else {
Log.d(Constants.TAG, "skip check update");
if(!BuildConfig.BUILD_TYPE.equals("debug")) {
//release才检查版本
if (!Constants.ACTION_OPEN_GAME.equals(getIntent().getAction())) {
Log.d(Constants.TAG, "start check update");
//check update
Beta.checkUpgrade(false, false);
} else {
Log.d(Constants.TAG, "skip check update");
}
}
//初始化决斗助手
initDuelAssistant();
......
......@@ -3,7 +3,6 @@ package cn.garymb.ygomobile.ui.widget;
import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.DialogInterface;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.AttributeSet;
......@@ -16,88 +15,81 @@ import android.widget.SpinnerAdapter;
import androidx.appcompat.widget.AppCompatSpinner;
import java.util.ArrayList;
import java.util.List;
import cn.garymb.ygomobile.lite.R;
public class SearchableSpinner extends AppCompatSpinner implements View.OnTouchListener,
SearchableListDialog.SearchableItem {
SearchableListDialog.onSearchItemClickListener {
public static final int NO_ITEM_SELECTED = -1;
private Context _context;
private List _items;
private SearchableListDialog _searchableListDialog;
private final ArrayList<Object> _items = new ArrayList<>();
private boolean _isDirty;
private BaseAdapter _arrayAdapter;
private String _strHintText;
private boolean _isFromInit;
private String mTitleString = "Select Item";
private int mFirstIndex = 0;
public SearchableSpinner(Context context) {
super(context);
this._context = context;
init();
this(context, null);
}
public SearchableSpinner(Context context, AttributeSet attrs) {
super(context, attrs);
this._context = context;
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SearchableSpinner);
final int N = a.getIndexCount();
for (int i = 0; i < N; ++i) {
int attr = a.getIndex(i);
if (attr == R.styleable.SearchableSpinner_hintText) {
_strHintText = a.getString(attr);
} else if (attr == R.styleable.SearchableSpinner_searchTitle) {
mTitleString = a.getString(attr);
}
}
a.recycle();
init();
this(context, attrs, 0);
}
public SearchableSpinner(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this._context = context;
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SearchableSpinner);
if (a != null) {
final int N = a.getIndexCount();
for (int i = 0; i < N; ++i) {
int attr = a.getIndex(i);
if (attr == R.styleable.SearchableSpinner_hintText) {
_strHintText = a.getString(attr);
} else if (attr == R.styleable.SearchableSpinner_searchTitle) {
mTitleString = a.getString(attr);
}
}
a.recycle();
}
init();
}
private void init() {
_items = new ArrayList();
_searchableListDialog = SearchableListDialog.newInstance
(_items);
_searchableListDialog = new SearchableListDialog(getContext());
_searchableListDialog.setTitle(mTitleString);
_searchableListDialog.setOnSearchableItemClickListener(this);
setOnTouchListener(this);
_arrayAdapter = (BaseAdapter) getAdapter();
if (!TextUtils.isEmpty(_strHintText)) {
ArrayAdapter arrayAdapter = new ArrayAdapter(_context, android.R.layout
.simple_list_item_1, new String[]{_strHintText});
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(getContext(),
android.R.layout.simple_list_item_1,
new String[]{_strHintText});
_isFromInit = true;
setAdapter(arrayAdapter);
}
}
public void setFirstIndex(int firstIndex) {
this.mFirstIndex = firstIndex;
}
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
if (null != _arrayAdapter) {
// Refresh content #6
// Change Start
// Description: The items were only set initially, not reloading the data in the
// spinner every time it is loaded with items in the adapter.
// Change end.
//修复 重复点击 bug
if (!_searchableListDialog.isAdded()) {
if(!_searchableListDialog.isShowing()) {
_items.clear();
for (int i = 0; i < _arrayAdapter.getCount(); i++) {
int N = _arrayAdapter.getCount();
for (int i = mFirstIndex; i < N; i++) {
_items.add(_arrayAdapter.getItem(i));
}
_searchableListDialog.show(scanForActivity(_context).getFragmentManager(), "TAG");
_searchableListDialog.show(_items);
}
}
}
......@@ -109,7 +101,7 @@ public class SearchableSpinner extends AppCompatSpinner implements View.OnTouchL
if (!_isFromInit) {
_arrayAdapter = (BaseAdapter) adapter;
if (!TextUtils.isEmpty(_strHintText) && !_isDirty) {
ArrayAdapter arrayAdapter = new ArrayAdapter(_context, android.R.layout
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(getContext(), android.R.layout
.simple_list_item_1, new String[]{_strHintText});
super.setAdapter(arrayAdapter);
} else {
......@@ -124,8 +116,7 @@ public class SearchableSpinner extends AppCompatSpinner implements View.OnTouchL
@Override
public void onSearchableItemClicked(Object item, int position) {
setSelection(_items.indexOf(item));
setSelection(_items.indexOf(item) + mFirstIndex);
if (!_isDirty) {
_isDirty = true;
setAdapter(_arrayAdapter);
......@@ -137,14 +128,6 @@ public class SearchableSpinner extends AppCompatSpinner implements View.OnTouchL
_searchableListDialog.setTitle(strTitle);
}
public void setPositiveButton(String strPositiveButtonText) {
_searchableListDialog.setPositiveButton(strPositiveButtonText);
}
public void setPositiveButton(String strPositiveButtonText, DialogInterface.OnClickListener onClickListener) {
_searchableListDialog.setPositiveButton(strPositiveButtonText, onClickListener);
}
public void setOnSearchTextChangedListener(SearchableListDialog.OnSearchTextChanged onSearchTextChanged) {
_searchableListDialog.setOnSearchTextChangedListener(onSearchTextChanged);
}
......
......@@ -10,48 +10,20 @@ public class CardUtils {
public static String getAllTypeString(Card card, StringManager stringManager) {
StringBuilder stringBuilder = new StringBuilder();
CardType[] cardTypes = CardType.values();
boolean isFrst = true;
if (card.isType(CardType.Spell)) {
for (CardType type : cardTypes) {
if (card.isType(type)) {
if (!isFrst) {
stringBuilder.append("|");
} else {
isFrst = false;
}
stringBuilder.append(stringManager.getTypeString(type.getId()));
// break;
boolean isFirst = true;
for (CardType type : cardTypes) {
if (card.isType(type)) {
if (!isFirst) {
stringBuilder.append("/");
} else {
isFirst = false;
}
}
// stringBuilder.append(stringManager.getTypeString(CardType.Spell.value()));
} else if (card.isType(CardType.Trap)) {
for (CardType type : cardTypes) {
if (card.isType(type)) {
if (!isFrst) {
stringBuilder.append("|");
} else {
isFrst = false;
}
stringBuilder.append(stringManager.getTypeString(type.getId()));
}
// break;
}
// stringBuilder.append(stringManager.getTypeString(CardType.Trap.value()));
} else {
for (CardType type : cardTypes) {
if (card.isType(type)) {
if (!isFrst) {
stringBuilder.append("/");
} else {
isFrst = false;
}
String str = stringManager.getTypeString(type.getId());
if (TextUtils.isEmpty(str)) {
stringBuilder.append("0x");
stringBuilder.append(String.format("%X", type.getId()));
} else {
stringBuilder.append(str);
}
String str = stringManager.getTypeString(type.getId());
if (TextUtils.isEmpty(str)) {
stringBuilder.append("0x");
stringBuilder.append(String.format("%X", type.getId()));
} else {
stringBuilder.append(str);
}
}
}
......
......@@ -167,22 +167,10 @@ public class FileUtils {
}
public static void copyFile(String oldPath, String newPath) throws IOException {
copyFile(oldPath, newPath, true);
}
public static void copyFile(String oldPath, String newPath, boolean isName) throws IOException {
//判断复制后的路径是否含有文件名,如果没有则加上
if (!isName) {
//由于newPath是路径加文件名,所以获取要复制的文件名与复制后的路径组成新的newPath
String abb[] = oldPath.split("/");
newPath = newPath + "/" + abb[abb.length - 1];
}
FileInputStream fis = new FileInputStream(oldPath);
FileOutputStream fos = new FileOutputStream(newPath);
byte[] buf = new byte[1024];
int len = 0;
int len;
while ((len = fis.read(buf)) != -1) {
fos.write(buf, 0, len);
}
......
......@@ -155,11 +155,11 @@ public class Card extends CardData implements Parcelable {
}
public boolean containsName(String key){
return Name != null && Name.toLowerCase(Locale.US).contains(key.toLowerCase(Locale.US));
return Name != null && Name.toLowerCase(Locale.US).contains(key);
}
public boolean containsDesc(String key){
return Desc != null && Desc.toLowerCase(Locale.US).contains(key.toLowerCase(Locale.US));
return Desc != null && Desc.toLowerCase(Locale.US).contains(key);
}
/**
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
......@@ -242,6 +242,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:orientation="horizontal">
<com.google.android.material.textfield.TextInputLayout
......@@ -266,20 +267,11 @@
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="60dp"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_search"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_gravity="center_vertical"
android:background="@drawable/button_bg"
android:text="@string/search" />
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_reset"
android:layout_marginLeft="10dp"
......@@ -289,6 +281,15 @@
android:layout_gravity="center_vertical"
android:background="@drawable/button_bg"
android:text="@string/reset" />
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_search"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="10dp"
android:layout_gravity="center_vertical"
android:background="@drawable/button_bg"
android:text="@string/search" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
</androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file
......@@ -29,4 +29,7 @@
<color name="colorMain">#2196F3</color>
<color name="background">#ECEFF1</color>
<color name="transparent">#00000000</color>
<color name="search_text_color">#ff8800</color>
<color name="search_list_item_color">#b8be35</color>
</resources>
\ No newline at end of file
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