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
dbc16daf
authored
Dec 19, 2023
by
wukun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
checkPay
parent
14e1dec7
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
82 additions
and
10 deletions
baseSDK/src/main/java/com/dayu/widgets/MyJzvdStd.java
learnCenter/src/main/java/com/dayu/learncenter/adapter/LearnAdapter.java
learnCenter/src/main/java/com/dayu/learncenter/presenter/common_learn/CommonLearnContract.java
learnCenter/src/main/java/com/dayu/learncenter/presenter/common_learn/CommonLearnPresenter.java
learnCenter/src/main/java/com/dayu/learncenter/ui/fragment/CommonLearnFragment.java
learnCenter/src/main/res/layout/item_common_learn.xml
baseSDK/src/main/java/com/dayu/widgets/MyJzvdStd.java
View file @
dbc16daf
...
...
@@ -2,6 +2,8 @@ package com.dayu.widgets;
import
android.content.Context
;
import
android.util.AttributeSet
;
import
android.util.Log
;
import
android.view.View
;
import
com.dayu.baselibrary.R
;
import
com.dayu.utils.ToastUtils
;
...
...
@@ -20,6 +22,28 @@ public class MyJzvdStd extends JzvdStd {
public
MyJzvdStd
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
View
viewById
=
findViewById
(
R
.
id
.
thumb
);
View
start_layout
=
findViewById
(
R
.
id
.
start_layout
);
View
start
=
findViewById
(
R
.
id
.
start
);
viewById
.
setOnClickListener
(
new
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
Log
.
e
(
TAG
,
"onClick: 111111111111"
);
}
});
start_layout
.
setOnClickListener
(
new
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
Log
.
e
(
TAG
,
"onClick: 111111111112"
);
}
});
start
.
setOnClickListener
(
new
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
Log
.
e
(
TAG
,
"onClick: 111111111113"
);
}
});
}
@Override
...
...
learnCenter/src/main/java/com/dayu/learncenter/adapter/LearnAdapter.java
View file @
dbc16daf
...
...
@@ -17,6 +17,7 @@ import cn.jzvd.JzvdStd;
public
class
LearnAdapter
extends
CoreAdapter
<
CommonLearnBean
,
ItemCommonLearnBinding
>
{
private
int
type
;
//1.全部 2.已学习 3.已发布
private
CommonLearnPresenter
mPresenter
;
private
com
.
dayu
.
learncenter
.
databinding
.
ItemCommonLearnBinding
mHolder
;
public
void
setPresenter
(
CommonLearnPresenter
mPresenter
)
{
this
.
mPresenter
=
mPresenter
;
...
...
@@ -29,6 +30,7 @@ public class LearnAdapter extends CoreAdapter<CommonLearnBean, ItemCommonLearnBi
@Override
protected
void
onBind
(
ItemCommonLearnBinding
holder
,
CommonLearnBean
item
,
int
position
)
{
super
.
onBind
(
holder
,
item
,
position
);
holder
.
tvTitle
.
setText
(
item
.
getName
());
holder
.
tvLooks
.
setText
((
item
.
getLearners
()+
item
.
getShareWatchs
())
+
""
);
...
...
@@ -39,6 +41,15 @@ public class LearnAdapter extends CoreAdapter<CommonLearnBean, ItemCommonLearnBi
holder
.
tvShares
.
setOnClickListener
(
view
->
mPresenter
.
shareVideo
(
item
));
holder
.
ivLike
.
setOnClickListener
(
view
->
mPresenter
.
likeVideo
(
item
));
holder
.
tvLike
.
setOnClickListener
(
view
->
mPresenter
.
likeVideo
(
item
));
holder
.
rlClick
.
setVisibility
(
View
.
VISIBLE
);
holder
.
rlClick
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
mPresenter
.
checkPayClick
(
item
);
mHolder
=
holder
;
holder
.
rlClick
.
setVisibility
(
View
.
GONE
);
}
});
if
(
type
==
2
)
{
holder
.
tvProgress
.
setVisibility
(
View
.
VISIBLE
);
holder
.
tvProgress
.
setText
(
mContext
.
getString
(
R
.
string
.
learn_progress
)
+
item
.
getProgressPercentage
()
+
"%"
);
...
...
@@ -85,4 +96,9 @@ public class LearnAdapter extends CoreAdapter<CommonLearnBean, ItemCommonLearnBi
}
});
}
public
void
startVideo
()
{
mHolder
.
jzVideo
.
startVideo
();
}
}
learnCenter/src/main/java/com/dayu/learncenter/presenter/common_learn/CommonLearnContract.java
View file @
dbc16daf
...
...
@@ -9,9 +9,13 @@ public interface CommonLearnContract {
void
shareVideo
(
CommonLearnBean
item
);
void
likeVideo
(
CommonLearnBean
item
);
void
palyVideo
(
CommonLearnBean
item
);
void
ShowDialog
(
CommonLearnBean
item
);
void
ShowDialog
(
CommonLearnBean
item
,
boolean
isVideo
);
void
ShowErrorDialog
(
CommonLearnBean
item
);
void
checkPayClick
(
CommonLearnBean
item
);
void
StartVideo
(
CommonLearnBean
item
);
}
abstract
class
Presenter
extends
BaseListPresenter
<
View
>
{
...
...
learnCenter/src/main/java/com/dayu/learncenter/presenter/common_learn/CommonLearnPresenter.java
View file @
dbc16daf
...
...
@@ -109,14 +109,19 @@ public class CommonLearnPresenter extends CommonLearnContract.Presenter {
}
public
void
checkPay
(
CommonLearnBean
item
){
public
void
checkPay
(
CommonLearnBean
item
,
boolean
isVideo
){
CheckPayData
checkPayData
=
new
CheckPayData
(
item
.
getId
(),
mUserId
);
Api
.
getService
(
LearnService
.
class
).
checkPay
(
checkPayData
).
compose
(
Api
.
applySchedulers
())
.
subscribe
(
baseObserver
(
success
->
{
if
(
success
){
if
(
isVideo
){
mView
.
StartVideo
(
item
);
}
else
{
mView
.
palyVideo
(
item
);
}
}
else
{
mView
.
ShowDialog
(
item
);
mView
.
ShowDialog
(
item
,
isVideo
);
}
}));
}
...
...
@@ -129,12 +134,20 @@ public class CommonLearnPresenter extends CommonLearnContract.Presenter {
mView
.
likeVideo
(
item
);
}
public
void
pay
(
CommonLearnBean
item
)
{
public
void
checkPayClick
(
CommonLearnBean
item
)
{
mView
.
checkPayClick
(
item
);
}
public
void
pay
(
CommonLearnBean
item
,
boolean
isVideo
)
{
PayData
payData
=
new
PayData
(
item
.
getId
(),
mUserId
,
1
);
Api
.
getService
(
LearnService
.
class
).
pay
(
payData
).
compose
(
Api
.
applySchedulers
())
.
subscribe
(
baseObserver
(
success
->
{
if
(
success
){
if
(
isVideo
){
mView
.
StartVideo
(
item
);
}
else
{
mView
.
palyVideo
(
item
);
}
}
else
{
mView
.
ShowErrorDialog
(
item
);
}
...
...
learnCenter/src/main/java/com/dayu/learncenter/ui/fragment/CommonLearnFragment.java
View file @
dbc16daf
...
...
@@ -125,7 +125,7 @@ public class CommonLearnFragment extends BaseFragment<CommonLearnPresenter, Frag
mBind
.
recyclerView
.
setAdapter
(
mAdapter
);
mAdapter
.
setOnItemClickListener
((
item
,
bind
)
->
{
mPresenter
.
checkPay
(
item
);
mPresenter
.
checkPay
(
item
,
false
);
});
...
...
@@ -224,11 +224,11 @@ public class CommonLearnFragment extends BaseFragment<CommonLearnPresenter, Frag
}
@Override
public
void
ShowDialog
(
CommonLearnBean
item
)
{
public
void
ShowDialog
(
CommonLearnBean
item
,
boolean
isVideo
)
{
CustomDialog
dialog
=
new
CustomDialog
(
getActivity
(),
R
.
style
.
CustomDialog
,
"付费"
+
item
.
getPrice
()
+
"元后观看"
,
(
dialog1
,
confirm
)
->
{
if
(
confirm
)
{
mPresenter
.
pay
(
item
);
mPresenter
.
pay
(
item
,
isVideo
);
}
});
dialog
.
setTitle
(
"温馨提醒"
)
...
...
@@ -240,13 +240,22 @@ public class CommonLearnFragment extends BaseFragment<CommonLearnPresenter, Frag
public
void
ShowErrorDialog
(
CommonLearnBean
item
)
{
CustomDialog
dialog
=
new
CustomDialog
(
getActivity
(),
R
.
style
.
CustomDialog
,
"账户余额不足!\n请先充值再抢单!"
,
(
dialog1
,
confirm
)
->
{
if
(
confirm
)
{
mPresenter
.
pay
(
item
);
}
});
dialog
.
setTitle
(
"温馨提醒"
)
.
setPositiveButton
(
"确定"
);
dialog
.
setOneButton
(
true
);
dialog
.
show
();
}
@Override
public
void
checkPayClick
(
CommonLearnBean
item
)
{
mPresenter
.
checkPay
(
item
,
true
);
}
@Override
public
void
StartVideo
(
CommonLearnBean
item
)
{
mAdapter
.
startVideo
();
}
}
learnCenter/src/main/res/layout/item_common_learn.xml
View file @
dbc16daf
...
...
@@ -21,6 +21,12 @@
android:id=
"@+id/jz_video"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
<RelativeLayout
android:id=
"@+id/rl_click"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
</RelativeLayout>
<RelativeLayout
android:id=
"@+id/rl_cover"
...
...
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