Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
TangKuPos
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
王海
TangKuPos
Commits
c82bb919
Commit
c82bb919
authored
Mar 16, 2018
by
zhang_z
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
加强Fragment切换的保护;
parent
d42d0399
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
12 deletions
+28
-12
app/src/main/java/com/xingdata/zzdpos/base/BaseActivity.java
app/src/main/java/com/xingdata/zzdpos/base/BaseActivity.java
+2
-3
app/src/main/java/com/xingdata/zzdpos/base/BaseFragment.java
app/src/main/java/com/xingdata/zzdpos/base/BaseFragment.java
+3
-5
app/src/main/java/com/xingdata/zzdpos/ui/scan/ScanFragment.java
...c/main/java/com/xingdata/zzdpos/ui/scan/ScanFragment.java
+18
-4
app/src/main/java/com/xingdata/zzdpos/ui/settle/SettleActivity.java
...in/java/com/xingdata/zzdpos/ui/settle/SettleActivity.java
+5
-0
No files found.
app/src/main/java/com/xingdata/zzdpos/base/BaseActivity.java
View file @
c82bb919
...
...
@@ -30,8 +30,7 @@ import me.yokeyword.fragmentation.SupportActivity;
* @author Zhangzhen
*/
public
abstract
class
BaseActivity
<
P
extends
BasePresenter
,
B
extends
ViewDataBinding
>
extends
SupportActivity
{
public
abstract
class
BaseActivity
<
P
extends
BasePresenter
,
B
extends
ViewDataBinding
>
extends
SupportActivity
{
public
Context
mContext
;
public
P
mPresenter
;
...
...
@@ -127,7 +126,7 @@ public abstract class BaseActivity<P extends BasePresenter, B extends ViewDataBi
@Override
public
void
start
(
ISupportFragment
toFragment
)
{
if
((
System
.
currentTimeMillis
()
-
mTime
)
>
5
00
)
{
if
((
System
.
currentTimeMillis
()
-
mTime
)
>
10
00
)
{
mTime
=
System
.
currentTimeMillis
();
super
.
start
(
toFragment
);
}
...
...
app/src/main/java/com/xingdata/zzdpos/base/BaseFragment.java
View file @
c82bb919
...
...
@@ -24,13 +24,13 @@ import me.yokeyword.fragmentation.SupportFragment;
* @param <B> Fragment对应的ViewDataBinding
* @author Zhangzhen
*/
public
abstract
class
BaseFragment
<
P
extends
BasePresenter
,
B
extends
ViewDataBinding
>
extends
SupportFragment
{
public
abstract
class
BaseFragment
<
P
extends
BasePresenter
,
B
extends
ViewDataBinding
>
extends
SupportFragment
{
public
Context
mContext
;
public
P
mPresenter
;
public
B
mViewBinding
;
public
LoadingDialog
mLoadingDialog
;
static
{
AppCompatDelegate
.
setCompatVectorFromResourcesEnabled
(
true
);
}
...
...
@@ -39,8 +39,7 @@ public abstract class BaseFragment<P extends BasePresenter, B extends ViewDataBi
@Nullable
@Override
public
View
onCreateView
(
@NonNull
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
public
View
onCreateView
(
@NonNull
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
mContext
=
ActivityUtils
.
getTopActivity
();
mPresenter
=
(
P
)
((
BaseActivity
)
getActivity
()).
mPresenter
;
mLoadingDialog
=
((
BaseActivity
)
getActivity
()).
mLoadingDialog
;
...
...
@@ -66,7 +65,6 @@ public abstract class BaseFragment<P extends BasePresenter, B extends ViewDataBi
KeyboardUtils
.
hideSoftInput
(
getActivity
());
}
public
String
getTabTitle
()
{
return
null
;
}
...
...
app/src/main/java/com/xingdata/zzdpos/ui/scan/ScanFragment.java
View file @
c82bb919
package
com
.
xingdata
.
zzdpos
.
ui
.
scan
;
import
android.content.Context
;
import
android.hardware.camera2.CameraAccessException
;
import
android.hardware.camera2.CameraManager
;
import
android.os.Handler
;
import
android.view.View
;
...
...
@@ -9,6 +10,7 @@ import android.widget.TextView;
import
com.blankj.utilcode.constant.PermissionConstants
;
import
com.blankj.utilcode.util.PermissionUtils
;
import
com.blankj.utilcode.util.TimeUtils
;
import
com.xingdata.zzdpos.R
;
import
com.xingdata.zzdpos.base.BaseFragment
;
import
com.xingdata.zzdpos.base.BasePresenter
;
...
...
@@ -29,6 +31,9 @@ public class ScanFragment<P extends BasePresenter> extends BaseFragment<P, Fragm
private
ViewStub
viewStub
;
private
View
inflated
;
private
Long
mTime
;
@Override
public
int
getLayoutId
()
{
return
R
.
layout
.
fragment_store_scan
;
...
...
@@ -66,6 +71,7 @@ public class ScanFragment<P extends BasePresenter> extends BaseFragment<P, Fragm
@Override
public
void
initView
()
{
isDenied
=
false
;
mTime
=
TimeUtils
.
getNowMills
();
PermissionUtils
.
permission
(
PermissionConstants
.
CAMERA
).
callback
(
new
PermissionUtils
.
FullCallback
()
{
@Override
public
void
onGranted
(
List
<
String
>
permissionsGranted
)
{
...
...
@@ -83,6 +89,17 @@ public class ScanFragment<P extends BasePresenter> extends BaseFragment<P, Fragm
private
void
initCamera
()
{
mCameraManager
=
(
CameraManager
)
mContext
.
getSystemService
(
Context
.
CAMERA_SERVICE
);
try
{
if
((
mCameraManager
!=
null
?
mCameraManager
.
getCameraIdList
().
length
:
0
)
>
1
)
{
mViewBinding
.
ivChange
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
mViewBinding
.
ivChange
.
setVisibility
(
View
.
GONE
);
}
}
catch
(
CameraAccessException
e
)
{
e
.
printStackTrace
();
}
if
(!
titleStr
.
equals
(
""
))
{
viewStub
=
mViewBinding
.
vsTitle
.
getViewStub
();
inflated
=
viewStub
.
inflate
();
...
...
@@ -116,21 +133,17 @@ public class ScanFragment<P extends BasePresenter> extends BaseFragment<P, Fragm
if
(
mCurCameraId
==
getDefaultCameraId
())
{
mCurCameraId
=
getFrontFacingCameraId
();
mScannerView
.
stopCamera
();
mScannerView
.
startCamera
(
getFrontFacingCameraId
());
}
else
{
mCurCameraId
=
getDefaultCameraId
();
mScannerView
.
stopCamera
();
mScannerView
.
startCamera
(
getDefaultCameraId
());
}
});
}
private
int
mCurCameraId
;
@Override
public
void
onResume
()
{
super
.
onResume
();
...
...
@@ -161,6 +174,7 @@ public class ScanFragment<P extends BasePresenter> extends BaseFragment<P, Fragm
@Override
public
boolean
onBackPressedSupport
()
{
if
(
TimeUtils
.
getNowMills
()
-
mTime
<=
500
)
return
true
;
if
(
mOnBackPressedListener
!=
null
)
mOnBackPressedListener
.
onBackPressed
();
return
super
.
onBackPressedSupport
();
}
...
...
app/src/main/java/com/xingdata/zzdpos/ui/settle/SettleActivity.java
View file @
c82bb919
...
...
@@ -4,6 +4,7 @@ import android.view.MotionEvent;
import
com.blankj.utilcode.util.ActivityUtils
;
import
com.blankj.utilcode.util.LogUtils
;
import
com.blankj.utilcode.util.TimeUtils
;
import
com.blankj.utilcode.util.ToastUtils
;
import
com.xingdata.zzdpos.C
;
import
com.xingdata.zzdpos.R
;
...
...
@@ -139,6 +140,7 @@ public class SettleActivity extends BaseActivity<SettlePresenter, ActivitySettle
// mPresenter.payInBank();
break
;
case
C
.
PAY_CHANNEL
.
ALI
:
if
(
TimeUtils
.
getNowMills
()
-
mTime
<
1000
)
return
;
this
.
showTitleBarByTitleMode
(
C
.
TITLE_MODE
.
TEXT
);
mViewBinding
.
tvTitle
.
setText
(
R
.
string
.
settle_channel_ali
);
mScanFragment
.
setOnScanCompletedListener
(
barcode
->
{
...
...
@@ -149,6 +151,7 @@ public class SettleActivity extends BaseActivity<SettlePresenter, ActivitySettle
this
.
start
(
mScanFragment
);
break
;
case
C
.
PAY_CHANNEL
.
WECHAT
:
if
(
TimeUtils
.
getNowMills
()
-
mTime
<
1000
)
return
;
this
.
showTitleBarByTitleMode
(
C
.
TITLE_MODE
.
TEXT
);
mViewBinding
.
tvTitle
.
setText
(
R
.
string
.
settle_channel_wechat
);
mScanFragment
.
setOnScanCompletedListener
(
barcode
->
{
...
...
@@ -204,9 +207,11 @@ public class SettleActivity extends BaseActivity<SettlePresenter, ActivitySettle
return
mSettleFragment
.
mViewBinding
.
etMark
.
getText
().
toString
();
}
private
long
mTime
;
@Override
public
void
backToSettleFragment
()
{
mTime
=
TimeUtils
.
getNowMills
();
this
.
showTitleBarByTitleMode
(
C
.
TITLE_MODE
.
TEXT
);
mViewBinding
.
tvTitle
.
setText
(
R
.
string
.
settle_title
);
mViewBinding
.
vSearch
.
hideSoftInput
();
...
...
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