├── .gitignore ├── .idea ├── caches │ └── build_file_checksums.ser ├── codeStyles │ └── Project.xml ├── gradle.xml ├── misc.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── Screenshot_gif ├── gif1.gif ├── gif2.gif └── gif3.gif ├── app-debug.apk ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── example │ │ └── administrator │ │ └── douyin │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── administrator │ │ │ └── douyin │ │ │ ├── FullWindowVideoView.java │ │ │ ├── Love.java │ │ │ ├── Love2.kt │ │ │ ├── MainActivity.java │ │ │ ├── MyLayoutManager.java │ │ │ ├── MyLayoutManager2.kt │ │ │ └── OnViewPagerListener.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ ├── circle_big_red.xml │ │ ├── circle_red.xml │ │ ├── cirque_gray.xml │ │ ├── echelon_bg.xml │ │ ├── ic_launcher_background.xml │ │ └── play_arrow.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ └── item_view_pager.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── add_bg.png │ │ ├── add_icon.png │ │ ├── header_icon_1.jpg │ │ ├── header_icon_2.jpeg │ │ ├── header_icon_3.jpeg │ │ ├── header_icon_4.jpg │ │ ├── heart_icon.png │ │ ├── ic_launcher.png │ │ ├── ic_launcher_round.png │ │ ├── ic_live_profile_paly.png │ │ ├── icon_home_like_after.png │ │ ├── icon_home_like_before.png │ │ ├── icon_storyhome_open.png │ │ ├── img_video_1.png │ │ ├── img_video_2.png │ │ ├── img_video_3.png │ │ ├── img_video_4.png │ │ ├── img_video_5.png │ │ ├── img_video_6.png │ │ ├── img_video_7.png │ │ ├── img_video_8.png │ │ ├── msg_icon.png │ │ ├── scan.png │ │ ├── search_icon.png │ │ ├── share_icon.png │ │ └── three_pointer.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── raw │ │ ├── video_1.mp4 │ │ ├── video_2.mp4 │ │ ├── video_3.mp4 │ │ ├── video_4.mp4 │ │ ├── video_5.mp4 │ │ ├── video_6.mp4 │ │ ├── video_7.mp4 │ │ └── video_8.mp4 │ │ ├── values-v19 │ │ └── styles.xml │ │ ├── values-v21 │ │ └── styles.xml │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── example │ └── administrator │ └── douyin │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/libraries 5 | /.idea/modules.xml 6 | /.idea/workspace.xml 7 | .DS_Store 8 | /build 9 | /captures 10 | .externalNativeBuild 11 | -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 31 | 32 | 33 | 34 | 35 | 36 | 38 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DouyinDemo 2 | 仿抖音上下滑动播放视频demo 3 | ### 4 | 效果图 5 | ### 6 | ![gif](https://github.com/PangHaHa12138/DouyinDemo/blob/master/Screenshot_gif/gif3.gif) 7 | ### 8 | ![gif](https://github.com/PangHaHa12138/DouyinDemo/blob/master/Screenshot_gif/gif2.gif) 9 | ### 10 | ![gif](https://github.com/PangHaHa12138/DouyinDemo/blob/master/Screenshot_gif/gif1.gif) 11 | 12 | -------------------------------------------------------------------------------- /Screenshot_gif/gif1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/Screenshot_gif/gif1.gif -------------------------------------------------------------------------------- /Screenshot_gif/gif2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/Screenshot_gif/gif2.gif -------------------------------------------------------------------------------- /Screenshot_gif/gif3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/Screenshot_gif/gif3.gif -------------------------------------------------------------------------------- /app-debug.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app-debug.apk -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | 4 | android { 5 | compileSdkVersion 27 6 | defaultConfig { 7 | applicationId "com.example.administrator.douyin" 8 | minSdkVersion 15 9 | targetSdkVersion 27 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | implementation fileTree(dir: 'libs', include: ['*.jar']) 24 | implementation 'com.android.support:appcompat-v7:27.1.1' 25 | implementation 'com.android.support.constraint:constraint-layout:1.1.2' 26 | implementation 'com.android.support:recyclerview-v7:27+' 27 | /*第三方库*/ 28 | implementation 'de.hdodenhof:circleimageview:2.2.0' 29 | testImplementation 'junit:junit:4.12' 30 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 31 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 32 | compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 33 | } 34 | repositories { 35 | mavenCentral() 36 | } 37 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/example/administrator/douyin/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.example.administrator.douyin; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.example.administrator.douyin", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/administrator/douyin/FullWindowVideoView.java: -------------------------------------------------------------------------------- 1 | package com.example.administrator.douyin; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.widget.VideoView; 6 | 7 | public class FullWindowVideoView extends VideoView { 8 | 9 | public FullWindowVideoView(Context context) { 10 | super(context); 11 | } 12 | 13 | public FullWindowVideoView(Context context, AttributeSet attrs) { 14 | super(context, attrs); 15 | } 16 | 17 | public FullWindowVideoView(Context context, AttributeSet attrs, int defStyleAttr) { 18 | super(context, attrs, defStyleAttr); 19 | } 20 | 21 | @Override 22 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 23 | // 其实就是在这里做了一些处理。 24 | int width = getDefaultSize(0, widthMeasureSpec); 25 | int height = getDefaultSize(0, heightMeasureSpec); 26 | setMeasuredDimension(width, height); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/administrator/douyin/Love.java: -------------------------------------------------------------------------------- 1 | package com.example.administrator.douyin; 2 | 3 | 4 | import android.animation.Animator; 5 | import android.animation.AnimatorListenerAdapter; 6 | import android.animation.AnimatorSet; 7 | import android.animation.ObjectAnimator; 8 | import android.animation.TimeInterpolator; 9 | import android.content.Context; 10 | import android.graphics.Canvas; 11 | import android.support.annotation.Nullable; 12 | import android.util.AttributeSet; 13 | import android.view.MotionEvent; 14 | import android.view.View; 15 | import android.view.animation.LinearInterpolator; 16 | import android.widget.ImageView; 17 | import android.widget.RelativeLayout; 18 | import android.widget.Toast; 19 | 20 | import java.util.Random; 21 | 22 | public class Love extends RelativeLayout { 23 | private Context mContext; 24 | float[] num = {-30, -20, 0, 20, 30};//随机心形图片角度 25 | 26 | public Love(Context context) { 27 | super(context); 28 | initView(context); 29 | } 30 | 31 | public Love(Context context, @Nullable AttributeSet attrs) { 32 | super(context, attrs); 33 | initView(context); 34 | } 35 | 36 | public Love(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { 37 | super(context, attrs, defStyleAttr); 38 | initView(context); 39 | } 40 | 41 | private void initView(Context context) { 42 | mContext = context; 43 | } 44 | 45 | @Override 46 | public boolean onTouchEvent(MotionEvent event) { 47 | 48 | final ImageView imageView = new ImageView(mContext); 49 | LayoutParams params = new LayoutParams(300, 300); 50 | params.leftMargin = (int) event.getX() - 150; 51 | params.topMargin = (int) event.getY() - 300; 52 | imageView.setImageDrawable(getResources().getDrawable(R.mipmap.icon_home_like_after)); 53 | imageView.setLayoutParams(params); 54 | addView(imageView); 55 | 56 | AnimatorSet animatorSet = new AnimatorSet(); 57 | animatorSet.play(scale(imageView, "scaleX", 2f, 0.9f, 100, 0)) 58 | .with(scale(imageView, "scaleY", 2f, 0.9f, 100, 0)) 59 | .with(rotation(imageView, 0, 0, num[new Random().nextInt(4)])) 60 | .with(alpha(imageView, 0, 1, 100, 0)) 61 | .with(scale(imageView, "scaleX", 0.9f, 1, 50, 150)) 62 | .with(scale(imageView, "scaleY", 0.9f, 1, 50, 150)) 63 | .with(translationY(imageView, 0, -600, 800, 400)) 64 | .with(alpha(imageView, 1, 0, 300, 400)) 65 | .with(scale(imageView, "scaleX", 1, 3f, 700, 400)) 66 | .with(scale(imageView, "scaleY", 1, 3f, 700, 400)); 67 | 68 | animatorSet.start(); 69 | animatorSet.addListener(new AnimatorListenerAdapter() { 70 | @Override 71 | public void onAnimationEnd(Animator animation) { 72 | super.onAnimationEnd(animation); 73 | removeViewInLayout(imageView); 74 | } 75 | }); 76 | return super.onTouchEvent(event); 77 | } 78 | 79 | public static ObjectAnimator scale(View view, String propertyName, float from, float to, long time, long delayTime) { 80 | ObjectAnimator translation = ObjectAnimator.ofFloat(view 81 | , propertyName 82 | , from, to); 83 | translation.setInterpolator(new LinearInterpolator()); 84 | translation.setStartDelay(delayTime); 85 | translation.setDuration(time); 86 | return translation; 87 | } 88 | 89 | public static ObjectAnimator translationX(View view, float from, float to, long time, long delayTime) { 90 | ObjectAnimator translation = ObjectAnimator.ofFloat(view 91 | , "translationX" 92 | , from, to); 93 | translation.setInterpolator(new LinearInterpolator()); 94 | translation.setStartDelay(delayTime); 95 | translation.setDuration(time); 96 | return translation; 97 | } 98 | 99 | public static ObjectAnimator translationY(View view, float from, float to, long time, long delayTime) { 100 | ObjectAnimator translation = ObjectAnimator.ofFloat(view 101 | , "translationY" 102 | , from, to); 103 | translation.setInterpolator(new LinearInterpolator()); 104 | translation.setStartDelay(delayTime); 105 | translation.setDuration(time); 106 | return translation; 107 | } 108 | 109 | public static ObjectAnimator alpha(View view, float from, float to, long time, long delayTime) { 110 | ObjectAnimator translation = ObjectAnimator.ofFloat(view 111 | , "alpha" 112 | , from, to); 113 | translation.setInterpolator(new LinearInterpolator()); 114 | translation.setStartDelay(delayTime); 115 | translation.setDuration(time); 116 | return translation; 117 | } 118 | 119 | public static ObjectAnimator rotation(View view, long time, long delayTime, float... values) { 120 | ObjectAnimator rotation = ObjectAnimator.ofFloat(view, "rotation", values); 121 | rotation.setDuration(time); 122 | rotation.setStartDelay(delayTime); 123 | rotation.setInterpolator(new TimeInterpolator() { 124 | @Override 125 | public float getInterpolation(float input) { 126 | return input; 127 | } 128 | }); 129 | return rotation; 130 | } 131 | } 132 | 133 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/administrator/douyin/Love2.kt: -------------------------------------------------------------------------------- 1 | package com.example.administrator.douyin 2 | 3 | import android.animation.Animator 4 | import android.animation.AnimatorListenerAdapter 5 | import android.animation.AnimatorSet 6 | import android.animation.ObjectAnimator 7 | import android.animation.TimeInterpolator 8 | import android.content.Context 9 | import android.os.SystemClock 10 | import android.util.AttributeSet 11 | import android.view.MotionEvent 12 | import android.view.View 13 | import android.view.animation.LinearInterpolator 14 | import android.widget.ImageView 15 | import android.widget.RelativeLayout 16 | import java.util.* 17 | 18 | 19 | /** 20 | * information:仿抖音点赞功能 21 | */ 22 | 23 | class Love2(context: Context) : RelativeLayout(context) { 24 | var mContext: Context? = null 25 | //动画中随机❤的旋转角度 26 | var num = floatArrayOf(-35f, -25f, 0f, 25f, 35f) 27 | 28 | //用来判断是否是连续的点击事件 29 | private val mHits = LongArray(3) 30 | 31 | constructor(context: Context, attrs: AttributeSet) : this(context) { 32 | mContext = context 33 | } 34 | 35 | 36 | override fun onTouchEvent(event: MotionEvent?): Boolean { 37 | 38 | System.arraycopy(mHits, 1, mHits, 0, mHits.size - 1) 39 | mHits[mHits.size - 1] = SystemClock.uptimeMillis() 40 | 41 | //用这个来判断是否是3击事件,判断数组中pos=2的点击事件的时间与数组中pos=0的点击事件的时间差值是否小于500,若是小于500认为是3击事件,这时需要绘制爱心图片 42 | if (mHits[0] >= (SystemClock.uptimeMillis() - 500)) { 43 | //点击是触发心形的图片add到整个view中,然后执行动画 44 | 45 | //有连续触摸的时候,创建一个展示心形的图片 46 | var iv: ImageView = ImageView(mContext) 47 | 48 | //设置展示的位置,需要在手指触摸的位置上方,即触摸点是心形的右下角的位置 49 | var lp: LayoutParams = LayoutParams(300, 300) 50 | lp.leftMargin = (event?.x!! - 150F).toInt() 51 | lp.topMargin = (event?.y!! - 300F).toInt() 52 | //设置图片资源 53 | iv.setImageDrawable(resources.getDrawable(R.mipmap.icon_home_like_after)) 54 | iv.layoutParams = lp 55 | 56 | //把IV添加到父布局当中 57 | addView(iv) 58 | 59 | //设置控件的动画 60 | var animatorSet: AnimatorSet = AnimatorSet() 61 | animatorSet.play( 62 | //缩放动画,X轴2倍缩小至0.9倍 63 | scaleAni(iv, "scaleX", 2f, 0.9f, 100, 0)) 64 | //缩放动画,Y轴2倍缩放至0.9倍 65 | .with(scaleAni(iv, "scaleY", 2f, 0.9f, 100, 0)) 66 | //旋转动画,随机旋转角 67 | .with(rotation(iv, 0, 0, num[Random().nextInt(4)])) 68 | //渐变透明动画,透明度从0-1 69 | .with(alphaAni(iv, 0F, 1F, 100, 0)) 70 | //缩放动画,X轴0.9倍缩小至 71 | .with(scaleAni(iv, "scaleX", 0.9f, 1F, 50, 150)) 72 | //缩放动画,Y轴0.9倍缩放至 73 | .with(scaleAni(iv, "scaleY", 0.9f, 1F, 50, 150)) 74 | //位移动画,Y轴从0上移至600 75 | .with(translationY(iv, 0F, -600F, 800, 400)) 76 | //透明动画,从1-0 77 | .with(alphaAni(iv, 1F, 0F, 300, 400)) 78 | //缩放动画,X轴1至3倍 79 | .with(scaleAni(iv, "scaleX", 1F, 3f, 700, 400)) 80 | //缩放动画,Y轴1至3倍 81 | .with(scaleAni(iv, "scaleY", 1F, 3f, 700, 400)) 82 | 83 | 84 | //开始动画 85 | animatorSet.start() 86 | //设置动画结束监听 87 | animatorSet.addListener(object : AnimatorListenerAdapter() { 88 | override fun onAnimationEnd(animation: Animator?) { 89 | super.onAnimationEnd(animation) 90 | 91 | //当动画结束以后,需要把控件从父布局移除 92 | removeViewInLayout(iv) 93 | } 94 | }) 95 | 96 | } 97 | 98 | return super.onTouchEvent(event) 99 | 100 | } 101 | 102 | 103 | fun scaleAni(view: View, propertyName: String, from: Float, to: Float, time: Long, delayTime: Long): ObjectAnimator { 104 | val ani: ObjectAnimator = ObjectAnimator.ofFloat(view, propertyName, from, to) 105 | ani.interpolator = LinearInterpolator() 106 | ani.startDelay = delayTime 107 | ani.duration = time 108 | return ani 109 | } 110 | 111 | fun translationX(view: View, from: Float, to: Float, time: Long, delayTime: Long): ObjectAnimator { 112 | val ani: ObjectAnimator = ObjectAnimator.ofFloat(view, "translationX", from, to) 113 | ani.interpolator = LinearInterpolator() 114 | ani.startDelay = delayTime 115 | ani.duration = time 116 | return ani 117 | } 118 | 119 | fun translationY(view: View, from: Float, to: Float, time: Long, delayTime: Long): ObjectAnimator { 120 | val ani: ObjectAnimator = ObjectAnimator.ofFloat(view, "translationY", from, to) 121 | ani.interpolator = LinearInterpolator() 122 | ani.startDelay = delayTime 123 | ani.duration = time 124 | return ani 125 | } 126 | 127 | fun alphaAni(view: View, from: Float, to: Float, time: Long, delayTime: Long): ObjectAnimator { 128 | val ani = ObjectAnimator.ofFloat(view, "alpha", from, to) 129 | ani.interpolator = LinearInterpolator() 130 | ani.startDelay = delayTime 131 | ani.duration = time 132 | return ani 133 | } 134 | 135 | fun rotation(view: View, time: Long, delayTime: Long, vararg values: Float): ObjectAnimator { 136 | val ani = ObjectAnimator.ofFloat(view, "rotation", *values) 137 | ani.duration = time 138 | ani.startDelay = delayTime 139 | ani.interpolator = TimeInterpolator { input -> input } 140 | return ani 141 | } 142 | 143 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/administrator/douyin/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.administrator.douyin; 2 | 3 | import android.annotation.TargetApi; 4 | import android.content.Context; 5 | import android.media.MediaPlayer; 6 | import android.net.Uri; 7 | import android.os.Build; 8 | import android.os.Bundle; 9 | import android.support.v7.app.AppCompatActivity; 10 | import android.support.v7.widget.OrientationHelper; 11 | import android.support.v7.widget.RecyclerView; 12 | import android.util.Log; 13 | import android.view.LayoutInflater; 14 | import android.view.View; 15 | import android.view.ViewGroup; 16 | import android.widget.ImageView; 17 | import android.widget.RelativeLayout; 18 | import android.widget.VideoView; 19 | 20 | 21 | public class MainActivity extends AppCompatActivity { 22 | private static final String TAG = "douyin"; 23 | private RecyclerView mRecyclerView; 24 | private MyAdapter mAdapter; 25 | MyLayoutManager2 myLayoutManager; 26 | 27 | @Override 28 | protected void onCreate(Bundle savedInstanceState) { 29 | super.onCreate(savedInstanceState); 30 | setContentView(R.layout.activity_main); 31 | initView(); 32 | initListener(); 33 | } 34 | 35 | private void initView() { 36 | mRecyclerView = findViewById(R.id.recycler); 37 | myLayoutManager = new MyLayoutManager2(this, OrientationHelper.VERTICAL, false); 38 | 39 | mAdapter = new MyAdapter(this); 40 | mRecyclerView.setLayoutManager(myLayoutManager); 41 | mRecyclerView.setAdapter(mAdapter); 42 | 43 | } 44 | 45 | private void initListener() { 46 | myLayoutManager.setOnViewPagerListener(new OnViewPagerListener() { 47 | @Override 48 | public void onInitComplete() { 49 | 50 | } 51 | 52 | @Override 53 | public void onPageRelease(boolean isNext, int position) { 54 | Log.e(TAG, "释放位置:" + position + " 下一页:" + isNext); 55 | int index = 0; 56 | if (isNext) { 57 | index = 0; 58 | } else { 59 | index = 1; 60 | } 61 | releaseVideo(index); 62 | } 63 | 64 | @Override 65 | public void onPageSelected(int position, boolean bottom) { 66 | Log.e(TAG, "选择位置:" + position + " 下一页:" + bottom); 67 | 68 | playVideo(0); 69 | } 70 | }); 71 | } 72 | 73 | class MyAdapter extends RecyclerView.Adapter { 74 | private int[] imgs = {R.mipmap.img_video_1, R.mipmap.img_video_2, R.mipmap.img_video_3, R.mipmap.img_video_4, R.mipmap.img_video_5, R.mipmap.img_video_6, R.mipmap.img_video_7, R.mipmap.img_video_8}; 75 | private int[] videos = {R.raw.video_1, R.raw.video_2, R.raw.video_3, R.raw.video_4, R.raw.video_5, R.raw.video_6, R.raw.video_7, R.raw.video_8}; 76 | private int index = 0; 77 | private Context mContext; 78 | 79 | public MyAdapter(Context context) { 80 | this.mContext = context; 81 | } 82 | 83 | 84 | @Override 85 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 86 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_view_pager, parent, false); 87 | return new ViewHolder(view); 88 | } 89 | 90 | @Override 91 | public void onBindViewHolder(ViewHolder holder, int position) { 92 | holder.img_thumb.setImageResource(imgs[index]); 93 | holder.videoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + videos[index])); 94 | index++; 95 | if (index >= 7) { 96 | index = 0; 97 | } 98 | } 99 | 100 | @Override 101 | public int getItemCount() { 102 | return 88; 103 | } 104 | 105 | public class ViewHolder extends RecyclerView.ViewHolder { 106 | ImageView img_thumb; 107 | VideoView videoView; 108 | ImageView img_play; 109 | RelativeLayout rootView; 110 | 111 | public ViewHolder(View itemView) { 112 | super(itemView); 113 | img_thumb = itemView.findViewById(R.id.img_thumb); 114 | videoView = itemView.findViewById(R.id.video_view); 115 | img_play = itemView.findViewById(R.id.img_play); 116 | rootView = itemView.findViewById(R.id.root_view); 117 | } 118 | } 119 | } 120 | 121 | private void releaseVideo(int index) { 122 | View itemView = mRecyclerView.getChildAt(index); 123 | final VideoView videoView = itemView.findViewById(R.id.video_view); 124 | final ImageView imgThumb = itemView.findViewById(R.id.img_thumb); 125 | final ImageView imgPlay = itemView.findViewById(R.id.img_play); 126 | videoView.stopPlayback(); 127 | imgThumb.animate().alpha(1).start(); 128 | imgPlay.animate().alpha(0f).start(); 129 | } 130 | 131 | 132 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) 133 | private void playVideo(int position) { 134 | View itemView = mRecyclerView.getChildAt(position); 135 | final FullWindowVideoView videoView = itemView.findViewById(R.id.video_view); 136 | final ImageView imgPlay = itemView.findViewById(R.id.img_play); 137 | final ImageView imgThumb = itemView.findViewById(R.id.img_thumb); 138 | final RelativeLayout rootView = itemView.findViewById(R.id.root_view); 139 | final MediaPlayer[] mediaPlayer = new MediaPlayer[1]; 140 | videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { 141 | @Override 142 | public void onPrepared(MediaPlayer mp) { 143 | 144 | } 145 | }); 146 | videoView.setOnInfoListener(new MediaPlayer.OnInfoListener() { 147 | @Override 148 | public boolean onInfo(MediaPlayer mp, int what, int extra) { 149 | mediaPlayer[0] = mp; 150 | mp.setLooping(true); 151 | imgThumb.animate().alpha(0).setDuration(200).start(); 152 | return false; 153 | } 154 | }); 155 | 156 | videoView.start(); 157 | 158 | imgPlay.setOnClickListener(new View.OnClickListener() { 159 | boolean isPlaying = true; 160 | 161 | @Override 162 | public void onClick(View v) { 163 | if (videoView.isPlaying()) { 164 | imgPlay.animate().alpha(0.7f).start(); 165 | videoView.pause(); 166 | isPlaying = false; 167 | } else { 168 | imgPlay.animate().alpha(0f).start(); 169 | videoView.start(); 170 | isPlaying = true; 171 | } 172 | } 173 | }); 174 | } 175 | 176 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/administrator/douyin/MyLayoutManager.java: -------------------------------------------------------------------------------- 1 | package com.example.administrator.douyin; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.NonNull; 5 | import android.support.v7.widget.LinearLayoutManager; 6 | import android.support.v7.widget.PagerSnapHelper; 7 | import android.support.v7.widget.RecyclerView; 8 | import android.view.View; 9 | 10 | public class MyLayoutManager extends LinearLayoutManager implements RecyclerView.OnChildAttachStateChangeListener { 11 | private int mDrift;//位移,用来判断移动方向 12 | 13 | private PagerSnapHelper mPagerSnapHelper; 14 | private OnViewPagerListener mOnViewPagerListener; 15 | 16 | public MyLayoutManager(Context context) { 17 | super(context); 18 | } 19 | 20 | public MyLayoutManager(Context context, int orientation, boolean reverseLayout) { 21 | super(context, orientation, reverseLayout); 22 | mPagerSnapHelper = new PagerSnapHelper(); 23 | } 24 | 25 | @Override 26 | public void onAttachedToWindow(RecyclerView view) { 27 | 28 | view.addOnChildAttachStateChangeListener(this); 29 | mPagerSnapHelper.attachToRecyclerView(view); 30 | super.onAttachedToWindow(view); 31 | } 32 | //当Item添加进来了 调用这个方法 33 | 34 | // 35 | @Override 36 | public void onChildViewAttachedToWindow(@NonNull View view) { 37 | // 播放视频操作 即将要播放的是上一个视频 还是下一个视频 38 | int position = getPosition(view); 39 | if (0 == position) { 40 | if (mOnViewPagerListener != null) { 41 | mOnViewPagerListener.onPageSelected(getPosition(view), false); 42 | } 43 | 44 | } 45 | } 46 | 47 | public void setOnViewPagerListener(OnViewPagerListener mOnViewPagerListener) { 48 | this.mOnViewPagerListener = mOnViewPagerListener; 49 | } 50 | 51 | @Override 52 | public void onScrollStateChanged(int state) { 53 | switch (state) { 54 | case RecyclerView.SCROLL_STATE_IDLE: 55 | View view = mPagerSnapHelper.findSnapView(this); 56 | int position = getPosition(view); 57 | if (mOnViewPagerListener != null) { 58 | mOnViewPagerListener.onPageSelected(position, position == getItemCount() - 1); 59 | 60 | } 61 | // postion ---回调 ----》播放 62 | 63 | 64 | break; 65 | } 66 | super.onScrollStateChanged(state); 67 | } 68 | 69 | @Override 70 | public void onChildViewDetachedFromWindow(@NonNull View view) { 71 | //暂停播放操作 72 | if (mDrift >= 0) { 73 | if (mOnViewPagerListener != null) 74 | mOnViewPagerListener.onPageRelease(true, getPosition(view)); 75 | } else { 76 | if (mOnViewPagerListener != null) 77 | mOnViewPagerListener.onPageRelease(false, getPosition(view)); 78 | } 79 | } 80 | 81 | 82 | @Override 83 | public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state) { 84 | this.mDrift = dy; 85 | return super.scrollVerticallyBy(dy, recycler, state); 86 | } 87 | 88 | @Override 89 | public boolean canScrollVertically() { 90 | return true; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/administrator/douyin/MyLayoutManager2.kt: -------------------------------------------------------------------------------- 1 | package com.example.administrator.douyin 2 | 3 | import android.content.Context 4 | import android.support.v7.widget.LinearLayoutManager 5 | import android.support.v7.widget.PagerSnapHelper 6 | import android.support.v7.widget.RecyclerView 7 | import android.view.View 8 | 9 | /** 10 | * @desc 11 | * @auth ${user} 12 | * @time 2018/8/9 15:38 13 | */ 14 | class MyLayoutManager2 : LinearLayoutManager, RecyclerView.OnChildAttachStateChangeListener { 15 | 16 | 17 | constructor(context: Context) : super(context) 18 | 19 | constructor(context: Context, @RecyclerView.Orientation orientation: Int, 20 | reverseLayout: Boolean) : super(context, orientation, reverseLayout) { 21 | pagerSpaner = PagerSnapHelper() 22 | } 23 | 24 | var pagerSpaner: PagerSnapHelper? = null 25 | var viewPagerListener: OnViewPagerListener? = null 26 | var diffY = 0 27 | 28 | override fun onAttachedToWindow(view: RecyclerView) { 29 | super.onAttachedToWindow(view) 30 | view.addOnChildAttachStateChangeListener(this) 31 | pagerSpaner!!.attachToRecyclerView(view) 32 | } 33 | 34 | 35 | override fun onChildViewDetachedFromWindow(view: View?) { 36 | val position = getPosition(view) 37 | if (0 < diffY) { 38 | viewPagerListener?.onPageRelease(true, position) 39 | } else { 40 | viewPagerListener?.onPageRelease(false, position) 41 | } 42 | } 43 | 44 | override fun onChildViewAttachedToWindow(view: View?) { 45 | 46 | val position = getPosition(view) 47 | if (0 == position) { 48 | viewPagerListener?.onPageSelected(position, false) 49 | } 50 | 51 | 52 | } 53 | 54 | override fun onScrollStateChanged(state: Int) { 55 | if (RecyclerView.SCROLL_STATE_IDLE == state) { 56 | val view = pagerSpaner!!.findSnapView(this) 57 | val position = getPosition(view) 58 | viewPagerListener?.onPageSelected(position, position == itemCount - 1) 59 | } 60 | super.onScrollStateChanged(state) 61 | } 62 | 63 | public fun setOnViewPagerListener(listener: OnViewPagerListener) { 64 | viewPagerListener = listener 65 | } 66 | 67 | override fun scrollVerticallyBy(dy: Int, recycler: RecyclerView.Recycler?, state: RecyclerView.State?): Int { 68 | diffY = dy 69 | return super.scrollVerticallyBy(dy, recycler, state) 70 | } 71 | 72 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/administrator/douyin/OnViewPagerListener.java: -------------------------------------------------------------------------------- 1 | package com.example.administrator.douyin; 2 | 3 | public interface OnViewPagerListener { 4 | /*初始化完成*/ 5 | void onInitComplete(); 6 | 7 | /*释放的监听*/ 8 | void onPageRelease(boolean isNext, int position); 9 | 10 | /*选中的监听以及判断是否滑动到底部*/ 11 | void onPageSelected(int position, boolean isBottom); 12 | 13 | 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/circle_big_red.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/circle_red.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/cirque_gray.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 9 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/echelon_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/play_arrow.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 21 | 22 | 28 | 29 | 38 | 39 | 47 | 48 | 49 | 58 | 59 | 68 | 69 | 70 | 71 | 78 | 79 | 87 | 88 | 98 | 99 | 109 | 110 | 116 | 117 | 127 | 128 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_view_pager.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 14 | 23 | 32 | 35 | 36 | 43 | 53 | 54 | 55 | 64 | 73 | 82 | 83 | 94 | 95 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/add_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/add_bg.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/add_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/add_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/header_icon_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/header_icon_1.jpg -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/header_icon_2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/header_icon_2.jpeg -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/header_icon_3.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/header_icon_3.jpeg -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/header_icon_4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/header_icon_4.jpg -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/heart_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/heart_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_live_profile_paly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/ic_live_profile_paly.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/icon_home_like_after.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/icon_home_like_after.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/icon_home_like_before.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/icon_home_like_before.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/icon_storyhome_open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/icon_storyhome_open.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/img_video_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/img_video_1.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/img_video_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/img_video_2.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/img_video_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/img_video_3.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/img_video_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/img_video_4.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/img_video_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/img_video_5.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/img_video_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/img_video_6.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/img_video_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/img_video_7.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/img_video_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/img_video_8.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/msg_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/msg_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/scan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/scan.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/search_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/search_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/share_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/share_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/three_pointer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxhdpi/three_pointer.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/raw/video_1.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/raw/video_1.mp4 -------------------------------------------------------------------------------- /app/src/main/res/raw/video_2.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/raw/video_2.mp4 -------------------------------------------------------------------------------- /app/src/main/res/raw/video_3.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/raw/video_3.mp4 -------------------------------------------------------------------------------- /app/src/main/res/raw/video_4.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/raw/video_4.mp4 -------------------------------------------------------------------------------- /app/src/main/res/raw/video_5.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/raw/video_5.mp4 -------------------------------------------------------------------------------- /app/src/main/res/raw/video_6.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/raw/video_6.mp4 -------------------------------------------------------------------------------- /app/src/main/res/raw/video_7.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/raw/video_7.mp4 -------------------------------------------------------------------------------- /app/src/main/res/raw/video_8.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/app/src/main/res/raw/video_8.mp4 -------------------------------------------------------------------------------- /app/src/main/res/values-v19/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 仿抖音1 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/example/administrator/douyin/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.example.administrator.douyin; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext.kotlin_version = '1.2.60' 5 | 6 | repositories { 7 | google() 8 | jcenter() 9 | } 10 | dependencies { 11 | classpath 'com.android.tools.build:gradle:3.1.2' 12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 13 | 14 | // NOTE: Do not place your application dependencies here; they belong 15 | // in the individual module build.gradle files 16 | } 17 | } 18 | 19 | allprojects { 20 | repositories { 21 | google() 22 | jcenter() 23 | } 24 | } 25 | 26 | task clean(type: Delete) { 27 | delete rootProject.buildDir 28 | } 29 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PangHaHa12138/DouyinDemo/b17ae5612c22e51e74534a82d91b8aa550119a3d/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Aug 08 20:04:27 CST 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------