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
cfb783b7
Commit
cfb783b7
authored
Aug 09, 2023
by
jyx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化添加广告导致下标错误问题,添加平滑滚动
parent
3db770b5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
27 deletions
+33
-27
DrawExpressManager.kt
...in/java/com/mints/helivideo/ad/draw/DrawExpressManager.kt
+2
-18
SuperShortVideoView.java
...ava/com/mints/helivideo/video/tx/SuperShortVideoView.java
+31
-9
No files found.
video/app/src/main/java/com/mints/helivideo/ad/draw/DrawExpressManager.kt
View file @
cfb783b7
...
...
@@ -138,7 +138,6 @@ class DrawExpressManager {
}
mTTFeedAd
=
it
[
0
]
isLoadSuccess
=
2
showAd
()
}
}
...
...
@@ -228,30 +227,15 @@ class DrawExpressManager {
Log
.
i
(
TAG
,
"express dislike 点击了取消"
)
}
})
isLoadSuccess
=
2
it
.
adView
?.
let
{
view
->
if
(
view
.
parent
!=
null
)
{
(
view
.
parent
as
ViewGroup
).
removeView
(
view
)
}
frameLayout
?.
addView
(
view
)
}
// val view: FrameLayout = frameLayout!!
// val frameLayout = FrameLayout(MintsApplication.getContext())
// frameLayout.addView(view)
viewCache
.
add
(
frameLayout
)
// mExpressAdCallback?.let {
// if (it.renderSuccess(viewCache.lastElement())) {
// LogUtil.d(
// TAG,
// "gromore信息流 onRenderSuccess -> showAd->$isShowAd \n adcode->$adcode ecpm->$ecpm"
// )
//
// isLoadSuccess = 0
// isShowAd = true
// adShowTime = System.currentTimeMillis()
// }
// }
// mExpressAdCallback = null
}
override
fun
onRenderFail
(
p0
:
View
?,
p1
:
String
?,
p2
:
Int
)
{
...
...
video/app/src/main/java/com/mints/helivideo/video/tx/SuperShortVideoView.java
View file @
cfb783b7
...
...
@@ -22,6 +22,7 @@ import com.mints.helivideo.mvp.model.VedioBean;
import
com.mints.helivideo.mvp.model.VideoMultiItemEntity
;
import
com.mints.helivideo.video.tx.adapter.TxVideoAdapter
;
import
java.lang.reflect.Field
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -83,7 +84,7 @@ public class SuperShortVideoView extends RelativeLayout {
mSnapHelper
.
attachToRecyclerView
(
mRecyclerView
);
mAdapter
=
new
TxVideoAdapter
();
mAdapter
.
setNewInstance
(
mList
);
mAdapter
.
setOnVideoEndListener
(()
->
onItemClick
(
mCurrentPosition
+
1
));
mAdapter
.
setOnVideoEndListener
(()
->
onItemClick
(
mCurrentPosition
+
1
,
true
));
mLayoutManager
=
new
LinearLayoutManager
(
getContext
(),
LinearLayoutManager
.
VERTICAL
,
false
)
{
@Override
protected
int
getExtraLayoutSpace
(
RecyclerView
.
State
state
)
{
...
...
@@ -117,9 +118,9 @@ public class SuperShortVideoView extends RelativeLayout {
if
(
position
==
mCurrentPosition
||
position
==
RecyclerView
.
NO_POSITION
)
return
;
Log
.
i
(
TAG
,
"[SCROLL_STATE_IDLE] mLastPositionInIDLE "
+
mLastPositionInIDLE
+
" position "
+
position
);
mCurrentPosition
=
position
;
addAdView
(
position
);
onPageSelectedMethod
(
position
);
if
(
isLuckPosition
(
position
))
{
...
...
@@ -220,16 +221,37 @@ public class SuperShortVideoView extends RelativeLayout {
}
public
void
onItemClick
(
final
int
position
)
{
onItemClick
(
position
,
false
);
}
public
void
onItemClick
(
final
int
position
,
boolean
isVideoEnd
)
{
if
(
mList
==
null
||
position
>=
mList
.
size
())
return
;
mRecyclerView
.
scrollToPosition
(
position
);
mRecyclerView
.
post
(()
->
{
Log
.
i
(
TAG
,
"onItemClick"
);
mCurrentPosition
=
position
;
if
(
isVideoEnd
)
{
changeLayoutPosition
(
position
);
// 执行 onScrollListener
mRecyclerView
.
smoothScrollToPosition
(
position
);
}
else
{
mRecyclerView
.
scrollToPosition
(
position
);
mRecyclerView
.
post
(()
->
{
Log
.
i
(
TAG
,
"onItemClick"
);
mCurrentPosition
=
position
;
addAdView
(
mCurrentPosition
);
onPageSelectedMethod
(
position
);
});
}
}
addAdView
(
mCurrentPosition
);
onPageSelectedMethod
(
position
);
});
private
void
changeLayoutPosition
(
int
position
)
{
try
{
Class
<
LinearLayoutManager
>
lm
=
LinearLayoutManager
.
class
;
Field
mPendingScrollPosition
=
lm
.
getDeclaredField
(
"mPendingScrollPosition"
);
mPendingScrollPosition
.
setAccessible
(
true
);
mPendingScrollPosition
.
set
(
mLayoutManager
,
position
);
}
catch
(
NoSuchFieldException
|
IllegalAccessException
e
)
{
e
.
printStackTrace
();
}
}
public
List
<
VideoMultiItemEntity
>
getData
()
{
...
...
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