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
096107cd
Commit
096107cd
authored
Sep 08, 2022
by
wjg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v2
parent
c2ad23a7
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
146 additions
and
123 deletions
+146
-123
app/src/main/AndroidManifest.xml
+8
-8
app/src/main/java/com/ihaoin/hooloo/device/base/MachineInfoSocket.java
+5
-5
app/src/main/java/com/ihaoin/hooloo/device/home/adapter/GoodsAdapter.java
+4
-2
app/src/main/java/com/ihaoin/hooloo/device/home/view/LauncherActivity.java
+49
-62
app/src/main/java/com/ihaoin/hooloo/device/interaction/InteractionSocket.java
+5
-5
app/src/main/java/com/ihaoin/hooloo/device/kds/KDSSocket.java
+2
-1
app/src/main/java/com/ihaoin/hooloo/device/kds/view/KdsPresentation.java
+57
-21
app/src/main/res/layout/activity_launcher.xml
+1
-1
app/src/main/res/layout/item_category.xml
+1
-0
app/src/main/res/layout/present_kds.xml
+4
-8
app/src/main/res/values-w800dp/dimens.xml
+5
-5
app/src/main/res/values/dimens.xml
+5
-5
No files found.
app/src/main/AndroidManifest.xml
View file @
096107cd
...
@@ -31,14 +31,14 @@
...
@@ -31,14 +31,14 @@
android:theme=
"@style/AppTheme"
android:theme=
"@style/AppTheme"
android:usesCleartextTraffic=
"true"
android:usesCleartextTraffic=
"true"
tools:replace=
"android:allowBackup,android:icon"
>
tools:replace=
"android:allowBackup,android:icon"
>
<!-- 悬浮窗入口
-->
<!-- <!– 悬浮窗入口 –>
-->
<meta-data
<!-- <meta-data-->
android:name=
"LogcatWindowEntrance"
<!-- android:name="LogcatWindowEntrance"-->
android:value=
"true"
/
>
<!-- android:value="true" />--
>
<!-- 通知栏入口
-->
<!-- <!– 通知栏入口 –>
-->
<meta-data
<!-- <meta-data-->
android:name=
"LogcatNotifyEntrance"
<!-- android:name="LogcatNotifyEntrance"-->
android:value=
"true"
/
>
<!-- android:value="true" />--
>
<activity
<activity
android:name=
".home.view.LauncherActivity"
android:name=
".home.view.LauncherActivity"
android:exported=
"true"
android:exported=
"true"
...
...
app/src/main/java/com/ihaoin/hooloo/device/base/MachineInfoSocket.java
View file @
096107cd
...
@@ -62,24 +62,24 @@ public class MachineInfoSocket extends Thread {
...
@@ -62,24 +62,24 @@ public class MachineInfoSocket extends Thread {
public
void
getMachineCode
()
{
public
void
getMachineCode
()
{
if
(
mSocket
==
null
)
{
if
(
mSocket
==
null
)
{
Utils
.
i
(
"socket未连接"
);
Utils
.
i
(
"
machine
socket未连接"
);
return
;
return
;
}
}
try
{
try
{
mSocket
.
emit
(
"notice"
,
""
,
(
Ack
)
args
->
{
mSocket
.
emit
(
"notice"
,
""
,
(
Ack
)
args
->
{
if
(
CollectionUtils
.
isEmpty
(
args
))
{
if
(
CollectionUtils
.
isEmpty
(
args
))
{
Utils
.
i
(
"notice args empty"
);
Utils
.
i
(
"
machine
notice args empty"
);
return
;
return
;
}
}
String
content
=
args
[
0
].
toString
();
String
content
=
args
[
0
].
toString
();
if
(
StringUtils
.
isEmpty
(
content
))
{
if
(
StringUtils
.
isEmpty
(
content
))
{
Utils
.
i
(
"notice content empty"
);
Utils
.
i
(
"
machine
notice content empty"
);
return
;
return
;
}
}
MachineInfoMsg
msg
=
JsonUtils
.
readValue
(
content
,
MachineInfoMsg
.
class
);
MachineInfoMsg
msg
=
JsonUtils
.
readValue
(
content
,
MachineInfoMsg
.
class
);
if
(
msg
==
null
)
{
if
(
msg
==
null
)
{
Utils
.
i
(
"notice msg empty"
);
Utils
.
i
(
"
machine
notice msg empty"
);
return
;
return
;
}
}
Utils
.
i
(
"get machine info: "
+
msg
);
Utils
.
i
(
"get machine info: "
+
msg
);
...
@@ -98,7 +98,7 @@ public class MachineInfoSocket extends Thread {
...
@@ -98,7 +98,7 @@ public class MachineInfoSocket extends Thread {
private
void
sendMessage
(
String
content
)
{
private
void
sendMessage
(
String
content
)
{
if
(
mSocket
==
null
)
{
if
(
mSocket
==
null
)
{
Utils
.
i
(
"socket未连接"
);
Utils
.
i
(
"
machine
socket未连接"
);
return
;
return
;
}
}
try
{
try
{
...
...
app/src/main/java/com/ihaoin/hooloo/device/home/adapter/GoodsAdapter.java
View file @
096107cd
...
@@ -39,7 +39,6 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo
...
@@ -39,7 +39,6 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo
protected
void
convert
(
BaseViewHolder
helper
,
ScrollBean
item
)
{
protected
void
convert
(
BaseViewHolder
helper
,
ScrollBean
item
)
{
ScrollBean
.
ScrollItemBean
t
=
item
.
t
;
ScrollBean
.
ScrollItemBean
t
=
item
.
t
;
ViewGroup
layoutItem
=
helper
.
getView
(
R
.
id
.
layout_item
);
ViewGroup
layoutItem
=
helper
.
getView
(
R
.
id
.
layout_item
);
// layoutItem.setForeground(null);
Goods
goods
=
(
Goods
)
t
.
getObject
();
Goods
goods
=
(
Goods
)
t
.
getObject
();
helper
.
setText
(
R
.
id
.
txt_name
,
goods
.
getName
());
helper
.
setText
(
R
.
id
.
txt_name
,
goods
.
getName
());
...
@@ -67,9 +66,12 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo
...
@@ -67,9 +66,12 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo
}
}
ImageView
imgThumbnail
=
helper
.
getView
(
R
.
id
.
img_thumbnail
);
ImageView
imgThumbnail
=
helper
.
getView
(
R
.
id
.
img_thumbnail
);
// RoundedCorners roundedCorners = new RoundedCorners(5);
// RequestOptions options = RequestOptions.bitmapTransform(roundedCorners);
if
(
goods
.
getPics
()
==
null
)
{
if
(
goods
.
getPics
()
==
null
)
{
imgThumbnail
.
setImageDrawable
(
null
);
imgThumbnail
.
setImageDrawable
(
null
);
}
else
{
}
else
{
// Utils.getGlide(mContext).load(Utils.getThumbnailUrl(goods.getPics().getThumbnail())).apply(options).into(imgThumbnail);
Utils
.
getGlide
(
mContext
).
load
(
Utils
.
getThumbnailUrl
(
goods
.
getPics
().
getThumbnail
())).
into
(
imgThumbnail
);
Utils
.
getGlide
(
mContext
).
load
(
Utils
.
getThumbnailUrl
(
goods
.
getPics
().
getThumbnail
())).
into
(
imgThumbnail
);
}
}
...
@@ -128,7 +130,7 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo
...
@@ -128,7 +130,7 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo
int
verPadding
=
Utils
.
getDimens
(
mContext
,
R
.
dimen
.
goods_padding_ver
);
int
verPadding
=
Utils
.
getDimens
(
mContext
,
R
.
dimen
.
goods_padding_ver
);
// 最后一个商品 并且购物条已经显示
// 最后一个商品 并且购物条已经显示
if
(
getData
().
indexOf
(
item
)
==
getItemCount
()
-
1
)
{
if
(
getData
().
indexOf
(
item
)
==
getItemCount
()
-
1
&&
trolleyState
)
{
// int padding = Utils.getDimens(mContext, R.dimen.padding10);
// int padding = Utils.getDimens(mContext, R.dimen.padding10);
int
bottomPadding
=
Utils
.
getDimens
(
mContext
,
R
.
dimen
.
goods_last_padding_bottom
);
int
bottomPadding
=
Utils
.
getDimens
(
mContext
,
R
.
dimen
.
goods_last_padding_bottom
);
layoutItem
.
setPadding
(
0
,
verPadding
,
0
,
bottomPadding
);
layoutItem
.
setPadding
(
0
,
verPadding
,
0
,
bottomPadding
);
...
...
app/src/main/java/com/ihaoin/hooloo/device/home/view/LauncherActivity.java
View file @
096107cd
...
@@ -19,8 +19,6 @@ import android.view.MotionEvent;
...
@@ -19,8 +19,6 @@ import android.view.MotionEvent;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewTreeObserver
;
import
android.view.ViewTreeObserver
;
import
android.view.WindowManager
;
import
android.view.WindowManager
;
import
android.view.animation.LinearInterpolator
;
import
android.widget.OverScroller
;
import
android.widget.RadioButton
;
import
android.widget.RadioButton
;
import
android.widget.RadioGroup
;
import
android.widget.RadioGroup
;
import
android.widget.RelativeLayout
;
import
android.widget.RelativeLayout
;
...
@@ -64,7 +62,6 @@ import com.ihaoin.hooloo.device.util.SharedPreferencesUtils;
...
@@ -64,7 +62,6 @@ import com.ihaoin.hooloo.device.util.SharedPreferencesUtils;
import
com.ihaoin.hooloo.device.util.StringUtils
;
import
com.ihaoin.hooloo.device.util.StringUtils
;
import
com.ihaoin.hooloo.device.util.Utils
;
import
com.ihaoin.hooloo.device.util.Utils
;
import
java.lang.reflect.Field
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -291,15 +288,15 @@ public class LauncherActivity extends Activity {
...
@@ -291,15 +288,15 @@ public class LauncherActivity extends Activity {
}
}
}
}
});
});
try
{
//
try {
Field
field
=
ScrollView
.
class
.
getDeclaredField
(
"mScroller"
);
//
Field field = ScrollView.class.getDeclaredField("mScroller");
field
.
setAccessible
(
true
);
//
field.setAccessible(true);
OverScroller
scroller
=
new
OverScroller
(
this
,
new
LinearInterpolator
());
//
OverScroller scroller = new OverScroller(this, new LinearInterpolator());
scroller
.
setFriction
(
50
);
//
scroller.setFriction(50);
field
.
set
(
scrollCategory
,
scroller
);
//
field.set(scrollCategory, scroller);
}
catch
(
Exception
e
)
{
//
} catch (Exception e) {
e
.
printStackTrace
();
//
e.printStackTrace();
}
//
}
}
}
/** 判断RecyclerView是否滚动到最下面 */
/** 判断RecyclerView是否滚动到最下面 */
...
@@ -319,6 +316,7 @@ public class LauncherActivity extends Activity {
...
@@ -319,6 +316,7 @@ public class LauncherActivity extends Activity {
int
drawablePadding
=
Utils
.
getDimens
(
LauncherActivity
.
this
,
R
.
dimen
.
category_drawable_padding
);
int
drawablePadding
=
Utils
.
getDimens
(
LauncherActivity
.
this
,
R
.
dimen
.
category_drawable_padding
);
Rect
rect
=
new
Rect
(
0
,
0
,
w
,
h
);
Rect
rect
=
new
Rect
(
0
,
0
,
w
,
h
);
groupCategory
.
setOnCheckedChangeListener
(
null
);
groupCategory
.
removeAllViews
();
groupCategory
.
removeAllViews
();
List
<
Category
>
categorys
=
HLApplication
.
getMainData
().
getCategorys
();
List
<
Category
>
categorys
=
HLApplication
.
getMainData
().
getCategorys
();
if
(!
CollectionUtils
.
isEmpty
(
categorys
))
{
if
(!
CollectionUtils
.
isEmpty
(
categorys
))
{
...
@@ -328,30 +326,29 @@ public class LauncherActivity extends Activity {
...
@@ -328,30 +326,29 @@ public class LauncherActivity extends Activity {
continue
;
continue
;
}
}
RadioGroup
.
LayoutParams
layoutParams
=
new
RadioGroup
.
LayoutParams
(
RadioGroup
.
LayoutParams
.
MATCH_PARENT
,
RadioGroup
.
LayoutParams
.
WRAP_CONTENT
);
RadioGroup
.
LayoutParams
layoutParams
=
new
RadioGroup
.
LayoutParams
(
RadioGroup
.
LayoutParams
.
MATCH_PARENT
,
RadioGroup
.
LayoutParams
.
WRAP_CONTENT
);
RadioButton
butn
Radio
=
(
RadioButton
)
this
.
getLayoutInflater
().
inflate
(
R
.
layout
.
item_category
,
null
);
RadioButton
butn
Category
=
(
RadioButton
)
this
.
getLayoutInflater
().
inflate
(
R
.
layout
.
item_category
,
null
);
butn
Radio
.
setText
(
category
.
getName
());
butn
Category
.
setText
(
category
.
getName
());
butn
Radio
.
setId
(
category
.
getId
());
butn
Category
.
setId
(
category
.
getId
());
butn
Radio
.
setTag
(
category
);
butn
Category
.
setTag
(
category
);
if
(
StringUtils
.
isEmpty
(
category
.
getIcon
()))
{
if
(
i
==
0
)
{
if
(
i
==
0
)
{
addLayoutListener
(
butnRadio
);
butnCategory
.
getPaint
().
setFakeBoldText
(
true
);
butnCategory
.
setChecked
(
true
);
}
}
}
else
{
int
finalIndex
=
i
;
int
finalIndex
=
i
;
Utils
.
getGlide
(
LauncherActivity
.
this
).
load
(
category
.
getIcon
()).
into
(
new
CustomTarget
<
Drawable
>()
{
Utils
.
getGlide
(
LauncherActivity
.
this
).
load
(
category
.
getIcon
()).
into
(
new
CustomTarget
<
Drawable
>()
{
@Override
@Override
public
void
onResourceReady
(
@NonNull
Drawable
drawable
,
@Nullable
Transition
<?
super
Drawable
>
transition
)
{
public
void
onResourceReady
(
@NonNull
Drawable
drawable
,
@Nullable
Transition
<?
super
Drawable
>
transition
)
{
drawable
.
setBounds
(
rect
);
drawable
.
setBounds
(
rect
);
butnRadio
.
setCompoundDrawablePadding
(
drawablePadding
);
butnCategory
.
setCompoundDrawablePadding
(
drawablePadding
);
butnRadio
.
setCompoundDrawables
(
null
,
drawable
,
null
,
null
);
butnCategory
.
setCompoundDrawables
(
null
,
drawable
,
null
,
null
);
Integer
left
=
Utils
.
getDimens
(
LauncherActivity
.
this
,
R
.
dimen
.
category_padding_hor
);
Integer
left
=
Utils
.
getDimens
(
LauncherActivity
.
this
,
R
.
dimen
.
category_padding_hor
);
Integer
top
=
Utils
.
getDimens
(
LauncherActivity
.
this
,
R
.
dimen
.
category_padding_top
);
Integer
top
=
Utils
.
getDimens
(
LauncherActivity
.
this
,
R
.
dimen
.
category_padding_top
);
Integer
right
=
left
;
Integer
right
=
left
;
Integer
bottom
=
Utils
.
getDimens
(
LauncherActivity
.
this
,
R
.
dimen
.
category_padding_bottom
);
Integer
bottom
=
Utils
.
getDimens
(
LauncherActivity
.
this
,
R
.
dimen
.
category_padding_bottom
);
butnRadio
.
setPadding
(
left
,
top
,
right
,
bottom
);
butnCategory
.
setPadding
(
left
,
top
,
right
,
bottom
);
if
(
finalIndex
==
0
)
{
if
(
finalIndex
==
0
)
{
addLayoutListener
(
butnRadio
);
addLayoutListener
(
butnCategory
);
}
}
}
}
...
@@ -359,13 +356,10 @@ public class LauncherActivity extends Activity {
...
@@ -359,13 +356,10 @@ public class LauncherActivity extends Activity {
public
void
onLoadCleared
(
@Nullable
Drawable
placeholder
)
{
public
void
onLoadCleared
(
@Nullable
Drawable
placeholder
)
{
}
}
});
});
}
groupCategory
.
addView
(
butnCategory
,
layoutParams
);
groupCategory
.
addView
(
butnRadio
,
layoutParams
);
// butnRadio.setForeground(null);
butnCategory
.
setOnClickListener
(
v
->
{
butnRadio
.
setOnClickListener
(
v
->
{
Category
tagCategory
=
(
Category
)
groupCategory
.
findViewById
(
v
.
getId
()).
getTag
();
Integer
checkedId
=
v
.
getId
();
Category
tagCategory
=
(
Category
)
groupCategory
.
findViewById
(
checkedId
).
getTag
();
int
position
=
categorys
.
indexOf
(
tagCategory
);
int
position
=
categorys
.
indexOf
(
tagCategory
);
goodsLayoutManager
.
scrollToPositionWithOffset
(
tPosition
.
get
(
position
),
0
);
goodsLayoutManager
.
scrollToPositionWithOffset
(
tPosition
.
get
(
position
),
0
);
});
});
...
@@ -373,35 +367,36 @@ public class LauncherActivity extends Activity {
...
@@ -373,35 +367,36 @@ public class LauncherActivity extends Activity {
}
}
groupCategory
.
setOnCheckedChangeListener
((
group
,
checkedId
)
->
{
groupCategory
.
setOnCheckedChangeListener
((
group
,
checkedId
)
->
{
for
(
int
i
=
0
;
i
<
groupCategory
.
getChildCount
();
i
++)
{
for
(
int
i
=
0
;
i
<
groupCategory
.
getChildCount
();
i
++)
{
RadioButton
butn
Radio
=
(
RadioButton
)
groupCategory
.
getChildAt
(
i
);
RadioButton
butn
Category
=
(
RadioButton
)
groupCategory
.
getChildAt
(
i
);
if
(
butn
Radio
.
getId
()
==
checkedId
)
{
if
(
butn
Category
.
getId
()
==
checkedId
)
{
setShadowView
(
butn
Radio
);
setShadowView
(
butn
Category
);
butn
Radio
.
getPaint
().
setFakeBoldText
(
true
);
butn
Category
.
getPaint
().
setFakeBoldText
(
true
);
}
else
{
}
else
{
butn
Radio
.
getPaint
().
setFakeBoldText
(
false
);
butn
Category
.
getPaint
().
setFakeBoldText
(
false
);
}
}
}
}
});
});
groupCategory
.
scrollTo
(
0
,
0
);
}
}
private
void
smoothTo
(
RadioButton
butn
Radio
)
{
private
void
smoothTo
(
RadioButton
butn
Category
)
{
scrollCategory
.
smoothScrollTo
(
0
,
getSmoothHeight
(
butn
Radio
));
scrollCategory
.
smoothScrollTo
(
0
,
getSmoothHeight
(
butn
Category
));
}
}
private
void
addLayoutListener
(
RadioButton
butn
Radio
)
{
private
void
addLayoutListener
(
RadioButton
butn
Category
)
{
butn
Radio
.
getViewTreeObserver
().
addOnGlobalLayoutListener
(
new
ViewTreeObserver
.
OnGlobalLayoutListener
()
{
butn
Category
.
getViewTreeObserver
().
addOnGlobalLayoutListener
(
new
ViewTreeObserver
.
OnGlobalLayoutListener
()
{
@Override
@Override
public
void
onGlobalLayout
()
{
public
void
onGlobalLayout
()
{
butn
Radio
.
getViewTreeObserver
().
removeOnGlobalLayoutListener
(
this
);
butn
Category
.
getViewTreeObserver
().
removeOnGlobalLayoutListener
(
this
);
butnRadio
.
performClick
(
);
setShadowView
(
butnCategory
);
}
}
});
});
}
}
private
void
setShadowView
(
View
butn
Radio
)
{
private
void
setShadowView
(
View
butn
Category
)
{
View
shadow
=
findViewById
(
R
.
id
.
shadow
);
View
shadow
=
findViewById
(
R
.
id
.
shadow
);
RelativeLayout
.
LayoutParams
lp
=
(
RelativeLayout
.
LayoutParams
)
shadow
.
getLayoutParams
();
RelativeLayout
.
LayoutParams
lp
=
(
RelativeLayout
.
LayoutParams
)
shadow
.
getLayoutParams
();
lp
.
topMargin
=
getShadowHeight
(
butn
Radio
);
lp
.
topMargin
=
getShadowHeight
(
butn
Category
);
shadow
.
setLayoutParams
(
lp
);
shadow
.
setLayoutParams
(
lp
);
}
}
...
@@ -414,7 +409,8 @@ public class LauncherActivity extends Activity {
...
@@ -414,7 +409,8 @@ public class LauncherActivity extends Activity {
}
}
private
int
getHeight
(
View
butnRadio
,
boolean
self
)
{
private
int
getHeight
(
View
butnRadio
,
boolean
self
)
{
int
height
=
Utils
.
getDimens
(
this
,
R
.
dimen
.
category_margin
);
// int height = Utils.getDimens(this, R.dimen.category_margin);
int
height
=
0
;
for
(
int
i
=
0
;
i
<
groupCategory
.
getChildCount
();
i
++)
{
for
(
int
i
=
0
;
i
<
groupCategory
.
getChildCount
();
i
++)
{
View
v
=
groupCategory
.
getChildAt
(
i
);
View
v
=
groupCategory
.
getChildAt
(
i
);
if
(!
self
&&
v
.
getId
()
==
butnRadio
.
getId
())
{
if
(!
self
&&
v
.
getId
()
==
butnRadio
.
getId
())
{
...
@@ -459,20 +455,6 @@ public class LauncherActivity extends Activity {
...
@@ -459,20 +455,6 @@ public class LauncherActivity extends Activity {
}
}
}
}
// private void startLoadDataThread() {
// loadData();
//// new Thread(() -> {
//// try {
//// while (true) {
//// runOnUiThread(() -> loadData());
//// Thread.sleep(1000 * 10);
//// }
//// } catch (Exception e) {
//// e.printStackTrace();
//// }
//// }).start();
// }
private
LoadDataHandler
loadDataHandler
;
private
LoadDataHandler
loadDataHandler
;
private
void
loadData
()
{
private
void
loadData
()
{
...
@@ -504,6 +486,11 @@ public class LauncherActivity extends Activity {
...
@@ -504,6 +486,11 @@ public class LauncherActivity extends Activity {
setRecommendsData
();
setRecommendsData
();
initCategorys
();
initCategorys
();
setGoodsData
();
setGoodsData
();
// initRecommends();
// setRecommendsData();
// initCategorys();
// initGoods();
// setGoodsData();
if
(
kdsView
!=
null
)
{
if
(
kdsView
!=
null
)
{
kdsView
.
mainDataChanged
();
kdsView
.
mainDataChanged
();
}
}
...
@@ -905,11 +892,11 @@ public class LauncherActivity extends Activity {
...
@@ -905,11 +892,11 @@ public class LauncherActivity extends Activity {
Utils
.
showToast
(
LauncherActivity
.
this
,
"hdmi state: "
+
state
);
Utils
.
showToast
(
LauncherActivity
.
this
,
"hdmi state: "
+
state
);
}
}
// TODO TEST
// TODO TEST
//
if (state) {
if
(
state
)
{
//
new Handler().postDelayed(() -> preparePresentView(), 1000 * 5);
new
Handler
().
postDelayed
(()
->
preparePresentView
(),
1000
*
5
);
//
} else {
}
else
{
//
hidePresentView();
hidePresentView
();
//
}
}
}
}
}
}
...
...
app/src/main/java/com/ihaoin/hooloo/device/interaction/InteractionSocket.java
View file @
096107cd
...
@@ -65,20 +65,20 @@ public class InteractionSocket extends Thread {
...
@@ -65,20 +65,20 @@ public class InteractionSocket extends Thread {
private
void
process
(
String
func
,
Object
[]
args
)
{
private
void
process
(
String
func
,
Object
[]
args
)
{
if
(
CollectionUtils
.
isEmpty
(
args
))
{
if
(
CollectionUtils
.
isEmpty
(
args
))
{
Utils
.
i
(
func
+
" args empty"
);
Utils
.
i
(
"interaction "
+
func
+
" args empty"
);
return
;
return
;
}
}
String
content
=
args
[
0
].
toString
();
String
content
=
args
[
0
].
toString
();
if
(
StringUtils
.
isEmpty
(
content
))
{
if
(
StringUtils
.
isEmpty
(
content
))
{
Utils
.
i
(
func
+
" content empty"
);
Utils
.
i
(
"interaction "
+
func
+
" content empty"
);
return
;
return
;
}
}
InteractionMsg
msg
=
JsonUtils
.
readValue
(
content
,
InteractionMsg
.
class
);
InteractionMsg
msg
=
JsonUtils
.
readValue
(
content
,
InteractionMsg
.
class
);
if
(
msg
==
null
)
{
if
(
msg
==
null
)
{
Utils
.
i
(
func
+
" msg empty"
);
Utils
.
i
(
"interaction "
+
func
+
" msg empty"
);
return
;
return
;
}
}
Utils
.
i
(
func
+
" receive msg: "
+
content
);
Utils
.
i
(
"interaction "
+
func
+
" receive msg: "
+
content
);
Utils
.
sendInteractionMsgBroadcast
(
mContext
,
msg
);
Utils
.
sendInteractionMsgBroadcast
(
mContext
,
msg
);
}
}
...
@@ -101,7 +101,7 @@ public class InteractionSocket extends Thread {
...
@@ -101,7 +101,7 @@ public class InteractionSocket extends Thread {
public
void
sendMessage
(
String
content
)
{
public
void
sendMessage
(
String
content
)
{
if
(
mSocket
==
null
)
{
if
(
mSocket
==
null
)
{
Utils
.
i
(
"socket未连接"
);
Utils
.
i
(
"
interaction
socket未连接"
);
return
;
return
;
}
}
try
{
try
{
...
...
app/src/main/java/com/ihaoin/hooloo/device/kds/KDSSocket.java
View file @
096107cd
...
@@ -64,6 +64,7 @@ public class KDSSocket extends Thread {
...
@@ -64,6 +64,7 @@ public class KDSSocket extends Thread {
Utils
.
i
(
"reply msg empty"
);
Utils
.
i
(
"reply msg empty"
);
return
;
return
;
}
}
Utils
.
i
(
"kds reply: "
+
content
);
Utils
.
sendKdsMsgBroadcast
(
mContext
,
msg
);
Utils
.
sendKdsMsgBroadcast
(
mContext
,
msg
);
};
};
...
@@ -86,7 +87,7 @@ public class KDSSocket extends Thread {
...
@@ -86,7 +87,7 @@ public class KDSSocket extends Thread {
public
void
sendMessage
(
String
content
)
{
public
void
sendMessage
(
String
content
)
{
if
(
mSocket
==
null
)
{
if
(
mSocket
==
null
)
{
Utils
.
i
(
"socket未连接"
);
Utils
.
i
(
"
kds
socket未连接"
);
return
;
return
;
}
}
try
{
try
{
...
...
app/src/main/java/com/ihaoin/hooloo/device/kds/view/KdsPresentation.java
View file @
096107cd
...
@@ -69,7 +69,7 @@ public class KdsPresentation extends Presentation {
...
@@ -69,7 +69,7 @@ public class KdsPresentation extends Presentation {
setOnDismissListener
(
dismissListener
);
setOnDismissListener
(
dismissListener
);
start
ImagePagerThread
();
start
Timer
();
startSocket
();
startSocket
();
}
}
...
@@ -125,6 +125,19 @@ public class KdsPresentation extends Presentation {
...
@@ -125,6 +125,19 @@ public class KdsPresentation extends Presentation {
smoothScroller
.
setTargetPosition
(
position
);
smoothScroller
.
setTargetPosition
(
position
);
startSmoothScroll
(
smoothScroller
);
startSmoothScroll
(
smoothScroller
);
}
}
long
times
=
0
;
@Override
public
void
onScrollStateChanged
(
int
state
)
{
super
.
onScrollStateChanged
(
state
);
if
(
state
==
2
)
{
times
=
System
.
currentTimeMillis
();
}
if
(
state
==
0
)
{
Utils
.
i
(
"machine state: "
+
state
+
", times: "
+
(
System
.
currentTimeMillis
()
-
times
));
}
}
};
};
LinearLayoutManager
imageLayoutManager
=
new
LinearLayoutManager
(
getContext
())
{
LinearLayoutManager
imageLayoutManager
=
new
LinearLayoutManager
(
getContext
())
{
...
@@ -134,12 +147,25 @@ public class KdsPresentation extends Presentation {
...
@@ -134,12 +147,25 @@ public class KdsPresentation extends Presentation {
// 返回:滑过1px时经历的时间(ms)。
// 返回:滑过1px时经历的时间(ms)。
@Override
@Override
protected
float
calculateSpeedPerPixel
(
DisplayMetrics
displayMetrics
)
{
protected
float
calculateSpeedPerPixel
(
DisplayMetrics
displayMetrics
)
{
return
0.
3
f
;
return
0.
2
f
;
}
}
};
};
smoothScroller
.
setTargetPosition
(
position
);
smoothScroller
.
setTargetPosition
(
position
);
startSmoothScroll
(
smoothScroller
);
startSmoothScroll
(
smoothScroller
);
}
}
long
times
=
0
;
@Override
public
void
onScrollStateChanged
(
int
state
)
{
super
.
onScrollStateChanged
(
state
);
if
(
state
==
2
)
{
times
=
System
.
currentTimeMillis
();
}
if
(
state
==
0
)
{
Utils
.
i
(
"image state: "
+
state
+
", times: "
+
(
System
.
currentTimeMillis
()
-
times
));
}
}
};
};
private
void
showImages
()
{
private
void
showImages
()
{
...
@@ -147,6 +173,7 @@ public class KdsPresentation extends Presentation {
...
@@ -147,6 +173,7 @@ public class KdsPresentation extends Presentation {
if
(
mainData
==
null
||
mainData
.
getImages
()
==
null
)
{
if
(
mainData
==
null
||
mainData
.
getImages
()
==
null
)
{
return
;
return
;
}
}
imagePosition
=
0
;
recyclerImagePager
.
removeAllViews
();
recyclerImagePager
.
removeAllViews
();
if
(
CollectionUtils
.
isEmpty
(
mainData
.
getImages
().
getLeft
()))
{
if
(
CollectionUtils
.
isEmpty
(
mainData
.
getImages
().
getLeft
()))
{
return
;
return
;
...
@@ -166,25 +193,23 @@ public class KdsPresentation extends Presentation {
...
@@ -166,25 +193,23 @@ public class KdsPresentation extends Presentation {
}
}
}
}
private
ImagePagerThread
imagePagerThread
;
private
TimerThread
timerThread
;
private
ImagePagerHandler
imagePagerHandler
;
private
void
startImagePagerThread
()
{
private
void
startTimer
()
{
imagePagerHandler
=
new
ImagePagerHandler
();
timerThread
=
new
TimerThread
();
imagePagerThread
=
new
ImagePagerThread
();
timerThread
.
start
();
imagePagerThread
.
start
();
}
}
private
class
ImagePag
erThread
extends
Thread
{
private
class
Tim
erThread
extends
Thread
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
try
{
try
{
while
(
true
)
{
while
(
true
)
{
// KDSMsg msg = KDSGen.getKdsMsg();
// Utils.sendKdsMsgBroadcast(getContext(), msg);
Thread
.
sleep
(
1000
*
5
);
Thread
.
sleep
(
1000
*
5
);
imagePagerHandler
.
sendEmptyMessage
(
1
);
timerHandler
.
sendEmptyMessage
(
1
);
Thread
.
sleep
(
1000
*
5
);
timerHandler
.
sendEmptyMessage
(
1
);
timerHandler
.
sendEmptyMessage
(
2
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -192,23 +217,34 @@ public class KdsPresentation extends Presentation {
...
@@ -192,23 +217,34 @@ public class KdsPresentation extends Presentation {
}
}
}
}
private
class
ImagePagerHandler
extends
Handler
{
@SuppressLint
(
"HandlerLeak"
)
Handler
timerHandler
=
new
Handler
()
{
@Override
@Override
public
void
handleMessage
(
@NonNull
Message
msg
)
{
public
void
handleMessage
(
@NonNull
Message
msg
)
{
setNextImage
();
if
(
msg
.
what
==
1
)
{
smoothMachineState
();
smoothMachineState
();
}
else
if
(
msg
.
what
==
2
)
{
setNextImage
();
}
}
}
}
};
private
Integer
imagePosition
=
0
;
private
Integer
imagePosition
=
0
;
private
Integer
statePosition
=
3
;
private
Integer
statePosition
=
3
;
private
void
setNextImage
()
{
private
void
setNextImage
()
{
if
(
imagePagerAdapter
==
null
||
imagePagerAdapter
.
getItemCount
()
<=
0
)
{
return
;
}
imagePosition
++;
imagePosition
++;
Utils
.
i
(
"showImage: "
+
imagePosition
);
recyclerImagePager
.
smoothScrollToPosition
(
imagePosition
);
recyclerImagePager
.
smoothScrollToPosition
(
imagePosition
);
}
}
private
void
smoothMachineState
()
{
private
void
smoothMachineState
()
{
if
(
machineStateAdapter
==
null
||
machineStateAdapter
.
getItemCount
()
<=
0
)
{
return
;
}
statePosition
++;
statePosition
++;
recyclerMachineState
.
smoothScrollToPosition
(
statePosition
);
recyclerMachineState
.
smoothScrollToPosition
(
statePosition
);
}
}
...
@@ -299,13 +335,13 @@ public class KdsPresentation extends Presentation {
...
@@ -299,13 +335,13 @@ public class KdsPresentation extends Presentation {
Utils
.
i
(
"kds present dismiss"
);
Utils
.
i
(
"kds present dismiss"
);
unregistKDSMessageReceiver
();
unregistKDSMessageReceiver
();
if
(
imagePag
erHandler
!=
null
)
{
if
(
tim
erHandler
!=
null
)
{
imagePag
erHandler
.
removeCallbacksAndMessages
(
null
);
tim
erHandler
.
removeCallbacksAndMessages
(
null
);
imagePag
erHandler
=
null
;
tim
erHandler
=
null
;
}
}
if
(
imagePag
erThread
!=
null
)
{
if
(
tim
erThread
!=
null
)
{
imagePag
erThread
.
interrupt
();
tim
erThread
.
interrupt
();
imagePag
erThread
=
null
;
tim
erThread
=
null
;
}
}
stopSocket
();
stopSocket
();
...
...
app/src/main/res/layout/activity_launcher.xml
View file @
096107cd
...
@@ -51,6 +51,7 @@
...
@@ -51,6 +51,7 @@
android:layout_weight=
"0.09792"
android:layout_weight=
"0.09792"
android:descendantFocusability=
"afterDescendants"
android:descendantFocusability=
"afterDescendants"
android:overScrollMode=
"never"
android:overScrollMode=
"never"
android:layout_marginTop=
"@dimen/category_margin"
android:scrollbars=
"none"
>
android:scrollbars=
"none"
>
<RelativeLayout
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
@@ -59,7 +60,6 @@
...
@@ -59,7 +60,6 @@
android:id=
"@+id/group_category"
android:id=
"@+id/group_category"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"@dimen/category_margin"
android:gravity=
"center"
android:gravity=
"center"
android:orientation=
"vertical"
android:orientation=
"vertical"
android:showDividers=
"middle"
/>
android:showDividers=
"middle"
/>
...
...
app/src/main/res/layout/item_category.xml
View file @
096107cd
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
android:foreground=
"@null"
android:foreground=
"@null"
android:gravity=
"center"
android:gravity=
"center"
android:paddingHorizontal=
"@dimen/category_padding_hor"
android:paddingHorizontal=
"@dimen/category_padding_hor"
android:checked=
"false"
android:paddingTop=
"@dimen/category_padding_top_noimg"
android:paddingTop=
"@dimen/category_padding_top_noimg"
android:paddingBottom=
"@dimen/category_padding_bottom_noimg"
android:paddingBottom=
"@dimen/category_padding_bottom_noimg"
android:text=
"123123"
android:text=
"123123"
...
...
app/src/main/res/layout/present_kds.xml
View file @
096107cd
...
@@ -8,21 +8,18 @@
...
@@ -8,21 +8,18 @@
android:orientation=
"horizontal"
>
android:orientation=
"horizontal"
>
<androidx.recyclerview.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/image_pager"
android:id=
"@+id/image_pager"
android:layout_width=
"
0dp
"
android:layout_width=
"
@dimen/menu_left
"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"0.73125"
android:descendantFocusability=
"afterDescendants"
android:descendantFocusability=
"afterDescendants"
android:orientation=
"horizontal"
android:orientation=
"horizontal"
android:overScrollMode=
"never"
/>
android:overScrollMode=
"never"
/>
<LinearLayout
<LinearLayout
android:layout_width=
"
0dp
"
android:layout_width=
"
@dimen/menu_right
"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"0.26875"
android:orientation=
"vertical"
>
android:orientation=
"vertical"
>
<RelativeLayout
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_height=
"@dimen/menu_right_top"
android:layout_weight=
"0.70185"
android:background=
"@color/menu_order_bg"
android:background=
"@color/menu_order_bg"
android:paddingStart=
"@dimen/menu_content_padding_hor"
android:paddingStart=
"@dimen/menu_content_padding_hor"
android:paddingTop=
"@dimen/menu_content_padding_top"
>
android:paddingTop=
"@dimen/menu_content_padding_top"
>
...
@@ -251,8 +248,7 @@
...
@@ -251,8 +248,7 @@
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_height=
"@dimen/menu_right_bottom"
android:layout_weight=
"0.29815"
android:background=
"@color/menu_state_bg"
android:background=
"@color/menu_state_bg"
android:paddingLeft=
"@dimen/menu_state_padding_hor"
android:paddingLeft=
"@dimen/menu_state_padding_hor"
android:paddingTop=
"@dimen/menu_state_padding_ver"
android:paddingTop=
"@dimen/menu_state_padding_ver"
...
...
app/src/main/res/values-w800dp/dimens.xml
View file @
096107cd
...
@@ -12,19 +12,19 @@
...
@@ -12,19 +12,19 @@
<dimen
name=
"recommend_padding"
>
38px
</dimen>
<dimen
name=
"recommend_padding"
>
38px
</dimen>
<dimen
name=
"recommend_image_height_0"
>
794px
</dimen>
<dimen
name=
"recommend_image_height_0"
>
794px
</dimen>
<dimen
name=
"recommend_image_height_other"
>
392px
</dimen>
<dimen
name=
"recommend_image_height_other"
>
392px
</dimen>
<dimen
name=
"recommend_name_margin_top"
>
82
px
</dimen>
<dimen
name=
"recommend_name_margin_top"
>
40
px
</dimen>
<dimen
name=
"recommend_name_margin_left"
>
68px
</dimen>
<dimen
name=
"recommend_name_margin_left"
>
68px
</dimen>
<dimen
name=
"recommend_desc_margin_top"
>
18px
</dimen>
<dimen
name=
"recommend_desc_margin_top"
>
18px
</dimen>
<dimen
name=
"recommend_desc_margin_left"
>
68px
</dimen>
<dimen
name=
"recommend_desc_margin_left"
>
68px
</dimen>
<dimen
name=
"goods_padding_top"
>
30
px
</dimen>
<dimen
name=
"goods_padding_top"
>
125
px
</dimen>
<dimen
name=
"goods_padding_ver"
>
30px
</dimen>
<dimen
name=
"goods_padding_ver"
>
30px
</dimen>
<dimen
name=
"goods_padding_right"
>
38px
</dimen>
<dimen
name=
"goods_padding_right"
>
38px
</dimen>
<dimen
name=
"goods_last_padding_bottom"
>
300
px
</dimen>
<dimen
name=
"goods_last_padding_bottom"
>
225
px
</dimen>
<dimen
name=
"goods_thum_size"
>
174px
</dimen>
<dimen
name=
"goods_thum_size"
>
174px
</dimen>
<dimen
name=
"goods_thum_margin_right"
>
40px
</dimen>
<dimen
name=
"goods_thum_margin_right"
>
40px
</dimen>
<dimen
name=
"goods_recommend_margin"
>
30px
</dimen>
<dimen
name=
"goods_recommend_margin"
>
30px
</dimen>
<dimen
name=
"goods_category_margin_top"
>
13
px
</dimen>
<dimen
name=
"goods_category_margin_top"
>
0
px
</dimen>
<dimen
name=
"goods_tag_margin_top"
>
13px
</dimen>
<dimen
name=
"goods_tag_margin_top"
>
13px
</dimen>
<dimen
name=
"goods_tag_padding_ver"
>
0px
</dimen>
<dimen
name=
"goods_tag_padding_ver"
>
0px
</dimen>
<dimen
name=
"goods_tag_padding_hor"
>
5px
</dimen>
<dimen
name=
"goods_tag_padding_hor"
>
5px
</dimen>
...
@@ -40,7 +40,7 @@
...
@@ -40,7 +40,7 @@
<dimen
name=
"category_drawable_padding"
>
10px
</dimen>
<dimen
name=
"category_drawable_padding"
>
10px
</dimen>
<dimen
name=
"category_drawable_width"
>
100px
</dimen>
<dimen
name=
"category_drawable_width"
>
100px
</dimen>
<dimen
name=
"category_drawable_height"
>
75px
</dimen>
<dimen
name=
"category_drawable_height"
>
75px
</dimen>
<dimen
name=
"category_margin"
>
12
9
px
</dimen>
<dimen
name=
"category_margin"
>
12
5
px
</dimen>
<dimen
name=
"category_divider_padding"
>
0px
</dimen>
<dimen
name=
"category_divider_padding"
>
0px
</dimen>
<dimen
name=
"tip_margin_top"
>
40px
</dimen>
<dimen
name=
"tip_margin_top"
>
40px
</dimen>
<dimen
name=
"tip_padding_top"
>
33px
</dimen>
<dimen
name=
"tip_padding_top"
>
33px
</dimen>
...
...
app/src/main/res/values/dimens.xml
View file @
096107cd
...
@@ -12,19 +12,19 @@
...
@@ -12,19 +12,19 @@
<dimen
name=
"recommend_padding"
>
38px
</dimen>
<dimen
name=
"recommend_padding"
>
38px
</dimen>
<dimen
name=
"recommend_image_height_0"
>
794px
</dimen>
<dimen
name=
"recommend_image_height_0"
>
794px
</dimen>
<dimen
name=
"recommend_image_height_other"
>
392px
</dimen>
<dimen
name=
"recommend_image_height_other"
>
392px
</dimen>
<dimen
name=
"recommend_name_margin_top"
>
82
px
</dimen>
<dimen
name=
"recommend_name_margin_top"
>
40
px
</dimen>
<dimen
name=
"recommend_name_margin_left"
>
68px
</dimen>
<dimen
name=
"recommend_name_margin_left"
>
68px
</dimen>
<dimen
name=
"recommend_desc_margin_top"
>
18px
</dimen>
<dimen
name=
"recommend_desc_margin_top"
>
18px
</dimen>
<dimen
name=
"recommend_desc_margin_left"
>
68px
</dimen>
<dimen
name=
"recommend_desc_margin_left"
>
68px
</dimen>
<dimen
name=
"goods_padding_top"
>
30
px
</dimen>
<dimen
name=
"goods_padding_top"
>
125
px
</dimen>
<dimen
name=
"goods_padding_ver"
>
30px
</dimen>
<dimen
name=
"goods_padding_ver"
>
30px
</dimen>
<dimen
name=
"goods_padding_right"
>
38px
</dimen>
<dimen
name=
"goods_padding_right"
>
38px
</dimen>
<dimen
name=
"goods_last_padding_bottom"
>
300
px
</dimen>
<dimen
name=
"goods_last_padding_bottom"
>
225
px
</dimen>
<dimen
name=
"goods_thum_size"
>
174px
</dimen>
<dimen
name=
"goods_thum_size"
>
174px
</dimen>
<dimen
name=
"goods_thum_margin_right"
>
40px
</dimen>
<dimen
name=
"goods_thum_margin_right"
>
40px
</dimen>
<dimen
name=
"goods_recommend_margin"
>
30px
</dimen>
<dimen
name=
"goods_recommend_margin"
>
30px
</dimen>
<dimen
name=
"goods_category_margin_top"
>
13
px
</dimen>
<dimen
name=
"goods_category_margin_top"
>
0
px
</dimen>
<dimen
name=
"goods_tag_margin_top"
>
13px
</dimen>
<dimen
name=
"goods_tag_margin_top"
>
13px
</dimen>
<dimen
name=
"goods_tag_padding_ver"
>
0px
</dimen>
<dimen
name=
"goods_tag_padding_ver"
>
0px
</dimen>
<dimen
name=
"goods_tag_padding_hor"
>
5px
</dimen>
<dimen
name=
"goods_tag_padding_hor"
>
5px
</dimen>
...
@@ -40,7 +40,7 @@
...
@@ -40,7 +40,7 @@
<dimen
name=
"category_drawable_padding"
>
10px
</dimen>
<dimen
name=
"category_drawable_padding"
>
10px
</dimen>
<dimen
name=
"category_drawable_width"
>
100px
</dimen>
<dimen
name=
"category_drawable_width"
>
100px
</dimen>
<dimen
name=
"category_drawable_height"
>
75px
</dimen>
<dimen
name=
"category_drawable_height"
>
75px
</dimen>
<dimen
name=
"category_margin"
>
12
9
px
</dimen>
<dimen
name=
"category_margin"
>
12
5
px
</dimen>
<dimen
name=
"category_divider_padding"
>
0px
</dimen>
<dimen
name=
"category_divider_padding"
>
0px
</dimen>
<dimen
name=
"tip_margin_top"
>
40px
</dimen>
<dimen
name=
"tip_margin_top"
>
40px
</dimen>
<dimen
name=
"tip_padding_top"
>
33px
</dimen>
<dimen
name=
"tip_padding_top"
>
33px
</dimen>
...
...
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