init
18
.gitignore
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
|
||||
/.idea/
|
||||
/app/src/test/java/com/uiui/videoplayer/
|
||||
/app/src/androidTest/java/com/uiui/videoplayer/
|
||||
1
app/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
67
app/build.gradle
Normal file
@@ -0,0 +1,67 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 28
|
||||
buildToolsVersion "30.0.3"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.uiui.videoplayer"
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 28
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
multiDexEnabled true
|
||||
ndk {
|
||||
// add support lib
|
||||
abiFilters 'armeabi-v7a' //, 'arm64-v8a'//, "mips" //,'armeabi''x86',, 'x86_64',
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.1.0'
|
||||
|
||||
implementation 'com.github.bumptech.glide:glide:4.11.0'
|
||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
|
||||
|
||||
implementation 'io.reactivex.rxjava2:rxjava:2.1.0'
|
||||
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
|
||||
|
||||
implementation 'cn.jzvd:jiaozivideoplayer:7.6.0'
|
||||
implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever-core:1.0.15'
|
||||
implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever-native:1.0.15'
|
||||
implementation 'com.github.ittianyu:BottomNavigationViewEx:2.0.4'
|
||||
implementation 'com.github.ctiao:DanmakuFlameMaster:0.9.25'
|
||||
implementation 'com.github.ctiao:ndkbitmap-armv7a:0.9.21'
|
||||
implementation 'com.danikula:videocache:2.7.0'
|
||||
implementation 'com.aliyun.sdk.android:AliyunPlayer:4.5.0-full'
|
||||
implementation 'com.alivc.conan:AlivcConan:0.9.5'
|
||||
implementation 'com.scwang.smart:refresh-layout-kernel:2.0.1'
|
||||
implementation 'com.scwang.smart:refresh-header-material:2.0.1'
|
||||
implementation 'com.scwang.smart:refresh-footer-classics:2.0.1'
|
||||
implementation 'tv.danmaku.ijk.media:ijkplayer-java:0.8.8'
|
||||
implementation 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.4'
|
||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.3'
|
||||
}
|
||||
21
app/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
30
app/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.uiui.videoplayer">
|
||||
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
|
||||
<application
|
||||
android:name=".base.MyApplication"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".activity.PlayActivity"></activity>
|
||||
<activity android:name=".activity.MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".activity.ActivityTikTok"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.uiui.videoplayer.CustomJzvd;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import cn.jzvd.JzvdStd;
|
||||
|
||||
public class JzvdStdAssert extends JzvdStd {
|
||||
public JzvdStdAssert(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public JzvdStdAssert(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onPrepared() {
|
||||
state = STATE_PREPARED;
|
||||
if (!preloading) {
|
||||
mediaInterface.start();
|
||||
preloading = false;
|
||||
}
|
||||
onStatePlaying();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.uiui.videoplayer.CustomJzvd;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.uiui.videoplayer.R;
|
||||
|
||||
import cn.jzvd.JzvdStd;
|
||||
|
||||
public class JzvdStdTikTok extends JzvdStd {
|
||||
public JzvdStdTikTok(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public JzvdStdTikTok(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
super.init(context);
|
||||
bottomContainer.setVisibility(GONE);
|
||||
topContainer.setVisibility(GONE);
|
||||
bottomProgressBar.setVisibility(GONE);
|
||||
posterImageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
}
|
||||
|
||||
|
||||
//changeUiTo 真能能修改ui的方法
|
||||
@Override
|
||||
public void changeUiToNormal() {
|
||||
super.changeUiToNormal();
|
||||
bottomContainer.setVisibility(GONE);
|
||||
topContainer.setVisibility(GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAllControlsVisiblity(int topCon, int bottomCon, int startBtn, int loadingPro,
|
||||
int posterImg, int bottomPro, int retryLayout) {
|
||||
topContainer.setVisibility(INVISIBLE);
|
||||
bottomContainer.setVisibility(INVISIBLE);
|
||||
startButton.setVisibility(startBtn);
|
||||
loadingProgressBar.setVisibility(loadingPro);
|
||||
posterImageView.setVisibility(posterImg);
|
||||
bottomProgressBar.setVisibility(GONE);
|
||||
mRetryLayout.setVisibility(retryLayout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dissmissControlView() {
|
||||
if (state != STATE_NORMAL
|
||||
&& state != STATE_ERROR
|
||||
&& state != STATE_AUTO_COMPLETE) {
|
||||
post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
bottomContainer.setVisibility(View.INVISIBLE);
|
||||
topContainer.setVisibility(View.INVISIBLE);
|
||||
startButton.setVisibility(View.INVISIBLE);
|
||||
if (clarityPopWindow != null) {
|
||||
clarityPopWindow.dismiss();
|
||||
}
|
||||
if (screen != SCREEN_TINY) {
|
||||
bottomProgressBar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClickUiToggle() {
|
||||
super.onClickUiToggle();
|
||||
Log.i(TAG, "click blank");
|
||||
startButton.performClick();
|
||||
bottomContainer.setVisibility(GONE);
|
||||
topContainer.setVisibility(GONE);
|
||||
}
|
||||
|
||||
public void updateStartImage() {
|
||||
if (state == STATE_PLAYING) {
|
||||
startButton.setVisibility(VISIBLE);
|
||||
startButton.setImageResource(R.drawable.tiktok_play_tiktok);
|
||||
replayTextView.setVisibility(GONE);
|
||||
} else if (state == STATE_ERROR) {
|
||||
startButton.setVisibility(INVISIBLE);
|
||||
replayTextView.setVisibility(GONE);
|
||||
} else if (state == STATE_AUTO_COMPLETE) {
|
||||
startButton.setVisibility(VISIBLE);
|
||||
startButton.setImageResource(R.drawable.tiktok_play_tiktok);
|
||||
replayTextView.setVisibility(VISIBLE);
|
||||
} else {
|
||||
startButton.setImageResource(R.drawable.tiktok_play_tiktok);
|
||||
replayTextView.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
188
app/src/main/java/com/uiui/videoplayer/CustomJzvd/MyJzvdStd.java
Normal file
@@ -0,0 +1,188 @@
|
||||
package com.uiui.videoplayer.CustomJzvd;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.SeekBar;
|
||||
|
||||
import com.uiui.videoplayer.R;
|
||||
|
||||
import cn.jzvd.JzvdStd;
|
||||
|
||||
/**
|
||||
* 这里可以监听到视频播放的生命周期和播放状态
|
||||
* 所有关于视频的逻辑都应该写在这里
|
||||
* Created by Nathen on 2017/7/2.
|
||||
*/
|
||||
public class MyJzvdStd extends JzvdStd {
|
||||
public MyJzvdStd(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public MyJzvdStd(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
super.init(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
super.onClick(v);
|
||||
int i = v.getId();
|
||||
if (i == cn.jzvd.R.id.fullscreen) {
|
||||
Log.i(TAG, "onClick: fullscreen button");
|
||||
} else if (i == R.id.start) {
|
||||
Log.i(TAG, "onClick: start button");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
super.onTouch(v, event);
|
||||
int id = v.getId();
|
||||
if (id == cn.jzvd.R.id.surface_container) {
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_UP:
|
||||
if (mChangePosition) {
|
||||
Log.i(TAG, "Touch screen seek position");
|
||||
}
|
||||
if (mChangeVolume) {
|
||||
Log.i(TAG, "Touch screen change volume");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.jz_layout_std;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startVideo() {
|
||||
super.startVideo();
|
||||
Log.i(TAG, "startVideo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
super.onStopTrackingTouch(seekBar);
|
||||
Log.i(TAG, "Seek position ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gotoFullscreen() {
|
||||
super.gotoFullscreen();
|
||||
Log.i(TAG, "goto Fullscreen");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gotoNormalScreen() {
|
||||
super.gotoNormalScreen();
|
||||
Log.i(TAG, "quit Fullscreen");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void autoFullscreen(float x) {
|
||||
super.autoFullscreen(x);
|
||||
Log.i(TAG, "auto Fullscreen");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickUiToggle() {
|
||||
super.onClickUiToggle();
|
||||
Log.i(TAG, "click blank");
|
||||
}
|
||||
|
||||
//onState 代表了播放器引擎的回调,播放视频各个过程的状态的回调
|
||||
@Override
|
||||
public void onStateNormal() {
|
||||
super.onStateNormal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatePreparing() {
|
||||
super.onStatePreparing();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatePlaying() {
|
||||
super.onStatePlaying();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatePause() {
|
||||
super.onStatePause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateError() {
|
||||
super.onStateError();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateAutoComplete() {
|
||||
super.onStateAutoComplete();
|
||||
Log.i(TAG, "Auto complete");
|
||||
}
|
||||
|
||||
//changeUiTo 真能能修改ui的方法
|
||||
@Override
|
||||
public void changeUiToNormal() {
|
||||
super.changeUiToNormal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeUiToPreparing() {
|
||||
super.changeUiToPreparing();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeUiToPlayingShow() {
|
||||
super.changeUiToPlayingShow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeUiToPlayingClear() {
|
||||
super.changeUiToPlayingClear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeUiToPauseShow() {
|
||||
super.changeUiToPauseShow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeUiToPauseClear() {
|
||||
super.changeUiToPauseClear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeUiToComplete() {
|
||||
super.changeUiToComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeUiToError() {
|
||||
super.changeUiToError();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInfo(int what, int extra) {
|
||||
super.onInfo(what, extra);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int what, int extra) {
|
||||
super.onError(what, extra);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package com.uiui.videoplayer.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.OrientationHelper;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.uiui.videoplayer.CustomJzvd.JzvdStdAssert;
|
||||
import com.uiui.videoplayer.CustomJzvd.JzvdStdTikTok;
|
||||
import com.uiui.videoplayer.R;
|
||||
import com.uiui.videoplayer.adapter.TikTokRecyclerViewAdapter;
|
||||
import com.uiui.videoplayer.base.ViewPagerLayoutManager;
|
||||
import com.uiui.videoplayer.listener.OnViewPagerListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cn.jzvd.Jzvd;
|
||||
|
||||
public class ActivityTikTok extends AppCompatActivity {
|
||||
|
||||
private RecyclerView rvTiktok;
|
||||
private TikTokRecyclerViewAdapter mAdapter;
|
||||
private ViewPagerLayoutManager mViewPagerLayoutManager;
|
||||
private int mCurrentPosition = -1;
|
||||
private int position = 0;
|
||||
private List<String> videoPath = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
|
||||
setContentView(R.layout.activity_tiktok);
|
||||
Intent intent = getIntent();
|
||||
if (null != intent) {
|
||||
position = intent.getIntExtra("position", 0);
|
||||
videoPath = intent.getStringArrayListExtra("list");
|
||||
}
|
||||
rvTiktok = findViewById(R.id.rv_tiktok);
|
||||
|
||||
mAdapter = new TikTokRecyclerViewAdapter(this,videoPath );
|
||||
mViewPagerLayoutManager = new ViewPagerLayoutManager(this, OrientationHelper.VERTICAL);
|
||||
rvTiktok.setLayoutManager(mViewPagerLayoutManager);
|
||||
rvTiktok.setAdapter(mAdapter);
|
||||
rvTiktok.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
|
||||
}
|
||||
});
|
||||
mViewPagerLayoutManager.setOnViewPagerListener(new OnViewPagerListener() {
|
||||
@Override
|
||||
public void onInitComplete() {
|
||||
//自动播放第一条
|
||||
autoPlayVideo(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageRelease(boolean isNext, int position) {
|
||||
if (mCurrentPosition == position) {
|
||||
Jzvd.releaseAllVideos();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position, boolean isBottom) {
|
||||
if (mCurrentPosition == position) {
|
||||
return;
|
||||
}
|
||||
autoPlayVideo(position);
|
||||
mCurrentPosition = position;
|
||||
}
|
||||
});
|
||||
|
||||
rvTiktok.addOnChildAttachStateChangeListener(new RecyclerView.OnChildAttachStateChangeListener() {
|
||||
@Override
|
||||
public void onChildViewAttachedToWindow(View view) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChildViewDetachedFromWindow(View view) {
|
||||
Jzvd jzvd = view.findViewById(R.id.videoplayer);
|
||||
if (jzvd != null && Jzvd.CURRENT_JZVD != null && jzvd.jzDataSource != null &&
|
||||
jzvd.jzDataSource.containsTheUrl(Jzvd.CURRENT_JZVD.jzDataSource.getCurrentUrl())) {
|
||||
if (Jzvd.CURRENT_JZVD != null && Jzvd.CURRENT_JZVD.screen != Jzvd.SCREEN_FULLSCREEN) {
|
||||
Jzvd.releaseAllVideos();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void autoPlayVideo(int postion) {
|
||||
if (rvTiktok == null || rvTiktok.getChildAt(0) == null) {
|
||||
return;
|
||||
}
|
||||
JzvdStdAssert player = rvTiktok.getChildAt(0).findViewById(R.id.videoplayer);
|
||||
if (player != null) {
|
||||
player.startVideoAfterPreloading();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (Jzvd.backPress()) {
|
||||
return;
|
||||
}
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
Jzvd.releaseAllVideos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
package com.uiui.videoplayer.activity;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
|
||||
import com.uiui.videoplayer.R;
|
||||
import com.uiui.videoplayer.base.RecycleGridLayoutManager;
|
||||
import com.uiui.videoplayer.base.SpacesItemDecoration;
|
||||
import com.uiui.videoplayer.adapter.VideoAdapter;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
private static final int REQUEST_PERMISSION_CODE = 200;
|
||||
String[] permissions = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
private RecyclerView recyclerView;
|
||||
private VideoAdapter adapter;
|
||||
private RecycleGridLayoutManager mManager;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
checkSelfPermission();
|
||||
initView();
|
||||
// String rootPath = Environment.getExternalStorageDirectory().getPath() + File.separator;
|
||||
// traverseFolder(rootPath);
|
||||
ScanTask scanTask = new ScanTask();
|
||||
scanTask.execute();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
recyclerView = findViewById(R.id.recyclerView);
|
||||
}
|
||||
|
||||
// private String[] getFolder(String folderPath) {
|
||||
//
|
||||
// }
|
||||
public void traverseFolder(String path) {
|
||||
int fileNum = 0, folderNum = 0;
|
||||
File file = new File(path);
|
||||
if (file.exists()) {
|
||||
LinkedList<File> list = new LinkedList<File>();
|
||||
File[] files = file.listFiles();
|
||||
for (File file2 : files) {
|
||||
if (file2.isDirectory()) {
|
||||
Log.e("traverseFolder1", "文件夹:" + file2.getAbsolutePath());
|
||||
list.add(file2);
|
||||
folderNum++;
|
||||
} else {
|
||||
Log.e("traverseFolder1", "文件:" + file2.getAbsolutePath());
|
||||
fileNum++;
|
||||
}
|
||||
}
|
||||
File temp_file;
|
||||
while (!list.isEmpty()) {
|
||||
temp_file = list.removeFirst();
|
||||
files = temp_file.listFiles();
|
||||
for (File file2 : files) {
|
||||
if (file2.isDirectory()) {
|
||||
Log.e("traverseFolder2", "文件夹:" + file2.getAbsolutePath());
|
||||
list.add(file2);
|
||||
folderNum++;
|
||||
} else {
|
||||
Log.e("traverseFolder2", "文件:" + file2.getAbsolutePath());
|
||||
fileNum++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log.e("traverseFolder1", "文件不存在!");
|
||||
}
|
||||
Log.e("traverseFolder1", "文件夹共有:" + folderNum + ",文件共有:" + fileNum);
|
||||
}
|
||||
|
||||
private static final String[] extension = new String[]{
|
||||
".3gp", ".flv", ".mkv", ".mov", ".mp4", ".webm"
|
||||
};
|
||||
|
||||
private static boolean isVideoFormat(String filePath) {
|
||||
for (String s : extension) {
|
||||
if (filePath.endsWith(s)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public class ScanTask extends AsyncTask<Void, String, List<String>> {
|
||||
|
||||
@Override
|
||||
protected List<String> doInBackground(Void... voids) {
|
||||
List<String> fileList = new ArrayList<>();
|
||||
String rootPath = Environment.getExternalStorageDirectory().getPath() + File.separator;
|
||||
File file = new File(rootPath);
|
||||
if (file.exists()) {
|
||||
LinkedList<File> list = new LinkedList<File>();
|
||||
File[] files = file.listFiles();
|
||||
for (File file2 : files) {
|
||||
publishProgress(file2.getAbsolutePath());
|
||||
if (file2.isDirectory()) {
|
||||
list.add(file2);
|
||||
} else {
|
||||
if (isVideoFormat(file2.getAbsolutePath())) {
|
||||
fileList.add(file2.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
File temp_file;
|
||||
while (!list.isEmpty()) {
|
||||
temp_file = list.removeFirst();
|
||||
files = temp_file.listFiles();
|
||||
for (File file2 : files) {
|
||||
publishProgress(file2.getAbsolutePath());
|
||||
if (file2.isDirectory()) {
|
||||
list.add(file2);
|
||||
} else {
|
||||
if (isVideoFormat(file2.getAbsolutePath())) {
|
||||
fileList.add(file2.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log.e("traverseFolder1", "文件不存在!");
|
||||
}
|
||||
return fileList;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onProgressUpdate(String... values) {
|
||||
super.onProgressUpdate(values);
|
||||
// Log.e("ScanTask", "onProgressUpdate: " + values[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(List<String> strings) {
|
||||
super.onPostExecute(strings);
|
||||
Log.e("ScanTask", "onPostExecute: " + strings);
|
||||
adapter = new VideoAdapter(MainActivity.this, strings);
|
||||
mManager = new RecycleGridLayoutManager(MainActivity.this, 2);
|
||||
recyclerView.setLayoutManager(mManager);
|
||||
recyclerView.setNestedScrollingEnabled(false);
|
||||
recyclerView.addItemDecoration(new SpacesItemDecoration(getResources().getDimensionPixelSize(R.dimen.PX1x), getResources().getDimensionPixelSize(R.dimen.PX1x),
|
||||
getResources().getDimensionPixelSize(R.dimen.PX1x), getResources().getDimensionPixelSize(R.dimen.PX1x)));
|
||||
((DefaultItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
|
||||
// recyclerView.setLayoutManager(new LinearLayoutManager(MainActivity.this));
|
||||
recyclerView.setAdapter(adapter);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkSelfPermission() {
|
||||
List<String> mPermissionList = new ArrayList<>();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
for (String s : permissions) {
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) {
|
||||
mPermissionList.add(s);
|
||||
}
|
||||
}
|
||||
if (mPermissionList.size() > 0) {//有权限没有通过,需要申请
|
||||
ActivityCompat.requestPermissions(this, permissions, REQUEST_PERMISSION_CODE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == REQUEST_PERMISSION_CODE) {
|
||||
//当然权限多了,建议使用Switch,不必纠结于此
|
||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
|
||||
} else if (grantResults[0] == PackageManager.PERMISSION_DENIED) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.uiui.videoplayer.activity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.uiui.videoplayer.R;
|
||||
|
||||
public class PlayActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_play);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.uiui.videoplayer.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.uiui.videoplayer.CustomJzvd.JzvdStdAssert;
|
||||
import com.uiui.videoplayer.R;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cn.jzvd.JZDataSource;
|
||||
import cn.jzvd.Jzvd;
|
||||
|
||||
public class TikTokRecyclerViewAdapter extends RecyclerView.Adapter<TikTokRecyclerViewAdapter.MyViewHolder> {
|
||||
|
||||
public static final String TAG = "AdapterTikTokRecyclerView";
|
||||
private List<String> videoPath;
|
||||
private Context context;
|
||||
|
||||
public TikTokRecyclerViewAdapter(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public TikTokRecyclerViewAdapter(Context context, List<String> list) {
|
||||
this.context = context;
|
||||
this.videoPath = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
MyViewHolder holder = new MyViewHolder(LayoutInflater.from(
|
||||
context).inflate(R.layout.item_tiktok, parent,
|
||||
false));
|
||||
return holder;
|
||||
}
|
||||
|
||||
@SuppressLint("LongLogTag")
|
||||
@Override
|
||||
public void onBindViewHolder(MyViewHolder holder, int position) {
|
||||
Log.i(TAG, "onBindViewHolder [" + holder.jzvdStdAssert.hashCode() + "] position=" + position);
|
||||
final String path = videoPath.get(position);
|
||||
JZDataSource jzDataSource = new JZDataSource(path, getFileName(path));
|
||||
jzDataSource.looping = true;
|
||||
holder.jzvdStdAssert.setUp(jzDataSource, Jzvd.SCREEN_NORMAL);
|
||||
// Glide.with(holder.jzvdStd.getContext()).load(UrlsKt.getPl3()[position]).into(holder.jzvdStd.posterImageView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return videoPath == null ? 0 : videoPath.size();
|
||||
}
|
||||
|
||||
private String getFileName(String path) {
|
||||
return path.substring(path.lastIndexOf("/") + 1);
|
||||
}
|
||||
|
||||
class MyViewHolder extends RecyclerView.ViewHolder {
|
||||
JzvdStdAssert jzvdStdAssert;
|
||||
|
||||
public MyViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
jzvdStdAssert = itemView.findViewById(R.id.videoplayer);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
168
app/src/main/java/com/uiui/videoplayer/adapter/VideoAdapter.java
Normal file
@@ -0,0 +1,168 @@
|
||||
package com.uiui.videoplayer.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.media.Image;
|
||||
import android.media.MediaMetadataRetriever;
|
||||
import android.os.AsyncTask;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.uiui.videoplayer.R;
|
||||
import com.uiui.videoplayer.activity.ActivityTikTok;
|
||||
import com.uiui.videoplayer.utils.ToastUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.ObservableOnSubscribe;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
public class VideoAdapter extends RecyclerView.Adapter<VideoAdapter.VideoHolder> {
|
||||
private Context mContext;
|
||||
private List<String> videoPath;
|
||||
|
||||
|
||||
public VideoAdapter() {
|
||||
|
||||
}
|
||||
|
||||
public VideoAdapter(Context context) {
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
public VideoAdapter(Context context, List<String> path) {
|
||||
this.mContext = context;
|
||||
this.videoPath = path;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public VideoHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
VideoHolder holder = new VideoHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_videofile, parent, false));
|
||||
return holder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final VideoHolder holder, final int position) {
|
||||
final String path = videoPath.get(position);
|
||||
File file = new File(path);
|
||||
if (file.exists() && file.isFile()) {
|
||||
// BitmapRetultListener bitmapRetultListener = new BitmapRetultListener() {
|
||||
// @Override
|
||||
// public void onScanCompleted(Bitmap bitmap) {
|
||||
// Glide.with(holder.video_image).load(bitmap).into(holder.video_image);
|
||||
// }
|
||||
// };
|
||||
Observable.create(new ObservableOnSubscribe<Bitmap>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Bitmap> emitter) throws Exception {
|
||||
MediaMetadataRetriever mmr = new MediaMetadataRetriever();
|
||||
mmr.setDataSource(path);
|
||||
String duration = mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
|
||||
Long time = Long.valueOf(duration);
|
||||
Bitmap bitmap = mmr.getFrameAtTime();//获得视频第一帧的Bitmap对象
|
||||
emitter.onNext(bitmap);
|
||||
}
|
||||
}).subscribeOn(Schedulers.newThread())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<Bitmap>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(Bitmap bitmap) {
|
||||
Glide.with(holder.video_image).load(bitmap).into(holder.video_image);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// this.listener = bitmapRetultListener;
|
||||
holder.title.setText(getFileName(path));
|
||||
}
|
||||
holder.root.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// ToastUtil.show(path);
|
||||
Intent intent = new Intent(mContext, ActivityTikTok.class);
|
||||
intent.putExtra("position", position);
|
||||
intent.putStringArrayListExtra("list", (ArrayList<String>) videoPath);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return videoPath == null ? 0 : videoPath.size();
|
||||
}
|
||||
|
||||
private String getFileName(String path) {
|
||||
return path.substring(path.lastIndexOf("/") + 1);
|
||||
}
|
||||
|
||||
static class VideoHolder extends RecyclerView.ViewHolder {
|
||||
ImageView video_image;
|
||||
TextView title;
|
||||
ConstraintLayout root;
|
||||
|
||||
public VideoHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
video_image = itemView.findViewById(R.id.video_image);
|
||||
title = itemView.findViewById(R.id.title_text);
|
||||
root = itemView.findViewById(R.id.root);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private BitmapRetultListener listener;
|
||||
|
||||
class BitmapTask extends AsyncTask<String, Void, Bitmap> {
|
||||
@Override
|
||||
protected Bitmap doInBackground(String... strings) {
|
||||
MediaMetadataRetriever mmr = new MediaMetadataRetriever();
|
||||
mmr.setDataSource(strings[0]);
|
||||
Bitmap bitmap = mmr.getFrameAtTime();//获得视频第一帧的Bitmap对象
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Bitmap bitmap) {
|
||||
listener.onScanCompleted(bitmap);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
interface BitmapRetultListener {
|
||||
void onScanCompleted(Bitmap bitmap);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.uiui.videoplayer.base;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import com.uiui.videoplayer.utils.ToastUtil;
|
||||
|
||||
public class MyApplication extends Application {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
ToastUtil.init(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.uiui.videoplayer.base;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
/**
|
||||
* Created by Administrator on 2016/11/18.
|
||||
*/
|
||||
|
||||
public class RecycleGridLayoutManager extends GridLayoutManager {
|
||||
|
||||
private int mwidth = 0;
|
||||
private int mheight = 0;
|
||||
private int[] mMeasuredDimension = new int[2];
|
||||
|
||||
public RecycleGridLayoutManager(Context context, int spanCount) {
|
||||
super(context, spanCount);
|
||||
}
|
||||
|
||||
public RecycleGridLayoutManager(Context context, int spanCount, int orientation, boolean reverseLayout) {
|
||||
super(context, spanCount, orientation, reverseLayout);
|
||||
}
|
||||
|
||||
public int getMwidth() {
|
||||
return mwidth;
|
||||
}
|
||||
|
||||
public void setMwidth(int mwidth) {
|
||||
this.mwidth = mwidth;
|
||||
}
|
||||
|
||||
public int getMheight() {
|
||||
return mheight;
|
||||
}
|
||||
|
||||
public void setMheight(int mheight) {
|
||||
this.mheight = mheight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMeasure(RecyclerView.Recycler recycler, RecyclerView.State state, int widthSpec, int heightSpec) {
|
||||
final int widthMode = View.MeasureSpec.getMode(widthSpec);
|
||||
final int heightMode = View.MeasureSpec.getMode(heightSpec);
|
||||
final int widthSize = View.MeasureSpec.getSize(widthSpec);
|
||||
final int heightSize = View.MeasureSpec.getSize(heightSpec);
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
int count = getItemCount();
|
||||
int span = getSpanCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
measureScrapChild(recycler, i,
|
||||
View.MeasureSpec.makeMeasureSpec(i, View.MeasureSpec.UNSPECIFIED),
|
||||
View.MeasureSpec.makeMeasureSpec(i, View.MeasureSpec.UNSPECIFIED),
|
||||
mMeasuredDimension);
|
||||
|
||||
if (getOrientation() == HORIZONTAL) {
|
||||
if (i % span == 0) {
|
||||
width = width + mMeasuredDimension[0];
|
||||
}
|
||||
if (i == 0) {
|
||||
height = mMeasuredDimension[1];
|
||||
}
|
||||
} else {
|
||||
if (i % span == 0) {
|
||||
height = height + mMeasuredDimension[1];
|
||||
}
|
||||
if (i == 0) {
|
||||
width = mMeasuredDimension[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (widthMode) {
|
||||
case View.MeasureSpec.EXACTLY:
|
||||
width = widthSize;
|
||||
case View.MeasureSpec.AT_MOST:
|
||||
case View.MeasureSpec.UNSPECIFIED:
|
||||
}
|
||||
|
||||
switch (heightMode) {
|
||||
case View.MeasureSpec.EXACTLY:
|
||||
height = heightSize;
|
||||
case View.MeasureSpec.AT_MOST:
|
||||
case View.MeasureSpec.UNSPECIFIED:
|
||||
}
|
||||
setMheight(height);
|
||||
setMwidth(width);
|
||||
setMeasuredDimension(width, height);
|
||||
}
|
||||
|
||||
private void measureScrapChild(RecyclerView.Recycler recycler, int position, int widthSpec,
|
||||
int heightSpec, int[] measuredDimension) {
|
||||
if (position < getItemCount()) {
|
||||
try {
|
||||
View view = recycler.getViewForPosition(0);//fix 动态添加时报IndexOutOfBoundsException
|
||||
if (view != null) {
|
||||
RecyclerView.LayoutParams p = (RecyclerView.LayoutParams) view.getLayoutParams();
|
||||
int childWidthSpec = ViewGroup.getChildMeasureSpec(widthSpec,
|
||||
getPaddingLeft() + getPaddingRight(), p.width);
|
||||
int childHeightSpec = ViewGroup.getChildMeasureSpec(heightSpec,
|
||||
getPaddingTop() + getPaddingBottom(), p.height);
|
||||
view.measure(childWidthSpec, childHeightSpec);
|
||||
measuredDimension[0] = view.getMeasuredWidth() + p.leftMargin + p.rightMargin;
|
||||
measuredDimension[1] = view.getMeasuredHeight() + p.bottomMargin + p.topMargin;
|
||||
recycler.recycleView(view);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.uiui.videoplayer.base;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
/**
|
||||
* RecycleView item 间距设置
|
||||
*/
|
||||
public class SpacesItemDecoration extends RecyclerView.ItemDecoration {
|
||||
private int left, right, bottom, top;
|
||||
|
||||
public SpacesItemDecoration(int space) {
|
||||
this.left = space;
|
||||
this.right = space;
|
||||
this.bottom = space;
|
||||
this.top = space;
|
||||
}
|
||||
|
||||
public SpacesItemDecoration(int top, int bottom, boolean flag) {
|
||||
this.top = top;
|
||||
this.bottom = bottom;
|
||||
this.left = 0;
|
||||
this.right = 0;
|
||||
}
|
||||
|
||||
public SpacesItemDecoration(int left, int right) {
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
this.bottom = 0;
|
||||
this.top = 0;
|
||||
}
|
||||
|
||||
public SpacesItemDecoration(int left, int right, int bottom, int top) {
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
this.bottom = bottom;
|
||||
this.top = top;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getItemOffsets(Rect outRect, View view,
|
||||
RecyclerView parent, RecyclerView.State state) {
|
||||
outRect.left = left;
|
||||
outRect.right = right;
|
||||
outRect.bottom = bottom;
|
||||
outRect.top = top;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package com.uiui.videoplayer.base;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.PagerSnapHelper;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.uiui.videoplayer.listener.OnViewPagerListener;
|
||||
|
||||
/**
|
||||
* Created by 钉某人
|
||||
* github: https://github.com/DingMouRen
|
||||
* email: naildingmouren@gmail.com
|
||||
*/
|
||||
|
||||
public class ViewPagerLayoutManager extends LinearLayoutManager {
|
||||
private static final String TAG = "ViewPagerLayoutManager";
|
||||
private PagerSnapHelper mPagerSnapHelper;
|
||||
private OnViewPagerListener mOnViewPagerListener;
|
||||
private RecyclerView mRecyclerView;
|
||||
private int mDrift;//位移,用来判断移动方向
|
||||
private RecyclerView.OnChildAttachStateChangeListener mChildAttachStateChangeListener = new RecyclerView.OnChildAttachStateChangeListener() {
|
||||
@Override
|
||||
public void onChildViewAttachedToWindow(View view) {
|
||||
if (mOnViewPagerListener != null && getChildCount() == 1) {
|
||||
mOnViewPagerListener.onInitComplete();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChildViewDetachedFromWindow(View view) {
|
||||
if (mDrift >= 0) {
|
||||
if (mOnViewPagerListener != null)
|
||||
mOnViewPagerListener.onPageRelease(true, getPosition(view));
|
||||
} else {
|
||||
if (mOnViewPagerListener != null)
|
||||
mOnViewPagerListener.onPageRelease(false, getPosition(view));
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
public ViewPagerLayoutManager(Context context, int orientation) {
|
||||
super(context, orientation, false);
|
||||
init();
|
||||
}
|
||||
|
||||
public ViewPagerLayoutManager(Context context, int orientation, boolean reverseLayout) {
|
||||
super(context, orientation, reverseLayout);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mPagerSnapHelper = new PagerSnapHelper();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToWindow(RecyclerView view) {
|
||||
super.onAttachedToWindow(view);
|
||||
mPagerSnapHelper.attachToRecyclerView(view);
|
||||
this.mRecyclerView = view;
|
||||
mRecyclerView.addOnChildAttachStateChangeListener(mChildAttachStateChangeListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
|
||||
super.onLayoutChildren(recycler, state);
|
||||
}
|
||||
|
||||
/**
|
||||
* 滑动状态的改变
|
||||
* 缓慢拖拽-> SCROLL_STATE_DRAGGING
|
||||
* 快速滚动-> SCROLL_STATE_SETTLING
|
||||
* 空闲状态-> SCROLL_STATE_IDLE
|
||||
*
|
||||
* @param state
|
||||
*/
|
||||
@Override
|
||||
public void onScrollStateChanged(int state) {
|
||||
switch (state) {
|
||||
case RecyclerView.SCROLL_STATE_IDLE:
|
||||
View viewIdle = mPagerSnapHelper.findSnapView(this);
|
||||
if (viewIdle != null) {
|
||||
int positionIdle = getPosition(viewIdle);
|
||||
if (mOnViewPagerListener != null && getChildCount() == 1) {
|
||||
mOnViewPagerListener.onPageSelected(positionIdle, positionIdle == getItemCount() - 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听竖直方向的相对偏移量
|
||||
*
|
||||
* @param dy
|
||||
* @param recycler
|
||||
* @param state
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state) {
|
||||
this.mDrift = dy;
|
||||
return super.scrollVerticallyBy(dy, recycler, state);
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听水平方向的相对偏移量
|
||||
*
|
||||
* @param dx
|
||||
* @param recycler
|
||||
* @param state
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler, RecyclerView.State state) {
|
||||
this.mDrift = dx;
|
||||
return super.scrollHorizontallyBy(dx, recycler, state);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置监听
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
public void setOnViewPagerListener(OnViewPagerListener listener) {
|
||||
this.mOnViewPagerListener = listener;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.uiui.videoplayer.listener;
|
||||
|
||||
/**
|
||||
* Created by 钉某人
|
||||
* github: https://github.com/DingMouRen
|
||||
* email: naildingmouren@gmail.com
|
||||
* 用于ViewPagerLayoutManager的监听
|
||||
*/
|
||||
|
||||
public interface OnViewPagerListener {
|
||||
|
||||
/*初始化完成*/
|
||||
void onInitComplete();
|
||||
|
||||
/*释放的监听*/
|
||||
void onPageRelease(boolean isNext, int position);
|
||||
|
||||
/*选中的监听以及判断是否滑动到底部*/
|
||||
void onPageSelected(int position, boolean isBottom);
|
||||
|
||||
|
||||
}
|
||||
14
app/src/main/java/com/uiui/videoplayer/utils/FileUtils.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.uiui.videoplayer.utils;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FileUtils {
|
||||
|
||||
|
||||
|
||||
}
|
||||
101
app/src/main/java/com/uiui/videoplayer/utils/ToastUtil.java
Normal file
@@ -0,0 +1,101 @@
|
||||
package com.uiui.videoplayer.utils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.uiui.videoplayer.BuildConfig;
|
||||
|
||||
|
||||
/**
|
||||
* Created by haoge on 2017/3/2.
|
||||
*/
|
||||
|
||||
public class ToastUtil {
|
||||
private static Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
private static Toast toast;
|
||||
private static Context mContext;
|
||||
|
||||
@SuppressLint("ShowToast")
|
||||
public static void init(Context context) {
|
||||
mContext = context;
|
||||
toast = Toast.makeText(mContext, "", Toast.LENGTH_SHORT);
|
||||
debugToast = Toast.makeText(mContext, "", Toast.LENGTH_SHORT);
|
||||
|
||||
}
|
||||
|
||||
private static long time1 = 0L;
|
||||
private static long time2 = 0L;
|
||||
|
||||
public static void show(final String msg) {
|
||||
mainHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
time2 = System.currentTimeMillis();
|
||||
if ((time2 - time1) > 3499) {
|
||||
showToast(mContext, msg, Toast.LENGTH_LONG);
|
||||
Log.e("fht", "LENGTH_LONG");
|
||||
time1 = time2;
|
||||
}
|
||||
} else {
|
||||
if (toast != null) {
|
||||
toast.setText(msg);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private static Toast mToast = null;
|
||||
|
||||
//android 8.0以后限制
|
||||
//https://www.jianshu.com/p/d9813ad03d59
|
||||
//https://www.jianshu.com/p/050ce052b873
|
||||
public static void showToast(Context context, String text, int duration) {
|
||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.P) {
|
||||
Toast.makeText(context, text, duration).show();
|
||||
} else {
|
||||
if (mToast == null) {
|
||||
mToast = Toast.makeText(context, text, duration);
|
||||
} else {
|
||||
mToast.setText(text);
|
||||
mToast.setDuration(duration);
|
||||
}
|
||||
mToast.show();
|
||||
}
|
||||
}
|
||||
|
||||
// public static void showInCenter(String msg) {
|
||||
// mainHandler.post(() -> {
|
||||
// if (toast != null) {
|
||||
// toast.setGravity(Gravity.CENTER, 0, 0);
|
||||
// toast.setText(msg);
|
||||
// toast.show();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
static Handler debugHandler = new Handler(Looper.getMainLooper());
|
||||
static Toast debugToast;
|
||||
|
||||
public static void debugShow(final String msg) {
|
||||
mainHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (BuildConfig.DEBUG) {
|
||||
if (toast != null) {
|
||||
toast.setText(msg);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
BIN
app/src/main/res/drawable-hdpi/tiktok_comment_normal.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
app/src/main/res/drawable-hdpi/tiktok_douyin_icon.png
Normal file
|
After Width: | Height: | Size: 473 B |
BIN
app/src/main/res/drawable-hdpi/tiktok_music_play.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
app/src/main/res/drawable-hdpi/tiktok_play_tiktok.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
app/src/main/res/drawable-hdpi/tiktok_star_normal.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
app/src/main/res/drawable-hdpi/tiktok_star_selected.png
Normal file
|
After Width: | Height: | Size: 586 B |
30
app/src/main/res/drawable-v24/ic_launcher_foreground.xml
Normal file
@@ -0,0 +1,30 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
||||
11
app/src/main/res/drawable/ic_border_white.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
<solid android:color="@android:color/white" />
|
||||
<padding
|
||||
android:bottom="1dp"
|
||||
android:left="1dp"
|
||||
android:right="1dp"
|
||||
android:top="1dp" />
|
||||
|
||||
</shape>
|
||||
10
app/src/main/res/drawable/ic_circle_red.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
<padding
|
||||
android:bottom="5dp"
|
||||
android:left="5dp"
|
||||
android:right="5dp"
|
||||
android:top="5dp" />
|
||||
<solid android:color="@android:color/holo_red_light" />
|
||||
</shape>
|
||||
170
app/src/main/res/drawable/ic_launcher_background.xml
Normal file
@@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
||||
5
app/src/main/res/drawable/ic_star_selector.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/tiktok_star_selected" android:state_selected="true" />
|
||||
<item android:drawable="@drawable/tiktok_star_normal" />
|
||||
</selector>
|
||||
16
app/src/main/res/layout/activity_main.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".activity.MainActivity">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</androidx.recyclerview.widget.RecyclerView>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
9
app/src/main/res/layout/activity_play.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".activity.PlayActivity">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
14
app/src/main/res/layout/activity_tiktok.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#333333"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_tiktok"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scrollbars="none" />
|
||||
|
||||
</RelativeLayout>
|
||||
12
app/src/main/res/layout/item_tiktok.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.uiui.videoplayer.CustomJzvd.JzvdStdAssert
|
||||
android:id="@+id/videoplayer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</FrameLayout>
|
||||
31
app/src/main/res/layout/item_videofile.xml
Normal file
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/video_image"
|
||||
android:layout_width="288dp"
|
||||
android:layout_height="162dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="8dp"
|
||||
android:maxLines="2"
|
||||
android:text="dsadasdadasdasdasddsadsadasdassdsad"
|
||||
android:textColor="@color/black"
|
||||
app:layout_constraintEnd_toEndOf="@+id/video_image"
|
||||
app:layout_constraintStart_toStartOf="@+id/video_image"
|
||||
app:layout_constraintTop_toBottomOf="@+id/video_image" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
5
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
5
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 7.3 KiB |
BIN
app/src/main/res/mipmap-xhdpi/tiktok_add_star.png
Normal file
|
After Width: | Height: | Size: 170 B |
BIN
app/src/main/res/mipmap-xhdpi/tiktok_bg_add.png
Normal file
|
After Width: | Height: | Size: 247 B |
BIN
app/src/main/res/mipmap-xhdpi/tiktok_btn_share.png
Normal file
|
After Width: | Height: | Size: 799 B |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 7.7 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
9
app/src/main/res/values/colors.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#6200EE</color>
|
||||
<color name="colorPrimaryDark">#3700B3</color>
|
||||
<color name="colorAccent">#03DAC5</color>
|
||||
<color name="white">#FFFFFF</color>
|
||||
<color name="black">#000000</color>
|
||||
|
||||
</resources>
|
||||
24
app/src/main/res/values/dimens.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<resources>
|
||||
<dimen name="PX0x">0dp</dimen>
|
||||
<dimen name="PX1x">1dp</dimen>
|
||||
<dimen name="PX5x">5dp</dimen>
|
||||
</resources>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
3
app/src/main/res/values/strings.xml
Normal file
@@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">视频播放器</string>
|
||||
</resources>
|
||||
11
app/src/main/res/values/styles.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
31
build.gradle
Normal file
@@ -0,0 +1,31 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.4.21'
|
||||
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.6.3'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
maven { url "https://www.jitpack.io" }
|
||||
maven { url "https://maven.aliyun.com/repository/public" } //jcenter & central
|
||||
maven { url "https://maven.aliyun.com/repository/google" }
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
20
gradle.properties
Normal file
@@ -0,0 +1,20 @@
|
||||
# Project-wide Gradle settings.
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx1536m
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app's APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
# Automatically convert third-party libraries to use AndroidX
|
||||
android.enableJetifier=true
|
||||
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#Wed Feb 24 10:40:26 CST 2021
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
|
||||
172
gradlew
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
84
gradlew.bat
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
2
settings.gradle
Normal file
@@ -0,0 +1,2 @@
|
||||
rootProject.name='视频播放器'
|
||||
include ':app'
|
||||