Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
M
magicbox
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王雪伟
magicbox
Commits
d7726323
Commit
d7726323
authored
Mar 08, 2022
by
王雪伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[提交人]:王雪伟
[提交简述] :海外魔盒 [实现方案] :修改地址选择器
parent
f01baad9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
95 additions
and
46 deletions
+95
-46
strings.xml
cms/src/main/res/values/strings.xml
+1
-1
EditAddressActivity.kt
...n/java/com/zxhl/main/page/activity/EditAddressActivity.kt
+80
-29
AddressBean.kt
...in/src/main/java/com/zxhl/main/page/entity/AddressBean.kt
+0
-2
AllAddressBean.java
...c/main/java/com/zxhl/main/page/entity/AllAddressBean.java
+0
-11
activity_layout_edit_address.xml
...Main/src/main/res/layout/activity_layout_edit_address.xml
+14
-3
No files found.
cms/src/main/res/values/strings.xml
View file @
d7726323
...
@@ -51,7 +51,7 @@
...
@@ -51,7 +51,7 @@
<string
name=
"box_detail_open_box_tips"
>
FAIRNESS GUARANTEED
</string>
<string
name=
"box_detail_open_box_tips"
>
FAIRNESS GUARANTEED
</string>
<string
name=
"box_detail_open_box_rule"
>
Rule
</string>
<string
name=
"box_detail_open_box_rule"
>
Rule
</string>
<string
name=
"box_detail_open_box_test_play"
>
TRY FOR FREE
</string>
<string
name=
"box_detail_open_box_test_play"
>
TRY FOR FREE
</string>
<string
name=
"box_detail_open_box_re_pumping"
>
重抽卡
</string>
<string
name=
"box_detail_open_box_re_pumping"
>
reopen card
</string>
<string
name=
"box_detail_open_box_shop_pool"
>
Items in this box
</string>
<string
name=
"box_detail_open_box_shop_pool"
>
Items in this box
</string>
<string
name=
"box_detail_open_box_one_lottery_btn"
>
Open
</string>
<string
name=
"box_detail_open_box_one_lottery_btn"
>
Open
</string>
<string
name=
"box_detail_open_box_five_lottery_btn"
>
Open 5x
</string>
<string
name=
"box_detail_open_box_five_lottery_btn"
>
Open 5x
</string>
...
...
moduleMain/src/main/java/com/zxhl/main/page/activity/EditAddressActivity.kt
View file @
d7726323
...
@@ -10,10 +10,11 @@ import android.provider.ContactsContract
...
@@ -10,10 +10,11 @@ import android.provider.ContactsContract
import
android.text.TextUtils
import
android.text.TextUtils
import
android.util.Log
import
android.util.Log
import
android.view.View
import
android.view.View
import
android.widget.AdapterView
import
android.widget.ArrayAdapter
import
android.widget.Toast
import
android.widget.Toast
import
androidx.core.app.ActivityCompat
import
androidx.core.app.ActivityCompat
import
androidx.core.content.ContextCompat
import
androidx.core.content.ContextCompat
import
com.google.gson.Gson
import
com.zxhl.cms.AppContext
import
com.zxhl.cms.AppContext
import
com.zxhl.cms.common.base.BaseActivity
import
com.zxhl.cms.common.base.BaseActivity
import
com.zxhl.cms.net.model.box.AddressEntity
import
com.zxhl.cms.net.model.box.AddressEntity
...
@@ -22,7 +23,6 @@ import com.zxhl.cms.utils.Utils
...
@@ -22,7 +23,6 @@ import com.zxhl.cms.utils.Utils
import
com.zxhl.main.R
import
com.zxhl.main.R
import
com.zxhl.main.page.contract.EditAddressContract
import
com.zxhl.main.page.contract.EditAddressContract
import
com.zxhl.main.page.entity.AddressBean
import
com.zxhl.main.page.entity.AddressBean
import
com.zxhl.main.page.entity.JsonBean
import
com.zxhl.main.page.presenter.EditAddressPresenter
import
com.zxhl.main.page.presenter.EditAddressPresenter
import
kotlinx.android.synthetic.main.activity_layout_edit_address.*
import
kotlinx.android.synthetic.main.activity_layout_edit_address.*
import
org.json.JSONArray
import
org.json.JSONArray
...
@@ -36,7 +36,10 @@ class EditAddressActivity : BaseActivity(), EditAddressContract.View {
...
@@ -36,7 +36,10 @@ class EditAddressActivity : BaseActivity(), EditAddressContract.View {
private
var
mPresenter
:
EditAddressPresenter
?
=
null
private
var
mPresenter
:
EditAddressPresenter
?
=
null
private
var
defaultAddress
:
String
=
"0"
private
var
defaultAddress
:
String
=
"0"
private
var
addressList
:
ArrayList
<
AddressBean
>
=
ArrayList
()
//地址
private
var
addressList
:
ArrayList
<
AddressBean
>
=
ArrayList
()
//城市
private
var
addressCountryList
:
ArrayList
<
String
>
=
ArrayList
()
//国家
private
var
isInitSelect
=
true
override
fun
onClick
(
v
:
View
?)
{
override
fun
onClick
(
v
:
View
?)
{
...
@@ -53,6 +56,7 @@ class EditAddressActivity : BaseActivity(), EditAddressContract.View {
...
@@ -53,6 +56,7 @@ class EditAddressActivity : BaseActivity(), EditAddressContract.View {
override
fun
init
()
{
override
fun
init
()
{
initCityData
()
initCityData
()
initSelect
()
var
username
=
intent
?.
data
?.
getQueryParameter
(
"username"
)
?:
""
var
username
=
intent
?.
data
?.
getQueryParameter
(
"username"
)
?:
""
var
mobile
=
intent
?.
data
?.
getQueryParameter
(
"mobile"
)
?:
""
var
mobile
=
intent
?.
data
?.
getQueryParameter
(
"mobile"
)
?:
""
...
@@ -75,14 +79,25 @@ class EditAddressActivity : BaseActivity(), EditAddressContract.View {
...
@@ -75,14 +79,25 @@ class EditAddressActivity : BaseActivity(), EditAddressContract.View {
id_img_moren
.
setImageResource
(
R
.
drawable
.
icon_guan
)
id_img_moren
.
setImageResource
(
R
.
drawable
.
icon_guan
)
}
}
}
}
//国家选择
id_select_country
.
setOnClickListener
{
isInitSelect
=
false
id_country_select_spinner
.
performClick
()
}
//城市选择
id_select_city
?.
setOnClickListener
{
id_select_city
?.
setOnClickListener
{
hideKeyBoard
()
// hideKeyBoard()
isInitSelect
=
false
id_city_select_spinner
.
performClick
()
}
}
// id_select_country?.text = addressList[0].country
// id_select_city?.text = addressList[0].cityLis?.get(0)
id_edit_name
?.
setText
(
username
)
id_edit_name
?.
setText
(
username
)
id_edit_phone
?.
setText
(
mobile
)
id_edit_phone
?.
setText
(
mobile
)
id_select_country
?.
text
=
addressList
[
0
].
country
id_select_city
?.
text
=
addressList
[
0
].
cityLis
?.
get
(
0
)
id_edit_address1
?.
setText
(
address
)
id_edit_address1
?.
setText
(
address
)
id_img_back
?.
setOnClickListener
{
id_img_back
?.
setOnClickListener
{
finish
()
finish
()
...
@@ -97,11 +112,11 @@ class EditAddressActivity : BaseActivity(), EditAddressContract.View {
...
@@ -97,11 +112,11 @@ class EditAddressActivity : BaseActivity(), EditAddressContract.View {
id_select_city
.
text
.
toString
()
id_select_city
.
text
.
toString
()
)
||
TextUtils
.
isEmpty
(
id_select_country
.
text
.
toString
())
)
||
TextUtils
.
isEmpty
(
id_select_country
.
text
.
toString
())
)
{
)
{
Utils
.
showToast
(
AppContext
.
get
(),
"请完整填写信息"
)
//
Utils.showToast(AppContext.get(), "请完整填写信息")
return
@setOnClickListener
return
@setOnClickListener
}
else
{
}
else
{
if
(
id_edit_phone
.
text
.
toString
()
?.
length
!=
11
)
{
if
(
id_edit_phone
.
text
.
toString
()
?.
length
!=
11
)
{
Utils
.
showToast
(
AppContext
.
get
(),
"请检查手机号码"
)
//
Utils.showToast(AppContext.get(), "请检查手机号码")
return
@setOnClickListener
return
@setOnClickListener
}
}
enity
=
AddressEntity
()
enity
=
AddressEntity
()
...
@@ -234,27 +249,8 @@ class EditAddressActivity : BaseActivity(), EditAddressContract.View {
...
@@ -234,27 +249,8 @@ class EditAddressActivity : BaseActivity(), EditAddressContract.View {
finish
()
finish
()
}
}
fun
parseData
(
result
:
String
?):
ArrayList
<
JsonBean
>?
{
//Gson 解析
val
detail
:
ArrayList
<
JsonBean
>
=
ArrayList
()
try
{
val
data
=
JSONArray
(
result
)
val
gson
=
Gson
()
for
(
i
in
0
until
data
.
length
())
{
val
entity
=
gson
.
fromJson
(
data
.
optJSONObject
(
i
).
toString
(),
JsonBean
::
class
.
java
)
detail
.
add
(
entity
)
}
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
return
detail
}
private
fun
initCityData
()
{
private
fun
initCityData
()
{
Log
.
d
(
"wxw"
,
"start"
)
//获取assets目录下的地址json文件数据
//获取assets目录下的地址json文件数据
val
addressJson
=
GetJsonDataUtil
().
getJson
(
this
,
"address.json"
)
val
addressJson
=
GetJsonDataUtil
().
getJson
(
this
,
"address.json"
)
...
@@ -266,18 +262,73 @@ class EditAddressActivity : BaseActivity(), EditAddressContract.View {
...
@@ -266,18 +262,73 @@ class EditAddressActivity : BaseActivity(), EditAddressContract.View {
val
key
=
keys
.
next
()
val
key
=
keys
.
next
()
val
value
:
JSONArray
?
=
addressObj
.
optJSONArray
(
key
)
val
value
:
JSONArray
?
=
addressObj
.
optJSONArray
(
key
)
var
addressBean
=
AddressBean
()
var
addressBean
=
AddressBean
()
addressBean
.
country
=
key
var
cityList
=
ArrayList
<
String
>(
value
?.
length
()
?:
0
)
var
cityList
=
ArrayList
<
String
>(
value
?.
length
()
?:
0
)
if
(
value
!=
null
&&
value
.
length
()
>
0
)
{
if
(
value
!=
null
&&
value
.
length
()
>
0
)
{
for
(
index
in
0
until
value
.
length
())
{
for
(
index
in
0
until
value
.
length
())
{
cityList
.
add
(
value
.
getString
(
index
))
cityList
.
add
(
value
.
getString
(
index
))
}
}
}
}
addressBean
.
country
=
key
addressBean
.
cityLis
=
cityList
addressBean
.
cityLis
=
cityList
addressCountryList
.
add
(
key
)
addressList
.
add
(
addressBean
)
addressList
.
add
(
addressBean
)
}
}
Log
.
d
(
"wxw"
,
"end"
+
addressList
.
size
)
}
private
fun
initSelect
()
{
val
strAdapter
:
ArrayAdapter
<
String
>
=
ArrayAdapter
<
String
>(
this
,
android
.
R
.
layout
.
simple_spinner_item
,
addressCountryList
)
strAdapter
.
setDropDownViewResource
(
android
.
R
.
layout
.
simple_spinner_dropdown_item
);
id_country_select_spinner
.
adapter
=
strAdapter
id_country_select_spinner
.
onItemSelectedListener
=
object
:
AdapterView
.
OnItemSelectedListener
{
override
fun
onItemSelected
(
parent
:
AdapterView
<
*
>?,
view
:
View
?,
position
:
Int
,
id
:
Long
)
{
Log
.
d
(
"wxw"
,
" 1select"
)
if
(!
isInitSelect
)
{
id_select_country
?.
text
=
addressCountryList
[
position
]
}
if
(
addressList
[
position
].
cityLis
!=
null
)
{
initCitySelect
(
addressList
[
position
].
cityLis
!!
)
}
}
override
fun
onNothingSelected
(
parent
:
AdapterView
<
*
>?)
{
Log
.
d
(
"wxw"
,
" 2select"
)
}
}
// if (defPos != -1) {
// id_country_select_spinner.setSelection(defPos)
// }
}
}
private
fun
initCitySelect
(
cityList
:
ArrayList
<
String
>)
{
val
strAdapter
:
ArrayAdapter
<
String
>
=
ArrayAdapter
<
String
>(
this
,
android
.
R
.
layout
.
simple_spinner_item
,
cityList
)
strAdapter
.
setDropDownViewResource
(
android
.
R
.
layout
.
simple_spinner_dropdown_item
);
id_city_select_spinner
.
adapter
=
strAdapter
id_city_select_spinner
.
onItemSelectedListener
=
object
:
AdapterView
.
OnItemSelectedListener
{
override
fun
onItemSelected
(
parent
:
AdapterView
<
*
>?,
view
:
View
?,
position
:
Int
,
id
:
Long
)
{
if
(!
isInitSelect
){
id_select_city
?.
text
=
cityList
[
position
]
}
}
override
fun
onNothingSelected
(
parent
:
AdapterView
<
*
>?)
{
}
}
}
}
}
\ No newline at end of file
moduleMain/src/main/java/com/zxhl/main/page/entity/AddressBean.kt
View file @
d7726323
package
com.zxhl.main.page.entity
package
com.zxhl.main.page.entity
import
com.zxhl.main.page.entity.JsonBean.CityBean
/**
/**
* @author (wangXuewei)
* @author (wangXuewei)
* @datetime 2022-03-08 16:30 GMT+8
* @datetime 2022-03-08 16:30 GMT+8
...
...
moduleMain/src/main/java/com/zxhl/main/page/entity/AllAddressBean.java
deleted
100644 → 0
View file @
f01baad9
package
com
.
zxhl
.
main
.
page
.
entity
;
/**
* @author (wangXuewei)
* @datetime 2022-03-08 16:15 GMT+8
* @detail :
*/
public
class
AllAddressBean
{
}
moduleMain/src/main/res/layout/activity_layout_edit_address.xml
View file @
d7726323
...
@@ -67,7 +67,7 @@
...
@@ -67,7 +67,7 @@
android:textColor=
"@color/color_333333"
android:textColor=
"@color/color_333333"
android:textColorHint=
"#B0B0B0"
android:textColorHint=
"#B0B0B0"
android:textCursorDrawable=
"@null"
android:textCursorDrawable=
"@null"
android:textSize=
"1
5
sp"
/>
android:textSize=
"1
3
sp"
/>
</LinearLayout>
</LinearLayout>
<!--电话-->
<!--电话-->
...
@@ -193,10 +193,16 @@
...
@@ -193,10 +193,16 @@
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:gravity=
"center_vertical"
android:gravity=
"center_vertical"
android:hint=
"@string/Please_select"
android:hint=
"@string/Please_select"
android:textColorHint=
"#B0B0B0"
android:textColor=
"@color/color_333333"
android:textColor=
"@color/color_333333"
android:textColorHint=
"#B0B0B0"
android:textSize=
"13sp"
/>
android:textSize=
"13sp"
/>
<androidx.appcompat.widget.AppCompatSpinner
android:id=
"@+id/id_country_select_spinner"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:spinnerMode=
"dialog"
/>
</LinearLayout>
</LinearLayout>
<!--城市-->
<!--城市-->
<LinearLayout
<LinearLayout
...
@@ -221,10 +227,15 @@
...
@@ -221,10 +227,15 @@
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:gravity=
"center_vertical"
android:gravity=
"center_vertical"
android:hint=
"@string/Please_select"
android:hint=
"@string/Please_select"
android:textColorHint=
"#B0B0B0"
android:textColor=
"@color/color_333333"
android:textColor=
"@color/color_333333"
android:textColorHint=
"#B0B0B0"
android:textSize=
"13sp"
/>
android:textSize=
"13sp"
/>
<androidx.appcompat.widget.AppCompatSpinner
android:id=
"@+id/id_city_select_spinner"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:spinnerMode=
"dialog"
/>
</LinearLayout>
</LinearLayout>
<!--填写省市-->
<!--填写省市-->
<LinearLayout
<LinearLayout
...
...
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