Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_vedio
Project
Project
Details
Activity
Releases
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
android
android_vedio
Commits
d3d81fda
Commit
d3d81fda
authored
Sep 07, 2023
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加猜歌
parent
a828d202
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
485 additions
and
3 deletions
+485
-3
DPHolder.java
...p/src/main/java/com/mints/helivideo/manager/DPHolder.java
+134
-0
MusicFragment.kt
...ain/java/com/mints/helivideo/ui/fragment/MusicFragment.kt
+293
-0
selector_quzi_button_default.xml
...pp/src/main/res/drawable/selector_quzi_button_default.xml
+7
-0
selector_quzi_button_error.xml
.../app/src/main/res/drawable/selector_quzi_button_error.xml
+7
-0
selector_quzi_button_ok.xml
video/app/src/main/res/drawable/selector_quzi_button_ok.xml
+7
-0
fragment_music.xml
video/app/src/main/res/layout/fragment_music.xml
+7
-3
media_layout_quiz.xml
video/app/src/main/res/layout/media_layout_quiz.xml
+30
-0
No files found.
video/app/src/main/java/com/mints/helivideo/manager/DPHolder.java
0 → 100644
View file @
d3d81fda
package
com
.
mints
.
helivideo
.
manager
;
import
com.bytedance.sdk.dp.DPSdk
;
import
com.bytedance.sdk.dp.DPWidgetBannerParams
;
import
com.bytedance.sdk.dp.DPWidgetBubbleParams
;
import
com.bytedance.sdk.dp.DPWidgetDrawParams
;
import
com.bytedance.sdk.dp.DPWidgetGridParams
;
import
com.bytedance.sdk.dp.DPWidgetInnerPushParams
;
import
com.bytedance.sdk.dp.DPWidgetNewsParams
;
import
com.bytedance.sdk.dp.DPWidgetTextChainParams
;
import
com.bytedance.sdk.dp.DPWidgetVideoCardParams
;
import
com.bytedance.sdk.dp.DPWidgetVideoSingleCardParams
;
import
com.bytedance.sdk.dp.IDPNativeData
;
import
com.bytedance.sdk.dp.IDPWidget
;
import
com.bytedance.sdk.dp.IDPWidgetFactory
;
import
org.json.JSONObject
;
/**
* Create by hanweiwei on 2020-03-26.
*/
public
final
class
DPHolder
{
private
static
volatile
DPHolder
sInstance
;
public
static
DPHolder
getInstance
()
{
if
(
sInstance
==
null
)
{
synchronized
(
DPHolder
.
class
)
{
if
(
sInstance
==
null
)
{
sInstance
=
new
DPHolder
();
}
}
}
return
sInstance
;
}
private
DPHolder
()
{
}
public
IDPWidget
buildDrawWidget
(
DPWidgetDrawParams
params
)
{
//创建draw视频流组件
return
getFactory
().
createDraw
(
params
);
}
public
IDPWidget
buildGridWidget
(
DPWidgetGridParams
params
)
{
//创建宫格组件
return
getFactory
().
createGrid
(
params
);
}
public
IDPWidget
buildDoubleFeedWidget
(
DPWidgetGridParams
params
)
{
//创建双Feed组件
return
getFactory
().
createDoubleFeed
(
params
);
}
public
IDPWidget
buildNewsTabsWidget
(
DPWidgetNewsParams
params
)
{
//创建多频道新闻组件
return
getFactory
().
createNewsTabs
(
params
);
}
public
IDPWidget
buildNewsOneTabWidget
(
DPWidgetNewsParams
params
)
{
//创建单列表新闻组件
return
getFactory
().
createNewsOneTab
(
params
);
}
public
void
loadVideoCard
(
DPWidgetVideoCardParams
params
,
IDPWidgetFactory
.
Callback
callback
)
{
getFactory
().
loadVideoCard
(
params
,
callback
);
}
public
void
loadSmallVideoCard
(
DPWidgetVideoCardParams
params
,
IDPWidgetFactory
.
Callback
callback
)
{
getFactory
().
loadSmallVideoCard
(
params
,
callback
);
}
public
void
loadVideoSingleCard
(
DPWidgetVideoSingleCardParams
params
,
IDPWidgetFactory
.
Callback
callback
)
{
getFactory
().
loadVideoSingleCard
(
params
,
callback
);
}
public
void
loadTextChain
(
DPWidgetTextChainParams
params
,
IDPWidgetFactory
.
Callback
callback
)
{
getFactory
().
loadTextChain
(
params
,
callback
);
}
public
void
loadCustomVideoCard
(
DPWidgetVideoCardParams
params
,
IDPWidgetFactory
.
Callback
callback
)
{
getFactory
().
loadCustomVideoCard
(
params
,
callback
);
}
public
void
loadBubble
(
DPWidgetBubbleParams
params
,
IDPWidgetFactory
.
Callback
callback
)
{
getFactory
().
loadBubble
(
params
,
callback
);
}
public
void
loadBanner
(
DPWidgetBannerParams
params
,
IDPWidgetFactory
.
Callback
callback
)
{
getFactory
().
loadBanner
(
params
,
callback
);
}
public
void
loadInnerPush
(
DPWidgetInnerPushParams
params
,
IDPWidgetFactory
.
Callback
callback
)
{
getFactory
().
loadInnerPush
(
params
,
callback
);
}
public
void
loadVideoSingleCard4News
(
DPWidgetVideoSingleCardParams
params
,
IDPWidgetFactory
.
Callback
callback
)
{
getFactory
().
loadVideoSingleCard4News
(
params
,
callback
);
}
public
void
loadNativeNews
(
DPWidgetNewsParams
params
,
IDPNativeData
.
DPNativeDataListener
listener
)
{
getFactory
().
loadNativeNews
(
params
,
listener
);
}
public
void
enterNewsDetail
(
DPWidgetNewsParams
params
,
long
groupId
,
String
data
)
{
getFactory
().
enterNewsDetail
(
params
,
groupId
,
data
);
}
public
void
loadPush
(
DPWidgetNewsParams
params
)
{
getFactory
().
pushNews
(
params
);
}
public
void
uploadLog
(
String
category
,
String
event
,
JSONObject
json
)
{
getFactory
().
uploadLog
(
category
,
event
,
json
);
}
public
void
notifyUserInfo
()
{
//接入红包功能的开发者,在用户登录成功后需要刷新用户信息
// long uid = LoginActivity.getUserId();
// if (uid == 0) {
// return;
// }
// getFactory().notifyUserInfo(new DPUser()
// .setUserId(uid)//必须透传用户uid
// .setName("test_name")//用户昵称,可选
// .setAvatarUrl("xxx")//用户图像,可选
// );
}
private
IDPWidgetFactory
getFactory
()
{
//一定要初始化后才能调用,否则会发生异常问题
return
DPSdk
.
factory
();
}
}
video/app/src/main/java/com/mints/helivideo/ui/fragment/MusicFragment.kt
View file @
d3d81fda
package
com.mints.helivideo.ui.fragment
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.Button
import
android.widget.Toast
import
androidx.annotation.Nullable
import
androidx.fragment.app.Fragment
import
com.bytedance.sdk.dp.*
import
com.mints.helivideo.R
import
com.mints.helivideo.manager.DPHolder
import
com.mints.helivideo.ui.fragment.base.LazyLoadBaseFragment
import
com.mints.helivideo.utils.LogUtil
class
MusicFragment
:
LazyLoadBaseFragment
()
{
private
val
TAG
=
"MusicFragment"
private
var
mIDPWidget
:
IDPWidget
?
=
null
private
var
mDrawFragment
:
Fragment
?
=
null
private
var
mPos
=
0
override
fun
getContentViewLayoutID
()
=
R
.
layout
.
fragment_music
override
fun
initViewsAndEvents
()
{
}
override
fun
onFragmentFirstVisible
()
{
if
(
DPSdk
.
isStartSuccess
())
{
//初始化draw组件
initDrawWidget
()
mDrawFragment
=
mIDPWidget
!!
.
getFragment
()
}
}
private
fun
initDrawWidget
()
{
mIDPWidget
=
DPHolder
.
getInstance
().
buildDrawWidget
(
DPWidgetDrawParams
.
obtain
().
liveAdCodeId
(
"947474066"
).
liveNativeAdCodeId
(
"947474068"
)
.
adOffset
(
0
)
//单位 dp,为 0 时可以不设置
.
quizMode
(
1
)
.
hideClose
(
false
,
null
)
.
listener
(
object
:
IDPDrawListener
()
{
override
fun
onDPRefreshFinish
()
{
LogUtil
.
d
(
TAG
,
"onDPRefreshFinish"
)
}
override
fun
onDPPageChange
(
position
:
Int
)
{
LogUtil
.
d
(
TAG
,
"onDPPageChange: $position"
)
}
override
fun
onDPPageChange
(
position
:
Int
,
map
:
Map
<
String
,
Any
>)
{
if
(
map
==
null
)
{
return
}
mPos
=
position
LogUtil
.
d
(
TAG
,
"onDPPageChange: $position, map = $map"
)
}
override
fun
onCreateQuizView
(
container
:
ViewGroup
):
View
{
val
quizView
:
View
=
LayoutInflater
.
from
(
container
.
context
)
.
inflate
(
R
.
layout
.
media_layout_quiz
,
container
,
false
)
LogUtil
.
d
(
TAG
,
"onCreateQuizView"
)
return
quizView
}
override
fun
onQuizBindData
(
view
:
View
,
options
:
List
<
String
>,
answer
:
Int
,
lastAnswer
:
Int
,
quizHandler
:
IDPQuizHandler
,
feedParamsForCallback
:
Map
<
String
,
Any
>
)
{
super
.
onQuizBindData
(
view
,
options
,
answer
,
lastAnswer
,
quizHandler
,
feedParamsForCallback
)
val
option0
=
view
.
findViewById
<
Button
>(
R
.
id
.
quiz_option0
)
val
option1
=
view
.
findViewById
<
Button
>(
R
.
id
.
quiz_option1
)
val
optionsList
:
MutableList
<
Button
>
=
ArrayList
()
optionsList
.
add
(
option0
)
optionsList
.
add
(
option1
)
for
(
i
in
optionsList
.
indices
)
{
val
right
=
answer
==
i
val
background
:
Int
=
if
(
right
)
R
.
drawable
.
selector_quzi_button_ok
else
R
.
drawable
.
selector_quzi_button_error
val
button
=
optionsList
[
i
]
button
.
text
=
options
[
i
]
button
.
setBackgroundResource
(
R
.
drawable
.
selector_quzi_button_default
)
button
.
setOnClickListener
{
if
(
right
)
{
Toast
.
makeText
(
view
.
context
,
"回答正确"
,
Toast
.
LENGTH_SHORT
).
show
()
}
else
{
Toast
.
makeText
(
view
.
context
,
"回答错误"
,
Toast
.
LENGTH_SHORT
).
show
()
}
for
(
btn
in
optionsList
)
{
btn
.
setBackgroundResource
(
R
.
drawable
.
selector_quzi_button_default
)
}
button
.
setBackgroundResource
(
background
)
quizHandler
.
reportResult
(
i
)
if
(
mIDPWidget
!=
null
)
{
mIDPWidget
!!
.
setCurrentPage
(
mPos
+
1
)
}
}
if
(
lastAnswer
==
i
)
{
button
.
setBackgroundResource
(
background
)
}
}
}
override
fun
onDPVideoPlay
(
map
:
Map
<
String
,
Any
>)
{
LogUtil
.
d
(
TAG
,
"onDPVideoPlay map = $map"
)
}
override
fun
onDPVideoOver
(
map
:
Map
<
String
,
Any
>)
{
LogUtil
.
d
(
TAG
,
"onDPVideoOver map = $map"
)
}
override
fun
onDPVideoCompletion
(
map
:
Map
<
String
,
Any
>)
{
LogUtil
.
d
(
TAG
,
"onDPVideoCompletion map = $map"
)
}
override
fun
onDPClose
()
{
LogUtil
.
d
(
TAG
,
"onDPClose"
)
}
override
fun
onDPReportResult
(
isSucceed
:
Boolean
)
{
LogUtil
.
d
(
TAG
,
"onDPReportResult isSucceed = $isSucceed"
)
}
override
fun
onDPPageStateChanged
(
pageState
:
DPPageState
)
{
LogUtil
.
d
(
TAG
,
"onDPPageStateChanged pageState = $pageState"
)
}
override
fun
onDPReportResult
(
isSucceed
:
Boolean
,
map
:
Map
<
String
,
Any
>)
{
LogUtil
.
d
(
TAG
,
"onDPReportResult isSucceed = $isSucceed, map = $map"
)
}
override
fun
onDPRequestStart
(
@Nullable
map
:
Map
<
String
,
Any
>?)
{
LogUtil
.
d
(
TAG
,
"onDPRequestStart"
)
}
override
fun
onDPRequestSuccess
(
list
:
List
<
Map
<
String
,
Any
>>)
{
if
(
list
==
null
)
{
return
}
for
(
i
in
list
.
indices
)
{
LogUtil
.
d
(
TAG
,
"onDPRequestSuccess i = "
+
i
+
", map = "
+
list
[
i
].
toString
()
)
}
}
override
fun
onDPRequestFail
(
code
:
Int
,
msg
:
String
,
@Nullable
map
:
Map
<
String
,
Any
>?
)
{
if
(
map
==
null
)
{
LogUtil
.
d
(
TAG
,
"onDPRequestFail code = $code, msg = $msg"
)
return
}
LogUtil
.
d
(
TAG
,
"onDPRequestFail code = $code, msg = $msg, map = $map"
)
}
override
fun
onDPClickAuthorName
(
map
:
Map
<
String
,
Any
>)
{
LogUtil
.
d
(
TAG
,
"onDPClickAuthorName map = $map"
)
}
override
fun
onDPClickAvatar
(
map
:
Map
<
String
,
Any
>)
{
LogUtil
.
d
(
TAG
,
"onDPClickAvatar map = $map"
)
}
override
fun
onDPClickComment
(
map
:
Map
<
String
,
Any
>)
{
LogUtil
.
d
(
TAG
,
"onDPClickComment map = $map"
)
}
override
fun
onDPClickLike
(
isLike
:
Boolean
,
map
:
Map
<
String
,
Any
>)
{
LogUtil
.
d
(
TAG
,
"onDPClickLike isLike = $isLike, map = $map"
)
}
override
fun
onDPVideoPause
(
map
:
Map
<
String
,
Any
>)
{
LogUtil
.
d
(
TAG
,
"onDPVideoPause map = $map"
)
}
override
fun
onDPVideoContinue
(
map
:
Map
<
String
,
Any
>)
{
LogUtil
.
d
(
TAG
,
"onDPVideoContinue map = $map"
)
}
override
fun
onDPClickShare
(
map
:
Map
<
String
,
Any
>)
{
LogUtil
.
d
(
TAG
,
"onDPClickShare map = $map"
)
}
}).
adListener
(
object
:
IDPAdListener
()
{
override
fun
onDPAdRequest
(
map
:
Map
<
String
,
Any
>)
{
LogUtil
.
d
(
TAG
,
"onDPAdRequest map = $map"
)
}
override
fun
onDPAdRequestSuccess
(
map
:
Map
<
String
,
Any
>)
{
LogUtil
.
d
(
TAG
,
"onDPAdRequestSuccess map = $map"
)
}
override
fun
onDPAdRequestFail
(
code
:
Int
,
msg
:
String
,
map
:
Map
<
String
,
Any
>)
{
LogUtil
.
d
(
TAG
,
"onDPAdRequestFail map = $map"
)
}
override
fun
onDPAdFillFail
(
map
:
Map
<
String
,
Any
>)
{
LogUtil
.
d
(
TAG
,
"onDPAdFillFail map = $map"
)
}
override
fun
onDPAdShow
(
map
:
Map
<
String
,
Any
>)
{
LogUtil
.
d
(
TAG
,
"onDPAdShow map = $map"
)
}
override
fun
onDPAdPlayStart
(
map
:
Map
<
String
,
Any
>)
{
LogUtil
.
d
(
TAG
,
"onDPAdPlayStart map = $map"
)
}
override
fun
onDPAdPlayPause
(
map
:
Map
<
String
,
Any
>)
{
LogUtil
.
d
(
TAG
,
"onDPAdPlayPause map = $map"
)
}
override
fun
onDPAdPlayContinue
(
map
:
Map
<
String
,
Any
>)
{
LogUtil
.
d
(
TAG
,
"onDPAdPlayContinue map = $map"
)
}
override
fun
onDPAdPlayComplete
(
map
:
Map
<
String
,
Any
>)
{
LogUtil
.
d
(
TAG
,
"onDPAdPlayComplete map = $map"
)
}
override
fun
onDPAdClicked
(
map
:
Map
<
String
,
Any
>)
{
LogUtil
.
d
(
TAG
,
"onDPAdClicked map = $map"
)
}
})
)
}
}
\ No newline at end of file
video/app/src/main/res/drawable/selector_quzi_button_default.xml
0 → 100644
View file @
d3d81fda
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<corners
android:radius=
"8dp"
/>
<solid
android:color=
"#55F5F5F5"
/>
</shape>
\ No newline at end of file
video/app/src/main/res/drawable/selector_quzi_button_error.xml
0 → 100644
View file @
d3d81fda
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<corners
android:radius=
"8dp"
/>
<solid
android:color=
"#BBFF0000"
/>
</shape>
\ No newline at end of file
video/app/src/main/res/drawable/selector_quzi_button_ok.xml
0 → 100644
View file @
d3d81fda
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<corners
android:radius=
"8dp"
/>
<solid
android:color=
"#BB00FF00"
/>
</shape>
\ No newline at end of file
video/app/src/main/res/layout/fragment_music.xml
View file @
d3d81fda
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
</FrameLayout>
\ No newline at end of file
<FrameLayout
android:id=
"@+id/draw_style1_frame"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
</RelativeLayout>
\ No newline at end of file
video/app/src/main/res/layout/media_layout_quiz.xml
0 → 100644
View file @
d3d81fda
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:paddingLeft=
"48dp"
android:paddingRight=
"48dp"
tools:background=
"@color/black"
>
<Button
android:id=
"@+id/quiz_option0"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_above=
"@+id/quiz_option1"
android:layout_centerHorizontal=
"true"
android:layout_marginBottom=
"20dp"
android:background=
"@drawable/selector_quzi_button_default"
tools:text=
"A.心太软"
/>
<Button
android:id=
"@+id/quiz_option1"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_alignParentBottom=
"true"
android:layout_centerHorizontal=
"true"
android:layout_marginBottom=
"50dp"
android:background=
"@drawable/selector_quzi_button_default"
tools:text=
"B.伤心太平洋"
/>
</RelativeLayout>
\ No newline at end of file
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