-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
lichunyang
committed
Jun 13, 2017
1 parent
b0a22fc
commit e53763f
Showing
113 changed files
with
4,804 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,3 +88,6 @@ $RECYCLE.BIN/ | |
|
||
# Windows shortcuts | ||
*.lnk | ||
|
||
.idea/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion "25.0.1" | ||
|
||
defaultConfig { | ||
applicationId "com.boredream.videoplayer" | ||
minSdkVersion 15 | ||
targetSdkVersion 25 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
testCompile 'junit:junit:4.12' | ||
compile 'com.android.support:appcompat-v7:25.3.1' | ||
compile "com.android.support:recyclerview-v7:25.3.1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in E:\Users\admin\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# 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 *; | ||
#} |
13 changes: 13 additions & 0 deletions
13
app/src/androidTest/java/com/boredream/videoplayer/ApplicationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.boredream.videoplayer; | ||
|
||
import android.app.Application; | ||
import android.test.ApplicationTestCase; | ||
|
||
/** | ||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> | ||
*/ | ||
public class ApplicationTest extends ApplicationTestCase<Application> { | ||
public ApplicationTest() { | ||
super(Application.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.boredream.videoplayer"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@drawable/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
35 changes: 35 additions & 0 deletions
35
app/src/main/java/com/boredream/videoplayer/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.boredream.videoplayer; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.View; | ||
|
||
import com.boredream.videoplayer.video.VideoControllerView; | ||
import com.boredream.videoplayer.video.bean.VideoDetailInfo; | ||
import com.boredream.videoplayer.video.utils.MockUtils; | ||
|
||
import java.util.HashMap; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
setContentView(R.layout.activity_main); | ||
|
||
final VideoControllerView vv = (VideoControllerView) findViewById(R.id.vv); | ||
findViewById(R.id.btn_start).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
VideoDetailInfo info = MockUtils.mockData(VideoDetailInfo.class); | ||
info.defaultDefinition = "common"; | ||
info.setCurDefinition(info.defaultDefinition); | ||
info.vedioUrlDto = new HashMap<>(); | ||
info.vedioUrlDto.put(info.defaultDefinition, "http://baobab.wdjcdn.com/1455782903700jy.mp4"); | ||
vv.startPlayVideo(info); | ||
} | ||
}); | ||
|
||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
app/src/main/java/com/boredream/videoplayer/video/DefaultOnVideoControlListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.boredream.videoplayer.video; | ||
|
||
/** | ||
* Created by lichunyang on 2017/5/11. | ||
*/ | ||
public class DefaultOnVideoControlListener implements OnVideoControlListener { | ||
|
||
@Override | ||
public void onExit() { | ||
|
||
} | ||
|
||
@Override | ||
public void onBack() { | ||
|
||
} | ||
|
||
@Override | ||
public void onFullScreen() { | ||
|
||
} | ||
|
||
@Override | ||
public void onCatalogItemSelected(int videoIndex) { | ||
|
||
} | ||
|
||
@Override | ||
public void onRatioSelected(String info) { | ||
|
||
} | ||
|
||
@Override | ||
public void onRetry(int status) { | ||
|
||
} | ||
|
||
@Override | ||
public void onComplete() { | ||
|
||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/boredream/videoplayer/video/OnVideoControlListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.boredream.videoplayer.video; | ||
|
||
public interface OnVideoControlListener { | ||
|
||
void onExit(); | ||
|
||
void onBack(); | ||
|
||
void onFullScreen(); | ||
|
||
void onCatalogItemSelected(int videoIndex); | ||
|
||
void onRatioSelected(String fluency); | ||
|
||
void onRetry(int status); | ||
|
||
void onComplete(); | ||
} |
136 changes: 136 additions & 0 deletions
136
app/src/main/java/com/boredream/videoplayer/video/VideoCatalogDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
package com.boredream.videoplayer.video; | ||
|
||
import android.annotation.TargetApi; | ||
import android.content.Context; | ||
import android.os.Build; | ||
import android.support.v7.widget.GridLayoutManager; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.util.AttributeSet; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.FrameLayout; | ||
import android.widget.TextView; | ||
|
||
import com.boredream.videoplayer.R; | ||
import com.boredream.videoplayer.video.bean.VideoDetailInfo; | ||
|
||
public class VideoCatalogDialog extends FrameLayout { | ||
|
||
private RecyclerView rv_catalog; | ||
private VideoCatalogAdapter adapter; | ||
|
||
public VideoCatalogDialog(Context context) { | ||
super(context); | ||
init(); | ||
} | ||
|
||
public VideoCatalogDialog(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
init(); | ||
} | ||
|
||
public VideoCatalogDialog(Context context, AttributeSet attrs, int defStyleAttr) { | ||
super(context, attrs, defStyleAttr); | ||
init(); | ||
} | ||
|
||
@TargetApi(Build.VERSION_CODES.LOLLIPOP) | ||
public VideoCatalogDialog(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { | ||
super(context, attrs, defStyleAttr, defStyleRes); | ||
init(); | ||
} | ||
|
||
private void init() { | ||
LayoutInflater.from(getContext()).inflate(R.layout.video_catalog_dialog, this); | ||
findViewById(R.id.v_mask).setOnClickListener(new OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
hide(); | ||
} | ||
}); | ||
// findViewById(R.id.video_catalog_content).setOnClickListener(v -> {/*nothing*/}); // FIXME: 2017/6/7 | ||
rv_catalog = (RecyclerView) findViewById(R.id.rv_catalog); | ||
} | ||
|
||
public void show(VideoDetailInfo video) { | ||
if (adapter == null) { | ||
adapter = new VideoCatalogAdapter(getContext(), video, onVideoControlListener); | ||
GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 4); | ||
rv_catalog.setLayoutManager(layoutManager); | ||
rv_catalog.setAdapter(adapter); | ||
} else { | ||
adapter.updateVideo(video); | ||
} | ||
|
||
setVisibility(View.VISIBLE); | ||
} | ||
|
||
public void hide() { | ||
setVisibility(GONE); | ||
} | ||
|
||
private OnVideoControlListener onVideoControlListener; | ||
|
||
public void setOnVideoControlListener(OnVideoControlListener onVideoControlListener) { | ||
this.onVideoControlListener = onVideoControlListener; | ||
} | ||
|
||
public static class VideoCatalogAdapter extends RecyclerView.Adapter<VideoCatalogAdapter.ViewHolder> { | ||
|
||
private Context context; | ||
private VideoDetailInfo video; | ||
private OnVideoControlListener onVideoControlListener; | ||
|
||
public VideoCatalogAdapter(Context context, VideoDetailInfo video, OnVideoControlListener onVideoControlListener) { | ||
this.context = context; | ||
this.video = video; | ||
this.onVideoControlListener = onVideoControlListener; | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return video.seriesNumberTotal; | ||
} | ||
|
||
public void updateVideo(VideoDetailInfo video) { | ||
this.video = video; | ||
notifyDataSetChanged(); | ||
} | ||
|
||
public static class ViewHolder extends RecyclerView.ViewHolder { | ||
public TextView tv_index; | ||
|
||
public ViewHolder(final View itemView) { | ||
super(itemView); | ||
tv_index = (TextView) itemView.findViewById(R.id.tv_index); | ||
} | ||
} | ||
|
||
@Override | ||
public VideoCatalogAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||
View v = LayoutInflater.from(context).inflate(R.layout.video_item_catalog, parent, false); | ||
return new ViewHolder(v); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(VideoCatalogAdapter.ViewHolder holder, int position) { | ||
final int seriesNumber = position + 1; | ||
holder.tv_index.setText(String.valueOf(seriesNumber)); | ||
holder.tv_index.setBackgroundResource(seriesNumber == video.seriesNumber ? | ||
R.drawable.oval_red_stroke : R.drawable.oval_white_stroke); | ||
holder.tv_index.setTextColor(seriesNumber == video.seriesNumber ? | ||
0xFFFF6E5E : 0xFFFFFFFF); | ||
|
||
holder.tv_index.setOnClickListener(new OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
if (onVideoControlListener != null) { | ||
onVideoControlListener.onCatalogItemSelected(seriesNumber); | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.