diff --git a/README-ZH.md b/README-ZH.md index 3352f86e2..fc7db6ed4 100644 --- a/README-ZH.md +++ b/README-ZH.md @@ -2,7 +2,7 @@ --

- +

@@ -26,7 +26,7 @@ ##效果 -**[jiecaovideoplayer-4.8.3-demo.apk](https://github.com/lipangit/JieCaoVideoPlayer/releases/download/v4.8.3/jiecaovideoplayer-4.8.3.apk)** +**[jiecaovideoplayer-5.0_preview-demo.apk](https://github.com/lipangit/JieCaoVideoPlayer/releases/download/v5.0_preview/jiecaovideoplayer-5.0_preview.apk)** ![Demo Screenshot][1] @@ -34,12 +34,12 @@ 即便是自定义UI,或者对Library有过修改,也是这四步骤来使用播放器。 -1.添加类库 +1.添加类库,稳定版本是4.8.3,这是用exoplayer播放的预览版本,给大家看看初步的效果,还有很多问题。 ```gradle -compile 'fm.jiecao:jiecaovideoplayer:4.8.3' +compile 'fm.jiecao:jiecaovideoplayer:5.0_preview' ``` -[或直接下载jar包](https://github.com/lipangit/JieCaoVideoPlayer/releases/tag/v4.8.3) +[或直接下载jar包](https://github.com/lipangit/JieCaoVideoPlayer/releases/tag/v5.0_preview) 2.添加布局 ```xml diff --git a/README.md b/README.md index d958dd65e..37cf925f6 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ --

- +

