Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
android
/
dayu
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
5ddff038
authored
Jun 06, 2024
by
xuxuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
打卡
parent
6b1d2514
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
124 additions
and
21 deletions
baseSDK/src/main/java/com/dayu/utils/PictrueUtils.java
orderCenter/src/main/java/com/dayu/order/presenter/checkintakephoto/CheckInTakePhotoPresenter.java
orderCenter/src/main/java/com/dayu/order/presenter/orderdoing/OrderDoingPresenter.java
orderCenter/src/main/java/com/dayu/order/ui/activity/CheckInTakePhotoActivity.java
orderCenter/src/main/java/com/dayu/order/ui/activity/OrderDetailsClockActivity.java
orderCenter/src/main/java/com/dayu/order/ui/adapter/OrderAdapter.java
orderCenter/src/main/java/com/dayu/order/ui/fragment/OrderFirstTabFragment.java
orderCenter/src/main/java/com/dayu/order/ui/fragment/OrderSecondTabFragment.java
baseSDK/src/main/java/com/dayu/utils/PictrueUtils.java
View file @
5ddff038
...
...
@@ -144,6 +144,7 @@ public class PictrueUtils {
.
openGallery
(
SelectMimeType
.
ofImage
())
//全部.PictureMimeType.ofAll()、图片.ofImage()、视频.ofVideo()
.
setImageEngine
(
GlideEngine
.
createGlideEngine
())
.
setImageSpanCount
(
4
)
.
setMaxSelectNum
(
1
)
.
setSelectionMode
(
SelectModeConfig
.
MULTIPLE
);
selector
.
forResult
(
PictureConfig
.
CHOOSE_REQUEST
);
}
...
...
orderCenter/src/main/java/com/dayu/order/presenter/checkintakephoto/CheckInTakePhotoPresenter.java
View file @
5ddff038
...
...
@@ -21,6 +21,10 @@ public class CheckInTakePhotoPresenter extends CheckInTakePhotoContract.Present
@Override
public
void
submit
(){
if
(
mView
.
getPhotoPath
().
isEmpty
()){
mView
.
showToast
(
"请先选择照片"
);
return
;
}
BaseApiFactory
.
uploadPhotoOne
(
BaseApiFactory
.
packPhoto
(
mView
.
getPhotoPath
()),
Constants
.
PHOTO
+
"/order/clockIn"
,
"yyMM"
)
.
subscribe
(
this
.
baseObserver
(
img
->
{
...
...
orderCenter/src/main/java/com/dayu/order/presenter/orderdoing/OrderDoingPresenter.java
View file @
5ddff038
...
...
@@ -2,20 +2,25 @@ package com.dayu.order.presenter.orderdoing;
import
static
com
.
dayu
.
utils
.
UIUtils
.
getString
;
import
android.Manifest
;
import
android.app.Activity
;
import
android.app.Fragment
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.IntentFilter
;
import
android.content.pm.PackageManager
;
import
android.location.Address
;
import
android.os.Bundle
;
import
androidx.core.content.ContextCompat
;
import
androidx.databinding.ObservableField
;
import
androidx.fragment.app.Fragment
;
import
com.dayu.base.api.Api
;
import
com.dayu.common.BaseApplication
;
import
com.dayu.common.Constants
;
import
com.dayu.event.UserInfo
;
import
com.dayu.location.base.LocationUtils1
;
import
com.dayu.order.R
;
import
com.dayu.order.api.OrderApiFactory
;
import
com.dayu.order.api.OrderService
;
...
...
@@ -35,9 +40,11 @@ import com.dayu.provider.event.RefreshServe;
import
com.dayu.provider.event.RefreshTab
;
import
com.dayu.utils.AppManager
;
import
com.dayu.utils.ToastUtils
;
import
com.dayu.utils.UIUtils
;
import
com.dayu.utils.UserManager
;
import
com.dayu.utils.UtilsDate
;
import
com.dayu.widgets.CustomDialog
;
import
com.tbruyelle.rxpermissions2.RxPermissions
;
import
org.greenrobot.eventbus.EventBus
;
import
org.json.JSONObject
;
...
...
@@ -66,22 +73,31 @@ public class OrderDoingPresenter extends orderDoingContract.Presenter {
private
int
position
=
0
;
private
int
checkInPosition
;
private
Activity
mActivity
;
private
int
checkinOrderId
;
//接收打卡拍照成功通知
private
BroadcastReceiver
receiver
=
new
BroadcastReceiver
()
{
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
if
(
intent
.
getAction
().
equals
(
CheckInTakePhotoActivity
.
TAKE_PHOTO_FINISH_BROADCAST
))
{
clockIn
(
checkinOrderId
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
baseObserver
(
aBoolean
->
{
ToastUtils
.
showShortToast
(
"打卡成功"
);
setPosition
(
position
);
EventBus
.
getDefault
().
post
(
new
RefreshServe
(
1
));
},
responeThrowable
->
{
}));
Fragment
fragment
=
(
Fragment
)
mView
;
if
(
intent
.
getAction
().
equals
(
CheckInTakePhotoActivity
.
TAKE_PHOTO_FINISH_BROADCAST
)
&&
(
mView
instanceof
OrderSecondTabFragment
)
)
{
String
photoUrl
=
intent
.
getStringExtra
(
"photoUrl"
);
//打卡获取到图片链接,下一步获取定位信息
mView
.
showDialog
();
getLocation
(
checkinOrderId
,
photoUrl
);
// clockIn(checkinOrderId)
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(baseObserver(aBoolean -> {
// ToastUtils.showShortToast("打卡成功");
// setPosition(position);
// EventBus.getDefault().post(new RefreshServe(1));
// }, responeThrowable -> {
//
// }));
}
}
};
...
...
@@ -290,14 +306,57 @@ public class OrderDoingPresenter extends orderDoingContract.Presenter {
Bundle
bundle
=
new
Bundle
();
mView
.
startActivityForReult
(
CheckInTakePhotoActivity
.
class
,
bundle
,
CheckInTakePhotoActivity
.
TAKE_PHOTO_CODE
);
}
public
Observable
<
Boolean
>
clockIn
(
int
id
)
{
//打卡接口
public
Observable
<
Boolean
>
clockIn
(
int
id
,
String
photoUrl
,
double
latitude
,
double
longitude
)
{
HashMap
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"orderId"
,
id
);
params
.
put
(
"commentInfo"
,
photoUrl
);
params
.
put
(
"latitude"
,
latitude
);
params
.
put
(
"longitude"
,
longitude
);
JSONObject
jsonObject
=
new
JSONObject
(
params
);
RequestBody
body
=
RequestBody
.
create
(
MediaType
.
parse
(
"application/json"
),
jsonObject
.
toString
());
return
OrderApiFactory
.
clockIn
(
body
);
}
//获取定位
private
void
getLocation
(
int
orderId
,
String
photoUrl
){
if
(
ContextCompat
.
checkSelfPermission
(
mActivity
,
Manifest
.
permission
.
ACCESS_COARSE_LOCATION
)
==
PackageManager
.
PERMISSION_GRANTED
)
{
LocationUtils1
.
getInstance
(
UIUtils
.
getContext
()).
setAddressCallback
(
new
LocationUtils1
.
AddressCallback
()
{
@Override
public
void
onGetAddress
(
Address
address
)
{
//获取定位无论成功失败,结束后调打卡接口
clockIn
(
checkinOrderId
,
photoUrl
,
address
.
getLatitude
(),
address
.
getLongitude
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
baseObserver
(
aBoolean
->
{
ToastUtils
.
showShortToast
(
"打卡成功"
);
setPosition
(
checkInPosition
);
EventBus
.
getDefault
().
post
(
new
RefreshServe
(
1
));
},
responeThrowable
->
{
}));
}
@Override
public
void
onGetLocation
(
double
lat
,
double
lng
)
{
}
});
}
else
{
clockIn
(
checkinOrderId
,
photoUrl
,
0.0
,
0.0
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
baseObserver
(
aBoolean
->
{
ToastUtils
.
showShortToast
(
"打卡成功"
);
setPosition
(
checkInPosition
);
EventBus
.
getDefault
().
post
(
new
RefreshServe
(
1
));
},
responeThrowable
->
{
}));
}
}
public
void
refreshClear
()
{
getOrders
(
mState
,
mUserId
,
mSiteId
,
mPage
,
Constants
.
PAGESIZE
);
}
...
...
@@ -325,4 +384,12 @@ public class OrderDoingPresenter extends orderDoingContract.Presenter {
this
.
position
=
position
;
}
public
Activity
getmActivity
()
{
return
mActivity
;
}
public
void
setmActivity
(
Activity
mActivity
)
{
this
.
mActivity
=
mActivity
;
}
}
orderCenter/src/main/java/com/dayu/order/ui/activity/CheckInTakePhotoActivity.java
View file @
5ddff038
...
...
@@ -22,7 +22,7 @@ import java.util.List;
public
class
CheckInTakePhotoActivity
extends
BaseActivity
<
CheckInTakePhotoPresenter
,
ActivityCheckInTakePhotoLayoutBinding
>
implements
CheckInTakePhotoContract
.
View
{
public
String
photoPath
;
public
String
photoPath
=
""
;
public
static
final
int
TAKE_PHOTO_CODE
=
700
;
...
...
orderCenter/src/main/java/com/dayu/order/ui/activity/OrderDetailsClockActivity.java
View file @
5ddff038
...
...
@@ -3,6 +3,7 @@ package com.dayu.order.ui.activity;
import
android.Manifest
;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.location.Address
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.view.View
;
...
...
@@ -22,6 +23,7 @@ import com.dayu.base.ui.activity.BaseActivity;
import
com.dayu.base.ui.activity.ImgGalleryActivty
;
import
com.dayu.common.Constants
;
import
com.dayu.event.UserInfo
;
import
com.dayu.location.base.LocationUtils1
;
import
com.dayu.order.R
;
import
com.dayu.order.api.OrderApiFactory
;
import
com.dayu.order.api.protocol.OrderDetail
;
...
...
@@ -36,6 +38,7 @@ import com.dayu.usercenter.ui.activity.BusinessDetailActivity;
import
com.dayu.utils.CommonUtils
;
import
com.dayu.utils.ProgressUtil
;
import
com.dayu.utils.ToastUtils
;
import
com.dayu.utils.UIUtils
;
import
com.dayu.utils.UserManager
;
import
com.dayu.widgets.CustomDialog
;
import
com.tbruyelle.rxpermissions2.RxPermissions
;
...
...
@@ -124,7 +127,7 @@ public class OrderDetailsClockActivity extends BaseActivity<OrderDetailClockPres
}
else
if
(
7
!=
detail
.
getSubStatus
())
{
// mBind.tvButton.setText("第" + detail.getFinishedDays() + "天打卡");
Spu
s
=
detail
.
getSpus
().
get
(
0
);
mBind
.
tvButton
.
setText
(
s
.
getFinNum
()%
2
==
0
?
"下班打卡"
:
"上班打卡"
);
mBind
.
tvButton
.
setText
(
(((
s
.
getFinNum
()
+
1
)
%
2
)
==
0
)
?
"下班打卡"
:
"上班打卡"
);
}
else
{
mBind
.
tvButton
.
setText
(
getString
(
R
.
string
.
submit_order
));
}
...
...
@@ -333,9 +336,33 @@ public class OrderDetailsClockActivity extends BaseActivity<OrderDetailClockPres
}
}
private
void
checkIn
(
String
photoUrl
){
//获取定位
private
void
getLocation
(
String
photoUrl
){
RxPermissions
permissions
=
new
RxPermissions
(
this
);
if
(
permissions
.
isGranted
(
Manifest
.
permission
.
ACCESS_COARSE_LOCATION
))
{
LocationUtils1
.
getInstance
(
UIUtils
.
getContext
()).
setAddressCallback
(
new
LocationUtils1
.
AddressCallback
()
{
@Override
public
void
onGetAddress
(
Address
address
)
{
//获取定位无论成功失败,结束后调打卡接口
checkIn
(
photoUrl
,
address
.
getLatitude
(),
address
.
getLongitude
());
}
@Override
public
void
onGetLocation
(
double
lat
,
double
lng
)
{
}
});
}
else
{
checkIn
(
photoUrl
,
0.0
,
0.0
);
}
}
private
void
checkIn
(
String
photoUrl
,
double
latitude
,
double
longitude
){
HashMap
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"orderId"
,
detailId
);
params
.
put
(
"commentInfo"
,
photoUrl
);
params
.
put
(
"latitude"
,
latitude
);
params
.
put
(
"longitude"
,
longitude
);
JSONObject
jsonObject
=
new
JSONObject
(
params
);
RequestBody
body
=
RequestBody
.
create
(
MediaType
.
parse
(
"application/json"
),
jsonObject
.
toString
());
OrderApiFactory
.
clockIn
(
body
)
...
...
@@ -354,7 +381,8 @@ public class OrderDetailsClockActivity extends BaseActivity<OrderDetailClockPres
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
if
(
requestCode
==
TAKE_PHOTO
&&
resultCode
==
RESULT_OK
){
checkIn
(
data
.
getStringExtra
(
"photoUrl"
));
showDialog
();
getLocation
(
data
.
getStringExtra
(
"photoUrl"
));
}
}
...
...
orderCenter/src/main/java/com/dayu/order/ui/adapter/OrderAdapter.java
View file @
5ddff038
...
...
@@ -180,7 +180,7 @@ public class OrderAdapter extends CoreAdapter<Order, FragmentOrderdoingItemBindi
//按天用工单
holder
.
tvOrderTime
.
setText
(
R
.
string
.
start_day
);
LinearLayout
.
LayoutParams
params
=
(
LinearLayout
.
LayoutParams
)
holder
.
tvOrderTime
.
getLayoutParams
();
params
.
topMargin
+=
2
0
;
params
.
topMargin
=
6
0
;
holder
.
tvOrderTime
.
setLayoutParams
(
params
);
holder
.
tvCount
.
setVisibility
(
holder
.
tvPrice
.
getVisibility
());
holder
.
tvDaysCount
.
setVisibility
(
View
.
VISIBLE
);
...
...
@@ -270,7 +270,7 @@ public class OrderAdapter extends CoreAdapter<Order, FragmentOrderdoingItemBindi
//按天用工单
holder
.
tvOrderTime
.
setText
(
R
.
string
.
start_day
);
LinearLayout
.
LayoutParams
params
=
(
LinearLayout
.
LayoutParams
)
holder
.
tvOrderTime
.
getLayoutParams
();
params
.
topMargin
+=
2
0
;
params
.
topMargin
=
6
0
;
holder
.
tvOrderTime
.
setLayoutParams
(
params
);
holder
.
tvCount
.
setVisibility
(
holder
.
tvPrice
.
getVisibility
());
holder
.
tvDaysCount
.
setVisibility
(
View
.
VISIBLE
);
...
...
@@ -326,7 +326,7 @@ public class OrderAdapter extends CoreAdapter<Order, FragmentOrderdoingItemBindi
//按天用工单
holder
.
tvOrderTime
.
setText
(
R
.
string
.
start_day
);
LinearLayout
.
LayoutParams
params
=
(
LinearLayout
.
LayoutParams
)
holder
.
tvOrderTime
.
getLayoutParams
();
params
.
topMargin
+=
2
0
;
params
.
topMargin
=
6
0
;
holder
.
tvOrderTime
.
setLayoutParams
(
params
);
holder
.
tvCount
.
setVisibility
(
holder
.
tvPrice
.
getVisibility
());
holder
.
tvDaysCount
.
setVisibility
(
View
.
VISIBLE
);
...
...
@@ -358,7 +358,7 @@ public class OrderAdapter extends CoreAdapter<Order, FragmentOrderdoingItemBindi
//按天用工单
holder
.
tvOrderTime
.
setText
(
R
.
string
.
start_day
);
LinearLayout
.
LayoutParams
params
=
(
LinearLayout
.
LayoutParams
)
holder
.
tvOrderTime
.
getLayoutParams
();
params
.
topMargin
+=
2
0
;
params
.
topMargin
=
6
0
;
holder
.
tvOrderTime
.
setLayoutParams
(
params
);
holder
.
tvCount
.
setVisibility
(
holder
.
tvPrice
.
getVisibility
());
holder
.
tvDaysCount
.
setVisibility
(
View
.
VISIBLE
);
...
...
@@ -488,7 +488,7 @@ public class OrderAdapter extends CoreAdapter<Order, FragmentOrderdoingItemBindi
//按天用工单
holder
.
tvOrderTime
.
setText
(
R
.
string
.
start_day
);
LinearLayout
.
LayoutParams
params
=
(
LinearLayout
.
LayoutParams
)
holder
.
tvOrderTime
.
getLayoutParams
();
params
.
topMargin
+=
2
0
;
params
.
topMargin
=
6
0
;
holder
.
tvOrderTime
.
setLayoutParams
(
params
);
holder
.
tvCount
.
setVisibility
(
holder
.
tvPrice
.
getVisibility
());
holder
.
tvDaysCount
.
setVisibility
(
View
.
VISIBLE
);
...
...
orderCenter/src/main/java/com/dayu/order/ui/fragment/OrderFirstTabFragment.java
View file @
5ddff038
...
...
@@ -38,6 +38,7 @@ public class OrderFirstTabFragment extends BaseFragment<OrderDoingPresenter, Fra
mAdapter
.
initPresenter
(
mPresenter
);
mBind
.
recyclerView
.
setAdapter
(
mAdapter
);
mPresenter
.
refresh
();
mPresenter
.
setmActivity
(
getActivity
());
EventBus
.
getDefault
().
register
(
this
);
mBind
.
recyclerView
.
setOnItemClickListener
(
new
OnItemClickListener
<
Order
,
FragmentOrderdoingItemBinding
>()
{
...
...
orderCenter/src/main/java/com/dayu/order/ui/fragment/OrderSecondTabFragment.java
View file @
5ddff038
...
...
@@ -55,6 +55,8 @@ public class OrderSecondTabFragment extends BaseFragment<OrderDoingPresenter, Fr
mAdapter
=
new
OrderAdapter
(
true
);
mAdapter
.
setViewType
(
R
.
layout
.
fragment_orderdoing_item
);
mAdapter
.
initPresenter
(
mPresenter
);
mPresenter
.
setmActivity
(
getActivity
());
mBind
.
recyclerView
.
setAdapter
(
mAdapter
);
mBind
.
recyclerView
.
setOnItemClickListener
(
new
OnItemClickListener
<
Order
,
FragmentOrderdoingItemBinding
>()
{
@Override
...
...
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