Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
machine
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hooloo
android
machine
Commits
8097f831
Commit
8097f831
authored
May 24, 2022
by
wjg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
daa586fa
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
394 additions
and
106 deletions
+394
-106
app/src/main/java/com/ihaoin/hooloo/device/adapter/GoodsAdapter.java
+9
-27
app/src/main/java/com/ihaoin/hooloo/device/adapter/TrolleyAdapter.java
+5
-5
app/src/main/java/com/ihaoin/hooloo/device/component/IntroViewPager.java
+92
-0
app/src/main/java/com/ihaoin/hooloo/device/util/Utils.java
+39
-0
app/src/main/java/com/ihaoin/hooloo/device/view/GoodsDetailDialog.java
+139
-29
app/src/main/java/com/ihaoin/hooloo/device/view/LauncherActivity.java
+14
-6
app/src/main/java/com/ihaoin/hooloo/device/view/TrolleyView.java
+1
-1
app/src/main/res/drawable/bg_image_placeholder.xml
+21
-0
app/src/main/res/drawable/ic_dot_unchecked.xml
+11
-0
app/src/main/res/drawable/sel_intro_indicator.xml
+5
-0
app/src/main/res/layout/item_goods.xml
+7
-7
app/src/main/res/layout/item_recommend.xml
+16
-8
app/src/main/res/layout/item_spec_rule_recommend.xml
+0
-11
app/src/main/res/layout/item_trolley.xml
+4
-4
app/src/main/res/layout/view_goods_detail.xml
+31
-8
No files found.
app/src/main/java/com/ihaoin/hooloo/device/adapter/GoodsAdapter.java
View file @
8097f831
...
...
@@ -24,8 +24,6 @@ import com.ihaoin.hooloo.device.util.StringUtils;
import
com.ihaoin.hooloo.device.util.Utils
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Optional
;
public
class
GoodsAdapter
extends
BaseSectionQuickAdapter
<
ScrollBean
,
BaseViewHolder
>
{
private
Context
mContext
;
...
...
@@ -74,16 +72,16 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo
Glide
.
with
(
mContext
).
load
(
goods
.
getPics
().
getThumbnail
()).
apply
(
options
).
into
(
imgThumbnail
);
}
Sku
sku
=
getDefaultSku
(
goods
.
getSkus
());
Sku
sku
=
Utils
.
getDefaultSku
(
goods
.
getSkus
());
if
(
sku
==
null
)
{
helper
.
setText
(
R
.
id
.
txt_price
,
String
.
valueOf
(
goods
.
getPrice
()));
helper
.
setText
(
R
.
id
.
txt_discount
,
String
.
valueOf
(
goods
.
getDiscount
()));
helper
.
setText
(
R
.
id
.
txt_price
,
Utils
.
toString
(
goods
.
getPrice
()));
helper
.
setText
(
R
.
id
.
txt_discount
,
Utils
.
toString
(
goods
.
getDiscount
()));
helper
.
setGone
(
R
.
id
.
txt_sellout
,
true
);
helper
.
setGone
(
R
.
id
.
butn_add
,
false
);
}
else
{
helper
.
setText
(
R
.
id
.
txt_price
,
String
.
valueOf
(
sku
.
getPrice
()));
helper
.
setText
(
R
.
id
.
txt_discount
,
String
.
valueOf
(
sku
.
getDiscount
()));
helper
.
setText
(
R
.
id
.
txt_price
,
Utils
.
toString
(
sku
.
getPrice
()));
helper
.
setText
(
R
.
id
.
txt_discount
,
Utils
.
toString
(
sku
.
getDiscount
()));
if
(
Base
.
TRUE
.
equals
(
sku
.
getState
()))
{
helper
.
setGone
(
R
.
id
.
txt_sellout
,
false
);
...
...
@@ -105,10 +103,10 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo
helper
.
setGone
(
R
.
id
.
img_recommend
,
false
);
}
TextView
ico
Discount
=
helper
.
getView
(
R
.
id
.
ico_discount
);
TextView
txt
Discount
=
helper
.
getView
(
R
.
id
.
txt_discount
);
ico
Discount
.
setPaintFlags
(
icoDiscount
.
getPaintFlags
()
|
Paint
.
STRIKE_THRU_TEXT_FLAG
);
txt
Discount
.
setPaintFlags
(
txtDiscount
.
getPaintFlags
()
|
Paint
.
STRIKE_THRU_TEXT_FLAG
);
TextView
ico
Price
=
helper
.
getView
(
R
.
id
.
ico_price
);
TextView
txt
Price
=
helper
.
getView
(
R
.
id
.
txt_price
);
ico
Price
.
setPaintFlags
(
icoPrice
.
getPaintFlags
()
|
Paint
.
STRIKE_THRU_TEXT_FLAG
);
txt
Price
.
setPaintFlags
(
txtPrice
.
getPaintFlags
()
|
Paint
.
STRIKE_THRU_TEXT_FLAG
);
View
layoutItem
=
helper
.
getView
(
R
.
id
.
layout_item
);
layoutItem
.
setOnClickListener
(
v
->
Utils
.
showGoodsDetail
(
mContext
,
goods
));
...
...
@@ -123,22 +121,6 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo
}
}
/** 获取SKU,优选获取默认的SKU */
private
Sku
getDefaultSku
(
List
<
Sku
>
skus
)
{
if
(
CollectionUtils
.
isEmpty
(
skus
))
{
return
null
;
}
Optional
<
Sku
>
optional
=
skus
.
stream
().
filter
(
x
->
Base
.
TRUE
.
equals
(
x
.
getIsDefault
())
&&
Base
.
TRUE
.
equals
(
x
.
getState
())).
findAny
();
if
(
optional
.
isPresent
())
{
return
optional
.
get
();
}
optional
=
skus
.
stream
().
filter
(
x
->
Base
.
TRUE
.
equals
(
x
.
getState
())).
findAny
();
if
(
optional
.
isPresent
())
{
return
optional
.
get
();
}
return
skus
.
get
(
0
);
}
private
boolean
trolleyState
=
false
;
public
boolean
isTrolleyState
()
{
...
...
app/src/main/java/com/ihaoin/hooloo/device/adapter/TrolleyAdapter.java
View file @
8097f831
...
...
@@ -38,9 +38,9 @@ public class TrolleyAdapter extends BaseAdapter {
ImageView
imgThumbnail
=
convertView
.
findViewById
(
R
.
id
.
img_thumbnail
);
TextView
txtName
=
convertView
.
findViewById
(
R
.
id
.
txt_name
);
TextView
txtOptions
=
convertView
.
findViewById
(
R
.
id
.
txt_options
);
TextView
icoPrice
=
convertView
.
findViewById
(
R
.
id
.
ico_price
);
TextView
txtPrice
=
convertView
.
findViewById
(
R
.
id
.
txt_price
);
TextView
txtDiscount
=
convertView
.
findViewById
(
R
.
id
.
txt_discount
);
TextView
icoDiscount
=
convertView
.
findViewById
(
R
.
id
.
ico_discount
);
View
butnSubtract
=
convertView
.
findViewById
(
R
.
id
.
butn_subtract
);
TextView
txtCount
=
convertView
.
findViewById
(
R
.
id
.
txt_count
);
View
butnAdd
=
convertView
.
findViewById
(
R
.
id
.
butn_add
);
...
...
@@ -67,11 +67,11 @@ public class TrolleyAdapter extends BaseAdapter {
txtOptions
.
setVisibility
(
View
.
GONE
);
}
txtPrice
.
setText
(
goods
.
getPrice
().
toString
(
));
txtDiscount
.
setText
(
goods
.
getDiscount
().
toString
(
));
txtPrice
.
setText
(
Utils
.
toString
(
goods
.
getPrice
()
));
txtDiscount
.
setText
(
Utils
.
toString
(
goods
.
getDiscount
()
));
ico
Discount
.
setPaintFlags
(
icoDiscount
.
getPaintFlags
()
|
Paint
.
STRIKE_THRU_TEXT_FLAG
);
txt
Discount
.
setPaintFlags
(
txtDiscount
.
getPaintFlags
()
|
Paint
.
STRIKE_THRU_TEXT_FLAG
);
ico
Price
.
setPaintFlags
(
icoPrice
.
getPaintFlags
()
|
Paint
.
STRIKE_THRU_TEXT_FLAG
);
txt
Price
.
setPaintFlags
(
txtPrice
.
getPaintFlags
()
|
Paint
.
STRIKE_THRU_TEXT_FLAG
);
txtCount
.
setText
(
goods
.
getCount
().
toString
());
butnSubtract
.
setOnClickListener
(
v
->
trolleyView
.
subtractGoods
(
position
));
butnAdd
.
setOnClickListener
(
v
->
trolleyView
.
addGoods
(
position
));
...
...
app/src/main/java/com/ihaoin/hooloo/device/component/IntroViewPager.java
0 → 100644
View file @
8097f831
package
com
.
ihaoin
.
hooloo
.
device
.
component
;
import
android.content.Context
;
import
android.util.AttributeSet
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.viewpager.widget.PagerAdapter
;
import
androidx.viewpager.widget.ViewPager
;
import
com.ihaoin.hooloo.device.util.CollectionUtils
;
import
java.util.List
;
public
class
IntroViewPager
extends
ViewPager
{
public
IntroViewPager
(
@NonNull
Context
context
)
{
super
(
context
);
}
public
IntroViewPager
(
@NonNull
Context
context
,
@Nullable
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
}
@Override
protected
void
onMeasure
(
int
widthMeasureSpec
,
int
heightMeasureSpec
)
{
if
(
getAdapter
()
==
null
)
{
super
.
onMeasure
(
widthMeasureSpec
,
heightMeasureSpec
);
return
;
}
int
index
=
getCurrentItem
();
int
height
=
0
;
View
v
=
getView
(
index
);
if
(
v
!=
null
)
{
v
.
measure
(
widthMeasureSpec
,
MeasureSpec
.
makeMeasureSpec
(
0
,
MeasureSpec
.
UNSPECIFIED
));
height
=
v
.
getMeasuredHeight
();
}
heightMeasureSpec
=
MeasureSpec
.
makeMeasureSpec
(
height
,
MeasureSpec
.
EXACTLY
);
super
.
onMeasure
(
widthMeasureSpec
,
heightMeasureSpec
);
}
private
List
<
View
>
introViews
;
public
void
setIntroViews
(
List
<
View
>
introViews
)
{
this
.
introViews
=
introViews
;
this
.
setAdapter
(
pagerAdapter
);
}
public
View
getView
(
int
index
)
{
if
(
CollectionUtils
.
isEmpty
(
introViews
))
{
return
null
;
}
return
introViews
.
get
(
index
);
}
public
int
getCount
()
{
if
(
pagerAdapter
==
null
)
{
return
0
;
}
return
pagerAdapter
.
getCount
();
}
private
PagerAdapter
pagerAdapter
=
new
PagerAdapter
()
{
@Override
public
int
getCount
()
{
return
CollectionUtils
.
isEmpty
(
introViews
)
?
0
:
introViews
.
size
();
}
@Override
public
boolean
isViewFromObject
(
@NonNull
View
view
,
@NonNull
Object
object
)
{
return
view
==
object
;
}
@Override
public
void
destroyItem
(
@NonNull
ViewGroup
container
,
int
position
,
@NonNull
Object
object
)
{
View
view
=
introViews
.
get
(
position
);
container
.
removeView
(
view
);
}
@NonNull
@Override
public
Object
instantiateItem
(
@NonNull
ViewGroup
container
,
int
position
)
{
if
(
CollectionUtils
.
isEmpty
(
introViews
))
{
return
null
;
}
View
view
=
introViews
.
get
(
position
);
container
.
addView
(
view
);
return
view
;
}
};
}
app/src/main/java/com/ihaoin/hooloo/device/util/Utils.java
View file @
8097f831
...
...
@@ -8,6 +8,7 @@ import android.util.DisplayMetrics;
import
android.view.TouchDelegate
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.RadioGroup
;
import
androidx.coordinatorlayout.widget.ViewGroupUtils
;
...
...
@@ -22,7 +23,10 @@ import com.ihaoin.hooloo.device.view.GoodsDetailDialog;
import
com.ihaoin.hooloo.device.view.SettingsActivity
;
import
com.ihaoin.hooloo.device.view.TipsDialog
;
import
java.math.BigDecimal
;
import
java.text.DecimalFormat
;
import
java.util.List
;
import
java.util.Optional
;
public
class
Utils
{
...
...
@@ -123,4 +127,39 @@ public class Utils {
}));
group
.
setTouchDelegate
(
composite
);
}
public
static
String
toString
(
BigDecimal
num
)
{
DecimalFormat
df
=
new
DecimalFormat
(
"#.00"
);
return
df
.
format
(
num
);
}
/** 获取SKU,优选获取默认的SKU */
public
static
Sku
getDefaultSku
(
List
<
Sku
>
skus
)
{
if
(
CollectionUtils
.
isEmpty
(
skus
))
{
return
null
;
}
Optional
<
Sku
>
optional
=
skus
.
stream
().
filter
(
x
->
Base
.
TRUE
.
equals
(
x
.
getIsDefault
())
&&
Base
.
TRUE
.
equals
(
x
.
getState
())).
findAny
();
if
(
optional
.
isPresent
())
{
return
optional
.
get
();
}
optional
=
skus
.
stream
().
filter
(
x
->
Base
.
TRUE
.
equals
(
x
.
getState
())).
findAny
();
if
(
optional
.
isPresent
())
{
return
optional
.
get
();
}
return
skus
.
get
(
0
);
}
public
static
void
check
(
RadioGroup
group
,
int
position
)
{
if
(
group
==
null
)
{
return
;
}
if
(
group
.
getChildCount
()
<
position
)
{
return
;
}
View
v
=
group
.
getChildAt
(
position
);
if
(
v
==
null
)
{
return
;
}
group
.
check
(
v
.
getId
());
}
}
app/src/main/java/com/ihaoin/hooloo/device/view/GoodsDetailDialog.java
View file @
8097f831
...
...
@@ -4,20 +4,26 @@ import android.app.Dialog;
import
android.content.Context
;
import
android.graphics.Paint
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Message
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.Button
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.RadioButton
;
import
android.widget.RadioGroup
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
androidx.annotation.NonNull
;
import
androidx.viewpager.widget.ViewPager
;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.request.RequestOptions
;
import
com.ihaoin.hooloo.device.HLApplication
;
import
com.ihaoin.hooloo.device.R
;
import
com.ihaoin.hooloo.device.component.IntroViewPager
;
import
com.ihaoin.hooloo.device.config.Base
;
import
com.ihaoin.hooloo.device.data.vo.Goods
;
import
com.ihaoin.hooloo.device.data.vo.GoodsRule
;
...
...
@@ -37,12 +43,13 @@ public class GoodsDetailDialog extends Dialog {
private
Goods
goods
;
private
Sku
checkSku
;
private
View
butnClose
;
private
ImageView
imgIntro
;
private
IntroViewPager
introPager
;
private
RadioGroup
introIndicator
;
private
TextView
txtName
;
private
LinearLayout
layoutSpecs
;
private
LinearLayout
layoutImages
;
private
TextView
txtPrice
;
private
TextView
ico
Discount
;
private
TextView
ico
Pirce
;
private
TextView
txtDiscount
;
private
Button
butnSubtract
;
private
TextView
txtCount
;
...
...
@@ -54,6 +61,7 @@ public class GoodsDetailDialog extends Dialog {
private
View
txtSellout
;
private
Integer
count
=
1
;
private
List
<
View
>
introViews
;
public
GoodsDetailDialog
(
@NonNull
Context
context
,
Goods
goods
)
{
super
(
context
);
...
...
@@ -72,12 +80,13 @@ public class GoodsDetailDialog extends Dialog {
layoutOperate
=
findViewById
(
R
.
id
.
layout_operate
);
txtSellout
=
findViewById
(
R
.
id
.
txt_sellout
);
butnClose
=
findViewById
(
R
.
id
.
butn_close
);
imgIntro
=
findViewById
(
R
.
id
.
img_intro
);
introPager
=
findViewById
(
R
.
id
.
intro_pager
);
introIndicator
=
findViewById
(
R
.
id
.
intro_indicator
);
txtName
=
findViewById
(
R
.
id
.
txt_name
);
layoutSpecs
=
findViewById
(
R
.
id
.
layout_specs
);
layoutImages
=
findViewById
(
R
.
id
.
layout_images
);
icoPirce
=
findViewById
(
R
.
id
.
ico_price
);
txtPrice
=
findViewById
(
R
.
id
.
txt_price
);
icoDiscount
=
findViewById
(
R
.
id
.
ico_discount
);
txtDiscount
=
findViewById
(
R
.
id
.
txt_discount
);
butnSubtract
=
findViewById
(
R
.
id
.
butn_subtract
);
txtCount
=
findViewById
(
R
.
id
.
txt_count
);
...
...
@@ -87,20 +96,50 @@ public class GoodsDetailDialog extends Dialog {
butnClose
.
setOnClickListener
(
x
->
dismiss
());
if
(
goods
.
getPics
()
==
null
)
{
imgIntro
.
setImageDrawable
(
null
);
}
else
{
Glide
.
with
(
getContext
()).
load
(
goods
.
getPics
().
getIntroImages
().
get
(
0
)).
into
(
imgIntro
);
introViews
=
new
ArrayList
<>();
if
(
goods
.
getPics
()
!=
null
&&
!
CollectionUtils
.
isEmpty
(
goods
.
getPics
().
getIntroImages
()))
{
// goods.getPics().getIntroImages().addAll(goods.getPics().getIntroImages()); // TODO TEST
for
(
int
i
=
0
;
i
<
goods
.
getPics
().
getIntroImages
().
size
();
i
++)
{
String
url
=
goods
.
getPics
().
getIntroImages
().
get
(
i
);
View
imgIntro
=
getIntroImage
(
url
);
View
btnIntro
=
getIntroButton
(
i
);
introViews
.
add
(
imgIntro
);
introIndicator
.
addView
(
btnIntro
);
}
introPager
.
setIntroViews
(
introViews
);
Utils
.
check
(
introIndicator
,
0
);
// introIndicator.check(0);
if
(
introIndicator
.
getChildCount
()
>
1
)
{
introIndicator
.
setVisibility
(
View
.
VISIBLE
);
startPageThread
();
introPager
.
addOnPageChangeListener
(
new
ViewPager
.
OnPageChangeListener
()
{
@Override
public
void
onPageScrolled
(
int
position
,
float
positionOffset
,
int
positionOffsetPixels
)
{
}
@Override
public
void
onPageSelected
(
int
position
)
{
Utils
.
check
(
introIndicator
,
position
);
}
@Override
public
void
onPageScrollStateChanged
(
int
state
)
{
}
});
}
}
txtName
.
setText
(
goods
.
getName
());
txtPrice
.
setText
(
String
.
valueOf
(
goods
.
getPrice
()));
txtDiscount
.
setText
(
String
.
valueOf
(
goods
.
getDiscount
()));
txtName
.
setText
(
goods
.
getName
());
txtPrice
.
setText
(
Utils
.
toString
(
goods
.
getPrice
()));
txtDiscount
.
setText
(
Utils
.
toString
(
goods
.
getDiscount
()));
butnSubtract
.
setOnClickListener
(
v
->
subtractGoods
());
butnAdd
.
setOnClickListener
(
v
->
addGoods
());
ico
Discount
.
setPaintFlags
(
icoDiscount
.
getPaintFlags
()
|
Paint
.
STRIKE_THRU_TEXT_FLAG
);
txt
Discount
.
setPaintFlags
(
txtDiscount
.
getPaintFlags
()
|
Paint
.
STRIKE_THRU_TEXT_FLAG
);
ico
Pirce
.
setPaintFlags
(
icoPirce
.
getPaintFlags
()
|
Paint
.
STRIKE_THRU_TEXT_FLAG
);
txt
Price
.
setPaintFlags
(
txtPrice
.
getPaintFlags
()
|
Paint
.
STRIKE_THRU_TEXT_FLAG
);
butnBuy
.
setOnClickListener
(
v
->
buyNow
());
butnTrolley
.
setOnClickListener
(
v
->
addTrolley
());
...
...
@@ -115,6 +154,75 @@ public class GoodsDetailDialog extends Dialog {
buildDetails
();
Utils
.
setTouchDelegate
(
findViewById
(
R
.
id
.
layout_root
),
Arrays
.
asList
(
butnClose
));
setOnDismissListener
(
dialog
->
{
if
(
pagerHandler
!=
null
)
{
pagerHandler
.
removeCallbacksAndMessages
(
null
);
pagerHandler
=
null
;
}
});
}
private
void
startPageThread
()
{
pagerHandler
=
new
PagerHandler
();
pagerThread
=
new
PagerThread
();
pagerThread
.
start
();
}
private
PagerThread
pagerThread
;
private
PagerHandler
pagerHandler
;
private
class
PagerThread
extends
Thread
{
@Override
public
void
run
()
{
try
{
while
(
true
)
{
Thread
.
sleep
(
1000
*
2
);
pagerHandler
.
sendEmptyMessage
(
1
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
private
class
PagerHandler
extends
Handler
{
@Override
public
void
handleMessage
(
@NonNull
Message
msg
)
{
int
index
=
introPager
.
getCurrentItem
();
int
count
=
introPager
.
getCount
();
if
(
index
+
1
>=
count
)
{
index
=
0
;
}
else
{
index
++;
}
introPager
.
setCurrentItem
(
index
,
true
);
}
}
private
View
getIntroButton
(
int
id
)
{
Integer
width
=
Utils
.
getDimens
(
getContext
(),
R
.
dimen
.
padding5
);
Integer
height
=
Utils
.
getDimens
(
getContext
(),
R
.
dimen
.
padding5
);
RadioGroup
.
LayoutParams
layoutParams
=
new
RadioGroup
.
LayoutParams
(
width
,
height
);
layoutParams
.
rightMargin
=
Utils
.
getDimens
(
getContext
(),
R
.
dimen
.
padding3
);
RadioButton
button
=
new
RadioButton
(
getContext
());
button
.
setLayoutParams
(
layoutParams
);
button
.
setButtonDrawable
(
null
);
button
.
setBackgroundResource
(
R
.
drawable
.
sel_intro_indicator
);
button
.
setText
(
""
);
button
.
setId
(
id
);
return
button
;
}
private
ImageView
getIntroImage
(
String
url
)
{
RequestOptions
options
=
new
RequestOptions
().
placeholder
(
R
.
drawable
.
bg_image_placeholder
);
ImageView
imgIntro
=
new
ImageView
(
getContext
());
ViewGroup
.
LayoutParams
layoutParams
=
new
ViewGroup
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
MATCH_PARENT
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
);
imgIntro
.
setLayoutParams
(
layoutParams
);
imgIntro
.
setAdjustViewBounds
(
true
);
Glide
.
with
(
getContext
()).
setDefaultRequestOptions
(
options
).
load
(
url
).
into
(
imgIntro
);
return
imgIntro
;
}
private
void
buyNow
()
{
...
...
@@ -175,22 +283,24 @@ public class GoodsDetailDialog extends Dialog {
TextView
button
=
ruleView
.
findViewById
(
R
.
id
.
butn_rule
);
button
.
setId
(
rule
.
getRuleId
());
button
.
setText
(
rule
.
getRuleName
());
if
(!
Base
.
TRUE
.
equals
(
rule
.
getState
()))
{
button
.
setEnabled
(
false
);
}
else
if
(
Base
.
TRUE
.
equals
(
rule
.
getIsDefault
()))
{
button
.
setSelected
(
true
);
ruleView
.
setSelected
(
true
);
}
if
(
Base
.
TRUE
.
equals
(
rule
.
getIsRecommend
()))
{
ruleView
.
findViewById
(
R
.
id
.
txt_recommend
).
setVisibility
(
View
.
VISIBLE
);
}
if
(!
Base
.
TRUE
.
equals
(
rule
.
getState
()))
{
button
.
setEnabled
(
false
);
}
else
{
if
(
Base
.
TRUE
.
equals
(
rule
.
getIsDefault
()))
{
button
.
setSelected
(
true
);
ruleView
.
setSelected
(
true
);
}
ruleView
.
setOnClickListener
(
v
->
{
clearSelected
(
layoutRules
);
ruleView
.
setSelected
(
true
);
button
.
setSelected
(
true
);
changeSkuWithRule
();
});
}
layoutRules
.
addView
(
ruleView
,
layoutParams
);
ruleView
.
setOnClickListener
(
v
->
{
clearSelected
(
layoutRules
);
ruleView
.
setSelected
(
true
);
button
.
setSelected
(
true
);
changeSkuWithRule
();
});
});
layoutSpecs
.
addView
(
specView
);
// layoutRules.setOnCheckedChangeListener((group, checkedId) -> changeSkuWithRule());
...
...
@@ -218,7 +328,7 @@ public class GoodsDetailDialog extends Dialog {
List
<
GoodsRule
>
rules
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
layoutSpecs
.
getChildCount
();
i
++)
{
View
v
=
layoutSpecs
.
getChildAt
(
i
);
LinearLayout
layoutRules
=
(
LinearLayout
)
v
.
findViewById
(
R
.
id
.
layout_rules
);
LinearLayout
layoutRules
=
v
.
findViewById
(
R
.
id
.
layout_rules
);
View
view
=
getSelectedView
(
layoutRules
);
if
(
view
==
null
)
{
continue
;
...
...
@@ -227,11 +337,11 @@ public class GoodsDetailDialog extends Dialog {
}
checkSku
=
matchSku
(
rules
);
if
(
checkSku
==
null
)
{
Toast
.
makeText
(
getContext
(),
R
.
string
.
not_found_goods
,
Toast
.
LENGTH_SHORT
).
show
();
//
Toast.makeText(getContext(), R.string.not_found_goods, Toast.LENGTH_SHORT).show();
return
;
}
txtPrice
.
setText
(
String
.
valueOf
(
checkSku
.
getPrice
()));
txtDiscount
.
setText
(
String
.
valueOf
(
checkSku
.
getDiscount
()));
txtPrice
.
setText
(
Utils
.
toString
(
checkSku
.
getPrice
()));
txtDiscount
.
setText
(
Utils
.
toString
(
checkSku
.
getDiscount
()));
}
private
View
getSelectedView
(
LinearLayout
layoutRules
)
{
...
...
app/src/main/java/com/ihaoin/hooloo/device/view/LauncherActivity.java
View file @
8097f831
...
...
@@ -73,13 +73,12 @@ public class LauncherActivity extends Activity {
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
Log
.
d
(
AppConfig
.
DEBUG_TAG
,
"onCreate"
);
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_launcher
);
getWindow
().
setFlags
(
WindowManager
.
LayoutParams
.
FLAG_FULLSCREEN
,
WindowManager
.
LayoutParams
.
FLAG_FULLSCREEN
);
mContext
=
this
;
setMachineCode
();
requestPermissions
();
trolleyView
=
findViewById
(
R
.
id
.
view_trolley
);
...
...
@@ -87,7 +86,6 @@ public class LauncherActivity extends Activity {
recGoods
=
findViewById
(
R
.
id
.
rec_right
);
recRecommends
=
findViewById
(
R
.
id
.
rec_recommend
);
initRecommends
();
setRecommendsData
();
...
...
@@ -347,15 +345,28 @@ public class LauncherActivity extends Activity {
@Override
protected
void
onDestroy
()
{
Log
.
d
(
AppConfig
.
DEBUG_TAG
,
"onDestroy"
);
super
.
onDestroy
();
exit
();
}
private
void
exit
()
{
Log
.
d
(
AppConfig
.
DEBUG_TAG
,
"exit"
);
this
.
unregistTrolleyGoodsChangedReceiver
();
this
.
unregistTrolleyStateChangedReceiver
();
this
.
unregistSettingChangedReceiver
();
System
.
exit
(
0
);
}
@Override
public
void
onBackPressed
()
{
super
.
onBackPressed
();
exit
();
}
private
TrolleyGoodsChangedReceiver
trolleyGoodsChangedReceiver
=
null
;
private
TrolleyStateChangedReceiver
trolleyStateChangedReceiver
=
null
;
private
SettingChangedReceiver
settingChangedReceiver
;
/** 注册购物车广播 */
private
void
registTrolleyGoodsChangedReceiver
()
{
...
...
@@ -426,9 +437,6 @@ public class LauncherActivity extends Activity {
}
}
private
SettingChangedReceiver
settingChangedReceiver
;
private
void
registSettingChangedReceiver
()
{
settingChangedReceiver
=
new
SettingChangedReceiver
();
IntentFilter
filter
=
new
IntentFilter
();
...
...
app/src/main/java/com/ihaoin/hooloo/device/view/TrolleyView.java
View file @
8097f831
...
...
@@ -174,7 +174,7 @@ public class TrolleyView extends RelativeLayout {
public
void
goodsChanged
()
{
this
.
trolleyAdapter
.
notifyDataSetChanged
();
this
.
txtCount
.
setText
(
getCheckedCount
().
toString
());
this
.
txtTotal
.
setText
(
getCheckedTotal
().
toString
(
));
this
.
txtTotal
.
setText
(
Utils
.
toString
(
getCheckedTotal
()
));
this
.
setView
();
this
.
measureListHeight
();
}
...
...
app/src/main/res/drawable/bg_image_placeholder.xml
0 → 100644
View file @
8097f831
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item>
<shape
android:shape=
"rectangle"
>
<!-- <corners android:radius="2dp" />-->
<solid
android:width=
"1dp"
android:color=
"@color/textSecondPrimary"
/>
</shape>
</item>
<!-- <item-->
<!-- android:bottom="10dp"-->
<!-- android:left="10dp"-->
<!-- android:right="10dp"-->
<!-- android:top="10dp">-->
<!-- <bitmap-->
<!-- android:gravity="center"-->
<!-- android:src="@mipmap/jiahao_2x" />-->
<!-- </item>-->
</layer-list>
app/src/main/res/drawable/ic_dot_unchecked.xml
0 → 100644
View file @
8097f831
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item>
<shape
android:shape=
"oval"
>
<solid
android:color=
"@color/textDisable"
/>
<size
android:width=
"30dp"
android:height=
"30dp"
/>
</shape>
</item>
</layer-list>
app/src/main/res/drawable/sel_intro_indicator.xml
0 → 100644
View file @
8097f831
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
>
<item
android:drawable=
"@drawable/ic_dot"
android:state_checked=
"true"
/>
<item
android:drawable=
"@drawable/ic_dot_unchecked"
/>
</selector>
app/src/main/res/layout/item_goods.xml
View file @
8097f831
...
...
@@ -63,7 +63,7 @@
android:layout_height=
"wrap_content"
android:layout_marginTop=
"@dimen/padding3"
>
<TextView
android:id=
"@+id/ico_
price
"
android:id=
"@+id/ico_
discount
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentBottom=
"true"
...
...
@@ -72,32 +72,32 @@
android:textColor=
"@color/textRed"
android:textSize=
"@dimen/ts_goods_item_price"
/>
<TextView
android:id=
"@+id/txt_
price
"
android:id=
"@+id/txt_
discount
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentBottom=
"true"
android:layout_toRightOf=
"@id/ico_
price
"
android:layout_toRightOf=
"@id/ico_
discount
"
android:text=
"19.9"
android:textColor=
"@color/textRed"
android:textSize=
"@dimen/ts_goods_item_price"
android:textStyle=
"bold"
/>
<TextView
android:id=
"@+id/ico_
discount
"
android:id=
"@+id/ico_
price
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentBottom=
"true"
android:layout_marginStart=
"@dimen/padding5"
android:layout_toEndOf=
"@id/txt_
price
"
android:layout_toEndOf=
"@id/txt_
discount
"
android:text=
"¥"
android:textColor=
"@color/textSecondPrimary"
android:textSize=
"@dimen/ts_goods_item_discount"
/>
<TextView
android:id=
"@+id/txt_
discount
"
android:id=
"@+id/txt_
price
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentBottom=
"true"
android:layout_toEndOf=
"@id/ico_
discount
"
android:layout_toEndOf=
"@id/ico_
price
"
android:text=
"29.9"
android:textColor=
"@color/textSecondPrimary"
android:textSize=
"@dimen/ts_goods_item_discount"
/>
...
...
app/src/main/res/layout/item_recommend.xml
View file @
8097f831
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:id=
"@+id/layout_item"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
...
...
@@ -8,25 +9,32 @@
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:adjustViewBounds=
"true"
android:scaleType=
"centerCrop"
/>
android:scaleType=
"centerCrop"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<TextView
android:id=
"@+id/txt_name"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_margin=
"@dimen/padding20"
android:layout_marginStart=
"@dimen/padding20"
android:layout_marginTop=
"@dimen/padding20"
android:singleLine=
"true"
android:textColor=
"@color/white"
android:textSize=
"@dimen/ts_recommend_name"
android:textStyle=
"bold"
/>
android:textStyle=
"bold"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<TextView
android:id=
"@+id/txt_intro"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/txt_name"
android:layout_marginStart=
"@dimen/padding20"
android:layout_margin
Top=
"@dimen/padding10
"
android:layout_margin
Bottom=
"@dimen/padding15
"
android:singleLine=
"true"
android:textColor=
"@color/white"
android:textSize=
"@dimen/ts_recommend_desc"
android:textStyle=
"bold"
/>
</RelativeLayout>
\ No newline at end of file
android:textStyle=
"bold"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintLeft_toLeftOf=
"parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/item_spec_rule_recommend.xml
deleted
100644 → 0
View file @
daa586fa
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/txt_recommend"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"@drawable/bg_spec_recommend"
android:paddingHorizontal=
"@dimen/padding5"
android:paddingVertical=
"@dimen/padding3"
android:text=
"推荐"
android:textColor=
"@color/white"
android:textSize=
"@dimen/ts_detail_spec_rec"
/>
app/src/main/res/layout/item_trolley.xml
View file @
8097f831
...
...
@@ -50,14 +50,14 @@
android:gravity=
"bottom"
android:orientation=
"horizontal"
>
<TextView
android:id=
"@+id/ico_
price
"
android:id=
"@+id/ico_
discount
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"¥"
android:textColor=
"@color/textRed"
android:textSize=
"@dimen/ts_goods_item_price"
/>
<TextView
android:id=
"@+id/txt_
price
"
android:id=
"@+id/txt_
discount
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"19.9"
...
...
@@ -65,7 +65,7 @@
android:textSize=
"@dimen/ts_goods_item_price"
android:textStyle=
"bold"
/>
<TextView
android:id=
"@+id/ico_
discount
"
android:id=
"@+id/ico_
price
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"@dimen/padding5"
...
...
@@ -73,7 +73,7 @@
android:textColor=
"@color/textSecondPrimary"
android:textSize=
"@dimen/ts_goods_item_discount"
/>
<TextView
android:id=
"@+id/txt_
discount
"
android:id=
"@+id/txt_
price
"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
...
...
app/src/main/res/layout/view_goods_detail.xml
View file @
8097f831
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:id=
"@+id/layout_root"
android:layout_width=
"@dimen/dialog_detail_width"
android:layout_height=
"match_parent"
>
...
...
@@ -17,13 +18,27 @@
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
android:padding=
"@dimen/padding10"
>
<ImageView
android:id=
"@+id/img_intro"
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_margin=
"@dimen/padding10"
android:layout_weight=
"1"
android:adjustViewBounds=
"true"
/>
android:layout_weight=
"1"
>
<com.ihaoin.hooloo.device.component.IntroViewPager
android:id=
"@+id/intro_pager"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<RadioGroup
android:id=
"@+id/intro_indicator"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"@dimen/padding10"
android:gravity=
"center"
android:orientation=
"horizontal"
android:visibility=
"gone"
app:layout_constraintBottom_toBottomOf=
"parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
...
...
@@ -43,6 +58,14 @@
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"@dimen/padding10"
android:text=
"商品详细"
android:textColor=
"@color/textPrimary"
android:textSize=
"@dimen/ts_detail_spec"
android:textStyle=
"bold"
/>
<LinearLayout
android:id=
"@+id/layout_images"
android:layout_width=
"match_parent"
...
...
@@ -72,14 +95,14 @@
android:gravity=
"bottom"
android:orientation=
"horizontal"
>
<TextView
android:id=
"@+id/ico_
price
"
android:id=
"@+id/ico_
discount
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"¥"
android:textColor=
"@color/textRed"
android:textSize=
"@dimen/ts_detail_price"
/>
<TextView
android:id=
"@+id/txt_
price
"
android:id=
"@+id/txt_
discount
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"center_vertical"
...
...
@@ -89,7 +112,7 @@
android:textStyle=
"bold"
/>
<TextView
android:id=
"@+id/ico_
discount
"
android:id=
"@+id/ico_
price
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"@dimen/padding5"
...
...
@@ -97,7 +120,7 @@
android:textColor=
"@color/textSecondPrimary"
android:textSize=
"@dimen/ts_detail_discount"
/>
<TextView
android:id=
"@+id/txt_
discount
"
android:id=
"@+id/txt_
price
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"center_vertical"
...
...
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