@@ -28,7 +28,7 @@ ## Effect -**[jiecaovideoplayer-4.8.3-demo.apk](https://github.com/lipangit/JieCaoVideoPlayer/releases/download/v4.8.3/jiecaovideoplayer-4.8.3.apk)** +**[jiecaovideoplayer-5.0_preview-demo.apk](https://github.com/lipangit/JieCaoVideoPlayer/releases/download/v5.0_preview/jiecaovideoplayer-5.0_preview.apk)** ![Demo Screenshot][1] @@ -36,12 +36,12 @@ Even the custom UI, or has changed to the Library, is also the four steps to use the player. -1.Import library +1.Import library but current stable version is still 4.8.3, 5.0 use exoplayer also have many problems. ```gradle -compile 'fm.jiecao:jiecaovideoplayer:4.8.3' +compile 'fm.jiecao:jiecaovideoplayer:5.0_preview' ``` -[Or download lib](https://github.com/lipangit/JieCaoVideoPlayer/releases/tag/v4.8.3) +[Or download lib](https://github.com/lipangit/JieCaoVideoPlayer/releases/tag/v5.0_preview) 2.Add JCVideoPlayer in your layout ```xml diff --git a/app/build.gradle b/app/build.gradle index 7a2e66dea..22039c78d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,15 +1,15 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 24 - buildToolsVersion '24.0.2' + compileSdkVersion 25 + buildToolsVersion '25.0.0' defaultConfig { applicationId "fm.jiecao.jiecaovideoplayer" - minSdkVersion 14 - targetSdkVersion 24 - versionCode 47 - versionName "4.8.3" + minSdkVersion 16 + targetSdkVersion 25 + versionCode 48 + versionName "5.0_preview" } buildTypes { release { @@ -26,15 +26,15 @@ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile project(':jcvideoplayer-lib') - compile 'com.github.bumptech.glide:glide:3.5.2' +// compile 'com.github.bumptech.glide:glide:3.5.2' compile 'com.squareup.picasso:picasso:2.5.1' - compile 'com.facebook.fresco:fresco:0.9.0' - compile 'com.mcxiaoke.volley:library:1.0.7' - compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4' +// compile 'com.facebook.fresco:fresco:0.9.0' +// compile 'com.mcxiaoke.volley:library:1.0.7' +// compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4' debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2' releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2' testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2' - compile 'com.android.support:recyclerview-v7:24.1.1' + compile 'com.android.support:recyclerview-v7:25.0.1' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7e957b1ec..b28523d50 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,6 +3,8 @@ package="fm.jiecao.jiecaovideoplayer"> + + This is webview
diff --git a/app/src/main/assets/local_video.mp4 b/app/src/main/assets/local_video.mp4 new file mode 100644 index 000000000..88ed66404 Binary files /dev/null and b/app/src/main/assets/local_video.mp4 differ diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardAutoComplete.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardAutoComplete.java new file mode 100644 index 000000000..c00d41b1c --- /dev/null +++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardAutoComplete.java @@ -0,0 +1,30 @@ +package fm.jiecao.jiecaovideoplayer.CustomView; + +import android.content.Context; +import android.util.AttributeSet; + +import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard; + +/** + * Created by Nathen on 2016/11/26. + */ + +public class JCVideoPlayerStandardAutoComplete extends JCVideoPlayerStandard { + public JCVideoPlayerStandardAutoComplete(Context context) { + super(context); + } + + public JCVideoPlayerStandardAutoComplete(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + public void onAutoCompletion() { + if (currentScreen == SCREEN_WINDOW_FULLSCREEN) { + setUiWitStateAndScreen(CURRENT_STATE_AUTO_COMPLETE); + } else { + super.onAutoCompletion(); + } + + } +} diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardFresco.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardFresco.java index 2d737907f..805ea6670 100755 --- a/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardFresco.java +++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardFresco.java @@ -18,8 +18,6 @@ import android.widget.TextView; import android.widget.Toast; -import com.facebook.drawee.view.SimpleDraweeView; - import java.util.Timer; import java.util.TimerTask; @@ -28,7 +26,10 @@ import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer; import fm.jiecao.jiecaovideoplayer.R; +//import com.facebook.drawee.view.SimpleDraweeView; + /** + * Just replace thumb from ImageView to SimpleDraweeView * Created by Nathen * On 2016/05/01 22:59 */ @@ -37,8 +38,7 @@ public class JCVideoPlayerStandardFresco extends JCVideoPlayer { public ImageView backButton; public ProgressBar bottomProgressBar, loadingProgressBar; public TextView titleTextView; - public SimpleDraweeView thumbImageView; - public ImageView coverImageView; + // public SimpleDraweeView thumbImageView; public ImageView tinyBackImageView; protected static Timer DISSMISS_CONTROL_VIEW_TIMER; @@ -60,38 +60,34 @@ public void init(Context context) { bottomProgressBar = (ProgressBar) findViewById(R.id.bottom_progressbar); titleTextView = (TextView) findViewById(R.id.title); backButton = (ImageView) findViewById(R.id.back); - thumbImageView = (SimpleDraweeView) findViewById(R.id.thumb); - coverImageView = (ImageView) findViewById(R.id.cover); +// thumbImageView = (SimpleDraweeView) findViewById(R.id.thumb); loadingProgressBar = (ProgressBar) findViewById(R.id.loading); tinyBackImageView = (ImageView) findViewById(R.id.back_tiny); - thumbImageView.setOnClickListener(this); +// thumbImageView.setOnClickListener(this); backButton.setOnClickListener(this); tinyBackImageView.setOnClickListener(this); } @Override - public boolean setUp(String url, int screen, Object... objects) { - if (objects.length == 0) return false; - if (super.setUp(url, screen, objects)) { - titleTextView.setText(objects[0].toString()); - if (currentScreen == SCREEN_WINDOW_FULLSCREEN) { - fullscreenButton.setImageResource(R.drawable.jc_shrink); - backButton.setVisibility(View.VISIBLE); - tinyBackImageView.setVisibility(View.INVISIBLE); - } else if (currentScreen == SCREEN_LAYOUT_LIST) { - fullscreenButton.setImageResource(R.drawable.jc_enlarge); - backButton.setVisibility(View.GONE); - tinyBackImageView.setVisibility(View.INVISIBLE); - } else if (currentScreen == SCREEN_WINDOW_TINY) { - tinyBackImageView.setVisibility(View.VISIBLE); - setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, - View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, View.INVISIBLE); - } - return true; + public void setUp(String url, int screen, Object... objects) { + super.setUp(url, screen, objects); + if (objects.length == 0) return; + titleTextView.setText(objects[0].toString()); + if (currentScreen == SCREEN_WINDOW_FULLSCREEN) { + fullscreenButton.setImageResource(R.drawable.jc_shrink); + backButton.setVisibility(View.VISIBLE); + tinyBackImageView.setVisibility(View.INVISIBLE); + } else if (currentScreen == SCREEN_LAYOUT_LIST) { + fullscreenButton.setImageResource(R.drawable.jc_enlarge); + backButton.setVisibility(View.GONE); + tinyBackImageView.setVisibility(View.INVISIBLE); + } else if (currentScreen == SCREEN_WINDOW_TINY) { + tinyBackImageView.setVisibility(View.VISIBLE); + setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, + View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, View.INVISIBLE); } - return false; } @Override @@ -500,8 +496,7 @@ private void setAllControlsVisible(int topCon, int bottomCon, int startBtn, int bottomContainer.setVisibility(bottomCon); startButton.setVisibility(startBtn); loadingProgressBar.setVisibility(loadingPro); - thumbImageView.setVisibility(thumbImg); - coverImageView.setVisibility(coverImg); +// thumbImageView.setVisibility(thumbImg); bottomProgressBar.setVisibility(bottomPro); } diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardShowShareButtonAfterFullscreen.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardShowShareButtonAfterFullscreen.java index 5e7690317..8834d90f3 100755 --- a/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardShowShareButtonAfterFullscreen.java +++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardShowShareButtonAfterFullscreen.java @@ -47,15 +47,12 @@ public void onClick(View v) { } @Override - public boolean setUp(String url, int screen, Object... objects) { - if (super.setUp(url, screen, objects)) { - if (currentScreen == SCREEN_WINDOW_FULLSCREEN) { - shareButton.setVisibility(View.VISIBLE); - } else { - shareButton.setVisibility(View.INVISIBLE); - } - return true; + public void setUp(String url, int screen, Object... objects) { + super.setUp(url, screen, objects); + if (currentScreen == SCREEN_WINDOW_FULLSCREEN) { + shareButton.setVisibility(View.VISIBLE); + } else { + shareButton.setVisibility(View.INVISIBLE); } - return false; } } diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardShowTitleAfterFullscreen.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardShowTitleAfterFullscreen.java index c64919406..ab9982e42 100755 --- a/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardShowTitleAfterFullscreen.java +++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardShowTitleAfterFullscreen.java @@ -20,15 +20,12 @@ public JCVideoPlayerStandardShowTitleAfterFullscreen(Context context, AttributeS } @Override - public boolean setUp(String url, int screen, Object... objects) { - if (super.setUp(url, screen, objects)) { - if (currentScreen == SCREEN_WINDOW_FULLSCREEN) { - titleTextView.setVisibility(View.VISIBLE); - } else { - titleTextView.setVisibility(View.INVISIBLE); - } - return true; + public void setUp(String url, int screen, Object... objects) { + super.setUp(url, screen, objects); + if (currentScreen == SCREEN_WINDOW_FULLSCREEN) { + titleTextView.setVisibility(View.VISIBLE); + } else { + titleTextView.setVisibility(View.INVISIBLE); } - return false; } } diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/DemoApplication.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/DemoApplication.java index bb8874f7c..d0a4dc317 100644 --- a/app/src/main/java/fm/jiecao/jiecaovideoplayer/DemoApplication.java +++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/DemoApplication.java @@ -1,17 +1,7 @@ package fm.jiecao.jiecaovideoplayer; import android.app.Application; -import android.graphics.Bitmap; -import android.graphics.Color; -import android.graphics.drawable.ColorDrawable; -import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator; -import com.nostra13.universalimageloader.core.DisplayImageOptions; -import com.nostra13.universalimageloader.core.ImageLoader; -import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; -import com.nostra13.universalimageloader.core.assist.ImageScaleType; -import com.nostra13.universalimageloader.core.assist.QueueProcessingType; -import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer; import com.squareup.leakcanary.LeakCanary; /** @@ -24,39 +14,9 @@ public class DemoApplication extends Application { public void onCreate() { super.onCreate(); LeakCanary.install(this); - initUniversalImageLoader(); //it is public static, you can set this everywhere //JCVideoPlayer.TOOL_BAR_EXIST = false; //JCVideoPlayer.ACTION_BAR_EXIST = false; } - - private void initUniversalImageLoader() { - ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(getApplicationContext()); - config.threadPriority(Thread.NORM_PRIORITY - 2); - config.denyCacheImageMultipleSizesInMemory(); - config.diskCacheFileNameGenerator(new Md5FileNameGenerator()); - config.diskCacheSize(50 * 1024 * 1024); // 50 MiB - config.tasksProcessingOrder(QueueProcessingType.LIFO); - config.writeDebugLogs(); // Remove for releaseAllVideos app - config.defaultDisplayImageOptions(getDefaultDisplayImageOption()); - // Initialize ImageLoader with configuration. - ImageLoader.getInstance().init(config.build()); - } - - public static DisplayImageOptions getDefaultDisplayImageOption() { - DisplayImageOptions options = new DisplayImageOptions.Builder() - .showImageOnLoading(new ColorDrawable(Color.parseColor("#f0f0f0"))) - .resetViewBeforeLoading(true) - .cacheInMemory(true) - .cacheOnDisk(true) - .considerExifParams(true) - .imageScaleType(ImageScaleType.EXACTLY_STRETCHED) - .bitmapConfig(Bitmap.Config.RGB_565) - .displayer(new FadeInBitmapDisplayer(500)) // 设置图片渐显的时间 -// .delayBeforeLoading(300) // 下载前的延迟时间 - .build(); - return options; - } - } diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/ListViewMultiHolderActivity.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/ListViewMultiHolderActivity.java index cf21d3dd1..2b8d647b0 100755 --- a/app/src/main/java/fm/jiecao/jiecaovideoplayer/ListViewMultiHolderActivity.java +++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/ListViewMultiHolderActivity.java @@ -86,11 +86,11 @@ public View getView(int position, View convertView, ViewGroup parent) { } viewHolder.jcVideoPlayer.setUp( - VideoConstant.videoUrls[position], JCVideoPlayer.SCREEN_LAYOUT_LIST, - VideoConstant.videoTitles[position]); + VideoConstant.videoUrls[0][position], JCVideoPlayer.SCREEN_LAYOUT_LIST, + VideoConstant.videoTitles[0][position]); Picasso.with(ListViewMultiHolderActivity.this) - .load(VideoConstant.videoThumbs[position]) + .load(VideoConstant.videoThumbs[0][position]) .into(viewHolder.jcVideoPlayer.thumbImageView); } else { TextViewHolder textViewHolder; diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/ListViewViewpagerActivity.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/ListViewViewpagerActivity.java index c937dfe23..ad8ab5735 100755 --- a/app/src/main/java/fm/jiecao/jiecaovideoplayer/ListViewViewpagerActivity.java +++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/ListViewViewpagerActivity.java @@ -33,9 +33,9 @@ protected void onCreate(Bundle savedInstanceState) { ListView listView2 = (ListView) getLayoutInflater().inflate(R.layout.layout_list, null); ListView listView3 = (ListView) getLayoutInflater().inflate(R.layout.layout_list, null); - listView1.setAdapter(new VideoListAdapter(this)); - listView2.setAdapter(new VideoListAdapter(this)); - listView3.setAdapter(new VideoListAdapter(this)); + listView1.setAdapter(new VideoListAdapter(this, 0)); + listView2.setAdapter(new VideoListAdapter(this, 1)); + listView3.setAdapter(new VideoListAdapter(this, 2)); listViews.add(listView1); listViews.add(listView2); diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/MainActivity.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/MainActivity.java index e545a01af..c053edb03 100644 --- a/app/src/main/java/fm/jiecao/jiecaovideoplayer/MainActivity.java +++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/MainActivity.java @@ -4,6 +4,7 @@ import android.hardware.Sensor; import android.hardware.SensorManager; import android.os.Bundle; +import android.os.Environment; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.util.Log; @@ -12,6 +13,11 @@ import com.squareup.picasso.Picasso; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + import fm.jiecao.jcvideoplayer_lib.JCUserAction; import fm.jiecao.jcvideoplayer_lib.JCUserActionStandard; import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer; @@ -56,12 +62,20 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { , JCVideoPlayerStandard.SCREEN_LAYOUT_NORMAL, "嫂子在家吗"); mJcVideoPlayerStandard = (JCVideoPlayerStandard) findViewById(R.id.jc_video); - mJcVideoPlayerStandard.setUp("http://video.jiecao.fm/8/17/%E6%8A%AB%E8%90%A8.mp4" - , JCVideoPlayerStandard.SCREEN_LAYOUT_NORMAL, "嫂子真嘚瑟"); + mJcVideoPlayerStandard.setUp("http://video.jiecao.fm/11/23/xin/%E5%81%87%E4%BA%BA.mp4" + , JCVideoPlayerStandard.SCREEN_LAYOUT_NORMAL, "嫂子不信"); + + /** Play video in local path, eg:record by system camera **/ +// cpAssertVideoToLocalPath(); +// mJcVideoPlayerStandard.setUp(Environment.getExternalStorageDirectory().getAbsolutePath() + "/DCIM/Camera/local_video.mp4" +// , JCVideoPlayerStandard.SCREEN_LAYOUT_NORMAL, "嫂子不信"); + /** Play video in assert **/ +// mJcVideoPlayerStandard.setUp("file:///android_asset/local_video.mp4" +// , JCVideoPlayerStandard.SCREEN_LAYOUT_NORMAL, "嫂子不信"); + Picasso.with(this) - .load("http://img4.jiecaojingxuan.com/2016/8/17/f2dbd12e-b1cb-4daf-aff1-8c6be2f64d1a.jpg") + .load("http://img4.jiecaojingxuan.com/2016/11/23/00b026e7-b830-4994-bc87-38f4033806a6.jpg@!640_360") .into(mJcVideoPlayerStandard.thumbImageView); - mJcVideoPlayerStandard.looping = true; JCVideoPlayer.setJcUserAction(new MyUserActionStandard()); mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); @@ -171,4 +185,24 @@ public void onEvent(int type, String url, int screen, Object... objects) { } } } + + public void cpAssertVideoToLocalPath() { + try { + InputStream myInput; + OutputStream myOutput = new FileOutputStream(Environment.getExternalStorageDirectory().getAbsolutePath() + "/DCIM/Camera/local_video.mp4"); + myInput = this.getAssets().open("local_video.mp4"); + byte[] buffer = new byte[1024]; + int length = myInput.read(buffer); + while (length > 0) { + myOutput.write(buffer, 0, length); + length = myInput.read(buffer); + } + + myOutput.flush(); + myInput.close(); + myOutput.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } } diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/RecyclerViewNormalActivity.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/RecyclerViewNormalActivity.java index 21bb996be..7e9d42f09 100644 --- a/app/src/main/java/fm/jiecao/jiecaovideoplayer/RecyclerViewNormalActivity.java +++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/RecyclerViewNormalActivity.java @@ -42,8 +42,8 @@ public void onChildViewAttachedToWindow(View view) { @Override public void onChildViewDetachedFromWindow(View view) { - if (JCVideoPlayerManager.getFirst() != null) { - JCVideoPlayer videoPlayer = (JCVideoPlayer) JCVideoPlayerManager.getFirst(); + if (JCVideoPlayerManager.getCurrentJcvdOnFirtFloor() != null) { + JCVideoPlayer videoPlayer = (JCVideoPlayer) JCVideoPlayerManager.getCurrentJcvdOnFirtFloor(); if (((ViewGroup) view).indexOfChild(videoPlayer) != -1 && videoPlayer.currentState == JCVideoPlayer.CURRENT_STATE_PLAYING) { JCVideoPlayer.releaseAllVideos(); } diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/RecyclerViewVideoAdapter.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/RecyclerViewVideoAdapter.java index 5fdb22152..fbde28088 100644 --- a/app/src/main/java/fm/jiecao/jiecaovideoplayer/RecyclerViewVideoAdapter.java +++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/RecyclerViewVideoAdapter.java @@ -35,10 +35,10 @@ public void onBindViewHolder(MyViewHolder holder, int position) { Log.i(TAG, "onBindViewHolder [" + holder.jcVideoPlayer.hashCode() + "] position=" + position); holder.jcVideoPlayer.setUp( - VideoConstant.videoUrls[position], JCVideoPlayer.SCREEN_LAYOUT_LIST, - VideoConstant.videoTitles[position]); + VideoConstant.videoUrls[0][position], JCVideoPlayer.SCREEN_LAYOUT_LIST, + VideoConstant.videoTitles[0][position]); Picasso.with(holder.jcVideoPlayer.getContext()) - .load(VideoConstant.videoThumbs[position]) + .load(VideoConstant.videoThumbs[0][position]) .into(holder.jcVideoPlayer.thumbImageView); } diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/UIImageLoaderActivity.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/UIImageLoaderActivity.java index 12cfc8ec9..9f4c61680 100644 --- a/app/src/main/java/fm/jiecao/jiecaovideoplayer/UIImageLoaderActivity.java +++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/UIImageLoaderActivity.java @@ -1,36 +1,30 @@ package fm.jiecao.jiecaovideoplayer; -import android.graphics.Bitmap; -import android.net.Uri; import android.os.Bundle; import android.support.annotation.Nullable; -import android.support.v4.util.LruCache; import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; -import android.view.View; -import com.android.volley.RequestQueue; -import com.android.volley.toolbox.Volley; -import com.bumptech.glide.Glide; -import com.facebook.drawee.backends.pipeline.Fresco; -import com.nostra13.universalimageloader.core.ImageLoader; import com.squareup.picasso.Picasso; import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer; import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard; import fm.jiecao.jiecaovideoplayer.CustomView.JCVideoPlayerStandardFresco; +//import com.facebook.drawee.backends.pipeline.Fresco; + /** + * These load image library is too large, We should stand out this library is small, so remove other load image library * Created by Nathen on 16/7/31. */ +@Deprecated // this should in small change public class UIImageLoaderActivity extends AppCompatActivity { - JCVideoPlayerStandard videoController1, videoController2, videoController3, videoController4; - JCVideoPlayerStandardFresco videoController5; + JCVideoPlayerStandard videoController1; + JCVideoPlayerStandardFresco videoController2; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - Fresco.initialize(this); setContentView(R.layout.activity_loadimage); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); @@ -41,69 +35,54 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { videoController1 = (JCVideoPlayerStandard) findViewById(R.id.videocontroller1); videoController1.setUp("http://video.jiecao.fm/8/17/%E6%8A%AB%E8%90%A8.mp4", JCVideoPlayer.SCREEN_LAYOUT_LIST, "嫂子抓住"); - ImageLoader.getInstance().displayImage("http://img4.jiecaojingxuan.com/2016/8/17/f2dbd12e-b1cb-4daf-aff1-8c6be2f64d1a.jpg", - videoController1.thumbImageView); - - videoController2 = (JCVideoPlayerStandard) findViewById(R.id.videocontroller2); - videoController2.setUp("http://video.jiecao.fm/8/17/%E6%8A%AB%E8%90%A8.mp4", JCVideoPlayer.SCREEN_LAYOUT_LIST, - "嫂子别晃"); - Glide.with(this) - .load("http://img4.jiecaojingxuan.com/2016/8/17/f2dbd12e-b1cb-4daf-aff1-8c6be2f64d1a.jpg") - .into(videoController2.thumbImageView); - - videoController3 = (JCVideoPlayerStandard) findViewById(R.id.videocontroller3); - videoController3.setUp("http://video.jiecao.fm/8/17/%E6%8A%AB%E8%90%A8.mp4", JCVideoPlayer.SCREEN_LAYOUT_LIST, - "嫂子别躲"); Picasso.with(this) .load("http://img4.jiecaojingxuan.com/2016/8/17/f2dbd12e-b1cb-4daf-aff1-8c6be2f64d1a.jpg") - .into(videoController3.thumbImageView); + .into(videoController1.thumbImageView); + /** ImageLoader **/ +// ImageLoader.getInstance().displayImage("http://img4.jiecaojingxuan.com/2016/8/17/f2dbd12e-b1cb-4daf-aff1-8c6be2f64d1a.jpg", +// videoController1.thumbImageView); + /** Glide **/ +// Glide.with(this) +// .load("http://img4.jiecaojingxuan.com/2016/8/17/f2dbd12e-b1cb-4daf-aff1-8c6be2f64d1a.jpg") +// .into(videoController1.thumbImageView); + /** volley **/ +// RequestQueue mQueue = Volley.newRequestQueue(getApplicationContext()); +// com.android.volley.toolbox.ImageLoader imageLoader = new com.android.volley.toolbox.ImageLoader(mQueue, new VolleyBitmapCache()); +// com.android.volley.toolbox.ImageLoader.ImageListener listener = +// com.android.volley.toolbox.ImageLoader.getImageListener(videoController1.thumbImageView, R.mipmap.ic_launcher, R.mipmap.ic_launcher); +// imageLoader.get("http://img4.jiecaojingxuan.com/2016/8/17/f2dbd12e-b1cb-4daf-aff1-8c6be2f64d1a.jpg", listener); + /** Fresco **/ +// Fresco.initialize(this); +// videoController2 = (JCVideoPlayerStandardFresco) findViewById(R.id.videocontroller2); +// videoController2.setUp("http://video.jiecao.fm/8/17/%E6%8A%AB%E8%90%A8.mp4", JCVideoPlayer.SCREEN_LAYOUT_LIST, +// "嫂子打电话"); +// Uri uri = Uri.parse("http://img4.jiecaojingxuan.com/2016/8/17/f2dbd12e-b1cb-4daf-aff1-8c6be2f64d1a.jpg"); +// videoController2.thumbImageView.setImageURI(uri); - videoController4 = (JCVideoPlayerStandard) findViewById(R.id.videocontroller4); - videoController4.setUp("http://video.jiecao.fm/8/17/%E6%8A%AB%E8%90%A8.mp4", JCVideoPlayer.SCREEN_LAYOUT_LIST, - "嫂子别忘了"); - RequestQueue mQueue = Volley.newRequestQueue(getApplicationContext()); - com.android.volley.toolbox.ImageLoader imageLoader = new com.android.volley.toolbox.ImageLoader(mQueue, new BitmapCache()); - com.android.volley.toolbox.ImageLoader.ImageListener listener = - com.android.volley.toolbox.ImageLoader.getImageListener(videoController4.thumbImageView, R.mipmap.ic_launcher, R.mipmap.ic_launcher); - imageLoader.get("http://img4.jiecaojingxuan.com/2016/8/17/f2dbd12e-b1cb-4daf-aff1-8c6be2f64d1a.jpg", listener); - - videoController5 = (JCVideoPlayerStandardFresco) findViewById(R.id.videocontroller5); - videoController5.setUp("http://video.jiecao.fm/8/17/%E6%8A%AB%E8%90%A8.mp4", JCVideoPlayer.SCREEN_LAYOUT_LIST, - "嫂子打电话"); - Uri uri = Uri.parse("http://img4.jiecaojingxuan.com/2016/8/17/f2dbd12e-b1cb-4daf-aff1-8c6be2f64d1a.jpg"); - videoController5.thumbImageView.setImageURI(uri); - - View vv = findViewById(R.id.scroll); - vv.setOnScrollChangeListener(new View.OnScrollChangeListener() { - @Override - public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) { - videoController1.onScrollChange(); - } - }); } - public class BitmapCache implements com.android.volley.toolbox.ImageLoader.ImageCache { - private LruCache cache; - - public BitmapCache() { - cache = new LruCache(8 * 1024 * 1024) { - @Override - protected int sizeOf(String key, Bitmap bitmap) { - return bitmap.getRowBytes() * bitmap.getHeight(); - } - }; - } - - @Override - public Bitmap getBitmap(String url) { - return cache.get(url); - } - - @Override - public void putBitmap(String url, Bitmap bitmap) { - cache.put(url, bitmap); - } - } +// public class VolleyBitmapCache implements com.android.volley.toolbox.ImageLoader.ImageCache { +// private LruCache cache; +// +// public VolleyBitmapCache() { +// cache = new LruCache(8 * 1024 * 1024) { +// @Override +// protected int sizeOf(String key, Bitmap bitmap) { +// return bitmap.getRowBytes() * bitmap.getHeight(); +// } +// }; +// } +// +// @Override +// public Bitmap getBitmap(String url) { +// return cache.get(url); +// } +// +// @Override +// public void putBitmap(String url, Bitmap bitmap) { +// cache.put(url, bitmap); +// } +// } @Override public void onBackPressed() { diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/UISmallChangeActivity.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/UISmallChangeActivity.java index f5565ed17..f98577d9d 100644 --- a/app/src/main/java/fm/jiecao/jiecaovideoplayer/UISmallChangeActivity.java +++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/UISmallChangeActivity.java @@ -8,6 +8,7 @@ import com.squareup.picasso.Picasso; import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer; +import fm.jiecao.jiecaovideoplayer.CustomView.JCVideoPlayerStandardAutoComplete; import fm.jiecao.jiecaovideoplayer.CustomView.JCVideoPlayerStandardShowShareButtonAfterFullscreen; import fm.jiecao.jiecaovideoplayer.CustomView.JCVideoPlayerStandardShowTextureViewAfterAutoComplete; import fm.jiecao.jiecaovideoplayer.CustomView.JCVideoPlayerStandardShowTitleAfterFullscreen; @@ -19,6 +20,7 @@ public class UISmallChangeActivity extends AppCompatActivity { JCVideoPlayerStandardShowShareButtonAfterFullscreen jcVideoPlayerStandardWithShareButton; JCVideoPlayerStandardShowTitleAfterFullscreen jcVideoPlayerStandardShowTitleAfterFullscreen; JCVideoPlayerStandardShowTextureViewAfterAutoComplete jcVideoPlayerStandardShowTextureViewAfterAutoComplete; + JCVideoPlayerStandardAutoComplete jcVideoPlayerStandardAutoComplete; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { @@ -31,26 +33,33 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { setContentView(R.layout.activity_ui_small_change); jcVideoPlayerStandardWithShareButton = (JCVideoPlayerStandardShowShareButtonAfterFullscreen) findViewById(R.id.custom_videoplayer_standard_with_share_button); - jcVideoPlayerStandardWithShareButton.setUp("http://video.jiecao.fm/8/17/%E6%8A%AB%E8%90%A8.mp4", JCVideoPlayer.SCREEN_LAYOUT_NORMAL - , "嫂子上飞机"); + jcVideoPlayerStandardWithShareButton.setUp("http://video.jiecao.fm/11/17/c/fxkR4gylyIZKeljem8xTvA__.mp4", JCVideoPlayer.SCREEN_LAYOUT_NORMAL + , "嫂子想呼吸"); Picasso.with(this) - .load("http://img4.jiecaojingxuan.com/2016/8/17/f2dbd12e-b1cb-4daf-aff1-8c6be2f64d1a.jpg") + .load("http://img4.jiecaojingxuan.com/2016/11/17/6fc2ae91-36e2-44c5-bb10-29ae5d5c678c.png@!640_360") .into(jcVideoPlayerStandardWithShareButton.thumbImageView); jcVideoPlayerStandardShowTitleAfterFullscreen = (JCVideoPlayerStandardShowTitleAfterFullscreen) findViewById(R.id.custom_videoplayer_standard_show_title_after_fullscreen); - jcVideoPlayerStandardShowTitleAfterFullscreen.setUp("http://video.jiecao.fm/8/17/%E6%8A%AB%E8%90%A8.mp4", JCVideoPlayer.SCREEN_LAYOUT_NORMAL - , "嫂子看电视"); + jcVideoPlayerStandardShowTitleAfterFullscreen.setUp("http://video.jiecao.fm/11/18/xu/%E6%91%87%E5%A4%B4.mp4", JCVideoPlayer.SCREEN_LAYOUT_NORMAL + , "嫂子想摇头"); Picasso.with(this) - .load("http://img4.jiecaojingxuan.com/2016/8/17/f2dbd12e-b1cb-4daf-aff1-8c6be2f64d1a.jpg") + .load("http://img4.jiecaojingxuan.com/2016/11/18/f03cee95-9b78-4dd5-986f-d162c06c385c.png@!640_360") .into(jcVideoPlayerStandardShowTitleAfterFullscreen.thumbImageView); jcVideoPlayerStandardShowTextureViewAfterAutoComplete = (JCVideoPlayerStandardShowTextureViewAfterAutoComplete) findViewById(R.id.custom_videoplayer_standard_show_textureview_aoto_complete); - jcVideoPlayerStandardShowTextureViewAfterAutoComplete.setUp("http://video.jiecao.fm/8/17/%E6%8A%AB%E8%90%A8.mp4", JCVideoPlayer.SCREEN_LAYOUT_NORMAL - , "嫂子还在浪"); + jcVideoPlayerStandardShowTextureViewAfterAutoComplete.setUp("http://video.jiecao.fm/11/18/c/I-KpaMJ-HMDfAy6tX2Jfag__.mp4", JCVideoPlayer.SCREEN_LAYOUT_NORMAL + , "嫂子想旅行"); Picasso.with(this) - .load("http://img4.jiecaojingxuan.com/2016/8/17/f2dbd12e-b1cb-4daf-aff1-8c6be2f64d1a.jpg") + .load("http://img4.jiecaojingxuan.com/2016/11/18/e7ea659f-c3d2-4979-9ea5-f993b05e5930.png@!640_360") .into(jcVideoPlayerStandardShowTextureViewAfterAutoComplete.thumbImageView); + + jcVideoPlayerStandardAutoComplete = (JCVideoPlayerStandardAutoComplete) findViewById(R.id.custom_videoplayer_standard_aoto_complete); + jcVideoPlayerStandardAutoComplete.setUp("http://video.jiecao.fm/8/17/%E6%8A%AB%E8%90%A8.mp4", JCVideoPlayer.SCREEN_LAYOUT_NORMAL + , "嫂子没来"); + Picasso.with(this) + .load("http://img4.jiecaojingxuan.com/2016/8/17/f2dbd12e-b1cb-4daf-aff1-8c6be2f64d1a.jpg") + .into(jcVideoPlayerStandardAutoComplete.thumbImageView); } @Override diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/VideoConstant.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/VideoConstant.java index 537ec80b9..51e486ea2 100644 --- a/app/src/main/java/fm/jiecao/jiecaovideoplayer/VideoConstant.java +++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/VideoConstant.java @@ -5,40 +5,88 @@ */ public class VideoConstant { - public static String[] videoUrls = { - "http://video.jiecao.fm/8/17/bGQS3BQQWUYrlzP1K4Tg4Q__.mp4", - "http://video.jiecao.fm/8/17/%E6%8A%AB%E8%90%A8.mp4", - "http://video.jiecao.fm/8/18/%E5%A4%A7%E5%AD%A6.mp4", - "http://video.jiecao.fm/8/16/%E8%B7%B3%E8%88%9E.mp4", - "http://video.jiecao.fm/8/16/%E9%B8%AD%E5%AD%90.mp4", - "http://video.jiecao.fm/8/16/%E9%A9%BC%E8%83%8C.mp4", - "http://video.jiecao.fm/8/16/%E4%BF%AF%E5%8D%A7%E6%92%91.mp4", - "http://video.jiecao.fm/5/1/%E8%87%AA%E5%8F%96%E5%85%B6%E8%BE%B1.mp4", - "http://gslb.miaopai.com/stream/ed5HCfnhovu3tyIQAiv60Q__.mp4", - "http://2449.vod.myqcloud.com/2449_22ca37a6ea9011e5acaaf51d105342e3.f20.mp4"}; + public static String[][] videoUrls = + { + { + "http://video.jiecao.fm/8/17/bGQS3BQQWUYrlzP1K4Tg4Q__.mp4", + "http://video.jiecao.fm/8/17/%E6%8A%AB%E8%90%A8.mp4", + "http://video.jiecao.fm/8/18/%E5%A4%A7%E5%AD%A6.mp4", + "http://video.jiecao.fm/8/16/%E8%B7%B3%E8%88%9E.mp4", + "http://video.jiecao.fm/8/16/%E9%B8%AD%E5%AD%90.mp4", + "http://video.jiecao.fm/8/16/%E9%A9%BC%E8%83%8C.mp4", + "http://video.jiecao.fm/8/16/%E4%BF%AF%E5%8D%A7%E6%92%91.mp4", + "http://video.jiecao.fm/5/1/%E8%87%AA%E5%8F%96%E5%85%B6%E8%BE%B1.mp4", + "http://gslb.miaopai.com/stream/ed5HCfnhovu3tyIQAiv60Q__.mp4", + "http://video.jiecao.fm/11/23/xu/%E5%A6%B9%E5%A6%B9.mp4" + }, + { + "http://video.jiecao.fm/11/24/xin/-%2024%20-%20.mp4", + "http://video.jiecao.fm/11/24/6/%E9%85%92%E9%A9%BE.mp4", + "http://video.jiecao.fm/11/23/6/%E7%8B%97.mp4", + "http://video.jiecao.fm/11/23/xu/%E7%94%B5%E5%BD%B1.mp4" + }, + { + "http://video.jiecao.fm/11/23/6/%E5%AD%A9%E5%AD%90.mp4", + "http://video.jiecao.fm/11/24/xu/%E6%97%A5%E5%8E%86.mp4", + "http://video.jiecao.fm/11/26/-iDareX.mp4", + "http://video.jiecao.fm/11/24/6/%E5%AD%94%E6%98%8E%E7%81%AF.mp4" + } + }; - public static String[] videoThumbs = { - "http://img4.jiecaojingxuan.com/2016/8/17/bd7ffc84-8407-4037-a078-7d922ce0fb0f.jpg", - "http://img4.jiecaojingxuan.com/2016/8/17/f2dbd12e-b1cb-4daf-aff1-8c6be2f64d1a.jpg", - "http://img4.jiecaojingxuan.com/2016/8/18/ccd86ca1-66c7-4331-9450-a3b7f765424a.png", - "http://img4.jiecaojingxuan.com/2016/8/16/2adde364-9be1-4864-b4b9-0b0bcc81ef2e.jpg", - "http://img4.jiecaojingxuan.com/2016/8/16/2a877211-4b68-4e3a-87be-6d2730faef27.png", - "http://img4.jiecaojingxuan.com/2016/8/16/aaeb5da9-ac50-4712-a28d-863fe40f1fc6.png", - "http://img4.jiecaojingxuan.com/2016/8/16/e565f9cc-eedc-45f0-99f8-5b0fa3aed567.jpg", - "http://img4.jiecaojingxuan.com/2016/5/1/3430ec64-e6a7-4d8e-b044-9d408e075b7c.jpg", - "http://img4.jiecaojingxuan.com/2016/3/14/2204a578-609b-440e-8af7-a0ee17ff3aee.jpg", - "http://cos.myqcloud.com/1000264/qcloud_video_attachment/842646334/vod_cover/cover1458036374.jpg"}; + public static String[][] videoThumbs = + { + { + "http://img4.jiecaojingxuan.com/2016/8/17/bd7ffc84-8407-4037-a078-7d922ce0fb0f.jpg", + "http://img4.jiecaojingxuan.com/2016/8/17/f2dbd12e-b1cb-4daf-aff1-8c6be2f64d1a.jpg", + "http://img4.jiecaojingxuan.com/2016/8/18/ccd86ca1-66c7-4331-9450-a3b7f765424a.png", + "http://img4.jiecaojingxuan.com/2016/8/16/2adde364-9be1-4864-b4b9-0b0bcc81ef2e.jpg", + "http://img4.jiecaojingxuan.com/2016/8/16/2a877211-4b68-4e3a-87be-6d2730faef27.png", + "http://img4.jiecaojingxuan.com/2016/8/16/aaeb5da9-ac50-4712-a28d-863fe40f1fc6.png", + "http://img4.jiecaojingxuan.com/2016/8/16/e565f9cc-eedc-45f0-99f8-5b0fa3aed567.jpg", + "http://img4.jiecaojingxuan.com/2016/5/1/3430ec64-e6a7-4d8e-b044-9d408e075b7c.jpg", + "http://img4.jiecaojingxuan.com/2016/3/14/2204a578-609b-440e-8af7-a0ee17ff3aee.jpg", + "http://img4.jiecaojingxuan.com/2016/11/23/1bb2ebbe-140d-4e2e-abd2-9e7e564f71ac.png@!640_360" + }, + { + "http://img4.jiecaojingxuan.com/2016/11/24/f18ee453-6aec-40a5-a046-3203111dd303.jpg@!640_360", + "http://img4.jiecaojingxuan.com/2016/11/24/00f5a243-1e9f-426c-94f4-888971987edb.jpg@!640_360", + "http://img4.jiecaojingxuan.com/2016/11/23/7df34ee9-1e4f-48f4-8acd-748c52368298.jpg@!640_360", + "http://img4.jiecaojingxuan.com/2016/11/23/ef46e139-e378-4298-8441-144888294f1f.png@!640_360" + }, + { + "http://img4.jiecaojingxuan.com/2016/11/23/0e58101d-5b47-4100-8fb3-0cce057fd622.jpg@!640_360", + "http://img4.jiecaojingxuan.com/2016/11/24/d6d3a520-b183-4867-8746-5b6aba6c1724.png@!640_360", + "http://img4.jiecaojingxuan.com/2016/11/26/caa3dade-5744-486d-a1b7-9780aebb9eb5.jpg@!640_360", + "http://img4.jiecaojingxuan.com/2016/11/24/2c3e62bb-6a32-4fb0-a1d5-d1260ad436a4.png@!640_360" + } + }; - public static String[] videoTitles = { - "嫂子出来", - "嫂子溢出", - "嫂子我姓王", - "嫂子趴好了", - "嫂子很渴", - "嫂子这样不好", - "嫂子别笑", - "嫂子坐火车", - "嫂子打游戏", - "嫂子稳当的"}; + public static String[][] videoTitles = + { + { + "嫂子出来", + "嫂子溢出", + "嫂子我姓王", + "嫂子趴好了", + "嫂子很渴", + "嫂子这样不好", + "嫂子别笑", + "嫂子坐火车", + "嫂子打游戏", + "嫂子还小" + }, + { + "嫂子堵车了", + "嫂子喝点", + "嫂子快走", + "嫂子别这样" + }, + { + "嫂子想偷", + "嫂子害羞了", + "嫂子淡定", + "嫂子好喜欢" + } + }; } diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/VideoListAdapter.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/VideoListAdapter.java index 858377524..e7ae77b74 100755 --- a/app/src/main/java/fm/jiecao/jiecaovideoplayer/VideoListAdapter.java +++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/VideoListAdapter.java @@ -22,14 +22,20 @@ public class VideoListAdapter extends BaseAdapter { int[] videoIndexs = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; Context context; + int pager = -1; public VideoListAdapter(Context context) { this.context = context; } + public VideoListAdapter(Context context, int pager) { + this.context = context; + this.pager = pager; + } + @Override public int getCount() { - return videoIndexs.length; + return pager == -1 ? videoIndexs.length : 4; } @Override @@ -44,7 +50,6 @@ public long getItemId(int position) { @Override public View getView(int position, View convertView, ViewGroup parent) { - Log.e(TAG, "why you always getview"); ViewHolder viewHolder; if (null == convertView) { @@ -56,14 +61,23 @@ public View getView(int position, View convertView, ViewGroup parent) { } else { viewHolder = (ViewHolder) convertView.getTag(); } + if (pager == -1) { + viewHolder.jcVideoPlayer.setUp( + VideoConstant.videoUrls[0][position], JCVideoPlayer.SCREEN_LAYOUT_LIST, + VideoConstant.videoTitles[0][position]); - viewHolder.jcVideoPlayer.setUp( - VideoConstant.videoUrls[position], JCVideoPlayer.SCREEN_LAYOUT_LIST, - VideoConstant.videoTitles[position]); + Picasso.with(convertView.getContext()) + .load(VideoConstant.videoThumbs[0][position]) + .into(viewHolder.jcVideoPlayer.thumbImageView); + } else { + viewHolder.jcVideoPlayer.setUp( + VideoConstant.videoUrls[pager][position], JCVideoPlayer.SCREEN_LAYOUT_LIST, + VideoConstant.videoTitles[pager][position]); - Picasso.with(convertView.getContext()) - .load(VideoConstant.videoThumbs[position]) - .into(viewHolder.jcVideoPlayer.thumbImageView); + Picasso.with(convertView.getContext()) + .load(VideoConstant.videoThumbs[pager][position]) + .into(viewHolder.jcVideoPlayer.thumbImageView); + } return convertView; } diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/WebViewActivity.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/WebViewActivity.java index 6346dec0c..316ccda10 100644 --- a/app/src/main/java/fm/jiecao/jiecaovideoplayer/WebViewActivity.java +++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/WebViewActivity.java @@ -40,23 +40,40 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { public class JCCallBack { @JavascriptInterface - public void adViewJieCaoVideoPlayer(final int width, final int height, final int top, final int left) { + public void adViewJieCaoVideoPlayer(final int width, final int height, final int top, final int left, final int index) { runOnUiThread(new Runnable() { @Override public void run() { - JCVideoPlayerStandard webVieo = new JCVideoPlayerStandard(WebViewActivity.this); - webVieo.setUp("http://video.jiecao.fm/8/17/%E6%8A%AB%E8%90%A8.mp4", - JCVideoPlayer.SCREEN_LAYOUT_LIST, "嫂子好困"); - Picasso.with(WebViewActivity.this) - .load("http://img4.jiecaojingxuan.com/2016/8/17/f2dbd12e-b1cb-4daf-aff1-8c6be2f64d1a.jpg") - .into(webVieo.thumbImageView); - ViewGroup.LayoutParams ll = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - AbsoluteLayout.LayoutParams layoutParams = new AbsoluteLayout.LayoutParams(ll); - layoutParams.y = JCUtils.dip2px(WebViewActivity.this, top); - layoutParams.x = JCUtils.dip2px(WebViewActivity.this, left); - layoutParams.height = JCUtils.dip2px(WebViewActivity.this, height); - layoutParams.width = JCUtils.dip2px(WebViewActivity.this, width); - mWebView.addView(webVieo, layoutParams); + if (index == 0) { + JCVideoPlayerStandard webVieo = new JCVideoPlayerStandard(WebViewActivity.this); + webVieo.setUp("http://video.jiecao.fm/11/16/c/68Tlrc9zNi3JomXpd-nUog__.mp4", + JCVideoPlayer.SCREEN_LAYOUT_LIST, "嫂子骑大马"); + Picasso.with(WebViewActivity.this) + .load("http://img4.jiecaojingxuan.com/2016/11/16/1d935cc5-a1e7-4779-bdfa-20fd7a60724c.jpg@!640_360") + .into(webVieo.thumbImageView); + ViewGroup.LayoutParams ll = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + AbsoluteLayout.LayoutParams layoutParams = new AbsoluteLayout.LayoutParams(ll); + layoutParams.y = JCUtils.dip2px(WebViewActivity.this, top); + layoutParams.x = JCUtils.dip2px(WebViewActivity.this, left); + layoutParams.height = JCUtils.dip2px(WebViewActivity.this, height); + layoutParams.width = JCUtils.dip2px(WebViewActivity.this, width); + mWebView.addView(webVieo, layoutParams); + } else { + JCVideoPlayerStandard webVieo = new JCVideoPlayerStandard(WebViewActivity.this); + webVieo.setUp("http://video.jiecao.fm/11/14/xin/%E5%90%B8%E6%AF%92.mp4", + JCVideoPlayer.SCREEN_LAYOUT_LIST, "嫂子失态了"); + Picasso.with(WebViewActivity.this) + .load("http://img4.jiecaojingxuan.com/2016/11/14/a019ffc1-556c-4a85-b70c-b1b49811d577.jpg@!640_360") + .into(webVieo.thumbImageView); + ViewGroup.LayoutParams ll = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + AbsoluteLayout.LayoutParams layoutParams = new AbsoluteLayout.LayoutParams(ll); + layoutParams.y = JCUtils.dip2px(WebViewActivity.this, top); + layoutParams.x = JCUtils.dip2px(WebViewActivity.this, left); + layoutParams.height = JCUtils.dip2px(WebViewActivity.this, height); + layoutParams.width = JCUtils.dip2px(WebViewActivity.this, width); + mWebView.addView(webVieo, layoutParams); + } + } }); diff --git a/app/src/main/res/layout/activity_loadimage.xml b/app/src/main/res/layout/activity_loadimage.xml index 197c2912a..0021b239f 100755 --- a/app/src/main/res/layout/activity_loadimage.xml +++ b/app/src/main/res/layout/activity_loadimage.xml @@ -22,64 +22,22 @@ android:layout_marginTop="3dp" android:text="ImageLoader" /> - - - - - - - - - - - - + android:layout_height="200dp" /> - - + android:text="Remove Annotation Will See Fresco" /> - - - + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 2226afd5a..8028d3583 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -52,7 +52,8 @@ android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_marginTop="8dp" - android:text="Auto tiny window" /> + android:text="Auto tiny window" + android:visibility="gone" />