Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fallenstardust
YGOMobile
Commits
5f03ee56
Commit
5f03ee56
authored
Oct 06, 2021
by
kenan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SearchableListDialog
parent
cf816b81
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
113 additions
and
206 deletions
+113
-206
mobile/src/main/java/cn/garymb/ygomobile/ui/adapters/SimpleSpinnerItem.java
...va/cn/garymb/ygomobile/ui/adapters/SimpleSpinnerItem.java
+5
-2
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardSearcher.java
.../main/java/cn/garymb/ygomobile/ui/cards/CardSearcher.java
+4
-2
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
...c/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
+9
-6
mobile/src/main/java/cn/garymb/ygomobile/ui/widget/SearchableListDialog.java
...a/cn/garymb/ygomobile/ui/widget/SearchableListDialog.java
+59
-147
mobile/src/main/java/cn/garymb/ygomobile/ui/widget/SearchableSpinner.java
...java/cn/garymb/ygomobile/ui/widget/SearchableSpinner.java
+32
-49
mobile/src/main/res/values/colors.xml
mobile/src/main/res/values/colors.xml
+3
-0
mobile/src/main/res/values/strings.xml
mobile/src/main/res/values/strings.xml
+1
-0
No files found.
mobile/src/main/java/cn/garymb/ygomobile/ui/adapters/SimpleSpinnerItem.java
View file @
5f03ee56
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
;
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardSearcher.java
View file @
5f03ee56
...
...
@@ -26,6 +26,7 @@ import cn.garymb.ygomobile.ui.adapters.SimpleSpinnerAdapter;
import
cn.garymb.ygomobile.ui.adapters.SimpleSpinnerItem
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.ui.widget.SearchableSpinner
;
import
ocgcore.DataManager
;
import
ocgcore.LimitManager
;
import
ocgcore.StringManager
;
...
...
@@ -55,7 +56,7 @@ public class CardSearcher implements View.OnClickListener {
private
final
Spinner
typeMonsterSpinner2
;
private
final
Spinner
typeSpellSpinner
;
private
final
Spinner
typeTrapSpinner
;
private
final
Spinner
setCodeSpinner
;
private
final
S
earchableS
pinner
setCodeSpinner
;
private
final
Spinner
categorySpinner
;
private
final
Spinner
raceSpinner
;
private
final
Spinner
levelSpinner
;
...
...
@@ -120,6 +121,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
);
...
...
@@ -439,7 +441,7 @@ public class CardSearcher implements View.OnClickListener {
private
void
initSetNameSpinners
(
Spinner
spinner
)
{
List
<
CardSet
>
setnames
=
mStringManager
.
getCardSets
();
List
<
SimpleSpinnerItem
>
items
=
new
ArrayList
<>();
items
.
add
(
new
SimpleSpinnerItem
(
0
,
getString
(
R
.
string
.
label_set
)));
items
.
add
(
new
SimpleSpinnerItem
(
0
,
mContext
.
getString
(
R
.
string
.
label_set
)));
for
(
CardSet
set
:
setnames
)
{
items
.
add
(
new
SimpleSpinnerItem
(
set
.
getCode
(),
set
.
getName
()));
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
View file @
5f03ee56
...
...
@@ -142,6 +142,8 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
};
//x5内核初始化接口
QbSdk
.
initX5Environment
(
this
,
cb
);
if
(!
BuildConfig
.
BUILD_TYPE
.
equals
(
"debug"
))
{
//release才检查版本
if
(!
Constants
.
ACTION_OPEN_GAME
.
equals
(
getIntent
().
getAction
()))
{
Log
.
d
(
Constants
.
TAG
,
"start check update"
);
//check update
...
...
@@ -149,6 +151,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
}
else
{
Log
.
d
(
Constants
.
TAG
,
"skip check update"
);
}
}
//初始化决斗助手
initDuelAssistant
();
//萌卡
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/widget/SearchableListDialog.java
View file @
5f03ee56
This diff is collapsed.
Click to expand it.
mobile/src/main/java/cn/garymb/ygomobile/ui/widget/SearchableSpinner.java
View file @
5f03ee56
...
...
@@ -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,34 +15,35 @@ 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
;
this
(
context
,
attrs
,
0
);
}
public
SearchableSpinner
(
Context
context
,
AttributeSet
attrs
,
int
defStyleAttr
)
{
super
(
context
,
attrs
,
defStyleAttr
);
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
);
...
...
@@ -54,50 +54,42 @@ public class SearchableSpinner extends AppCompatSpinner implements View.OnTouchL
}
}
a
.
recycle
();
init
();
}
public
SearchableSpinner
(
Context
context
,
AttributeSet
attrs
,
int
defStyleAttr
)
{
super
(
context
,
attrs
,
defStyleAttr
);
this
.
_context
=
context
;
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
);
}
...
...
mobile/src/main/res/values/colors.xml
View file @
5f03ee56
...
...
@@ -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
mobile/src/main/res/values/strings.xml
View file @
5f03ee56
...
...
@@ -328,4 +328,5 @@
<string
name=
"label_ot_SC_OCG"
>
SChinese OCG
</string>
<string
name=
"settings_screen_padding"
>
Reserved height of curved screen
</string>
<string
name=
"tip_load_cdb_error"
>
加载数据出错
</string>
<string
name=
"text_none"
translatable=
"false"
>
N/A
</string>
</resources>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment