package com.douyin;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.Gravity;
import com.aliyun.vodplayer.media.AliyunVodPlayer;
import com.aliyun.vodplayer.media.IAliyunVodPlayer;
import com.github.rubensousa.gravitysnaphelper.GravityPagerSnapHelper;
import com.github.rubensousa.gravitysnaphelper.GravitySnapHelper;
import java.util.ArrayList;
import java.util.List;
import butterknife.ButterKnife;
import butterknife.InjectView;
/**
* Created by bao on 2018/5/28.
*/
public class MainActivity extends BaseActivity {
@InjectView(R.id.recycler_view)
RecyclerView recyclerView;
//当前pos,防止没滑动过去重新加载视频
private int current_position = -1;
//停止拖动为true
private boolean isstop_scroll = true;
@Override
protected int setContentViewResId() {
return R.layout.activity_main;
}
@Override
public void init() {
String videolist[] = {"http://ksy.fffffive.com/mda-hinp1ik37b0rt1mj/mda-hinp1ik37b0rt1mj.mp4",
"http://ksy.fffffive.com/mda-himtqzs2un1u8x2v/mda-himtqzs2un1u8x2v.mp4",
"http://ksy.fffffive.com/mda-hiw5zixc1ghpgrhn/mda-hiw5zixc1ghpgrhn.mp4",
"http://ksy.fffffive.com/mda-hiw61ic7i4qkcvmx/mda-hiw61ic7i4qkcvmx.mp4",
"http://ksy.fffffive.com/mda-hihvysind8etz7ga/mda-hihvysind8etz7ga.mp4",
"http://ksy.fffffive.com/mda-hiw60i3kczgum0av/mda-hiw60i3kczgum0av.mp4",
"http://ksy.fffffive.com/mda-hidnzn5r61qwhxp4/mda-hidnzn5r61qwhxp4.mp4",
"http://ksy.fffffive.com/mda-he1zy3rky0rwrf60/mda-he1zy3rky0rwrf60.mp4",
"http://ksy.fffffive.com/mda-hh6cxd0dqjqcszcj/mda-hh6cxd0dqjqcszcj.mp4",
"http://ksy.fffffive.com/mda-hifsrhtqjn8jxeha/mda-hifsrhtqjn8jxeha.mp4",
"http://ksy.fffffive.com/mda-hics799vjrg0w5az/mda-hics799vjrg0w5az.mp4",
"http://ksy.fffffive.com/mda-hfshah045smezhtf/mda-hfshah045smezhtf.mp4",
"http://ksy.fffffive.com/mda-hh4mbturm902j7wi/mda-hh4mbturm902j7wi.mp4",
"http://ksy.fffffive.com/mda-hiwxzficjivwmsch/mda-hiwxzficjivwmsch.mp4",
"http://ksy.fffffive.com/mda-hhug2p7hfbhnv40r/mda-hhug2p7hfbhnv40r.mp4",
"http://ksy.fffffive.com/mda-hieuuaei6cufye2c/mda-hieuuaei6cufye2c.mp4",
"http://ksy.fffffive.com/mda-hibhufepe5m1tfw1/mda-hibhufepe5m1tfw1.mp4",
"http://ksy.fffffive.com/mda-hhzeh4c05ivmtiv7/mda-hhzeh4c05ivmtiv7.mp4",
"http://ksy.fffffive.com/mda-hfrigfn2y9jvzm72/mda-hfrigfn2y9jvzm72.mp4",
"http://ksy.fffffive.com/mda-himek207gvvqg3wq/mda-himek207gvvqg3wq.mp4"};
String imglist[] = {"http://ksy.fffffive.com/mda-hinp1ik37b0rt1mj/mda-hinp1ik37b0rt1mj.jpg",
"http://ksy.fffffive.com/mda-himtqzs2un1u8x2v/mda-himtqzs2un1u8x2v.jpg",
"http://ksy.fffffive.com/mda-hiw5zixc1ghpgrhn/mda-hiw5zixc1ghpgrhn.jpg",
"http://ksy.fffffive.com/mda-hiw61ic7i4qkcvmx/mda-hiw61ic7i4qkcvmx.jpg",
"http://ksy.fffffive.com/mda-hihvysind8etz7ga/mda-hihvysind8etz7ga.jpg",
"http://ksy.fffffive.com/mda-hiw60i3kczgum0av/mda-hiw60i3kczgum0av.jpg",
"http://ksy.fffffive.com/mda-hidnzn5r61qwhxp4/mda-hidnzn5r61qwhxp4.jpg",
"http://ksy.fffffive.com/mda-he1zy3rky0rwrf60/mda-he1zy3rky0rwrf60.jpg",
"http://ksy.fffffive.com/mda-hh6cxd0dqjqcszcj/mda-hh6cxd0dqjqcszcj.jpg",
"http://ksy.fffffive.com/mda-hifsrhtqjn8jxeha/mda-hifsrhtqjn8jxeha.jpg",
"http://ksy.fffffive.com/mda-hics799vjrg0w5az/mda-hics799vjrg0w5az.jpg",
"http://ksy.fffffive.com/mda-hfshah045smezhtf/mda-hfshah045smezhtf.jpg",
"http://ksy.fffffive.com/mda-hh4mbturm902j7wi/mda-hh4mbturm902j7wi.jpg",
"http://ksy.fffffive.com/mda-hiwxzficjivwmsch/mda-hiwxzficjivwmsch.jpg",
"http://ksy.fffffive.com/mda-hhug2p7hfbhnv40r/mda-hhug2p7hfbhnv40r.jpg",
"http://ksy.fffffive.com/mda-hieuuaei6cufye2c/mda-hieuuaei6cufye2c.jpg",
"http://ksy.fffffive.com/mda-hibhufepe5m1tfw1/mda-hibhufepe5m1tfw1.jpg",
"http://ksy.fffffive.com/mda-hhzeh4c05ivmtiv7/mda-hhzeh4c05ivmtiv7.jpg",
"http://ksy.fffffive.com/mda-hfrigfn2y9jvzm72/mda-hfrigfn2y9jvzm72.jpg",
"http://ksy.fffffive.com/mda-himek207gvvqg3wq/mda-himek207gvvqg3wq.jpg"};
videoinit();
final List<VideoBean> list = new ArrayList<>();
for (int i = 0; i < imglist.length; i++) {
VideoBean bean = new VideoBean();
bean.setVideoid(i);
bean.setVideoimg(imglist[i]);
bean.setVideourl(videolist[i]);
list.add(bean);
}
//初始化RecyclerView
//创建LinearLayoutManager 对象 这里使用LinearLayoutManager 是线性布局的意思
LinearLayoutManager layoutmanager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
//设置RecyclerView 布局
recyclerView.setLayoutManager(layoutmanager);
//设置Adapter
final VideoAdapter adapter = new VideoAdapter(list);
recyclerView.setAdapter(adapter);
//item切换监听
//向下滑动,可监听到最后一个
new GravityPagerSnapHelper(Gravity.BOTTOM, false, new GravitySnapHelper.SnapListener() {
@Override
public void onSnap(final int positions) {
//切换Item之后的操作
Log.e("bottom", "" + positions);
if (isstop_scroll == true) {
if (positions == list.size() - 1) {
if (current_position != positions) {
adapter.setsnaphelper(positions);
adapter.notifyDataSetChanged();
current_position = positions;
}
}
}
}
}).attachToRecyclerView(recyclerView);
//向上滑动,可监听到0
new GravityPagerSnapHelper(Gravity.TOP, false, new GravitySnapHelper.SnapListener() {
@Override
public void onSnap(final int positions) {
//切换Item之后的操作
Log.e("top", "" + positions);
if (isstop_scroll == true) {
if (current_position != positions) {
adapter.setsnaphelper(positions);
adapter.notifyDataSetChanged();
current_position = positions;
}
}
}
}).attachToRecyclerView(recyclerView);
//item切换监听
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
switch (newState) {
case 0:
isstop_scroll = true;
Log.e("--------------", newState + "recyclerview已经停止滚动");
break;
case 1:
isstop_scroll = false;
Log.e("--------------", newState + "recyclerview正在被拖拽");
break;
case 2:
isstop_scroll = false;
Log.e("--------------", newState + "recyclerview正在依靠惯性滚动");
break;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Android 仿写抖音视频切换功能.rar
共77个文件
xml:40个
java:7个
png:5个
需积分: 24 8 下载量 98 浏览量
2019-07-10
17:56:42
上传
评论
收藏 6.71MB RAR 举报
温馨提示
Android 仿写抖音视频APP端清淅度切换功能,初始化播放器(只需调用一次即可,建议在application中初始化),在本例子中,滑屏时SurfaceView出现白屏和黑屏问题得到了解决,准备成功之后可以调用start方法开始播放,播放正常完成时触发,视频清晰度切换成功后触发,视频清晰度切换失败时触发。
资源推荐
资源详情
资源评论
收起资源包目录
douyinvideo.rar (77个子文件)
codesc.net
抖音视频切换
douyin
gradlew.bat 2KB
gradlew 5KB
gradle.properties 872B
.gradle
2.4
taskArtifacts
fileHashes.bin 139KB
cache.properties.lock 17B
taskArtifacts.bin 68KB
fileSnapshots.bin 1.16MB
cache.properties 31B
outputFileStates.bin 20KB
app
proguard-rules.pro 670B
src
test
java
com
douyin
ExampleUnitTest.java 317B
androidTest
java
com
douyin
ApplicationTest.java 353B
main
res
menu
menu_main.xml 367B
mipmap-xxxhdpi
ic_launcher.png 10KB
drawable
mipmap-hdpi
ic_launcher.png 3KB
values
colors.xml 214B
strings.xml 126B
styles.xml 722B
dimens.xml 259B
mipmap-xxhdpi
ic_launcher.png 8KB
mipmap-mdpi
ic_launcher.png 2KB
mipmap-xhdpi
ic_launcher.png 5KB
layout
content_main.xml 828B
activity_main.xml 655B
adapter_video.xml 794B
values-v21
styles.xml 355B
values-w820dp
dimens.xml 364B
java
com
douyin
Myappcation.java 560B
VideoAdapter.java 7KB
VideoBean.java 655B
MainActivity.java 9KB
BaseActivity.java 2KB
AndroidManifest.xml 968B
app.iml 11KB
.gitignore 8B
build.gradle 1KB
libs
AlivcPlayer-3.4.2.aar 6.06MB
AliyunVodPlayer-3.4.2.aar 273KB
AlivcReporter-1.1.aar 25KB
AliyunVodPlayerView-3.4.2.aar 184KB
gradle
wrapper
gradle-wrapper.jar 49KB
gradle-wrapper.properties 236B
.idea
gradle.xml 608B
runConfigurations.xml 564B
misc.xml 2KB
vcs.xml 164B
.name 6B
copyright
profiles_settings.xml 76B
modules.xml 349B
encodings.xml 159B
compiler.xml 686B
workspace.xml 145KB
libraries
support_annotations_25_3_1.xml 535B
recyclerview_v7_25_3_1.xml 799B
AliyunVodPlayer_3_4_2_.xml 393B
support_v4_25_3_1.xml 420B
support_vector_drawable_25_3_1.xml 660B
AlivcReporter_1_1_.xml 381B
picasso_2_5_2.xml 522B
support_core_utils_25_3_1.xml 817B
animated_vector_drawable_25_3_1.xml 665B
gravitysnaphelper_1_5.xml 646B
butterknife_6_1_0.xml 532B
design_25_3_1.xml 745B
support_compat_25_3_1.xml 793B
support_core_ui_25_3_1.xml 799B
appcompat_v7_25_3_1.xml 781B
support_media_compat_25_3_1.xml 829B
transition_25_3_1.xml 595B
support_fragment_25_3_1.xml 805B
AlivcPlayer_3_4_2_.xml 381B
douyin.iml 937B
.gitignore 98B
local.properties 518B
settings.gradle 16B
build
intermediates
dex-cache
cache.xml 2KB
build.gradle 521B
共 77 条
- 1
资源评论
weixin_39841848
- 粉丝: 512
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功