├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── elliott │ │ └── supervideoplayer │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── elliott │ │ │ └── supervideoplayer │ │ │ ├── CustomMediaController.java │ │ │ ├── CustomMediaLiveController.java │ │ │ ├── LaunchActivity.java │ │ │ ├── VideoViewActivity.java │ │ │ ├── VideoViewLiveActivity.java │ │ │ ├── adapter │ │ │ ├── VideoAdapter.java │ │ │ └── ViewPagerAdapter.java │ │ │ ├── db │ │ │ ├── DaoMaster.java │ │ │ ├── DaoSession.java │ │ │ ├── VideoBeanDao.java │ │ │ └── VideoBeanDaoHelper.java │ │ │ ├── model │ │ │ └── VideoBean.java │ │ │ └── utils │ │ │ ├── Base64.java │ │ │ ├── BitmapUtil.java │ │ │ ├── CommonAdapter.java │ │ │ ├── DensityUtils.java │ │ │ ├── DialogUtils.java │ │ │ ├── ExceptionHandler.java │ │ │ ├── FileUtil.java │ │ │ ├── LogUtils.java │ │ │ ├── RandomUtil.java │ │ │ ├── T.java │ │ │ ├── TimeUtils.java │ │ │ └── ViewHolder.java │ └── res │ │ ├── drawable-hdpi │ │ ├── abc_ic_clear_search_api_holo_light.png │ │ ├── action_delete_selected_light.png │ │ ├── action_edit_light.png │ │ ├── action_hidden_default_dark.png │ │ ├── action_open_url.png │ │ ├── button_action.png │ │ ├── file_url_light.png │ │ ├── ic_delete.png │ │ ├── ic_launcher_vplayer.png │ │ ├── video_brightness_bg.png │ │ ├── video_num_bg.png │ │ ├── video_num_front.png │ │ └── video_volumn_bg.png │ │ ├── drawable-xhdpi │ │ ├── file_subtitle.png │ │ ├── mediacontroller_lock.png │ │ ├── mediacontroller_next.png │ │ ├── mediacontroller_pause.png │ │ ├── mediacontroller_play.png │ │ ├── mediacontroller_previous.png │ │ ├── mediacontroller_screen_fit.png │ │ ├── mediacontroller_screen_size.png │ │ ├── mediacontroller_setting.png │ │ ├── mediacontroller_snapshot.png │ │ ├── mediacontroller_sreen_size_100.png │ │ ├── mediacontroller_sreen_size_crop.png │ │ └── mediacontroller_unlock.png │ │ ├── drawable │ │ └── circular_border_not_radius.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── adjust_test_layout.xml │ │ ├── mediacontroller.xml │ │ ├── mediacontroller_live.xml │ │ ├── normal_dialog.xml │ │ ├── setting_layout.xml │ │ ├── toast_view.xml │ │ ├── video_adjust_layout.xml │ │ ├── video_item_layout.xml │ │ ├── video_play_layout.xml │ │ ├── video_title.xml │ │ └── video_title_live.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_vplayer.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── raw │ │ └── comments.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── elliott │ └── supervideoplayer │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle ├── source ├── Screenshot_2016-05-19-11-39-39.jpeg ├── Screenshot_2016-05-19-11-39-49.jpeg ├── Screenshot_2016-05-19-11-40-21.jpeg ├── start.gif └── start3.gif └── vitamio ├── .classpath ├── .gitignore ├── .project ├── AndroidManifest.xml ├── README.md ├── build.gradle ├── gradle.properties ├── gradlew ├── gradlew.bat ├── libs ├── arm64-v8a │ ├── libOMX.24.so │ ├── libffmpeg.so │ ├── libstlport_shared.so │ ├── libvao.0.so │ ├── libvinit.so │ ├── libvplayer.so │ ├── libvscanner.so │ ├── libvvo.0.so │ └── libvvo.9.so ├── armeabi-v7a │ ├── libOMX.11.so │ ├── libOMX.14.so │ ├── libOMX.18.so │ ├── libOMX.9.so │ ├── libffmpeg.so │ ├── libstlport_shared.so │ ├── libvao.0.so │ ├── libvinit.so │ ├── libvplayer.so │ ├── libvscanner.so │ ├── libvvo.0.so │ ├── libvvo.7.so │ ├── libvvo.8.so │ ├── libvvo.9.so │ └── libvvo.j.so └── x86 │ ├── libOMX.14.so │ ├── libOMX.18.so │ ├── libOMX.9.so │ ├── libffmpeg.so │ ├── libstlport_shared.so │ ├── libvao.0.so │ ├── libvinit.so │ ├── libvplayer.so │ ├── libvscanner.so │ ├── libvvo.0.so │ ├── libvvo.9.so │ └── libvvo.j.so ├── lint.xml ├── local.properties ├── proguard-project.txt ├── project.properties ├── res ├── drawable-hdpi │ └── ic_launcher.png ├── drawable-ldpi │ └── ic_launcher.png ├── drawable-mdpi │ └── ic_launcher.png ├── drawable-xhdpi │ ├── ic_launcher.png │ ├── mediacontroller_pause.png │ ├── mediacontroller_play.png │ ├── scrubber_control_disabled_holo.png │ ├── scrubber_control_focused_holo.png │ ├── scrubber_control_normal_holo.png │ ├── scrubber_control_pressed_holo.png │ ├── scrubber_primary_holo.9.png │ ├── scrubber_secondary_holo.9.png │ └── scrubber_track_holo_dark.9.png ├── drawable │ ├── mediacontroller_button.xml │ ├── scrubber_control_selector_holo.xml │ └── scrubber_progress_horizontal_holo_dark.xml ├── layout │ └── mediacontroller.xml └── values │ ├── colors.xml │ ├── strings.xml │ └── styles.xml └── src └── io └── vov └── vitamio ├── EGL.java ├── LibsChecker.java ├── MediaFile.java ├── MediaFormat.java ├── MediaMetadataRetriever.java ├── MediaPlayer.java ├── MediaScanner.java ├── MediaScannerClient.java ├── Metadata.java ├── ThumbnailUtils.java ├── VIntent.java ├── Vitamio.java ├── VitamioLicense.java ├── activity └── InitActivity.java ├── provider ├── MediaStore.java └── MiniThumbFile.java ├── utils ├── Base64.java ├── CPU.java ├── ContextUtils.java ├── Crypto.java ├── Device.java ├── FileUtils.java ├── IOUtils.java ├── Log.java ├── ScreenResolution.java └── StringUtils.java └── widget ├── CenterLayout.java ├── MediaController.java ├── OutlineTextView.java └── VideoView.java /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | 19 | # Local configuration file (sdk path, etc) 20 | local.properties 21 | 22 | # Proguard folder generated by Eclipse 23 | proguard/ 24 | 25 | 26 | # Android Studio project files 27 | *.iml 28 | .gradle 29 | .idea 30 | build 31 | <<<<<<< HEAD 32 | /build.gradle 33 | /.idea/ 34 | 35 | build.gradle 36 | 37 | .idea/misc.xml 38 | ======= 39 | .DS_Store 40 | 41 | /app/.gitignore -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | SuperVideoPlayer -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | 1.8 51 | 52 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SuperVideoPlayer 2 | 3 | **【停止维护说明:这个项目的开始的初衷是为了大家方便vitamio库项目而做的一个示例工程,但是vitamio并不是开源项目。导致很多功能根本无法进行二次开发。这项目也就没有维护的必要了。有需要的朋友,敬请期待我真正基于开源库开发的视频播放库!】** 4 | 5 | 集成android流媒体处理vitamio框架。实现播放本地视频,网络视频,直播等功能。 6 | > 写这个开源项目的初衷: 7 | 刚接触流媒体处理的时候,一个小的问题都能被难住半天。然后跑到qq群里面去问,google去搜(ps:官方群不鸟你)。一直觉得这样浪费了很多很多宝贵的时间。写这个开源项目是主要想把自己的踩过的一些坑都整理出来,能帮助到一些新接触流媒体处理的开发者。更多的是抛砖引玉,小弟也是流媒体处理的新兵一只。希望各位流媒体处理的大神,小神大家能一起开发这个项目,我们一起实现一个实用流媒体的开源库(走过的坑不能白走啊!!)。 8 | 9 | **注意事项**: 10 | 1. 用studio 导入项目可能较慢,耐心等一下**。 11 | 2. 播放本地视频只需要修改VideoViewActivity的mVideoView.setVideoPath(mVideoPath);将mVideoPath修改为你本地的视频的 路径:例如:“/storage/sdcard0/xxx.mp4"即可。 12 | 3. 关于Videoview的一些设置,大家可以参考vitamio的API。[vitamio Api链接](https://www.vitamio.org/docs/API/) 13 | 14 | --- 15 | **目前集成了vitamio,综合vitamio的特性目前实现的功能有**: 16 | 17 | - 播放本地视频,网络视频,直播 18 | - 左右侧滑动调节声音和亮度 19 | - 缓存视频进度条 20 | - 切换不同显示大小(全屏,拉伸,剪切) 21 | - 支持截屏 22 | - 支持快进,快退 23 | - **支持弹幕功能** 24 | 25 | 26 | vitamio支持的视频格式: 27 | - DivX/Xvid 28 | - FLV 29 | - TS/TP 30 | - MKV 31 | - MOV 32 | - M4V 33 | - AVI 34 | - MP4 35 | - 3GP 36 | 37 | 直播流格式: 38 | - MMS 39 | - RTSP (RTP, SDP), RTMP 40 | - HTTP progressive streaming 41 | - HLS - HTTP live streaming (M3U8) 42 | 43 | > 注: 不同视频格式的测试地址有mp4,avi,flv,直播流的测试地址有:RTMP,M3U8。如果大家有其他视频格式的链接地址,帮忙发我一下。添加到issue中就行 44 | 45 | 下一步: 46 | - 添加视频设置界面,可以设置播放的一些配置(画面质量,硬解码等) 47 | - 边播放,边缓存到本地 48 | 49 | 示例: 50 | 51 | --- 52 | 53 | ![Alt text](https://github.com/curtis2/SuperVideoPlayer/blob/0aaf3ce2b6fc817d50ffdbe79a75ef6701c0b96b/source/start.gif) 54 | 55 | ![Alt text](https://github.com/curtis2/SuperVideoPlayer/blob/master/source/start3.gif) 56 | 57 | ![Alt text](https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/master/source/Screenshot_2016-05-19-11-39-39.jpeg) 58 | ![Alt text](https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/master/source/Screenshot_2016-05-19-11-39-49.jpeg) 59 | ![Alt text](https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/master/source/Screenshot_2016-05-19-11-40-21.jpeg) 60 | 61 | *** 62 | 63 | ## 项目介绍: 64 | --- 65 | 1.引入库项目 66 | - **greenDAO** greenDAO是一个Android对象关系映射工具(ORM)库 67 | - **CircularFloatingActionMenu** 是用于安卓系统中的可自定义的动态圆形浮动菜单按钮。 68 | - **SwipeMenuListView** 是一种可以在某一个view条目中响应用户左右侧滑滑出操作菜单的UI类库。 69 | - **DanmakuFlameMaster** android弹幕支持库 70 | - **vitamio** 视频播放库 71 | 72 | > 引入的库除了 vitamio以外,其他的都只是涉及到界面ui,数据存储相关的。和流媒体的处理关系不太。 实现流媒体功能的时候完全可以不用考虑这些。 不要因为这个不参与这个项目哦。 73 | 74 | 2.核心类介绍 75 | 76 |   **LaunchActivity**: 77 | -  应用启动界面,有加载数据,添加数据。切换不同界面等功能。 78 | 79 | *** 80 |   **VideoViewActivity**: 81 | 82 | -   视频播放界面,在改类中使用vitamio的VideoActivity播放视频。 83 | 84 | *** 85 |   **CustomMediaController** : 86 | 87 | -   继承vitamio的MediaController类,是一个FrameLayout. CustomMediaController 类主要是用于显示视频控制布局(就是播放,暂停,截屏,左右滑动切换声音的界面)。 88 | 89 | >注:截屏,锁屏功能都是使用VideoView进行开发。所以都是在VideoViewActivity和CustomMediaController 中进行。 90 | CustomMediaController 类中处理相关ui操作,VideoViewActivity中处理VideoView的相关设置。 91 | 92 | 93 | 94 | ## 参与步骤: 95 | --- 96 | 1. 将该项目fork到自己的github; 97 | 2. 完成待实现功能的代码编写和测试。 98 | 3. 提交pull requests.(提交之前记得先拉取一下,避免冲突哦!!) 99 | 100 | 101 | ## 问题反馈: 102 | --- 103 |  如果在使用过程中发现有问题,请描述清楚问题。我会尽力去解决,如果你有好的解决方案,也欢迎提交requests. 104 |   例如: 视频播放不了 105 | - 请写明视频格式,和链接,然后在github上提交issue。 106 | 107 | ## 扩展 108 | --- 109 | 大家如果在使用中想要提出公司业务相关的功能,比如视频前加广告,可以直接提交到issue上。(ps:这个我现在也不知道怎么做)。我会把一些好的需求加到项目的功能计划中,相信大家一起参与就能实现。 110 | 111 | ## 版权说明 112 | --- 113 | 项目目前是基于vitamio进行二次开发的,该开源库对个人开发者免费,对公司收费。如果是公司使用,请自行和[vitamio公司](https://www.vitamio.org)协商付费。 114 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.elliott.supervideoplayer" 9 | minSdkVersion 16 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(include: ['*.jar'], dir: 'libs') 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.2.1' 26 | compile 'org.greenrobot:greendao:2.2.0' 27 | compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2' 28 | compile 'com.baoyz.swipemenulistview:library:1.3.0' 29 | compile 'com.github.ctiao:DanmakuFlameMaster:0.4.5' 30 | compile 'com.android.support:percent:23.4.0' 31 | compile project(':vitamio') 32 | } 33 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in E:\tools\android_sdk\android-sdk-windows/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/elliott/supervideoplayer/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.elliott.supervideoplayer; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 26 | 27 | 34 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/elliott/supervideoplayer/CustomMediaLiveController.java: -------------------------------------------------------------------------------- 1 | package com.elliott.supervideoplayer; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.widget.CompoundButton; 7 | import android.widget.Switch; 8 | 9 | import io.vov.vitamio.widget.MediaController; 10 | import master.flame.danmaku.controller.IDanmakuView; 11 | import master.flame.danmaku.danmaku.model.android.DanmakuContext; 12 | import master.flame.danmaku.danmaku.parser.BaseDanmakuParser; 13 | 14 | /** 15 | * auther: elliott zhang 16 | * Emaill:18292967668@163.com 17 | */ 18 | public class CustomMediaLiveController extends MediaController { 19 | private Context mContext; 20 | VideoViewActivity activity; 21 | /** 22 | * 弹幕相关 23 | */ 24 | private IDanmakuView mDanmakuView; 25 | private Switch mtanMuSwitch; 26 | private DanmakuContext mDanmakuContext; 27 | private BaseDanmakuParser mParser; 28 | 29 | public CustomMediaLiveController(Context context) { 30 | super(context); 31 | this.mContext = context; 32 | } 33 | 34 | @Override 35 | protected View makeControllerView() { 36 | return ((LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)). 37 | inflate(getResources().getIdentifier("mediacontroller_live", "layout", mContext.getPackageName()), this); 38 | } 39 | 40 | @Override 41 | protected void initOtherView() { 42 | mtanMuSwitch= (Switch) mRoot.findViewById(R.id.switch_tanmu); 43 | mtanMuSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { 44 | @Override 45 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 46 | if(isChecked){ 47 | mtanMuSwitch.setBackgroundColor(getResources().getColor(R.color.video_red_color)); 48 | //开启弹幕 49 | mDanmakuView.prepare(mParser, mDanmakuContext); 50 | mDanmakuView.show(); 51 | }else{ 52 | mtanMuSwitch.setBackgroundColor(getResources().getColor(R.color.video_gray_color)); 53 | //关闭弹幕 54 | mDanmakuView.hide(); 55 | } 56 | } 57 | }); 58 | } 59 | public void setTanMuView(IDanmakuView tanMuView,DanmakuContext mDanmakuContext,BaseDanmakuParser mParser ) { 60 | this.mDanmakuView = tanMuView; 61 | this.mDanmakuContext=mDanmakuContext; 62 | this.mParser=mParser; 63 | } 64 | 65 | 66 | } 67 | -------------------------------------------------------------------------------- /app/src/main/java/com/elliott/supervideoplayer/adapter/VideoAdapter.java: -------------------------------------------------------------------------------- 1 | package com.elliott.supervideoplayer.adapter; 2 | 3 | import android.content.Context; 4 | 5 | import com.elliott.supervideoplayer.R; 6 | import com.elliott.supervideoplayer.model.VideoBean; 7 | import com.elliott.supervideoplayer.utils.CommonAdapter; 8 | import com.elliott.supervideoplayer.utils.ViewHolder; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | /** 14 | * auther: elliott zhang 15 | * Emaill:18292967668@163.com 16 | */ 17 | public class VideoAdapter extends CommonAdapter { 18 | 19 | public VideoAdapter(Context context, List mDatas, int layoutId) { 20 | super(context, mDatas, layoutId); 21 | } 22 | 23 | public void setDatas(ArrayList list){ 24 | this.mDatas=list; 25 | } 26 | @Override 27 | public void convert(ViewHolder holder, VideoBean item) { 28 | holder.setText(R.id.item_name_tv,item.getVideoName()) 29 | .setText(R.id.item_link_tv,item.getVideoLink()); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/java/com/elliott/supervideoplayer/adapter/ViewPagerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.elliott.supervideoplayer.adapter; 2 | 3 | import android.support.v4.view.PagerAdapter; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * auther: elliott zhang 11 | * Emaill:18292967668@163.com 12 | */ 13 | public class ViewPagerAdapter extends PagerAdapter { 14 | private List mListViews; 15 | 16 | public ViewPagerAdapter(List mListViews) { 17 | this.mListViews = mListViews;//构造方法,参数是我们的页卡,这样比较方便。 18 | } 19 | 20 | @Override 21 | public void destroyItem(ViewGroup container, int position, Object object) { 22 | container.removeView(mListViews.get(position));//删除页卡 23 | } 24 | 25 | 26 | @Override 27 | public Object instantiateItem(ViewGroup container, int position) { //这个方法用来实例化页卡 28 | container.addView(mListViews.get(position), 0);//添加页卡 29 | return mListViews.get(position); 30 | } 31 | 32 | @Override 33 | public int getCount() { 34 | return mListViews.size();//返回页卡的数量 35 | } 36 | 37 | @Override 38 | public boolean isViewFromObject(View arg0, Object arg1) { 39 | return arg0==arg1;//官方提示这样写 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/elliott/supervideoplayer/db/DaoMaster.java: -------------------------------------------------------------------------------- 1 | package com.elliott.supervideoplayer.db; 2 | 3 | import android.content.Context; 4 | import android.database.sqlite.SQLiteDatabase; 5 | import android.database.sqlite.SQLiteDatabase.CursorFactory; 6 | import android.database.sqlite.SQLiteOpenHelper; 7 | import android.util.Log; 8 | 9 | import de.greenrobot.dao.AbstractDaoMaster; 10 | import de.greenrobot.dao.identityscope.IdentityScopeType; 11 | 12 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 13 | /** 14 | * Master of DAO (schema version 1): knows all DAOs. 15 | */ 16 | public class DaoMaster extends AbstractDaoMaster { 17 | public static final int SCHEMA_VERSION = 1; 18 | 19 | /** Creates underlying database table using DAOs. */ 20 | public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) { 21 | VideoBeanDao.createTable(db, ifNotExists); 22 | } 23 | 24 | /** Drops underlying database table using DAOs. */ 25 | public static void dropAllTables(SQLiteDatabase db, boolean ifExists) { 26 | VideoBeanDao.dropTable(db, ifExists); 27 | } 28 | 29 | public static abstract class OpenHelper extends SQLiteOpenHelper { 30 | 31 | public OpenHelper(Context context, String name, CursorFactory factory) { 32 | super(context, name, factory, SCHEMA_VERSION); 33 | } 34 | 35 | @Override 36 | public void onCreate(SQLiteDatabase db) { 37 | Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); 38 | createAllTables(db, false); 39 | } 40 | } 41 | 42 | /** WARNING: Drops all table on Upgrade! Use only during development. */ 43 | public static class DevOpenHelper extends OpenHelper { 44 | public DevOpenHelper(Context context, String name, CursorFactory factory) { 45 | super(context, name, factory); 46 | } 47 | 48 | @Override 49 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { 50 | Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); 51 | dropAllTables(db, true); 52 | onCreate(db); 53 | } 54 | } 55 | 56 | public DaoMaster(SQLiteDatabase db) { 57 | super(db, SCHEMA_VERSION); 58 | registerDaoClass(VideoBeanDao.class); 59 | } 60 | 61 | public DaoSession newSession() { 62 | return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); 63 | } 64 | 65 | public DaoSession newSession(IdentityScopeType type) { 66 | return new DaoSession(db, type, daoConfigMap); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /app/src/main/java/com/elliott/supervideoplayer/db/DaoSession.java: -------------------------------------------------------------------------------- 1 | package com.elliott.supervideoplayer.db; 2 | 3 | import android.database.sqlite.SQLiteDatabase; 4 | 5 | import com.elliott.supervideoplayer.model.VideoBean; 6 | 7 | import java.util.Map; 8 | 9 | import de.greenrobot.dao.AbstractDao; 10 | import de.greenrobot.dao.AbstractDaoSession; 11 | import de.greenrobot.dao.identityscope.IdentityScopeType; 12 | import de.greenrobot.dao.internal.DaoConfig; 13 | 14 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 15 | 16 | /** 17 | * {@inheritDoc} 18 | * 19 | * @see de.greenrobot.dao.AbstractDaoSession 20 | */ 21 | public class DaoSession extends AbstractDaoSession { 22 | 23 | private final DaoConfig videoBeanDaoConfig; 24 | 25 | private final VideoBeanDao videoBeanDao; 26 | 27 | public DaoSession(SQLiteDatabase db, IdentityScopeType type, Map>, DaoConfig> 28 | daoConfigMap) { 29 | super(db); 30 | 31 | videoBeanDaoConfig = daoConfigMap.get(VideoBeanDao.class).clone(); 32 | videoBeanDaoConfig.initIdentityScope(type); 33 | 34 | videoBeanDao = new VideoBeanDao(videoBeanDaoConfig, this); 35 | 36 | registerDao(VideoBean.class, videoBeanDao); 37 | } 38 | 39 | public void clear() { 40 | videoBeanDaoConfig.getIdentityScope().clear(); 41 | } 42 | 43 | public VideoBeanDao getVideoBeanDao() { 44 | return videoBeanDao; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/java/com/elliott/supervideoplayer/db/VideoBeanDao.java: -------------------------------------------------------------------------------- 1 | package com.elliott.supervideoplayer.db; 2 | 3 | import android.database.Cursor; 4 | import android.database.sqlite.SQLiteDatabase; 5 | import android.database.sqlite.SQLiteStatement; 6 | 7 | import com.elliott.supervideoplayer.model.VideoBean; 8 | 9 | import de.greenrobot.dao.AbstractDao; 10 | import de.greenrobot.dao.Property; 11 | import de.greenrobot.dao.internal.DaoConfig; 12 | 13 | 14 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 15 | /** 16 | * DAO for table VIDEO_BEAN. 17 | */ 18 | public class VideoBeanDao extends AbstractDao { 19 | 20 | public static final String TABLENAME = "VIDEO_BEAN"; 21 | 22 | /** 23 | * Properties of entity VideoBean.
24 | * Can be used for QueryBuilder and for referencing column names. 25 | */ 26 | public static class Properties { 27 | public final static Property Id = new Property(0, Long.class, "id", true, "_id"); 28 | public final static Property VideoName = new Property(1, String.class, "VideoName", false, "VIDEO_NAME"); 29 | public final static Property VideoLink = new Property(2, String.class, "VideoLink", false, "VIDEO_LINK"); 30 | public final static Property ThumbnailPath = new Property(3, String.class, "thumbnailPath", false, "THUMBNAIL_PATH"); 31 | public final static Property Totalsize = new Property(4, String.class, "totalsize", false, "TOTALSIZE"); 32 | public final static Property Totalduration = new Property(5, String.class, "totalduration", false, "TOTALDURATION"); 33 | public final static Property Type = new Property(6, Integer.class, "type", false, "TYPE"); 34 | }; 35 | 36 | 37 | public VideoBeanDao(DaoConfig config) { 38 | super(config); 39 | } 40 | 41 | public VideoBeanDao(DaoConfig config, DaoSession daoSession) { 42 | super(config, daoSession); 43 | } 44 | 45 | /** Creates the underlying database table. */ 46 | public static void createTable(SQLiteDatabase db, boolean ifNotExists) { 47 | String constraint = ifNotExists? "IF NOT EXISTS ": ""; 48 | db.execSQL("CREATE TABLE " + constraint + "'VIDEO_BEAN' (" + // 49 | "'_id' INTEGER PRIMARY KEY ," + // 0: id 50 | "'VIDEO_NAME' TEXT NOT NULL ," + // 1: VideoName 51 | "'VIDEO_LINK' TEXT," + // 2: VideoLink 52 | "'THUMBNAIL_PATH' TEXT," + // 3: thumbnailPath 53 | "'TOTALSIZE' TEXT," + // 4: totalsize 54 | "'TOTALDURATION' TEXT," + // 5: totalduration 55 | "'TYPE' INTEGER);"); // 6: type 56 | } 57 | 58 | /** Drops the underlying database table. */ 59 | public static void dropTable(SQLiteDatabase db, boolean ifExists) { 60 | String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "'VIDEO_BEAN'"; 61 | db.execSQL(sql); 62 | } 63 | 64 | /** @inheritdoc */ 65 | @Override 66 | protected void bindValues(SQLiteStatement stmt, VideoBean entity) { 67 | stmt.clearBindings(); 68 | 69 | Long id = entity.getId(); 70 | if (id != null) { 71 | stmt.bindLong(1, id); 72 | } 73 | stmt.bindString(2, entity.getVideoName()); 74 | 75 | String VideoLink = entity.getVideoLink(); 76 | if (VideoLink != null) { 77 | stmt.bindString(3, VideoLink); 78 | } 79 | 80 | String thumbnailPath = entity.getThumbnailPath(); 81 | if (thumbnailPath != null) { 82 | stmt.bindString(4, thumbnailPath); 83 | } 84 | 85 | String totalsize = entity.getTotalsize(); 86 | if (totalsize != null) { 87 | stmt.bindString(5, totalsize); 88 | } 89 | 90 | String totalduration = entity.getTotalduration(); 91 | if (totalduration != null) { 92 | stmt.bindString(6, totalduration); 93 | } 94 | 95 | Integer type = entity.getType(); 96 | if (type != null) { 97 | stmt.bindLong(7, type); 98 | } 99 | } 100 | 101 | /** @inheritdoc */ 102 | @Override 103 | public Long readKey(Cursor cursor, int offset) { 104 | return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); 105 | } 106 | 107 | /** @inheritdoc */ 108 | @Override 109 | public VideoBean readEntity(Cursor cursor, int offset) { 110 | VideoBean entity = new VideoBean( // 111 | cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id 112 | cursor.getString(offset + 1), // VideoName 113 | cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // VideoLink 114 | cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // thumbnailPath 115 | cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // totalsize 116 | cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // totalduration 117 | cursor.isNull(offset + 6) ? null : cursor.getInt(offset + 6) // type 118 | ); 119 | return entity; 120 | } 121 | 122 | /** @inheritdoc */ 123 | @Override 124 | public void readEntity(Cursor cursor, VideoBean entity, int offset) { 125 | entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); 126 | entity.setVideoName(cursor.getString(offset + 1)); 127 | entity.setVideoLink(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); 128 | entity.setThumbnailPath(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); 129 | entity.setTotalsize(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); 130 | entity.setTotalduration(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); 131 | entity.setType(cursor.isNull(offset + 6) ? null : cursor.getInt(offset + 6)); 132 | } 133 | 134 | /** @inheritdoc */ 135 | @Override 136 | protected Long updateKeyAfterInsert(VideoBean entity, long rowId) { 137 | entity.setId(rowId); 138 | return rowId; 139 | } 140 | 141 | /** @inheritdoc */ 142 | @Override 143 | public Long getKey(VideoBean entity) { 144 | if(entity != null) { 145 | return entity.getId(); 146 | } else { 147 | return null; 148 | } 149 | } 150 | 151 | /** @inheritdoc */ 152 | @Override 153 | protected boolean isEntityUpdateable() { 154 | return true; 155 | } 156 | 157 | } 158 | -------------------------------------------------------------------------------- /app/src/main/java/com/elliott/supervideoplayer/db/VideoBeanDaoHelper.java: -------------------------------------------------------------------------------- 1 | package com.elliott.supervideoplayer.db; 2 | 3 | import android.content.Context; 4 | import android.database.sqlite.SQLiteDatabase; 5 | 6 | import com.elliott.supervideoplayer.model.VideoBean; 7 | 8 | import java.util.ArrayList; 9 | 10 | /** 11 | * auther: elliott zhang 12 | * Emaill:18292967668@163.com 13 | */ 14 | public class VideoBeanDaoHelper { 15 | VideoBeanDao noteDao; 16 | public VideoBeanDaoHelper(Context context) { 17 | DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(context, "VideoBean-db", null); 18 | SQLiteDatabase db = helper.getWritableDatabase(); 19 | DaoMaster daoMaster = new DaoMaster(db); 20 | DaoSession daoSession = daoMaster.newSession(); 21 | noteDao = daoSession.getVideoBeanDao(); 22 | } 23 | 24 | public ArrayList getDatasByType(int type){ 25 | return (ArrayList) noteDao.queryBuilder().where(VideoBeanDao.Properties.Type.eq(type)).list(); 26 | } 27 | 28 | public void insertBean(VideoBean bean){ 29 | noteDao.insert(bean); 30 | } 31 | 32 | public void deleteBean(VideoBean bean){ 33 | noteDao.delete(bean); 34 | } 35 | 36 | public void updateBean(VideoBean bean){ 37 | noteDao.update(bean); 38 | } 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/elliott/supervideoplayer/model/VideoBean.java: -------------------------------------------------------------------------------- 1 | package com.elliott.supervideoplayer.model; 2 | 3 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 4 | /** 5 | * Entity mapped to table VIDEO_BEAN. 6 | */ 7 | public class VideoBean { 8 | private Long id; 9 | /** Not-null value. */ 10 | private String VideoName; 11 | private String VideoLink; 12 | private String thumbnailPath; 13 | private String totalsize; 14 | private String totalduration; 15 | private Integer type; 16 | 17 | public VideoBean() { 18 | } 19 | 20 | public VideoBean(Long id) { 21 | this.id = id; 22 | } 23 | 24 | public VideoBean(Long id, String VideoName, String VideoLink, String thumbnailPath, String totalsize, String totalduration, Integer type) { 25 | this.id = id; 26 | this.VideoName = VideoName; 27 | this.VideoLink = VideoLink; 28 | this.thumbnailPath = thumbnailPath; 29 | this.totalsize = totalsize; 30 | this.totalduration = totalduration; 31 | this.type = type; 32 | } 33 | 34 | public Long getId() { 35 | return id; 36 | } 37 | 38 | public void setId(Long id) { 39 | this.id = id; 40 | } 41 | 42 | /** Not-null value. */ 43 | public String getVideoName() { 44 | return VideoName; 45 | } 46 | 47 | /** Not-null value; ensure this value is available before it is saved to the database. */ 48 | public void setVideoName(String VideoName) { 49 | this.VideoName = VideoName; 50 | } 51 | 52 | public String getVideoLink() { 53 | return VideoLink; 54 | } 55 | 56 | public void setVideoLink(String VideoLink) { 57 | this.VideoLink = VideoLink; 58 | } 59 | 60 | public String getThumbnailPath() { 61 | return thumbnailPath; 62 | } 63 | 64 | public void setThumbnailPath(String thumbnailPath) { 65 | this.thumbnailPath = thumbnailPath; 66 | } 67 | 68 | public String getTotalsize() { 69 | return totalsize; 70 | } 71 | 72 | public void setTotalsize(String totalsize) { 73 | this.totalsize = totalsize; 74 | } 75 | 76 | public String getTotalduration() { 77 | return totalduration; 78 | } 79 | 80 | public void setTotalduration(String totalduration) { 81 | this.totalduration = totalduration; 82 | } 83 | 84 | public Integer getType() { 85 | return type; 86 | } 87 | 88 | public void setType(Integer type) { 89 | this.type = type; 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /app/src/main/java/com/elliott/supervideoplayer/utils/CommonAdapter.java: -------------------------------------------------------------------------------- 1 | package com.elliott.supervideoplayer.utils; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.BaseAdapter; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * auther: elliott zhang 13 | * Emaill:18292967668@163.com 14 | */ 15 | public abstract class CommonAdapter extends BaseAdapter { 16 | protected LayoutInflater mInflater; 17 | protected Context mContext; 18 | protected List mDatas; 19 | protected int layoutId; 20 | public CommonAdapter(Context context, List mDatas, int layoutId) 21 | { 22 | mInflater = LayoutInflater.from(context); 23 | this.mContext = context; 24 | this.mDatas = mDatas; 25 | this.layoutId = layoutId; 26 | } 27 | @Override 28 | public int getCount() { 29 | return mDatas.size(); 30 | } 31 | 32 | @Override 33 | public Object getItem(int position) { 34 | return mDatas.get(position); 35 | } 36 | 37 | @Override 38 | public long getItemId(int position) { 39 | return position; 40 | } 41 | @Override 42 | public View getView(int position, View convertView, ViewGroup parent) 43 | { 44 | ViewHolder holder = ViewHolder.get(mContext, convertView, parent,layoutId, position); 45 | convert(holder, (T)getItem(position)); 46 | return holder.getConvertView(); 47 | } 48 | 49 | public abstract void convert(ViewHolder holder, T item); 50 | 51 | 52 | 53 | } 54 | -------------------------------------------------------------------------------- /app/src/main/java/com/elliott/supervideoplayer/utils/DensityUtils.java: -------------------------------------------------------------------------------- 1 | package com.elliott.supervideoplayer.utils; 2 | 3 | import android.content.Context; 4 | import android.util.TypedValue; 5 | 6 | /** 7 | * 常用单位转换的辅助类 8 | * auther: elliott zhang 9 | * Emaill:18292967668@163.com 10 | */ 11 | public class DensityUtils { 12 | private DensityUtils() 13 | { 14 | /* cannot be instantiated */ 15 | throw new UnsupportedOperationException("cannot be instantiated"); 16 | } 17 | 18 | public static int dp2px(Context context, float dpVal) 19 | { 20 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 21 | dpVal, context.getResources().getDisplayMetrics()); 22 | } 23 | 24 | /** 25 | * sp转px 26 | * 27 | * @param context 28 | * @param val 29 | * @return 30 | */ 31 | public static int sp2px(Context context, float spVal) 32 | { 33 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 34 | spVal, context.getResources().getDisplayMetrics()); 35 | } 36 | 37 | /** 38 | * px转dp 39 | * 40 | * @param context 41 | * @param pxVal 42 | * @return 43 | */ 44 | public static float px2dp(Context context, float pxVal) 45 | { 46 | final float scale = context.getResources().getDisplayMetrics().density; 47 | return (pxVal / scale); 48 | } 49 | 50 | /** 51 | * px转sp 52 | * 53 | * @param fontScale 54 | * @param pxVal 55 | * @return 56 | */ 57 | public static float px2sp(Context context, float pxVal) 58 | { 59 | return (pxVal / context.getResources().getDisplayMetrics().scaledDensity); 60 | } 61 | 62 | 63 | } 64 | -------------------------------------------------------------------------------- /app/src/main/java/com/elliott/supervideoplayer/utils/DialogUtils.java: -------------------------------------------------------------------------------- 1 | package com.elliott.supervideoplayer.utils; 2 | 3 | import android.app.AlertDialog; 4 | import android.content.Context; 5 | import android.util.SparseArray; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.widget.TextView; 9 | 10 | /** 11 | * 用于创建自定义dialog的工具类 12 | * auther: elliott zhang 13 | * Emaill:18292967668@163.com 14 | */ 15 | public class DialogUtils { 16 | private SparseArray mViews; 17 | private Context mContext; 18 | private View mContentView; 19 | AlertDialog alertDialog; 20 | 21 | public DialogUtils( Context mContext, int mLayoutId) { 22 | this.mContext = mContext; 23 | mContentView= LayoutInflater.from(mContext).inflate(mLayoutId, null); 24 | mViews = new SparseArray(); 25 | } 26 | 27 | public DialogUtils show(){ 28 | if(alertDialog==null){ 29 | alertDialog=new AlertDialog.Builder(mContext).create(); 30 | alertDialog.setView(mContentView); 31 | } 32 | alertDialog.show(); 33 | return this; 34 | } 35 | 36 | public void close(){ 37 | if(alertDialog!=null&&alertDialog.isShowing()){ 38 | alertDialog.dismiss(); 39 | } 40 | } 41 | /** 42 | * 通过控件的Id获取对于的控件,如果没有则加入views 43 | * @param viewId 44 | * @return 45 | */ 46 | public T getView(int viewId) 47 | { 48 | 49 | View view = mViews.get(viewId); 50 | if (view == null) 51 | { 52 | view = mContentView.findViewById(viewId); 53 | mViews.put(viewId, view); 54 | } 55 | return (T) view; 56 | } 57 | 58 | /** 59 | * 设置TextView的值 60 | * 61 | * @param viewId 62 | * @param text 63 | * @return 64 | */ 65 | public DialogUtils setText(int viewId, String text) 66 | { 67 | TextView tv = getView(viewId); 68 | tv.setText(text); 69 | return this; 70 | } 71 | 72 | public DialogUtils setVisible(int viewId, boolean visible) 73 | { 74 | View view = getView(viewId); 75 | view.setVisibility(visible ? View.VISIBLE : View.GONE); 76 | return this; 77 | } 78 | /** 79 | * 关于事件的 80 | */ 81 | public DialogUtils setOnClickListener(int viewId, 82 | View.OnClickListener listener) 83 | { 84 | View view = getView(viewId); 85 | view.setOnClickListener(listener); 86 | return this; 87 | } 88 | 89 | public DialogUtils setOnTouchListener(int viewId, 90 | View.OnTouchListener listener) 91 | { 92 | View view = getView(viewId); 93 | view.setOnTouchListener(listener); 94 | return this; 95 | } 96 | 97 | public DialogUtils setOnLongClickListener(int viewId, 98 | View.OnLongClickListener listener) 99 | { 100 | View view = getView(viewId); 101 | view.setOnLongClickListener(listener); 102 | return this; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /app/src/main/java/com/elliott/supervideoplayer/utils/ExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.elliott.supervideoplayer.utils; 2 | 3 | import java.io.PrintWriter; 4 | import java.io.StringWriter; 5 | 6 | /** 7 | * auther: elliott zhang 8 | * Emaill:18292967668@163.com 9 | */ 10 | public class ExceptionHandler implements java.lang.Thread.UncaughtExceptionHandler { 11 | private final String LINE_SEPARATOR = "\n"; 12 | public static final String LOG_TAG = ExceptionHandler.class.getSimpleName(); 13 | 14 | @SuppressWarnings("deprecation") 15 | public void uncaughtException(Thread thread, Throwable exception) { 16 | StringWriter stackTrace = new StringWriter(); 17 | exception.printStackTrace(new PrintWriter(stackTrace)); 18 | 19 | StringBuilder errorReport = new StringBuilder(); 20 | errorReport.append(stackTrace.toString()); 21 | 22 | LogUtils.e(LogUtils.LOG_TAG, errorReport.toString()); 23 | 24 | android.os.Process.killProcess(android.os.Process.myPid()); 25 | System.exit(10); 26 | } 27 | } -------------------------------------------------------------------------------- /app/src/main/java/com/elliott/supervideoplayer/utils/FileUtil.java: -------------------------------------------------------------------------------- 1 | package com.elliott.supervideoplayer.utils; 2 | 3 | import java.io.*; 4 | import java.nio.channels.FileChannel; 5 | import java.text.DecimalFormat; 6 | 7 | /** 8 | * @author MaTianyu 9 | * @date 2014-08-10 10 | */ 11 | public class FileUtil { 12 | 13 | private static final String TAG = FileUtil.class.getSimpleName(); 14 | 15 | public static void fileChannelCopy(File s, File t) { 16 | FileInputStream fi = null; 17 | FileOutputStream fo = null; 18 | try { 19 | fi = new FileInputStream(s); 20 | fo = new FileOutputStream(t); 21 | FileChannel in = fi.getChannel();//得到对应的文件通道 22 | FileChannel out = fo.getChannel();//得到对应的文件通道 23 | in.transferTo(0, in.size(), out);//连接两个通道,并且从in通道读取,然后写入out通道 24 | } catch (IOException e) { 25 | e.printStackTrace(); 26 | } finally { 27 | try { 28 | if (fo != null) fo.close(); 29 | if (fi != null) fi.close(); 30 | } catch (IOException e) { 31 | e.printStackTrace(); 32 | } 33 | 34 | } 35 | } 36 | 37 | public static String formatFileSizeToString(long fileLen) {// 转换文件大小 38 | DecimalFormat df = new DecimalFormat("#.00"); 39 | String fileSizeString = ""; 40 | if (fileLen < 1024) { 41 | fileSizeString = df.format((double) fileLen) + "B"; 42 | } else if (fileLen < 1048576) { 43 | fileSizeString = df.format((double) fileLen / 1024) + "K"; 44 | } else if (fileLen < 1073741824) { 45 | fileSizeString = df.format((double) fileLen / 1048576) + "M"; 46 | } else { 47 | fileSizeString = df.format((double) fileLen / 1073741824) + "G"; 48 | } 49 | return fileSizeString; 50 | } 51 | 52 | /*** 53 | * 根据路径删除图片 54 | */ 55 | public static boolean deleteFile(File file)throws IOException{ 56 | return file != null && file.delete(); 57 | } 58 | 59 | /*** 60 | * 获取文件扩展名 61 | * @param filename 62 | * @return 返回文件扩展名 63 | */ 64 | public static String getExtensionName(String filename) { 65 | if ((filename != null) && (filename.length() > 0)) { 66 | int dot = filename.lastIndexOf('.'); 67 | if ((dot >-1) && (dot < (filename.length() - 1))) { 68 | return filename.substring(dot + 1); 69 | } 70 | } 71 | return filename; 72 | } 73 | 74 | 75 | /** 76 | * 读取指定文件的输出 77 | */ 78 | public static String getFileOutputString(String path) { 79 | try { 80 | BufferedReader bufferedReader = new BufferedReader(new FileReader(path), 8192); 81 | StringBuilder sb = new StringBuilder(); 82 | String line = null; 83 | while ((line = bufferedReader.readLine()) != null) { 84 | sb.append("\n").append(line); 85 | } 86 | bufferedReader.close(); 87 | return sb.toString(); 88 | } catch (IOException e) { 89 | e.printStackTrace(); 90 | } 91 | return null; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /app/src/main/java/com/elliott/supervideoplayer/utils/LogUtils.java: -------------------------------------------------------------------------------- 1 | package com.elliott.supervideoplayer.utils; 2 | 3 | import android.util.Log; 4 | 5 | 6 | public class LogUtils { 7 | public static String LOG_TAG = "superpalyer"; 8 | /* public static void writeLogToFile(String logContent) { 9 | if (!UclassUtils.IS_DEBUG) 10 | return; 11 | // sdcard/Uclass/Log/yyyy-MM-dd.txt 12 | File logFile = new File(LocalFileUtils.getLogDir() + "/" + DateUtils.currDay() + ".txt"); 13 | if (!logFile.exists()) { 14 | try { 15 | logFile.createNewFile(); 16 | } catch (IOException e) { 17 | e.printStackTrace(); 18 | } 19 | } 20 | FileWriter fw = null; 21 | try { 22 | fw = new FileWriter(logFile, true); 23 | Date date = new Date(); 24 | String content = DateUtils.dateToString(date, DateUtils.FORMAT_ONE) +" <<<<>>> " + logContent; 25 | fw.write("\r\n"); 26 | fw.write(content); 27 | fw.flush(); 28 | } catch (Exception e) { 29 | e.printStackTrace(); 30 | } finally { 31 | if (fw != null) { 32 | try { 33 | fw.close(); 34 | } catch (IOException e) { 35 | // TODO Auto-generated catch block 36 | e.printStackTrace(); 37 | } 38 | } 39 | } 40 | } 41 | */ 42 | private LogUtils() 43 | { 44 | /* cannot be instantiated */ 45 | throw new UnsupportedOperationException("cannot be instantiated"); 46 | } 47 | 48 | public static boolean isDebug = true;// 是否需要打印bug,可以在application的onCreate函数里面初始化 49 | private static final String TAG = "TeacherHelp"; 50 | 51 | // 下面四个是默认tag的函数 52 | public static void i(String msg) 53 | { 54 | if (isDebug) 55 | Log.i(TAG, msg); 56 | } 57 | 58 | public static void d(String msg) 59 | { 60 | if (isDebug) 61 | Log.d(TAG, msg); 62 | } 63 | 64 | public static void e(String msg) 65 | { 66 | if (isDebug) 67 | Log.e(TAG, msg); 68 | } 69 | 70 | public static void v(String msg) 71 | { 72 | if (isDebug) 73 | Log.v(TAG, msg); 74 | } 75 | 76 | // 下面是传入自定义tag的函数 77 | public static void i(String tag, String msg) 78 | { 79 | if (isDebug) 80 | Log.i(tag, msg); 81 | } 82 | 83 | public static void d(String tag, String msg) 84 | { 85 | if (isDebug) 86 | Log.i(tag, msg); 87 | } 88 | 89 | public static void e(String tag, String msg) 90 | { 91 | if (isDebug) 92 | Log.e(tag, msg); 93 | } 94 | 95 | public static void v(String tag, String msg) 96 | { 97 | if (isDebug) 98 | Log.i(tag, msg); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /app/src/main/java/com/elliott/supervideoplayer/utils/RandomUtil.java: -------------------------------------------------------------------------------- 1 | package com.elliott.supervideoplayer.utils; 2 | 3 | import java.util.Random; 4 | 5 | /** 6 | * 随机工具类 7 | * modified form Trinea 8 | * @author trinea 9 | * @date 2014-12-10 10 | */ 11 | public class RandomUtil { 12 | public static final String NUMBERS_AND_LETTERS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; 13 | public static final String NUMBERS = "0123456789"; 14 | public static final String LETTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; 15 | public static final String CAPITAL_LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 16 | public static final String LOWER_CASE_LETTERS = "abcdefghijklmnopqrstuvwxyz"; 17 | 18 | private RandomUtil() { 19 | throw new AssertionError(); 20 | } 21 | 22 | /** 23 | * get a fixed-length random string, its a mixture of uppercase, lowercase letters and numbers 24 | * 25 | * @param length 26 | * @return 27 | * @see RandomUtil#getRandom(String source, int length) 28 | */ 29 | public static String getRandomNumbersAndLetters(int length) { 30 | return getRandom(NUMBERS_AND_LETTERS, length); 31 | } 32 | 33 | /** 34 | * get a fixed-length random string, its a mixture of numbers 35 | * 36 | * @param length 37 | * @return 38 | * @see RandomUtil#getRandom(String source, int length) 39 | */ 40 | public static String getRandomNumbers(int length) { 41 | return getRandom(NUMBERS, length); 42 | } 43 | 44 | /** 45 | * get a fixed-length random string, its a mixture of uppercase and lowercase letters 46 | * 47 | * @param length 48 | * @return 49 | * @see RandomUtil#getRandom(String source, int length) 50 | */ 51 | public static String getRandomLetters(int length) { 52 | return getRandom(LETTERS, length); 53 | } 54 | 55 | /** 56 | * get a fixed-length random string, its a mixture of uppercase letters 57 | * 58 | * @param length 59 | * @return 60 | * @see RandomUtil#getRandom(String source, int length) 61 | */ 62 | public static String getRandomCapitalLetters(int length) { 63 | return getRandom(CAPITAL_LETTERS, length); 64 | } 65 | 66 | /** 67 | * get a fixed-length random string, its a mixture of lowercase letters 68 | * 69 | * @param length 70 | * @return 71 | * @see RandomUtil#getRandom(String source, int length) 72 | */ 73 | public static String getRandomLowerCaseLetters(int length) { 74 | return getRandom(LOWER_CASE_LETTERS, length); 75 | } 76 | 77 | /** 78 | * get a fixed-length random string, its a mixture of chars in source 79 | * 80 | * @param source 81 | * @param length 82 | * @return
    83 | *
  • if source is null or empty, return null
  • 84 | *
  • else see {@link RandomUtil#getRandom(char[] sourceChar, int length)}
  • 85 | *
86 | */ 87 | public static String getRandom(String source, int length) { 88 | return source == null ? null : getRandom(source.toCharArray(), length); 89 | } 90 | 91 | /** 92 | * get a fixed-length random string, its a mixture of chars in sourceChar 93 | * 94 | * @param sourceChar 95 | * @param length 96 | * @return
    97 | *
  • if sourceChar is null or empty, return null
  • 98 | *
  • if length less than 0, return null
  • 99 | *
100 | */ 101 | public static String getRandom(char[] sourceChar, int length) { 102 | if (sourceChar == null || sourceChar.length == 0 || length < 0) { 103 | return null; 104 | } 105 | 106 | StringBuilder str = new StringBuilder(length); 107 | Random random = new Random(); 108 | for (int i = 0; i < length; i++) { 109 | str.append(sourceChar[random.nextInt(sourceChar.length)]); 110 | } 111 | return str.toString(); 112 | } 113 | 114 | /** 115 | * get random int between 0 and max 116 | * 117 | * @param max 118 | * @return
    119 | *
  • if max <= 0, return 0
  • 120 | *
  • else return random int between 0 and max
  • 121 | *
122 | */ 123 | public static int getRandom(int max) { 124 | return getRandom(0, max); 125 | } 126 | 127 | /** 128 | * get random int between min and max 129 | * 130 | * @param min 131 | * @param max 132 | * @return
    133 | *
  • if min > max, return 0
  • 134 | *
  • if min == max, return min
  • 135 | *
  • else return random int between min and max
  • 136 | *
137 | */ 138 | public static int getRandom(int min, int max) { 139 | if (min > max) { 140 | return 0; 141 | } 142 | if (min == max) { 143 | return min; 144 | } 145 | return min + new Random().nextInt(max - min); 146 | } 147 | 148 | /** 149 | * Shuffling algorithm, Randomly permutes the specified array using a default source of randomness 150 | */ 151 | public static boolean shuffle(Object[] objArray) { 152 | if (objArray == null) { 153 | return false; 154 | } 155 | return shuffle(objArray, getRandom(objArray.length)); 156 | } 157 | 158 | /** 159 | * Shuffling algorithm, Randomly permutes the specified array 160 | */ 161 | public static boolean shuffle(Object[] objArray, int shuffleCount) { 162 | int length; 163 | if (objArray == null || shuffleCount < 0 || (length = objArray.length) < shuffleCount) { 164 | return false; 165 | } 166 | 167 | for (int i = 1; i <= shuffleCount; i++) { 168 | int random = getRandom(length - i); 169 | Object temp = objArray[length - i]; 170 | objArray[length - i] = objArray[random]; 171 | objArray[random] = temp; 172 | } 173 | return true; 174 | } 175 | 176 | /** 177 | * Shuffling algorithm, Randomly permutes the specified int array using a default source of randomness 178 | */ 179 | public static int[] shuffle(int[] intArray) { 180 | if (intArray == null) { 181 | return null; 182 | } 183 | 184 | return shuffle(intArray, getRandom(intArray.length)); 185 | } 186 | 187 | /** 188 | * Shuffling algorithm, Randomly permutes the specified int array 189 | */ 190 | public static int[] shuffle(int[] intArray, int shuffleCount) { 191 | int length; 192 | if (intArray == null || shuffleCount < 0 || (length = intArray.length) < shuffleCount) { 193 | return null; 194 | } 195 | 196 | int[] out = new int[shuffleCount]; 197 | for (int i = 1; i <= shuffleCount; i++) { 198 | int random = getRandom(length - i); 199 | out[i - 1] = intArray[random]; 200 | int temp = intArray[length - i]; 201 | intArray[length - i] = intArray[random]; 202 | intArray[random] = temp; 203 | } 204 | return out; 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /app/src/main/java/com/elliott/supervideoplayer/utils/T.java: -------------------------------------------------------------------------------- 1 | package com.elliott.supervideoplayer.utils; 2 | 3 | import android.content.Context; 4 | import android.text.TextPaint; 5 | import android.view.Gravity; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.widget.TextView; 9 | import android.widget.Toast; 10 | 11 | import com.elliott.supervideoplayer.R; 12 | 13 | /** 14 | * auther: elliott zhang 15 | * Emaill:18292967668@163.com 16 | */ 17 | public class T { 18 | private T() 19 | { 20 | /* cannot be instantiated */ 21 | throw new UnsupportedOperationException("cannot be instantiated"); 22 | } 23 | 24 | public static boolean isShow = true; 25 | 26 | 27 | /** 28 | * 显示自定Toast 29 | * @param context 30 | * @param msg 31 | */ 32 | public static void showToastMsgShort(Context context, String msg) { 33 | Toast toast = new Toast(context); 34 | LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 35 | View view = layoutInflater.inflate(R.layout.toast_view, null); 36 | TextView tv = (TextView) view.findViewById(R.id.toast_msg); 37 | tv.setText(msg); 38 | TextPaint tp = tv.getPaint(); 39 | tp.setFakeBoldText(true); 40 | toast.setView(view); 41 | toast.setGravity(Gravity.CENTER, 0, 0); 42 | toast.setDuration(Toast.LENGTH_SHORT); 43 | toast.show(); 44 | } 45 | /** 46 | * 短时间显示Toast 47 | * 48 | * @param context 49 | * @param message 50 | */ 51 | public static void showShort(Context context, CharSequence message) 52 | { 53 | if (isShow) 54 | Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); 55 | } 56 | 57 | /** 58 | * 短时间显示Toast 59 | * 60 | * @param context 61 | * @param message 62 | */ 63 | public static void showShort(Context context, int message) 64 | { 65 | if (isShow) 66 | Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); 67 | } 68 | 69 | /** 70 | * 长时间显示Toast 71 | * 72 | * @param context 73 | * @param message 74 | */ 75 | public static void showLong(Context context, CharSequence message) 76 | { 77 | if (isShow) 78 | Toast.makeText(context, message, Toast.LENGTH_LONG).show(); 79 | } 80 | 81 | /** 82 | * 长时间显示Toast 83 | * 84 | * @param context 85 | * @param message 86 | */ 87 | public static void showLong(Context context, int message) 88 | { 89 | if (isShow) 90 | Toast.makeText(context, message, Toast.LENGTH_LONG).show(); 91 | } 92 | 93 | /** 94 | * 自定义显示Toast时间 95 | * 96 | * @param context 97 | * @param message 98 | * @param duration 99 | */ 100 | public static void show(Context context, CharSequence message, int duration) 101 | { 102 | if (isShow) 103 | Toast.makeText(context, message, duration).show(); 104 | } 105 | 106 | /** 107 | * 自定义显示Toast时间 108 | * 109 | * @param context 110 | * @param message 111 | * @param duration 112 | */ 113 | public static void show(Context context, int message, int duration) 114 | { 115 | if (isShow) 116 | Toast.makeText(context, message, duration).show(); 117 | } 118 | 119 | } 120 | -------------------------------------------------------------------------------- /app/src/main/java/com/elliott/supervideoplayer/utils/TimeUtils.java: -------------------------------------------------------------------------------- 1 | package com.elliott.supervideoplayer.utils; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | 6 | /** 7 | * TimeUtils 8 | * 9 | * @author Trinea 2013-8-24 10 | */ 11 | public class TimeUtils { 12 | 13 | public static final SimpleDateFormat DEFAULT_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 14 | public static final SimpleDateFormat DATE_FORMAT_DATE = new SimpleDateFormat("yyyy-MM-dd"); 15 | 16 | private TimeUtils() { 17 | throw new AssertionError(); 18 | } 19 | 20 | /** 21 | * long time to string 22 | * 23 | * @param timeInMillis 24 | * @param dateFormat 25 | * @return 26 | */ 27 | public static String getTime(long timeInMillis, SimpleDateFormat dateFormat) { 28 | return dateFormat.format(new Date(timeInMillis)); 29 | } 30 | 31 | /** 32 | * long time to string, format is {@link #DEFAULT_DATE_FORMAT} 33 | * 34 | * @param timeInMillis 35 | * @return 36 | */ 37 | public static String getTime(long timeInMillis) { 38 | return getTime(timeInMillis, DEFAULT_DATE_FORMAT); 39 | } 40 | 41 | /** 42 | * get current time in milliseconds 43 | * 44 | * @return 45 | */ 46 | public static long getCurrentTimeInLong() { 47 | return System.currentTimeMillis(); 48 | } 49 | 50 | /** 51 | * get current time in milliseconds, format is {@link #DEFAULT_DATE_FORMAT} 52 | * 53 | * @return 54 | */ 55 | public static String getCurrentTimeInString() { 56 | return getTime(getCurrentTimeInLong()); 57 | } 58 | 59 | /** 60 | * get current time in milliseconds 61 | * 62 | * @return 63 | */ 64 | public static String getCurrentTimeInString(SimpleDateFormat dateFormat) { 65 | return getTime(getCurrentTimeInLong(), dateFormat); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/abc_ic_clear_search_api_holo_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-hdpi/abc_ic_clear_search_api_holo_light.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/action_delete_selected_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-hdpi/action_delete_selected_light.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/action_edit_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-hdpi/action_edit_light.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/action_hidden_default_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-hdpi/action_hidden_default_dark.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/action_open_url.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-hdpi/action_open_url.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/button_action.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-hdpi/button_action.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/file_url_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-hdpi/file_url_light.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-hdpi/ic_delete.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_launcher_vplayer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-hdpi/ic_launcher_vplayer.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/video_brightness_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-hdpi/video_brightness_bg.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/video_num_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-hdpi/video_num_bg.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/video_num_front.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-hdpi/video_num_front.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/video_volumn_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-hdpi/video_volumn_bg.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/file_subtitle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-xhdpi/file_subtitle.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/mediacontroller_lock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-xhdpi/mediacontroller_lock.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/mediacontroller_next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-xhdpi/mediacontroller_next.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/mediacontroller_pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-xhdpi/mediacontroller_pause.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/mediacontroller_play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-xhdpi/mediacontroller_play.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/mediacontroller_previous.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-xhdpi/mediacontroller_previous.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/mediacontroller_screen_fit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-xhdpi/mediacontroller_screen_fit.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/mediacontroller_screen_size.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-xhdpi/mediacontroller_screen_size.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/mediacontroller_setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-xhdpi/mediacontroller_setting.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/mediacontroller_snapshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-xhdpi/mediacontroller_snapshot.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/mediacontroller_sreen_size_100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-xhdpi/mediacontroller_sreen_size_100.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/mediacontroller_sreen_size_crop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-xhdpi/mediacontroller_sreen_size_crop.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/mediacontroller_unlock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/drawable-xhdpi/mediacontroller_unlock.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/circular_border_not_radius.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 14 | 20 | 27 | 34 | 42 | 49 | 56 | 57 | 64 | 72 | 78 | 85 | 86 | 87 | 88 | 94 | 95 | 102 | 103 | 114 | 115 | -------------------------------------------------------------------------------- /app/src/main/res/layout/adjust_test_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/mediacontroller.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 8 | 13 | 19 | 28 | 35 | 36 | 43 | 44 | 52 | 53 | 63 | 64 | 65 | 66 | 73 | 74 | 81 | 82 | 91 | 92 | 103 | 112 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /app/src/main/res/layout/mediacontroller_live.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 20 | 27 | 35 | 44 | 51 | 52 | 62 | -------------------------------------------------------------------------------- /app/src/main/res/layout/normal_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 15 | 21 | 29 | 30 | 35 | 42 | 48 | 55 | 62 | 68 | 74 | 84 | 89 | 90 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /app/src/main/res/layout/setting_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 19 | 20 | 21 | 29 | 30 | 39 | 40 | -------------------------------------------------------------------------------- /app/src/main/res/layout/toast_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/layout/video_adjust_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 17 | 22 | 23 | 29 | 30 | 37 | 38 | -------------------------------------------------------------------------------- /app/src/main/res/layout/video_item_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 18 | 19 | 30 | 31 | 42 | 43 | 53 | 54 | 64 | -------------------------------------------------------------------------------- /app/src/main/res/layout/video_play_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | 12 | 16 | 24 | 25 | 31 | 32 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /app/src/main/res/layout/video_title.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 14 | 21 | 33 | 34 | 35 | 42 | 54 | 66 | 78 | 85 | 86 | -------------------------------------------------------------------------------- /app/src/main/res/layout/video_title_live.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 15 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_vplayer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/mipmap-hdpi/ic_launcher_vplayer.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | 8 | 9 | #ffffff 10 | #2ea18f 11 | #CC0000 12 | #BFBFBF 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | 1dp 7 | 3dp 8 | 5dp 9 | 8dp 10 | 10dp 11 | 12dp 12 | 13dp 13 | 14dp 14 | 15dp 15 | 16dp 16 | 18dp 17 | 20dp 18 | 22dp 19 | 24dp 20 | 25dp 21 | 30dp 22 | 35dp 23 | 40dp 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | SuperVideoPlayer 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/elliott/supervideoplayer/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.elliott.supervideoplayer; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.2.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Nov 10 17:23:03 CST 2016 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-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /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 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 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 Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':vitamio' 2 | -------------------------------------------------------------------------------- /source/Screenshot_2016-05-19-11-39-39.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/source/Screenshot_2016-05-19-11-39-39.jpeg -------------------------------------------------------------------------------- /source/Screenshot_2016-05-19-11-39-49.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/source/Screenshot_2016-05-19-11-39-49.jpeg -------------------------------------------------------------------------------- /source/Screenshot_2016-05-19-11-40-21.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/source/Screenshot_2016-05-19-11-40-21.jpeg -------------------------------------------------------------------------------- /source/start.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/source/start.gif -------------------------------------------------------------------------------- /source/start3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/source/start3.gif -------------------------------------------------------------------------------- /vitamio/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /vitamio/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle/ 2 | .DS_Store 3 | local.properties 4 | 5 | # build files 6 | build/ 7 | bin/ 8 | gen/ 9 | output/ 10 | 11 | # android studio 12 | *.iml 13 | .idea -------------------------------------------------------------------------------- /vitamio/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | InitActivity 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /vitamio/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /vitamio/README.md: -------------------------------------------------------------------------------- 1 | Vitamio 2 | =============== 3 | 4 | This folder contains the main library which should be linked against as an 5 | Android library project in your application. 6 | -------------------------------------------------------------------------------- /vitamio/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | dependencies { 4 | } 5 | 6 | android { 7 | compileSdkVersion 21 8 | buildToolsVersion "21.1" 9 | 10 | defaultConfig { 11 | minSdkVersion 15 12 | targetSdkVersion 21 13 | } 14 | sourceSets { 15 | main { 16 | manifest.srcFile 'AndroidManifest.xml' 17 | java.srcDirs = ['src'] 18 | jniLibs.srcDirs = ['libs'] 19 | aidl.srcDirs = ['src'] 20 | renderscript.srcDirs = ['src'] 21 | res.srcDirs = ['res'] 22 | } 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /vitamio/gradle.properties: -------------------------------------------------------------------------------- 1 | ## Project-wide Gradle settings. 2 | # 3 | # For more details on how to configure your build environment visit 4 | # http://www.gradle.org/docs/current/userguide/build_environment.html 5 | # 6 | # Specifies the JVM arguments used for the daemon process. 7 | # The setting is particularly useful for tweaking memory settings. 8 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 9 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 10 | # 11 | # When configured, Gradle will run in incubating parallel mode. 12 | # This option should only be used with decoupled projects. More details, visit 13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 14 | # org.gradle.parallel=true 15 | #Mon Apr 11 18:38:14 CST 2016 16 | systemProp.http.proxyHost=mirrors.neusoft.edu.cn 17 | systemProp.http.proxyPort=80 18 | -------------------------------------------------------------------------------- /vitamio/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 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 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /vitamio/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 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 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 Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /vitamio/libs/arm64-v8a/libOMX.24.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/arm64-v8a/libOMX.24.so -------------------------------------------------------------------------------- /vitamio/libs/arm64-v8a/libffmpeg.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/arm64-v8a/libffmpeg.so -------------------------------------------------------------------------------- /vitamio/libs/arm64-v8a/libstlport_shared.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/arm64-v8a/libstlport_shared.so -------------------------------------------------------------------------------- /vitamio/libs/arm64-v8a/libvao.0.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/arm64-v8a/libvao.0.so -------------------------------------------------------------------------------- /vitamio/libs/arm64-v8a/libvinit.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/arm64-v8a/libvinit.so -------------------------------------------------------------------------------- /vitamio/libs/arm64-v8a/libvplayer.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/arm64-v8a/libvplayer.so -------------------------------------------------------------------------------- /vitamio/libs/arm64-v8a/libvscanner.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/arm64-v8a/libvscanner.so -------------------------------------------------------------------------------- /vitamio/libs/arm64-v8a/libvvo.0.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/arm64-v8a/libvvo.0.so -------------------------------------------------------------------------------- /vitamio/libs/arm64-v8a/libvvo.9.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/arm64-v8a/libvvo.9.so -------------------------------------------------------------------------------- /vitamio/libs/armeabi-v7a/libOMX.11.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/armeabi-v7a/libOMX.11.so -------------------------------------------------------------------------------- /vitamio/libs/armeabi-v7a/libOMX.14.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/armeabi-v7a/libOMX.14.so -------------------------------------------------------------------------------- /vitamio/libs/armeabi-v7a/libOMX.18.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/armeabi-v7a/libOMX.18.so -------------------------------------------------------------------------------- /vitamio/libs/armeabi-v7a/libOMX.9.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/armeabi-v7a/libOMX.9.so -------------------------------------------------------------------------------- /vitamio/libs/armeabi-v7a/libffmpeg.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/armeabi-v7a/libffmpeg.so -------------------------------------------------------------------------------- /vitamio/libs/armeabi-v7a/libstlport_shared.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/armeabi-v7a/libstlport_shared.so -------------------------------------------------------------------------------- /vitamio/libs/armeabi-v7a/libvao.0.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/armeabi-v7a/libvao.0.so -------------------------------------------------------------------------------- /vitamio/libs/armeabi-v7a/libvinit.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/armeabi-v7a/libvinit.so -------------------------------------------------------------------------------- /vitamio/libs/armeabi-v7a/libvplayer.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/armeabi-v7a/libvplayer.so -------------------------------------------------------------------------------- /vitamio/libs/armeabi-v7a/libvscanner.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/armeabi-v7a/libvscanner.so -------------------------------------------------------------------------------- /vitamio/libs/armeabi-v7a/libvvo.0.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/armeabi-v7a/libvvo.0.so -------------------------------------------------------------------------------- /vitamio/libs/armeabi-v7a/libvvo.7.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/armeabi-v7a/libvvo.7.so -------------------------------------------------------------------------------- /vitamio/libs/armeabi-v7a/libvvo.8.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/armeabi-v7a/libvvo.8.so -------------------------------------------------------------------------------- /vitamio/libs/armeabi-v7a/libvvo.9.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/armeabi-v7a/libvvo.9.so -------------------------------------------------------------------------------- /vitamio/libs/armeabi-v7a/libvvo.j.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/armeabi-v7a/libvvo.j.so -------------------------------------------------------------------------------- /vitamio/libs/x86/libOMX.14.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/x86/libOMX.14.so -------------------------------------------------------------------------------- /vitamio/libs/x86/libOMX.18.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/x86/libOMX.18.so -------------------------------------------------------------------------------- /vitamio/libs/x86/libOMX.9.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/x86/libOMX.9.so -------------------------------------------------------------------------------- /vitamio/libs/x86/libffmpeg.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/x86/libffmpeg.so -------------------------------------------------------------------------------- /vitamio/libs/x86/libstlport_shared.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/x86/libstlport_shared.so -------------------------------------------------------------------------------- /vitamio/libs/x86/libvao.0.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/x86/libvao.0.so -------------------------------------------------------------------------------- /vitamio/libs/x86/libvinit.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/x86/libvinit.so -------------------------------------------------------------------------------- /vitamio/libs/x86/libvplayer.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/x86/libvplayer.so -------------------------------------------------------------------------------- /vitamio/libs/x86/libvscanner.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/x86/libvscanner.so -------------------------------------------------------------------------------- /vitamio/libs/x86/libvvo.0.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/x86/libvvo.0.so -------------------------------------------------------------------------------- /vitamio/libs/x86/libvvo.9.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/x86/libvvo.9.so -------------------------------------------------------------------------------- /vitamio/libs/x86/libvvo.j.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/libs/x86/libvvo.j.so -------------------------------------------------------------------------------- /vitamio/lint.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /vitamio/local.properties: -------------------------------------------------------------------------------- 1 | ## This file is automatically generated by Android Studio. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must *NOT* be checked into Version Control Systems, 5 | # as it contains information specific to your local configuration. 6 | # 7 | # Location of the SDK. This is only used by Gradle. 8 | # For customization when using a Version Control System, please read the 9 | # header note. 10 | #Mon Apr 11 18:37:55 CST 2016 11 | sdk.dir=/Users/gengsong/Documents/dev_path/sdk 12 | -------------------------------------------------------------------------------- /vitamio/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | 22 | # For Vitamio classes 23 | -keep public class io.vov.vitamio.MediaPlayer { *; } 24 | -keep public class io.vov.vitamio.IMediaScannerService { *; } 25 | -keep public class io.vov.vitamio.MediaScanner { *; } 26 | -keep public class io.vov.vitamio.MediaScannerClient { *; } 27 | -keep public class io.vov.vitamio.VitamioLicense { *; } 28 | -keep public class io.vov.vitamio.Vitamio { *; } 29 | -keep public class io.vov.vitamio.MediaMetadataRetriever { *; } 30 | -------------------------------------------------------------------------------- /vitamio/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-19 15 | android.library=true 16 | -------------------------------------------------------------------------------- /vitamio/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /vitamio/res/drawable-ldpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/res/drawable-ldpi/ic_launcher.png -------------------------------------------------------------------------------- /vitamio/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /vitamio/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /vitamio/res/drawable-xhdpi/mediacontroller_pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/res/drawable-xhdpi/mediacontroller_pause.png -------------------------------------------------------------------------------- /vitamio/res/drawable-xhdpi/mediacontroller_play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/res/drawable-xhdpi/mediacontroller_play.png -------------------------------------------------------------------------------- /vitamio/res/drawable-xhdpi/scrubber_control_disabled_holo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/res/drawable-xhdpi/scrubber_control_disabled_holo.png -------------------------------------------------------------------------------- /vitamio/res/drawable-xhdpi/scrubber_control_focused_holo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/res/drawable-xhdpi/scrubber_control_focused_holo.png -------------------------------------------------------------------------------- /vitamio/res/drawable-xhdpi/scrubber_control_normal_holo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/res/drawable-xhdpi/scrubber_control_normal_holo.png -------------------------------------------------------------------------------- /vitamio/res/drawable-xhdpi/scrubber_control_pressed_holo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/res/drawable-xhdpi/scrubber_control_pressed_holo.png -------------------------------------------------------------------------------- /vitamio/res/drawable-xhdpi/scrubber_primary_holo.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/res/drawable-xhdpi/scrubber_primary_holo.9.png -------------------------------------------------------------------------------- /vitamio/res/drawable-xhdpi/scrubber_secondary_holo.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/res/drawable-xhdpi/scrubber_secondary_holo.9.png -------------------------------------------------------------------------------- /vitamio/res/drawable-xhdpi/scrubber_track_holo_dark.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/curtis2/SuperVideoPlayer/f7e0afcdd9785f635204e71e0054b7940c3c94c2/vitamio/res/drawable-xhdpi/scrubber_track_holo_dark.9.png -------------------------------------------------------------------------------- /vitamio/res/drawable/mediacontroller_button.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /vitamio/res/drawable/scrubber_control_selector_holo.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /vitamio/res/drawable/scrubber_progress_horizontal_holo_dark.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 17 | 18 | 21 | 22 | 23 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /vitamio/res/layout/mediacontroller.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 22 | 23 | 31 | 32 | 40 | 41 | 51 | 52 | 53 | 61 | 62 | -------------------------------------------------------------------------------- /vitamio/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #00000000 5 | #ff53c1bd 6 | #99000000 7 | 8 | -------------------------------------------------------------------------------- /vitamio/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | VitamioLibrary 5 | Initializing decoders… 6 | Vitamio tools 7 | Access Vitamio package and resources. 8 | Receive Vitamio messages 9 | Receive all broadcasts from Vitamio service. 10 | Write Vitamio providers 11 | Delete, update or create new items in Vitamio providers. 12 | 13 | Cannot play video 14 | Sorry, this video is not valid for streaming to 15 | this device. 16 | 17 | Sorry, this video cannot be played. 18 | OK 19 | Play/Pause 20 | 21 | -------------------------------------------------------------------------------- /vitamio/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 21 | 22 | -------------------------------------------------------------------------------- /vitamio/src/io/vov/vitamio/LibsChecker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 YIXIA.COM 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.vov.vitamio; 18 | 19 | import android.app.Activity; 20 | import android.content.Intent; 21 | 22 | /** 23 | * LibsChecker is a wrapper of {@link Vitamio}, it helps to initialize Vitamio 24 | * easily. 25 | *

26 | *

27 |  * public void onCreate(Bundle b) {
28 |  * 	super.onCreate(b);
29 |  * 	if (!io.vov.vitamio.LibsChecker.checkVitamioLibs(this))
30 |  * 		return;
31 |  *
32 |  * 	// Code using Vitamio should go below {@link LibsChecker#checkVitamioLibs}
33 |  * }
34 |  * 
35 | */ 36 | public final class LibsChecker { 37 | public static final String FROM_ME = "fromVitamioInitActivity"; 38 | 39 | public static final boolean checkVitamioLibs(Activity ctx) { 40 | if (!Vitamio.isInitialized(ctx) && !ctx.getIntent().getBooleanExtra(FROM_ME, false)) { 41 | Intent i = new Intent(); 42 | i.setClassName(Vitamio.getVitamioPackage(), "io.vov.vitamio.activity.InitActivity"); 43 | i.putExtras(ctx.getIntent()); 44 | i.setData(ctx.getIntent().getData()); 45 | i.putExtra("package", ctx.getPackageName()); 46 | i.putExtra("className", ctx.getClass().getName()); 47 | ctx.startActivity(i); 48 | ctx.finish(); 49 | return false; 50 | } 51 | return true; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /vitamio/src/io/vov/vitamio/MediaScannerClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * Copyright (C) 2013 YIXIA.COM 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package io.vov.vitamio; 19 | 20 | /** 21 | * DON'T TOUCH THIS FILE IF YOU DON'T KNOW THE MediaScanner PROCEDURE!!! 22 | */ 23 | public interface MediaScannerClient { 24 | public void scanFile(String path, long lastModified, long fileSize); 25 | 26 | public void addNoMediaFolder(String path); 27 | 28 | public void handleStringTag(String name, byte[] value, String valueEncoding); 29 | 30 | public void setMimeType(String mimeType); 31 | } -------------------------------------------------------------------------------- /vitamio/src/io/vov/vitamio/ThumbnailUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * Copyright (C) 2013 YIXIA.COM 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package io.vov.vitamio; 19 | 20 | import android.content.Context; 21 | import android.graphics.Bitmap; 22 | import android.graphics.Canvas; 23 | import android.graphics.Matrix; 24 | import android.graphics.Rect; 25 | import io.vov.vitamio.provider.MediaStore.Video; 26 | 27 | /** 28 | * ThumbnailUtils is a wrapper of MediaMetadataRetriever to retrive a thumbnail 29 | * of video file. 30 | *

31 | *

 32 |  * Bitmap thumb = ThumbnailUtils.createVideoThumbnail(this, videoPath, MINI_KIND);
 33 |  * 
34 | */ 35 | public class ThumbnailUtils { 36 | private static final int OPTIONS_NONE = 0x0; 37 | private static final int OPTIONS_SCALE_UP = 0x1; 38 | public static final int OPTIONS_RECYCLE_INPUT = 0x2; 39 | public static final int TARGET_SIZE_MINI_THUMBNAIL_WIDTH = 426; 40 | public static final int TARGET_SIZE_MINI_THUMBNAIL_HEIGHT = 320; 41 | public static final int TARGET_SIZE_MICRO_THUMBNAIL_WIDTH = 212; 42 | public static final int TARGET_SIZE_MICRO_THUMBNAIL_HEIGHT = 160; 43 | 44 | 45 | public static Bitmap createVideoThumbnail(Context ctx, String filePath, int kind) { 46 | if (!Vitamio.isInitialized(ctx)) { 47 | return null; 48 | } 49 | Bitmap bitmap = null; 50 | MediaMetadataRetriever retriever = null; 51 | try { 52 | retriever = new MediaMetadataRetriever(ctx); 53 | retriever.setDataSource(filePath); 54 | bitmap = retriever.getFrameAtTime(-1); 55 | } catch (Exception ex) { 56 | } finally { 57 | try { 58 | retriever.release(); 59 | } catch (RuntimeException ex) { 60 | } 61 | } 62 | 63 | if (bitmap != null) { 64 | if (kind == Video.Thumbnails.MICRO_KIND) 65 | bitmap = extractThumbnail(bitmap, TARGET_SIZE_MICRO_THUMBNAIL_WIDTH, TARGET_SIZE_MICRO_THUMBNAIL_HEIGHT, OPTIONS_RECYCLE_INPUT); 66 | else if (kind == Video.Thumbnails.MINI_KIND) 67 | bitmap = extractThumbnail(bitmap, TARGET_SIZE_MINI_THUMBNAIL_WIDTH, TARGET_SIZE_MINI_THUMBNAIL_HEIGHT, OPTIONS_RECYCLE_INPUT); 68 | } 69 | return bitmap; 70 | } 71 | 72 | public static Bitmap extractThumbnail(Bitmap source, int width, int height) { 73 | return extractThumbnail(source, width, height, OPTIONS_NONE); 74 | } 75 | 76 | public static Bitmap extractThumbnail(Bitmap source, int width, int height, int options) { 77 | if (source == null) 78 | return null; 79 | 80 | float scale; 81 | if (source.getWidth() < source.getHeight()) 82 | scale = width / (float) source.getWidth(); 83 | else 84 | scale = height / (float) source.getHeight(); 85 | Matrix matrix = new Matrix(); 86 | matrix.setScale(scale, scale); 87 | Bitmap thumbnail = transform(matrix, source, width, height, OPTIONS_SCALE_UP | options); 88 | return thumbnail; 89 | } 90 | 91 | private static Bitmap transform(Matrix scaler, Bitmap source, int targetWidth, int targetHeight, int options) { 92 | boolean scaleUp = (options & OPTIONS_SCALE_UP) != 0; 93 | boolean recycle = (options & OPTIONS_RECYCLE_INPUT) != 0; 94 | 95 | int deltaX = source.getWidth() - targetWidth; 96 | int deltaY = source.getHeight() - targetHeight; 97 | if (!scaleUp && (deltaX < 0 || deltaY < 0)) { 98 | Bitmap b2 = Bitmap.createBitmap(targetWidth, targetHeight, Bitmap.Config.ARGB_8888); 99 | Canvas c = new Canvas(b2); 100 | 101 | int deltaXHalf = Math.max(0, deltaX / 2); 102 | int deltaYHalf = Math.max(0, deltaY / 2); 103 | Rect src = new Rect(deltaXHalf, deltaYHalf, deltaXHalf + Math.min(targetWidth, source.getWidth()), deltaYHalf + Math.min(targetHeight, source.getHeight())); 104 | int dstX = (targetWidth - src.width()) / 2; 105 | int dstY = (targetHeight - src.height()) / 2; 106 | Rect dst = new Rect(dstX, dstY, targetWidth - dstX, targetHeight - dstY); 107 | c.drawBitmap(source, src, dst, null); 108 | if (recycle) 109 | source.recycle(); 110 | return b2; 111 | } 112 | 113 | float bitmapWidthF = source.getWidth(); 114 | float bitmapHeightF = source.getHeight(); 115 | float bitmapAspect = bitmapWidthF / bitmapHeightF; 116 | float viewAspect = (float) targetWidth / targetHeight; 117 | 118 | float scale = bitmapAspect > viewAspect ? targetHeight / bitmapHeightF : targetWidth / bitmapWidthF; 119 | if (scale < .9F || scale > 1F) 120 | scaler.setScale(scale, scale); 121 | else 122 | scaler = null; 123 | 124 | Bitmap b1; 125 | if (scaler != null) 126 | b1 = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), scaler, true); 127 | else 128 | b1 = source; 129 | 130 | if (recycle && b1 != source) 131 | source.recycle(); 132 | 133 | int dx1 = Math.max(0, b1.getWidth() - targetWidth); 134 | int dy1 = Math.max(0, b1.getHeight() - targetHeight); 135 | 136 | Bitmap b2 = Bitmap.createBitmap(b1, dx1 / 2, dy1 / 2, targetWidth, targetHeight); 137 | 138 | if (b2 != b1 && (recycle || b1 != source)) 139 | b1.recycle(); 140 | 141 | return b2; 142 | } 143 | 144 | } -------------------------------------------------------------------------------- /vitamio/src/io/vov/vitamio/VIntent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 YIXIA.COM 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.vov.vitamio; 18 | 19 | /** 20 | * Common intent actions used by Vitamio component. 21 | */ 22 | public class VIntent { 23 | public static final String ACTION_MEDIA_SCANNER_SCAN_DIRECTORY = "com.yixia.vitamio.action.MEDIA_SCANNER_SCAN_DIRECTORY"; 24 | public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "com.yixia.vitamio.action.MEDIA_SCANNER_SCAN_FILE"; 25 | public static final String ACTION_MEDIA_SCANNER_STARTED = "com.yixia.vitamio.action.MEDIA_SCANNER_STARTED"; 26 | public static final String ACTION_MEDIA_SCANNER_FINISHED = "com.yixia.vitamio.action.MEDIA_SCANNER_FINISHED"; 27 | } 28 | -------------------------------------------------------------------------------- /vitamio/src/io/vov/vitamio/Vitamio.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 YIXIA.COM 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.vov.vitamio; 18 | 19 | import android.content.Context; 20 | 21 | import io.vov.vitamio.utils.CPU; 22 | import io.vov.vitamio.utils.ContextUtils; 23 | import io.vov.vitamio.utils.IOUtils; 24 | import io.vov.vitamio.utils.Log; 25 | 26 | 27 | 28 | /** 29 | * Inspect this class before using any other Vitamio classes. 30 | *

31 | * Don't modify this class, or the full Vitamio library may be broken. 32 | */ 33 | public class Vitamio { 34 | private static String vitamioPackage; 35 | private static String vitamioLibraryPath; 36 | 37 | /** 38 | * Check if Vitamio is initialized at this device 39 | * 40 | * @param ctx Android Context 41 | * @return true if the Vitamio has been initialized. 42 | */ 43 | public static boolean isInitialized(Context ctx) { 44 | vitamioPackage = ctx.getPackageName(); 45 | vitamioLibraryPath = ContextUtils.getDataDir(ctx) + "lib/"; 46 | return true; 47 | } 48 | 49 | public static String getVitamioPackage() { 50 | return vitamioPackage; 51 | } 52 | 53 | 54 | public static final String getLibraryPath() { 55 | return vitamioLibraryPath; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /vitamio/src/io/vov/vitamio/VitamioLicense.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 YIXIA.COM 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.vov.vitamio; 18 | 19 | /** 20 | * DON'T MODIFY THIS FILE IF YOU WANT TO USE VITAMIO 21 | */ 22 | public class VitamioLicense { 23 | public static final String LICENSE = "Copyright (c) YIXIA (http://yixia.com).\nTHIS SOFTWARE (Vitamio) IS WORK OF YIXIA (http://yixia.com)"; 24 | } -------------------------------------------------------------------------------- /vitamio/src/io/vov/vitamio/activity/InitActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 YIXIA.COM 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.vov.vitamio.activity; 18 | 19 | import android.app.Activity; 20 | import android.app.ProgressDialog; 21 | import android.content.Context; 22 | import android.content.Intent; 23 | import android.os.AsyncTask; 24 | import android.os.Bundle; 25 | import android.os.Handler; 26 | import android.os.Message; 27 | import android.view.WindowManager; 28 | 29 | import io.vov.vitamio.Vitamio; 30 | 31 | import java.lang.ref.WeakReference; 32 | 33 | public class InitActivity extends Activity { 34 | public static final String FROM_ME = "fromVitamioInitActivity"; 35 | private ProgressDialog mPD; 36 | private UIHandler uiHandler; 37 | 38 | protected void onCreate(Bundle savedInstanceState) { 39 | super.onCreate(savedInstanceState); 40 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); 41 | uiHandler = new UIHandler(this); 42 | 43 | new AsyncTask() { 44 | @Override 45 | protected void onPreExecute() { 46 | mPD = new ProgressDialog(InitActivity.this); 47 | mPD.setCancelable(false); 48 | mPD.setMessage(InitActivity.this.getString(getResources().getIdentifier("vitamio_init_decoders", "string", getPackageName()))); 49 | mPD.show(); 50 | } 51 | 52 | 53 | @Override 54 | protected void onPostExecute(Boolean inited) { 55 | if (inited) { 56 | uiHandler.sendEmptyMessage(0); 57 | } 58 | } 59 | 60 | 61 | @Override 62 | protected Boolean doInBackground(Object... arg0) { 63 | // TODO Auto-generated method stub 64 | return null; 65 | } 66 | 67 | }.execute(); 68 | } 69 | 70 | private static class UIHandler extends Handler { 71 | private WeakReference mContext; 72 | 73 | public UIHandler(Context c) { 74 | mContext = new WeakReference(c); 75 | } 76 | 77 | public void handleMessage(Message msg) { 78 | InitActivity ctx = (InitActivity) mContext.get(); 79 | switch (msg.what) { 80 | case 0: 81 | ctx.mPD.dismiss(); 82 | Intent src = ctx.getIntent(); 83 | Intent i = new Intent(); 84 | i.setClassName(src.getStringExtra("package"), src.getStringExtra("className")); 85 | i.setData(src.getData()); 86 | i.putExtras(src); 87 | i.putExtra(FROM_ME, true); 88 | ctx.startActivity(i); 89 | ctx.finish(); 90 | break; 91 | } 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /vitamio/src/io/vov/vitamio/provider/MiniThumbFile.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * Copyright (C) 2013 YIXIA.COM 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package io.vov.vitamio.provider; 19 | 20 | import android.net.Uri; 21 | import android.os.Environment; 22 | 23 | import io.vov.vitamio.provider.MediaStore.Video; 24 | import io.vov.vitamio.utils.Log; 25 | 26 | import java.io.File; 27 | import java.io.IOException; 28 | import java.io.RandomAccessFile; 29 | import java.nio.ByteBuffer; 30 | import java.nio.channels.FileChannel; 31 | import java.nio.channels.FileLock; 32 | import java.util.Hashtable; 33 | 34 | public class MiniThumbFile { 35 | protected static final int BYTES_PER_MINTHUMB = 10000; 36 | private static final int MINI_THUMB_DATA_FILE_VERSION = 7; 37 | private static final int HEADER_SIZE = 1 + 8 + 4; 38 | private static Hashtable sThumbFiles = new Hashtable(); 39 | private Uri mUri; 40 | private RandomAccessFile mMiniThumbFile; 41 | private FileChannel mChannel; 42 | private ByteBuffer mBuffer; 43 | 44 | public MiniThumbFile(Uri uri) { 45 | mUri = uri; 46 | mBuffer = ByteBuffer.allocateDirect(BYTES_PER_MINTHUMB); 47 | } 48 | 49 | protected static synchronized void reset() { 50 | for (MiniThumbFile file : sThumbFiles.values()) 51 | file.deactivate(); 52 | sThumbFiles.clear(); 53 | } 54 | 55 | protected static synchronized MiniThumbFile instance(Uri uri) { 56 | String type = uri.getPathSegments().get(0); 57 | MiniThumbFile file = sThumbFiles.get(type); 58 | if (file == null) { 59 | file = new MiniThumbFile(Uri.parse(MediaStore.CONTENT_AUTHORITY_SLASH + type + "/media")); 60 | sThumbFiles.put(type, file); 61 | } 62 | 63 | return file; 64 | } 65 | 66 | private String randomAccessFilePath(int version) { 67 | String directoryName = Environment.getExternalStorageDirectory().toString() + "/" + Video.Thumbnails.THUMBNAILS_DIRECTORY; 68 | return directoryName + "/.thumbdata" + version + "-" + mUri.hashCode(); 69 | } 70 | 71 | private void removeOldFile() { 72 | String oldPath = randomAccessFilePath(MINI_THUMB_DATA_FILE_VERSION - 1); 73 | File oldFile = new File(oldPath); 74 | if (oldFile.exists()) { 75 | try { 76 | oldFile.delete(); 77 | } catch (SecurityException ex) { 78 | } 79 | } 80 | } 81 | 82 | private RandomAccessFile miniThumbDataFile() { 83 | if (mMiniThumbFile == null) { 84 | removeOldFile(); 85 | String path = randomAccessFilePath(MINI_THUMB_DATA_FILE_VERSION); 86 | File directory = new File(path).getParentFile(); 87 | if (!directory.isDirectory()) { 88 | if (!directory.mkdirs()) 89 | Log.e("Unable to create .thumbnails directory %s", directory.toString()); 90 | } 91 | File f = new File(path); 92 | try { 93 | mMiniThumbFile = new RandomAccessFile(f, "rw"); 94 | } catch (IOException ex) { 95 | try { 96 | mMiniThumbFile = new RandomAccessFile(f, "r"); 97 | } catch (IOException ex2) { 98 | } 99 | } 100 | 101 | if (mMiniThumbFile != null) 102 | mChannel = mMiniThumbFile.getChannel(); 103 | } 104 | return mMiniThumbFile; 105 | } 106 | 107 | protected synchronized void deactivate() { 108 | if (mMiniThumbFile != null) { 109 | try { 110 | mMiniThumbFile.close(); 111 | mMiniThumbFile = null; 112 | } catch (IOException ex) { 113 | } 114 | } 115 | } 116 | 117 | protected synchronized long getMagic(long id) { 118 | RandomAccessFile r = miniThumbDataFile(); 119 | if (r != null) { 120 | long pos = id * BYTES_PER_MINTHUMB; 121 | FileLock lock = null; 122 | try { 123 | mBuffer.clear(); 124 | mBuffer.limit(1 + 8); 125 | 126 | lock = mChannel.lock(pos, 1 + 8, true); 127 | if (mChannel.read(mBuffer, pos) == 9) { 128 | mBuffer.position(0); 129 | if (mBuffer.get() == 1) 130 | return mBuffer.getLong(); 131 | } 132 | } catch (IOException ex) { 133 | Log.e("Got exception checking file magic: ", ex); 134 | } catch (RuntimeException ex) { 135 | Log.e("Got exception when reading magic, id = %d, disk full or mount read-only? %s", id, ex.getClass().toString()); 136 | } finally { 137 | try { 138 | if (lock != null) 139 | lock.release(); 140 | } catch (IOException ex) { 141 | } 142 | } 143 | } 144 | return 0; 145 | } 146 | 147 | protected synchronized void saveMiniThumbToFile(byte[] data, long id, long magic) throws IOException { 148 | RandomAccessFile r = miniThumbDataFile(); 149 | if (r == null) 150 | return; 151 | 152 | long pos = id * BYTES_PER_MINTHUMB; 153 | FileLock lock = null; 154 | try { 155 | if (data != null) { 156 | if (data.length > BYTES_PER_MINTHUMB - HEADER_SIZE) 157 | return; 158 | 159 | mBuffer.clear(); 160 | mBuffer.put((byte) 1); 161 | mBuffer.putLong(magic); 162 | mBuffer.putInt(data.length); 163 | mBuffer.put(data); 164 | mBuffer.flip(); 165 | 166 | lock = mChannel.lock(pos, BYTES_PER_MINTHUMB, false); 167 | mChannel.write(mBuffer, pos); 168 | } 169 | } catch (IOException ex) { 170 | Log.e("couldn't save mini thumbnail data for %d; %s", id, ex.getMessage()); 171 | throw ex; 172 | } catch (RuntimeException ex) { 173 | Log.e("couldn't save mini thumbnail data for %d, disk full or mount read-only? %s", id, ex.getClass().toString()); 174 | } finally { 175 | try { 176 | if (lock != null) 177 | lock.release(); 178 | } catch (IOException ex) { 179 | } 180 | } 181 | } 182 | 183 | protected synchronized byte[] getMiniThumbFromFile(long id, byte[] data) { 184 | RandomAccessFile r = miniThumbDataFile(); 185 | if (r == null) 186 | return null; 187 | 188 | long pos = id * BYTES_PER_MINTHUMB; 189 | FileLock lock = null; 190 | try { 191 | mBuffer.clear(); 192 | lock = mChannel.lock(pos, BYTES_PER_MINTHUMB, true); 193 | int size = mChannel.read(mBuffer, pos); 194 | if (size > 1 + 8 + 4) { 195 | mBuffer.position(9); 196 | int length = mBuffer.getInt(); 197 | 198 | if (size >= 1 + 8 + 4 + length && data.length >= length) { 199 | mBuffer.get(data, 0, length); 200 | return data; 201 | } 202 | } 203 | } catch (IOException ex) { 204 | Log.e("got exception when reading thumbnail id = %d, exception: %s", id, ex.getMessage()); 205 | } catch (RuntimeException ex) { 206 | Log.e("Got exception when reading thumbnail, id = %d, disk full or mount read-only? %s", id, ex.getClass().toString()); 207 | } finally { 208 | try { 209 | if (lock != null) 210 | lock.release(); 211 | } catch (IOException ex) { 212 | } 213 | } 214 | return null; 215 | } 216 | } -------------------------------------------------------------------------------- /vitamio/src/io/vov/vitamio/utils/CPU.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 YIXIA.COM 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.vov.vitamio.utils; 17 | 18 | import java.io.BufferedReader; 19 | import java.io.File; 20 | import java.io.FileReader; 21 | import java.io.IOException; 22 | import java.util.HashMap; 23 | import java.util.Map; 24 | 25 | import android.os.Build; 26 | import android.text.TextUtils; 27 | 28 | public class CPU { 29 | private static final Map cpuinfo = new HashMap(); 30 | private static int cachedFeature = -1; 31 | private static String cachedFeatureString = null; 32 | public static final int FEATURE_ARM_V5TE = 1 << 0; 33 | public static final int FEATURE_ARM_V6 = 1 << 1; 34 | public static final int FEATURE_ARM_VFP = 1 << 2; 35 | public static final int FEATURE_ARM_V7A = 1 << 3; 36 | public static final int FEATURE_ARM_VFPV3 = 1 << 4; 37 | public static final int FEATURE_ARM_NEON = 1 << 5; 38 | public static final int FEATURE_X86 = 1 << 6; 39 | public static final int FEATURE_MIPS = 1 << 7; 40 | 41 | public static String getFeatureString() { 42 | getFeature(); 43 | return cachedFeatureString; 44 | } 45 | 46 | public static int getFeature() { 47 | if (cachedFeature > 0) 48 | return getCachedFeature(); 49 | 50 | cachedFeature = FEATURE_ARM_V5TE; 51 | 52 | if (cpuinfo.isEmpty()) { 53 | BufferedReader bis = null; 54 | try { 55 | bis = new BufferedReader(new FileReader(new File("/proc/cpuinfo"))); 56 | String line; 57 | String[] pairs; 58 | while ((line = bis.readLine()) != null) { 59 | if (!line.trim().equals("")) { 60 | pairs = line.split(":"); 61 | if (pairs.length > 1) 62 | cpuinfo.put(pairs[0].trim(), pairs[1].trim()); 63 | } 64 | } 65 | } catch (Exception e) { 66 | Log.e("getCPUFeature", e); 67 | } finally { 68 | try { 69 | if (bis != null) 70 | bis.close(); 71 | } catch (IOException e) { 72 | Log.e("getCPUFeature", e); 73 | } 74 | } 75 | } 76 | 77 | if (!cpuinfo.isEmpty()) { 78 | for (String key : cpuinfo.keySet()) 79 | Log.d("%s:%s", key, cpuinfo.get(key)); 80 | 81 | boolean hasARMv6 = false; 82 | boolean hasARMv7 = false; 83 | 84 | String val = cpuinfo.get("CPU architecture"); 85 | if (!TextUtils.isEmpty(val)) { 86 | try { 87 | int i = StringUtils.convertToInt(val); 88 | Log.d("CPU architecture: %s", i); 89 | if (i >= 7) { 90 | hasARMv6 = true; 91 | hasARMv7 = true; 92 | } else if (i >= 6) { 93 | hasARMv6 = true; 94 | hasARMv7 = false; 95 | } 96 | } catch (NumberFormatException ex) { 97 | Log.e("getCPUFeature", ex); 98 | } 99 | 100 | val = cpuinfo.get("Processor"); 101 | if (TextUtils.isEmpty(val)) { 102 | val = cpuinfo.get("model name"); 103 | } 104 | if (val != null && (val.contains("(v7l)") || val.contains("ARMv7"))) { 105 | hasARMv6 = true; 106 | hasARMv7 = true; 107 | } 108 | if (val != null && (val.contains("(v6l)") || val.contains("ARMv6"))) { 109 | hasARMv6 = true; 110 | hasARMv7 = false; 111 | } 112 | 113 | if (hasARMv6) 114 | cachedFeature |= FEATURE_ARM_V6; 115 | if (hasARMv7) 116 | cachedFeature |= FEATURE_ARM_V7A; 117 | 118 | val = cpuinfo.get("Features"); 119 | if (val != null) { 120 | if (val.contains("neon")) 121 | cachedFeature |= FEATURE_ARM_VFP | FEATURE_ARM_VFPV3 | FEATURE_ARM_NEON; 122 | else if (val.contains("vfpv3")) 123 | cachedFeature |= FEATURE_ARM_VFP | FEATURE_ARM_VFPV3; 124 | else if (val.contains("vfp")) 125 | cachedFeature |= FEATURE_ARM_VFP; 126 | } 127 | } else { 128 | String vendor_id = cpuinfo.get("vendor_id"); 129 | String mips = cpuinfo.get("cpu model"); 130 | if (!TextUtils.isEmpty(vendor_id) && vendor_id.contains("GenuineIntel")) { 131 | cachedFeature |= FEATURE_X86; 132 | } else if (!TextUtils.isEmpty(mips) && mips.contains("MIPS")) { 133 | cachedFeature |= FEATURE_MIPS; 134 | } 135 | } 136 | } 137 | 138 | return getCachedFeature(); 139 | } 140 | 141 | private static int getCachedFeature() { 142 | if (cachedFeatureString == null) { 143 | StringBuffer sb = new StringBuffer(); 144 | if ((cachedFeature & FEATURE_ARM_V5TE) > 0) 145 | sb.append("V5TE "); 146 | if ((cachedFeature & FEATURE_ARM_V6) > 0) 147 | sb.append("V6 "); 148 | if ((cachedFeature & FEATURE_ARM_VFP) > 0) 149 | sb.append("VFP "); 150 | if ((cachedFeature & FEATURE_ARM_V7A) > 0) 151 | sb.append("V7A "); 152 | if ((cachedFeature & FEATURE_ARM_VFPV3) > 0) 153 | sb.append("VFPV3 "); 154 | if ((cachedFeature & FEATURE_ARM_NEON) > 0) 155 | sb.append("NEON "); 156 | if ((cachedFeature & FEATURE_X86) > 0) 157 | sb.append("X86 "); 158 | if ((cachedFeature & FEATURE_MIPS) > 0) 159 | sb.append("MIPS "); 160 | cachedFeatureString = sb.toString(); 161 | } 162 | Log.d("GET CPU FATURE: %s", cachedFeatureString); 163 | return cachedFeature; 164 | } 165 | 166 | public static boolean isDroidXDroid2() { 167 | return (Build.MODEL.trim().equalsIgnoreCase("DROIDX") || Build.MODEL.trim().equalsIgnoreCase("DROID2") || Build.FINGERPRINT.toLowerCase().contains("shadow") || Build.FINGERPRINT.toLowerCase().contains("droid2")); 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /vitamio/src/io/vov/vitamio/utils/ContextUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 YIXIA.COM 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.vov.vitamio.utils; 17 | 18 | import android.content.Context; 19 | import android.content.pm.ApplicationInfo; 20 | 21 | public class ContextUtils { 22 | public static int getVersionCode(Context ctx) { 23 | int version = 0; 24 | try { 25 | version = ctx.getPackageManager().getPackageInfo(ctx.getApplicationInfo().packageName, 0).versionCode; 26 | } catch (Exception e) { 27 | Log.e("getVersionInt", e); 28 | } 29 | return version; 30 | } 31 | 32 | public static String getDataDir(Context ctx) { 33 | ApplicationInfo ai = ctx.getApplicationInfo(); 34 | if (ai.dataDir != null) 35 | return fixLastSlash(ai.dataDir); 36 | else 37 | return "/data/data/" + ai.packageName + "/"; 38 | } 39 | 40 | public static String fixLastSlash(String str) { 41 | String res = str == null ? "/" : str.trim() + "/"; 42 | if (res.length() > 2 && res.charAt(res.length() - 2) == '/') 43 | res = res.substring(0, res.length() - 1); 44 | return res; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /vitamio/src/io/vov/vitamio/utils/Crypto.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 YIXIA.COM 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.vov.vitamio.utils; 17 | 18 | import java.io.BufferedInputStream; 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | import java.io.ObjectInputStream; 22 | import java.io.UnsupportedEncodingException; 23 | import java.math.BigInteger; 24 | import java.security.MessageDigest; 25 | import java.security.PublicKey; 26 | import java.security.spec.AlgorithmParameterSpec; 27 | 28 | import javax.crypto.Cipher; 29 | import javax.crypto.SecretKey; 30 | import javax.crypto.spec.IvParameterSpec; 31 | import javax.crypto.spec.SecretKeySpec; 32 | 33 | public class Crypto { 34 | private Cipher ecipher; 35 | 36 | public Crypto(String key) { 37 | try { 38 | SecretKeySpec skey = new SecretKeySpec(generateKey(key), "AES"); 39 | setupCrypto(skey); 40 | } catch (Exception e) { 41 | Log.e("Crypto", e); 42 | } 43 | } 44 | 45 | private void setupCrypto(SecretKey key) { 46 | byte[] iv = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }; 47 | AlgorithmParameterSpec paramSpec = new IvParameterSpec(iv); 48 | try { 49 | ecipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); 50 | ecipher.init(Cipher.ENCRYPT_MODE, key, paramSpec); 51 | } catch (Exception e) { 52 | ecipher = null; 53 | Log.e("setupCrypto", e); 54 | } 55 | } 56 | 57 | public String encrypt(String plaintext) { 58 | if (ecipher == null) 59 | return ""; 60 | 61 | try { 62 | byte[] ciphertext = ecipher.doFinal(plaintext.getBytes("UTF-8")); 63 | return Base64.encodeToString(ciphertext, Base64.NO_WRAP); 64 | } catch (Exception e) { 65 | Log.e("encryp", e); 66 | return ""; 67 | } 68 | } 69 | 70 | public static String md5(String plain) { 71 | try { 72 | MessageDigest m = MessageDigest.getInstance("MD5"); 73 | m.update(plain.getBytes()); 74 | byte[] digest = m.digest(); 75 | BigInteger bigInt = new BigInteger(1, digest); 76 | String hashtext = bigInt.toString(16); 77 | while (hashtext.length() < 32) { 78 | hashtext = "0" + hashtext; 79 | } 80 | return hashtext; 81 | } catch (Exception e) { 82 | return ""; 83 | } 84 | } 85 | 86 | private static byte[] generateKey(String input) { 87 | try { 88 | byte[] bytesOfMessage = input.getBytes("UTF-8"); 89 | MessageDigest md = MessageDigest.getInstance("SHA256"); 90 | return md.digest(bytesOfMessage); 91 | } catch (Exception e) { 92 | Log.e("generateKey", e); 93 | return null; 94 | } 95 | } 96 | 97 | private PublicKey readKeyFromStream(InputStream keyStream) throws IOException { 98 | ObjectInputStream oin = new ObjectInputStream(new BufferedInputStream(keyStream)); 99 | try { 100 | PublicKey pubKey = (PublicKey) oin.readObject(); 101 | return pubKey; 102 | } catch (Exception e) { 103 | Log.e("readKeyFromStream", e); 104 | return null; 105 | } finally { 106 | oin.close(); 107 | } 108 | } 109 | 110 | public String rsaEncrypt(InputStream keyStream, String data) { 111 | try { 112 | return rsaEncrypt(keyStream, data.getBytes("UTF-8")); 113 | } catch (UnsupportedEncodingException e) { 114 | return ""; 115 | } 116 | } 117 | 118 | public String rsaEncrypt(InputStream keyStream, byte[] data) { 119 | try { 120 | PublicKey pubKey = readKeyFromStream(keyStream); 121 | Cipher cipher = Cipher.getInstance("RSA/ECB/NoPadding"); 122 | cipher.init(Cipher.ENCRYPT_MODE, pubKey); 123 | byte[] cipherData = cipher.doFinal(data); 124 | return Base64.encodeToString(cipherData, Base64.NO_WRAP); 125 | } catch (Exception e) { 126 | Log.e("rsaEncrypt", e); 127 | return ""; 128 | } 129 | } 130 | 131 | } 132 | -------------------------------------------------------------------------------- /vitamio/src/io/vov/vitamio/utils/Device.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 YIXIA.COM 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.vov.vitamio.utils; 17 | 18 | import android.annotation.SuppressLint; 19 | import android.content.Context; 20 | import android.net.ConnectivityManager; 21 | import android.os.Build; 22 | import android.provider.Settings; 23 | import android.telephony.TelephonyManager; 24 | import android.util.DisplayMetrics; 25 | 26 | import java.util.Locale; 27 | 28 | public class Device { 29 | public static String getLocale() { 30 | Locale locale = Locale.getDefault(); 31 | if (locale != null) { 32 | String lo = locale.getLanguage(); 33 | Log.i("getLocale " + lo); 34 | if (lo != null) { 35 | return lo.toLowerCase(); 36 | } 37 | } 38 | return "en"; 39 | } 40 | 41 | public static String getDeviceFeatures(Context ctx) { 42 | return getIdentifiers(ctx) + getSystemFeatures() + getScreenFeatures(ctx); 43 | } 44 | 45 | @SuppressLint("NewApi") 46 | public static String getIdentifiers(Context ctx) { 47 | StringBuilder sb = new StringBuilder(); 48 | if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) 49 | sb.append(getPair("serial", Build.SERIAL)); 50 | else 51 | sb.append(getPair("serial", "No Serial")); 52 | sb.append(getPair("android_id", Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.ANDROID_ID))); 53 | TelephonyManager tel = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); 54 | sb.append(getPair("sim_country_iso", tel.getSimCountryIso())); 55 | sb.append(getPair("network_operator_name", tel.getNetworkOperatorName())); 56 | sb.append(getPair("unique_id", Crypto.md5(sb.toString()))); 57 | ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); 58 | sb.append(getPair("network_type", cm.getActiveNetworkInfo() == null ? "-1" : String.valueOf(cm.getActiveNetworkInfo().getType()))); 59 | return sb.toString(); 60 | } 61 | 62 | public static String getSystemFeatures() { 63 | StringBuilder sb = new StringBuilder(); 64 | sb.append(getPair("android_release", Build.VERSION.RELEASE)); 65 | sb.append(getPair("android_sdk_int", "" + Build.VERSION.SDK_INT)); 66 | sb.append(getPair("device_cpu_abi", Build.CPU_ABI)); 67 | sb.append(getPair("device_model", Build.MODEL)); 68 | sb.append(getPair("device_manufacturer", Build.MANUFACTURER)); 69 | sb.append(getPair("device_board", Build.BOARD)); 70 | sb.append(getPair("device_fingerprint", Build.FINGERPRINT)); 71 | sb.append(getPair("device_cpu_feature", CPU.getFeatureString())); 72 | return sb.toString(); 73 | } 74 | 75 | public static String getScreenFeatures(Context ctx) { 76 | StringBuilder sb = new StringBuilder(); 77 | DisplayMetrics disp = ctx.getResources().getDisplayMetrics(); 78 | sb.append(getPair("screen_density", "" + disp.density)); 79 | sb.append(getPair("screen_density_dpi", "" + disp.densityDpi)); 80 | sb.append(getPair("screen_height_pixels", "" + disp.heightPixels)); 81 | sb.append(getPair("screen_width_pixels", "" + disp.widthPixels)); 82 | sb.append(getPair("screen_scaled_density", "" + disp.scaledDensity)); 83 | sb.append(getPair("screen_xdpi", "" + disp.xdpi)); 84 | sb.append(getPair("screen_ydpi", "" + disp.ydpi)); 85 | return sb.toString(); 86 | } 87 | 88 | private static String getPair(String key, String value) { 89 | key = key == null ? "" : key.trim(); 90 | value = value == null ? "" : value.trim(); 91 | return "&" + key + "=" + value; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /vitamio/src/io/vov/vitamio/utils/FileUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 YIXIA.COM 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.vov.vitamio.utils; 17 | 18 | import android.net.Uri; 19 | import android.text.TextUtils; 20 | 21 | import java.io.File; 22 | import java.io.IOException; 23 | 24 | public class FileUtils { 25 | private static final String FILE_NAME_RESERVED = "|\\?*<\":>+[]/'"; 26 | 27 | public static String getUniqueFileName(String name, String id) { 28 | StringBuilder sb = new StringBuilder(); 29 | for (Character c : name.toCharArray()) { 30 | if (FILE_NAME_RESERVED.indexOf(c) == -1) { 31 | sb.append(c); 32 | } 33 | } 34 | name = sb.toString(); 35 | if (name.length() > 16) { 36 | name = name.substring(0, 16); 37 | } 38 | id = Crypto.md5(id); 39 | name += id; 40 | try { 41 | File f = File.createTempFile(name, null); 42 | if (f.exists()) { 43 | f.delete(); 44 | return name; 45 | } 46 | } catch (IOException e) { 47 | } 48 | return id; 49 | } 50 | 51 | public static String getCanonical(File f) { 52 | if (f == null) 53 | return null; 54 | 55 | try { 56 | return f.getCanonicalPath(); 57 | } catch (IOException e) { 58 | return f.getAbsolutePath(); 59 | } 60 | } 61 | 62 | /** 63 | * Get the path for the file:/// only 64 | * 65 | * @param uri 66 | * @return 67 | */ 68 | public static String getPath(String uri) { 69 | Log.i("FileUtils#getPath(%s)", uri); 70 | if (TextUtils.isEmpty(uri)) 71 | return null; 72 | if (uri.startsWith("file://") && uri.length() > 7) 73 | return Uri.decode(uri.substring(7)); 74 | return Uri.decode(uri); 75 | } 76 | 77 | public static String getName(String uri) { 78 | String path = getPath(uri); 79 | if (path != null) 80 | return new File(path).getName(); 81 | return null; 82 | } 83 | 84 | public static void deleteDir(File f) { 85 | if (f.exists() && f.isDirectory()) { 86 | for (File file : f.listFiles()) { 87 | if (file.isDirectory()) 88 | deleteDir(file); 89 | file.delete(); 90 | } 91 | f.delete(); 92 | } 93 | } 94 | } -------------------------------------------------------------------------------- /vitamio/src/io/vov/vitamio/utils/IOUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 YIXIA.COM 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.vov.vitamio.utils; 17 | 18 | import android.database.Cursor; 19 | import android.os.ParcelFileDescriptor; 20 | import android.util.Log; 21 | 22 | import java.io.Closeable; 23 | 24 | public class IOUtils { 25 | 26 | private static final String TAG = "IOUtils"; 27 | 28 | public static void closeSilently(Closeable c) { 29 | if (c == null) 30 | return; 31 | try { 32 | c.close(); 33 | } catch (Throwable t) { 34 | Log.w(TAG, "fail to close", t); 35 | } 36 | } 37 | 38 | public static void closeSilently(ParcelFileDescriptor c) { 39 | if (c == null) 40 | return; 41 | try { 42 | c.close(); 43 | } catch (Throwable t) { 44 | Log.w(TAG, "fail to close", t); 45 | } 46 | } 47 | 48 | public static void closeSilently(Cursor cursor) { 49 | try { 50 | if (cursor != null) cursor.close(); 51 | } catch (Throwable t) { 52 | Log.w(TAG, "fail to close", t); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /vitamio/src/io/vov/vitamio/utils/Log.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 YIXIA.COM 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.vov.vitamio.utils; 17 | 18 | import io.vov.vitamio.BuildConfig; 19 | 20 | import java.util.MissingFormatArgumentException; 21 | 22 | public class Log { 23 | public static final String TAG = "Vitamio[Player]"; 24 | 25 | public static void i(String msg, Object... args) { 26 | try { 27 | if (BuildConfig.DEBUG) 28 | android.util.Log.i(TAG, String.format(msg, args)); 29 | } catch (MissingFormatArgumentException e) { 30 | android.util.Log.e(TAG, "vitamio.Log", e); 31 | android.util.Log.i(TAG, msg); 32 | } 33 | } 34 | 35 | public static void d(String msg, Object... args) { 36 | try { 37 | if (BuildConfig.DEBUG) 38 | android.util.Log.d(TAG, String.format(msg, args)); 39 | } catch (MissingFormatArgumentException e) { 40 | android.util.Log.e(TAG, "vitamio.Log", e); 41 | android.util.Log.d(TAG, msg); 42 | } 43 | } 44 | 45 | public static void e(String msg, Object... args) { 46 | try { 47 | android.util.Log.e(TAG, String.format(msg, args)); 48 | } catch (MissingFormatArgumentException e) { 49 | android.util.Log.e(TAG, "vitamio.Log", e); 50 | android.util.Log.e(TAG, msg); 51 | } 52 | } 53 | 54 | public static void e(String msg, Throwable t) { 55 | android.util.Log.e(TAG, msg, t); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /vitamio/src/io/vov/vitamio/utils/ScreenResolution.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * Copyright (C) 2013 YIXIA.COM 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package io.vov.vitamio.utils; 18 | 19 | import android.annotation.TargetApi; 20 | import android.content.Context; 21 | import android.os.Build; 22 | import android.util.DisplayMetrics; 23 | import android.util.Pair; 24 | import android.view.Display; 25 | import android.view.WindowManager; 26 | 27 | import java.lang.reflect.Method; 28 | 29 | /** 30 | * Class to get the real screen resolution includes the system status bar. 31 | * We can get the value by calling the getRealMetrics method if API >= 17 32 | * Reflection needed on old devices.. 33 | * */ 34 | public class ScreenResolution { 35 | /** 36 | * Gets the resolution, 37 | * @return a pair to return the width and height 38 | * */ 39 | public static Pair getResolution(Context ctx){ 40 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { 41 | return getRealResolution(ctx); 42 | } 43 | else { 44 | return getRealResolutionOnOldDevice(ctx); 45 | } 46 | } 47 | 48 | /** 49 | * Gets resolution on old devices. 50 | * Tries the reflection to get the real resolution first. 51 | * Fall back to getDisplayMetrics if the above method failed. 52 | * */ 53 | private static Pair getRealResolutionOnOldDevice(Context ctx) { 54 | try{ 55 | WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE); 56 | Display display = wm.getDefaultDisplay(); 57 | Method mGetRawWidth = Display.class.getMethod("getRawWidth"); 58 | Method mGetRawHeight = Display.class.getMethod("getRawHeight"); 59 | Integer realWidth = (Integer) mGetRawWidth.invoke(display); 60 | Integer realHeight = (Integer) mGetRawHeight.invoke(display); 61 | return new Pair(realWidth, realHeight); 62 | } 63 | catch (Exception e) { 64 | DisplayMetrics disp = ctx.getResources().getDisplayMetrics(); 65 | return new Pair(disp.widthPixels, disp.heightPixels); 66 | } 67 | } 68 | 69 | /** 70 | * Gets real resolution via the new getRealMetrics API. 71 | * */ 72 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) 73 | private static Pair getRealResolution(Context ctx) { 74 | WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE); 75 | Display display = wm.getDefaultDisplay(); 76 | DisplayMetrics metrics = new DisplayMetrics(); 77 | display.getRealMetrics(metrics); 78 | return new Pair(metrics.widthPixels, metrics.heightPixels); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /vitamio/src/io/vov/vitamio/utils/StringUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 YIXIA.COM 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.vov.vitamio.utils; 17 | 18 | import java.util.Arrays; 19 | import java.util.Iterator; 20 | 21 | public class StringUtils { 22 | public static String join(Object[] elements, CharSequence separator) { 23 | return join(Arrays.asList(elements), separator); 24 | } 25 | 26 | public static String join(Iterable elements, CharSequence separator) { 27 | StringBuilder builder = new StringBuilder(); 28 | 29 | if (elements != null) { 30 | Iterator iter = elements.iterator(); 31 | if (iter.hasNext()) { 32 | builder.append(String.valueOf(iter.next())); 33 | while (iter.hasNext()) { 34 | builder.append(separator).append(String.valueOf(iter.next())); 35 | } 36 | } 37 | } 38 | 39 | return builder.toString(); 40 | } 41 | 42 | public static String fixLastSlash(String str) { 43 | String res = str == null ? "/" : str.trim() + "/"; 44 | if (res.length() > 2 && res.charAt(res.length() - 2) == '/') 45 | res = res.substring(0, res.length() - 1); 46 | return res; 47 | } 48 | 49 | public static int convertToInt(String str) throws NumberFormatException { 50 | int s, e; 51 | for (s = 0; s < str.length(); s++) 52 | if (Character.isDigit(str.charAt(s))) 53 | break; 54 | for (e = str.length(); e > 0; e--) 55 | if (Character.isDigit(str.charAt(e - 1))) 56 | break; 57 | if (e > s) { 58 | try { 59 | return Integer.parseInt(str.substring(s, e)); 60 | } catch (NumberFormatException ex) { 61 | Log.e("convertToInt", ex); 62 | throw new NumberFormatException(); 63 | } 64 | } else { 65 | throw new NumberFormatException(); 66 | } 67 | } 68 | 69 | public static String generateTime(long time) { 70 | int totalSeconds = (int) (time / 1000); 71 | int seconds = totalSeconds % 60; 72 | int minutes = (totalSeconds / 60) % 60; 73 | int hours = totalSeconds / 3600; 74 | 75 | return hours > 0 ? String.format("%02d:%02d:%02d", hours, minutes, seconds) : String.format("%02d:%02d", minutes, seconds); 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /vitamio/src/io/vov/vitamio/widget/CenterLayout.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 YIXIA.COM 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.vov.vitamio.widget; 18 | 19 | import android.content.Context; 20 | import android.util.AttributeSet; 21 | import android.view.View; 22 | import android.view.ViewGroup; 23 | import android.widget.RemoteViews.RemoteView; 24 | 25 | @RemoteView 26 | public class CenterLayout extends ViewGroup { 27 | private int mPaddingLeft = 0; 28 | private int mPaddingRight = 0; 29 | private int mPaddingTop = 0; 30 | private int mPaddingBottom = 0; 31 | private int mWidth, mHeight; 32 | 33 | public CenterLayout(Context context) { 34 | super(context); 35 | } 36 | 37 | public CenterLayout(Context context, AttributeSet attrs) { 38 | super(context, attrs); 39 | } 40 | 41 | public CenterLayout(Context context, AttributeSet attrs, int defStyle) { 42 | super(context, attrs, defStyle); 43 | } 44 | 45 | @Override 46 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 47 | int count = getChildCount(); 48 | 49 | int maxHeight = 0; 50 | int maxWidth = 0; 51 | 52 | measureChildren(widthMeasureSpec, heightMeasureSpec); 53 | 54 | for (int i = 0; i < count; i++) { 55 | View child = getChildAt(i); 56 | if (child.getVisibility() != GONE) { 57 | int childRight; 58 | int childBottom; 59 | 60 | CenterLayout.LayoutParams lp = (CenterLayout.LayoutParams) child.getLayoutParams(); 61 | 62 | childRight = lp.x + child.getMeasuredWidth(); 63 | childBottom = lp.y + child.getMeasuredHeight(); 64 | 65 | maxWidth = Math.max(maxWidth, childRight); 66 | maxHeight = Math.max(maxHeight, childBottom); 67 | } 68 | } 69 | 70 | maxWidth += mPaddingLeft + mPaddingRight; 71 | maxHeight += mPaddingTop + mPaddingBottom; 72 | 73 | maxHeight = Math.max(maxHeight, getSuggestedMinimumHeight()); 74 | maxWidth = Math.max(maxWidth, getSuggestedMinimumWidth()); 75 | 76 | setMeasuredDimension(resolveSize(maxWidth, widthMeasureSpec), resolveSize(maxHeight, heightMeasureSpec)); 77 | } 78 | 79 | @Override 80 | protected void onLayout(boolean changed, int l, int t, int r, int b) { 81 | int count = getChildCount(); 82 | mWidth = getMeasuredWidth(); 83 | mHeight = getMeasuredHeight(); 84 | for (int i = 0; i < count; i++) { 85 | View child = getChildAt(i); 86 | if (child.getVisibility() != GONE) { 87 | CenterLayout.LayoutParams lp = (CenterLayout.LayoutParams) child.getLayoutParams(); 88 | int childLeft = mPaddingLeft + lp.x; 89 | if (lp.width > 0) 90 | childLeft += (int) ((mWidth - lp.width) / 2.0); 91 | else 92 | childLeft += (int) ((mWidth - child.getMeasuredWidth()) / 2.0); 93 | int childTop = mPaddingTop + lp.y; 94 | if (lp.height > 0) 95 | childTop += (int) ((mHeight - lp.height) / 2.0); 96 | else 97 | childTop += (int) ((mHeight - child.getMeasuredHeight()) / 2.0); 98 | child.layout(childLeft, childTop, childLeft + child.getMeasuredWidth(), childTop + child.getMeasuredHeight()); 99 | } 100 | } 101 | } 102 | 103 | @Override 104 | protected boolean checkLayoutParams(ViewGroup.LayoutParams p) { 105 | return p instanceof CenterLayout.LayoutParams; 106 | } 107 | 108 | @Override 109 | protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) { 110 | return new LayoutParams(p); 111 | } 112 | 113 | public static class LayoutParams extends ViewGroup.LayoutParams { 114 | public int x; 115 | public int y; 116 | 117 | public LayoutParams(int width, int height, int x, int y) { 118 | super(width, height); 119 | this.x = x; 120 | this.y = y; 121 | } 122 | 123 | public LayoutParams(ViewGroup.LayoutParams source) { 124 | super(source); 125 | } 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /vitamio/src/io/vov/vitamio/widget/OutlineTextView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 YIXIA.COM 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.vov.vitamio.widget; 18 | 19 | import android.content.Context; 20 | import android.graphics.Canvas; 21 | import android.graphics.Paint; 22 | import android.graphics.Typeface; 23 | import android.text.Layout; 24 | import android.text.StaticLayout; 25 | import android.text.TextPaint; 26 | import android.util.AttributeSet; 27 | import android.widget.TextView; 28 | 29 | /** 30 | * Display text with border, use the same XML attrs as 31 | * {@link android.widget.TextView}, except that {@link OutlineTextView} will 32 | * transform the shadow to border 33 | */ 34 | public class OutlineTextView extends TextView { 35 | private TextPaint mTextPaint; 36 | private TextPaint mTextPaintOutline; 37 | private String mText = ""; 38 | private int mAscent = 0; 39 | private float mBorderSize; 40 | private int mBorderColor; 41 | private int mColor; 42 | private float mSpacingMult = 1.0f; 43 | private float mSpacingAdd = 0; 44 | private boolean mIncludePad = true; 45 | 46 | public OutlineTextView(Context context) { 47 | super(context); 48 | initPaint(); 49 | } 50 | 51 | public OutlineTextView(Context context, AttributeSet attrs) { 52 | super(context, attrs); 53 | initPaint(); 54 | } 55 | 56 | public OutlineTextView(Context context, AttributeSet attrs, int defStyle) { 57 | super(context, attrs, defStyle); 58 | initPaint(); 59 | } 60 | 61 | private void initPaint() { 62 | mTextPaint = new TextPaint(); 63 | mTextPaint.setAntiAlias(true); 64 | mTextPaint.setTextSize(getTextSize()); 65 | mTextPaint.setColor(mColor); 66 | mTextPaint.setStyle(Paint.Style.FILL); 67 | mTextPaint.setTypeface(getTypeface()); 68 | 69 | mTextPaintOutline = new TextPaint(); 70 | mTextPaintOutline.setAntiAlias(true); 71 | mTextPaintOutline.setTextSize(getTextSize()); 72 | mTextPaintOutline.setColor(mBorderColor); 73 | mTextPaintOutline.setStyle(Paint.Style.STROKE); 74 | mTextPaintOutline.setTypeface(getTypeface()); 75 | mTextPaintOutline.setStrokeWidth(mBorderSize); 76 | } 77 | 78 | public void setText(String text) { 79 | super.setText(text); 80 | mText = text.toString(); 81 | requestLayout(); 82 | invalidate(); 83 | } 84 | 85 | public void setTextSize(float size) { 86 | super.setTextSize(size); 87 | requestLayout(); 88 | invalidate(); 89 | initPaint(); 90 | } 91 | 92 | public void setTextColor(int color) { 93 | super.setTextColor(color); 94 | mColor = color; 95 | invalidate(); 96 | initPaint(); 97 | } 98 | 99 | public void setShadowLayer(float radius, float dx, float dy, int color) { 100 | super.setShadowLayer(radius, dx, dy, color); 101 | mBorderSize = radius; 102 | mBorderColor = color; 103 | requestLayout(); 104 | invalidate(); 105 | initPaint(); 106 | } 107 | 108 | public void setTypeface(Typeface tf, int style) { 109 | super.setTypeface(tf, style); 110 | requestLayout(); 111 | invalidate(); 112 | initPaint(); 113 | } 114 | 115 | public void setTypeface(Typeface tf) { 116 | super.setTypeface(tf); 117 | requestLayout(); 118 | invalidate(); 119 | initPaint(); 120 | } 121 | 122 | @Override 123 | protected void onDraw(Canvas canvas) { 124 | Layout layout = new StaticLayout(getText(), mTextPaintOutline, getWidth(), Layout.Alignment.ALIGN_CENTER, mSpacingMult, mSpacingAdd, mIncludePad); 125 | layout.draw(canvas); 126 | layout = new StaticLayout(getText(), mTextPaint, getWidth(), Layout.Alignment.ALIGN_CENTER, mSpacingMult, mSpacingAdd, mIncludePad); 127 | layout.draw(canvas); 128 | } 129 | 130 | @Override 131 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 132 | Layout layout = new StaticLayout(getText(), mTextPaintOutline, measureWidth(widthMeasureSpec), Layout.Alignment.ALIGN_CENTER, mSpacingMult, mSpacingAdd, mIncludePad); 133 | int ex = (int) (mBorderSize * 2 + 1); 134 | setMeasuredDimension(measureWidth(widthMeasureSpec) + ex, measureHeight(heightMeasureSpec) * layout.getLineCount() + ex); 135 | } 136 | 137 | private int measureWidth(int measureSpec) { 138 | int result = 0; 139 | int specMode = MeasureSpec.getMode(measureSpec); 140 | int specSize = MeasureSpec.getSize(measureSpec); 141 | 142 | if (specMode == MeasureSpec.EXACTLY) { 143 | result = specSize; 144 | } else { 145 | result = (int) mTextPaintOutline.measureText(mText) + getPaddingLeft() + getPaddingRight(); 146 | if (specMode == MeasureSpec.AT_MOST) { 147 | result = Math.min(result, specSize); 148 | } 149 | } 150 | 151 | return result; 152 | } 153 | 154 | private int measureHeight(int measureSpec) { 155 | int result = 0; 156 | int specMode = MeasureSpec.getMode(measureSpec); 157 | int specSize = MeasureSpec.getSize(measureSpec); 158 | 159 | mAscent = (int) mTextPaintOutline.ascent(); 160 | if (specMode == MeasureSpec.EXACTLY) { 161 | result = specSize; 162 | } else { 163 | result = (int) (-mAscent + mTextPaintOutline.descent()) + getPaddingTop() + getPaddingBottom(); 164 | if (specMode == MeasureSpec.AT_MOST) { 165 | result = Math.min(result, specSize); 166 | } 167 | } 168 | return result; 169 | } 170 | } --------------------------------------------------------------------------------