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
83340ba8
Commit
83340ba8
authored
Jun 28, 2022
by
wjg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加空闲时间清空购物车,并回到首页
parent
d7fdc3e1
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
158 additions
and
22 deletions
+158
-22
app/src/main/java/com/ihaoin/hooloo/device/HLApplication.java
+1
-0
app/src/main/java/com/ihaoin/hooloo/device/config/Base.java
+2
-0
app/src/main/java/com/ihaoin/hooloo/device/util/Utils.java
+4
-0
app/src/main/java/com/ihaoin/hooloo/device/view/GoodsDetailDialog.java
+35
-15
app/src/main/java/com/ihaoin/hooloo/device/view/LauncherActivity.java
+56
-0
app/src/main/java/com/ihaoin/hooloo/device/view/TipsDialog.java
+44
-0
app/src/main/res/layout/activity_launcher.xml
+14
-6
app/src/main/res/layout/view_trolley.xml
+1
-0
app/src/main/res/values-w1080dp/dimens.xml
+1
-1
No files found.
app/src/main/java/com/ihaoin/hooloo/device/HLApplication.java
View file @
83340ba8
...
@@ -78,6 +78,7 @@ public class HLApplication extends Application {
...
@@ -78,6 +78,7 @@ public class HLApplication extends Application {
}
}
}
}
@Override
@Override
public
void
onTerminate
()
{
public
void
onTerminate
()
{
super
.
onTerminate
();
super
.
onTerminate
();
...
...
app/src/main/java/com/ihaoin/hooloo/device/config/Base.java
View file @
83340ba8
...
@@ -19,5 +19,7 @@ public class Base {
...
@@ -19,5 +19,7 @@ public class Base {
public
static
final
String
BROADCAST_ACTION_MACHINE_CODE_CHANGED
=
"ACTION_MACHINE_CODE_CHANGED"
;
public
static
final
String
BROADCAST_ACTION_MACHINE_CODE_CHANGED
=
"ACTION_MACHINE_CODE_CHANGED"
;
public
static
final
String
BROADCAST_ACTION_MENU_STATE_CHANGED
=
"ACTION_MENU_STATE_CHANGED"
;
public
static
final
String
BROADCAST_ACTION_MENU_STATE_CHANGED
=
"ACTION_MENU_STATE_CHANGED"
;
public
static
final
String
BROADCAST_ACTION_LOGCAT_STATE_CHANGED
=
"ACTION_LOGCAT_STATE_CHANGED"
;
public
static
final
String
BROADCAST_ACTION_LOGCAT_STATE_CHANGED
=
"ACTION_LOGCAT_STATE_CHANGED"
;
public
static
final
String
BROADCAST_ACTION_TOUCH_EVENT
=
"ACTION_TOUCH_EVENT"
;
public
static
final
String
BROADCAST_ACTION_TIMEOUT
=
"ACTION_TIMEOUT"
;
}
}
app/src/main/java/com/ihaoin/hooloo/device/util/Utils.java
View file @
83340ba8
...
@@ -34,10 +34,14 @@ import com.ihaoin.hooloo.device.view.TipsDialog;
...
@@ -34,10 +34,14 @@ import com.ihaoin.hooloo.device.view.TipsDialog;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.text.DecimalFormat
;
import
java.text.DecimalFormat
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Optional
;
public
class
Utils
{
public
class
Utils
{
public
static
long
getTimestamp
()
{
return
new
Date
().
getTime
();
}
public
static
void
fastBroadcast
(
Context
context
,
String
action
)
{
public
static
void
fastBroadcast
(
Context
context
,
String
action
)
{
Intent
intent
=
new
Intent
();
Intent
intent
=
new
Intent
();
...
...
app/src/main/java/com/ihaoin/hooloo/device/view/GoodsDetailDialog.java
View file @
83340ba8
package
com
.
ihaoin
.
hooloo
.
device
.
view
;
package
com
.
ihaoin
.
hooloo
.
device
.
view
;
import
android.app.Dialog
;
import
android.app.Dialog
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.content.IntentFilter
;
import
android.graphics.Paint
;
import
android.graphics.Paint
;
import
android.graphics.Typeface
;
import
android.graphics.Typeface
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Handler
;
import
android.os.Message
;
import
android.os.Message
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewGroup
;
import
android.widget.Button
;
import
android.widget.Button
;
...
@@ -83,6 +87,13 @@ public class GoodsDetailDialog extends Dialog {
...
@@ -83,6 +87,13 @@ public class GoodsDetailDialog extends Dialog {
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
this
.
setContentView
(
R
.
layout
.
view_goods_detail
);
this
.
setContentView
(
R
.
layout
.
view_goods_detail
);
initViews
();
initViews
();
regsitTimeoutReceiver
();
}
@Override
public
boolean
dispatchTouchEvent
(
@NonNull
MotionEvent
ev
)
{
Utils
.
fastBroadcast
(
getContext
(),
Base
.
BROADCAST_ACTION_TOUCH_EVENT
);
return
super
.
dispatchTouchEvent
(
ev
);
}
}
private
void
initViews
()
{
private
void
initViews
()
{
...
@@ -209,6 +220,7 @@ public class GoodsDetailDialog extends Dialog {
...
@@ -209,6 +220,7 @@ public class GoodsDetailDialog extends Dialog {
pagerThread
.
interrupt
();
pagerThread
.
interrupt
();
pagerThread
=
null
;
pagerThread
=
null
;
}
}
unregsitTimeoutReceiver
();
}
}
};
};
...
@@ -651,21 +663,29 @@ public class GoodsDetailDialog extends Dialog {
...
@@ -651,21 +663,29 @@ public class GoodsDetailDialog extends Dialog {
private
void
showSelloutViews
()
{
private
void
showSelloutViews
()
{
dismiss
();
dismiss
();
// layoutOperate.setVisibility(View.GONE);
// layoutButns.setVisibility(View.GONE);
// txtSellout.setVisibility(View.VISIBLE);
// setAllRuleSellouts(); // 所有规格设置为售罄
}
}
// private void setAllRuleSellouts() {
private
TimeoutReceiver
timeoutReceiver
;
// if (mGoods == null || CollectionUtils.isEmpty(mGoods.getSpecs())) {
// return;
class
TimeoutReceiver
extends
BroadcastReceiver
{
// }
@Override
// mGoods.getSpecs().forEach(spec -> {
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
// if (CollectionUtils.isEmpty(spec.getRules())) {
dismiss
();
// return;
}
// }
}
// spec.getRules().forEach(rule -> rule.setState(SkuState.SELLOUT.getCode()));
// });
private
void
regsitTimeoutReceiver
()
{
// }
timeoutReceiver
=
new
TimeoutReceiver
();
IntentFilter
filter
=
new
IntentFilter
();
filter
.
addAction
(
Base
.
BROADCAST_ACTION_TIMEOUT
);
this
.
getContext
().
registerReceiver
(
timeoutReceiver
,
filter
);
}
private
void
unregsitTimeoutReceiver
()
{
if
(
timeoutReceiver
!=
null
)
{
this
.
getContext
().
unregisterReceiver
(
timeoutReceiver
);
timeoutReceiver
=
null
;
}
}
}
}
app/src/main/java/com/ihaoin/hooloo/device/view/LauncherActivity.java
View file @
83340ba8
...
@@ -13,6 +13,7 @@ import android.os.Bundle;
...
@@ -13,6 +13,7 @@ import android.os.Bundle;
import
android.os.Message
;
import
android.os.Message
;
import
android.util.Log
;
import
android.util.Log
;
import
android.view.Display
;
import
android.view.Display
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.View
;
import
android.view.WindowManager
;
import
android.view.WindowManager
;
import
android.widget.RadioButton
;
import
android.widget.RadioButton
;
...
@@ -54,6 +55,7 @@ import java.util.List;
...
@@ -54,6 +55,7 @@ import java.util.List;
public
class
LauncherActivity
extends
Activity
{
public
class
LauncherActivity
extends
Activity
{
private
SkuStateChangeReceiver
skuChangeReceiver
;
private
SkuStateChangeReceiver
skuChangeReceiver
;
private
GoodsChangeReceiver
goodsChangeReceiver
;
private
GoodsChangeReceiver
goodsChangeReceiver
;
private
TouchReceiver
touchReceiver
;
private
RadioGroup
groupCategory
;
private
RadioGroup
groupCategory
;
private
RecyclerView
recGoods
;
private
RecyclerView
recGoods
;
...
@@ -106,9 +108,19 @@ public class LauncherActivity extends Activity {
...
@@ -106,9 +108,19 @@ public class LauncherActivity extends Activity {
prepareMenuView
();
prepareMenuView
();
regsitSkuChangeReceiver
();
regsitSkuChangeReceiver
();
regsitGoodsChangeReceiver
();
regsitGoodsChangeReceiver
();
regsitTouchReceiver
();
startLoadDataThread
();
startLoadDataThread
();
initSettingsQueue
();
initSettingsQueue
();
new
TimeoutThread
().
start
();
}
@Override
public
boolean
dispatchTouchEvent
(
MotionEvent
ev
)
{
Log
.
i
(
AppConfig
.
TAG
,
"dispatchTouchEvent"
);
TIMESTAMP
=
Utils
.
getTimestamp
();
return
super
.
dispatchTouchEvent
(
ev
);
}
}
private
void
initSettingsQueue
()
{
private
void
initSettingsQueue
()
{
...
@@ -402,6 +414,7 @@ public class LauncherActivity extends Activity {
...
@@ -402,6 +414,7 @@ public class LauncherActivity extends Activity {
this
.
unregistSettingChangedReceiver
();
this
.
unregistSettingChangedReceiver
();
this
.
unregsitSkuChangeReceiver
();
this
.
unregsitSkuChangeReceiver
();
this
.
unregsitGoodsChangeReceiver
();
this
.
unregsitGoodsChangeReceiver
();
this
.
unregsitTouchReceiver
();
System
.
exit
(
0
);
System
.
exit
(
0
);
}
}
...
@@ -592,6 +605,20 @@ public class LauncherActivity extends Activity {
...
@@ -592,6 +605,20 @@ public class LauncherActivity extends Activity {
}
}
}
}
private
void
regsitTouchReceiver
()
{
touchReceiver
=
new
TouchReceiver
();
IntentFilter
filter
=
new
IntentFilter
();
filter
.
addAction
(
Base
.
BROADCAST_ACTION_TOUCH_EVENT
);
this
.
registerReceiver
(
touchReceiver
,
filter
);
}
private
void
unregsitTouchReceiver
()
{
if
(
touchReceiver
!=
null
)
{
this
.
unregisterReceiver
(
touchReceiver
);
touchReceiver
=
null
;
}
}
class
SkuStateChangeReceiver
extends
BroadcastReceiver
{
class
SkuStateChangeReceiver
extends
BroadcastReceiver
{
@Override
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
...
@@ -664,4 +691,33 @@ public class LauncherActivity extends Activity {
...
@@ -664,4 +691,33 @@ public class LauncherActivity extends Activity {
loadData
();
loadData
();
}
}
}
}
class
TouchReceiver
extends
BroadcastReceiver
{
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
TIMESTAMP
=
Utils
.
getTimestamp
();
}
}
public
static
Long
TIMESTAMP
=
System
.
currentTimeMillis
();
/** 判断空闲时间定时器 */
private
class
TimeoutThread
extends
Thread
{
@Override
public
void
run
()
{
super
.
run
();
try
{
while
(
true
)
{
Thread
.
sleep
(
1000
);
Log
.
i
(
AppConfig
.
TAG
,
String
.
valueOf
(
Utils
.
getTimestamp
()
-
TIMESTAMP
));
if
(
Utils
.
getTimestamp
()
-
TIMESTAMP
>
1000
*
5
)
{
TIMESTAMP
=
Utils
.
getTimestamp
();
Utils
.
fastBroadcast
(
HLApplication
.
SELF
,
Base
.
BROADCAST_ACTION_CLEAR_GOODS
);
Utils
.
fastBroadcast
(
HLApplication
.
SELF
,
Base
.
BROADCAST_ACTION_TIMEOUT
);
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
}
}
app/src/main/java/com/ihaoin/hooloo/device/view/TipsDialog.java
View file @
83340ba8
package
com
.
ihaoin
.
hooloo
.
device
.
view
;
package
com
.
ihaoin
.
hooloo
.
device
.
view
;
import
android.app.Dialog
;
import
android.app.Dialog
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.content.IntentFilter
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.View
;
import
android.webkit.WebResourceRequest
;
import
android.webkit.WebResourceRequest
;
import
android.webkit.WebView
;
import
android.webkit.WebView
;
...
@@ -12,6 +17,7 @@ import androidx.annotation.NonNull;
...
@@ -12,6 +17,7 @@ import androidx.annotation.NonNull;
import
com.ihaoin.hooloo.device.HLApplication
;
import
com.ihaoin.hooloo.device.HLApplication
;
import
com.ihaoin.hooloo.device.R
;
import
com.ihaoin.hooloo.device.R
;
import
com.ihaoin.hooloo.device.config.Base
;
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
;
...
@@ -34,6 +40,7 @@ public class TipsDialog extends Dialog {
...
@@ -34,6 +40,7 @@ public class TipsDialog extends Dialog {
return
;
return
;
}
}
initViews
();
initViews
();
regsitTimeoutReceiver
();
}
}
private
void
initViews
()
{
private
void
initViews
()
{
...
@@ -50,5 +57,42 @@ public class TipsDialog extends Dialog {
...
@@ -50,5 +57,42 @@ public class TipsDialog extends Dialog {
butnClose
.
setOnClickListener
(
x
->
dismiss
());
butnClose
.
setOnClickListener
(
x
->
dismiss
());
Utils
.
setTouchDelegate
(
findViewById
(
R
.
id
.
layout_root
),
Arrays
.
asList
(
butnClose
));
Utils
.
setTouchDelegate
(
findViewById
(
R
.
id
.
layout_root
),
Arrays
.
asList
(
butnClose
));
setOnDismissListener
(
dismissListener
);
}
@Override
public
boolean
dispatchTouchEvent
(
@NonNull
MotionEvent
ev
)
{
Utils
.
fastBroadcast
(
getContext
(),
Base
.
BROADCAST_ACTION_TOUCH_EVENT
);
return
super
.
dispatchTouchEvent
(
ev
);
}
OnDismissListener
dismissListener
=
new
OnDismissListener
()
{
@Override
public
void
onDismiss
(
DialogInterface
dialog
)
{
unregsitTimeoutReceiver
();
}
};
private
TimeoutReceiver
timeoutReceiver
;
class
TimeoutReceiver
extends
BroadcastReceiver
{
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
dismiss
();
}
}
private
void
regsitTimeoutReceiver
()
{
timeoutReceiver
=
new
TimeoutReceiver
();
IntentFilter
filter
=
new
IntentFilter
();
filter
.
addAction
(
Base
.
BROADCAST_ACTION_TIMEOUT
);
this
.
getContext
().
registerReceiver
(
timeoutReceiver
,
filter
);
}
private
void
unregsitTimeoutReceiver
()
{
if
(
timeoutReceiver
!=
null
)
{
this
.
getContext
().
unregisterReceiver
(
timeoutReceiver
);
timeoutReceiver
=
null
;
}
}
}
}
}
app/src/main/res/layout/activity_launcher.xml
View file @
83340ba8
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/layout_launcher"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/white"
>
android:background=
"@color/white"
>
...
@@ -14,7 +15,14 @@
...
@@ -14,7 +15,14 @@
android:layout_weight=
"0.59375"
android:layout_weight=
"0.59375"
android:orientation=
"vertical"
android:orientation=
"vertical"
android:paddingHorizontal=
"@dimen/recommend_padding"
>
android:paddingHorizontal=
"@dimen/recommend_padding"
>
<include
layout=
"@layout/item_logo"
/>
<ImageView
android:id=
"@+id/img_logo"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:adjustViewBounds=
"true"
android:src=
"@mipmap/logo"
/>
<androidx.recyclerview.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rec_recommend"
android:id=
"@+id/rec_recommend"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
@@ -35,8 +43,9 @@
...
@@ -35,8 +43,9 @@
<include
layout=
"@layout/item_goods_category"
/>
<include
layout=
"@layout/item_goods_category"
/>
</FrameLayout>
</FrameLayout>
<ScrollView
<ScrollView
android:layout_width=
"
wrap_content
"
android:layout_width=
"
0dp
"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"0.09792"
android:descendantFocusability=
"afterDescendants"
android:descendantFocusability=
"afterDescendants"
android:scrollbars=
"none"
>
android:scrollbars=
"none"
>
<LinearLayout
<LinearLayout
...
@@ -64,5 +73,4 @@
...
@@ -64,5 +73,4 @@
android:id=
"@+id/view_trolley"
android:id=
"@+id/view_trolley"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
android:layout_height=
"wrap_content"
/>
</FrameLayout>
</RelativeLayout>
\ No newline at end of file
\ No newline at end of file
app/src/main/res/layout/view_trolley.xml
View file @
83340ba8
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/layout_root"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
android:layout_height=
"wrap_content"
>
<RelativeLayout
<RelativeLayout
...
...
app/src/main/res/values-w1080dp/dimens.xml
View file @
83340ba8
...
@@ -44,7 +44,7 @@
...
@@ -44,7 +44,7 @@
<dimen
name=
"menu_content_padding_top"
>
38px
</dimen>
<dimen
name=
"menu_content_padding_top"
>
38px
</dimen>
<dimen
name=
"menu_content_padding_bottom"
>
38px
</dimen>
<dimen
name=
"menu_content_padding_bottom"
>
38px
</dimen>
<dimen
name=
"menu_order_margin_top"
>
43px
</dimen>
<dimen
name=
"menu_order_margin_top"
>
43px
</dimen>
<dimen
name=
"menu_spacing_hor"
>
3
7
px
</dimen>
<dimen
name=
"menu_spacing_hor"
>
3
0
px
</dimen>
<dimen
name=
"menu_spacing_ver"
>
20px
</dimen>
<dimen
name=
"menu_spacing_ver"
>
20px
</dimen>
<dimen
name=
"goods_detail_padding_ver"
>
55px
</dimen>
<dimen
name=
"goods_detail_padding_ver"
>
55px
</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