Ver código fonte

修复邀请赚钱中好友列表刷新挂掉的bug;
视频编辑页面添加视频帧列表并显示,且可以拖动定位进度与要剪切的长度

zengjiebin 7 anos atrás
pai
commit
0ce57d7f6f

+ 9 - 0
app/src/main/java/com/kfzs/duanduan/utils/NumberFormatUtils.java

@@ -92,6 +92,15 @@ public class NumberFormatUtils {
     }
 
     /**
+     * 最多保留一位小数
+     * @param bonus
+     * @return
+     */
+    public static String retainMost1(double bonus) {
+        DecimalFormat df = new DecimalFormat("#.#");
+        return df.format(bonus);
+    }
+    /**
      * 最多保留两位小数
      * @param bonus
      * @return

+ 13 - 0
app/src/main/java/com/sheep/gamegroup/model/entity/Lp.java

@@ -80,4 +80,17 @@ public class Lp {
         this.height = (int) (height * per);
         return this;
     }
+
+    public Lp addLeftMargin(float mx) {
+        int addMargin = (int) (per * mx);
+        switch (leftMargin) {
+            case NONE:
+                leftMargin = addMargin;
+                break;
+            default:
+                leftMargin += addMargin;
+                break;
+        }
+        return this;
+    }
 }

+ 5 - 2
app/src/main/java/com/sheep/gamegroup/util/Jump2View.java

@@ -2263,9 +2263,12 @@ public class Jump2View {
      *
      * @param url 播放地址
      */
-    public void goActEditVideo(String url) {
+    public void goActEditVideo(String url, long duration) {
         Activity activity = ActivityManager.getInstance().currentActivity();
-        activity.startActivity(DataUtil.putObject(new Intent(activity, ActEditVideo.class), url));
+        Intent intent = new Intent(activity, ActEditVideo.class);
+        DataUtil.putObject(intent, url);
+        DataUtil.putObject(intent, duration);
+        activity.startActivity(intent);
     }
 
     /**

+ 84 - 16
app/src/main/java/com/sheep/gamegroup/util/MediaMetadataRetrieverUtil.java

@@ -3,8 +3,17 @@ package com.sheep.gamegroup.util;
 import android.content.Context;
 import android.graphics.Bitmap;
 import android.media.MediaMetadataRetriever;
+import android.support.annotation.NonNull;
+import android.support.v7.widget.GridLayoutManager;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.View;
+import android.widget.ImageView;
 
+import com.chad.library.adapter.base.BaseQuickAdapter;
+import com.chad.library.adapter.base.BaseViewHolder;
 import com.sheep.gamegroup.absBase.AbsObserver;
+import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 
 import java.io.File;
@@ -29,31 +38,90 @@ import io.reactivex.schedulers.Schedulers;
  */
 public class MediaMetadataRetrieverUtil {
     private static final String TAG = "MediaMetadataRetrieverUtil";
+    //要操作的本地视频文件
+    private String fromFile;
+    //输出路径
+    private String outDir = SheepApp.getInstance().getDir("frame", Context.MODE_PRIVATE).getAbsolutePath();
+    //视频文件的总时长,单位毫秒
+    private long duration;
+    //要截取的图片个数
+    private int size = 10;
 
-    public static String getFilePath(String fromFile, String outDir, int index) {
-        return String.format(Locale.CHINA, "%s%s%s_frame_%d.png", outDir, File.separator, FileUtil.getFileNameNoExFromPath(fromFile), index);
+    public MediaMetadataRetrieverUtil(String fromFile, long duration) {
+        this.fromFile = fromFile;
+        this.duration = duration;
+    }
+
+    public String getFromFile() {
+        return fromFile;
+    }
+
+    public void setFromFile(String fromFile) {
+        this.fromFile = fromFile;
+    }
+
+    public String getOutDir() {
+        return outDir;
     }
 
+    public void setOutDir(String outDir) {
+        this.outDir = outDir;
+    }
+
+    public long getDuration() {
+        return duration;
+    }
+
+    public void setDuration(long duration) {
+        this.duration = duration;
+    }
+
+    public int getSize() {
+        return size;
+    }
+
+    public void setSize(int size) {
+        this.size = size;
+    }
 
     /**
      * 取出视频文件中的图片帧列表
-     *
-     * @param fromFile 要操作的本地视频文件
-     * @param duration 单位毫秒
-     * @param size     需要的图片个数
-     * @return
      */
-    public static void tryGetFrameFileList(final String fromFile, final long duration, final int size, AbsObserver<List<String>> absObserver) {
+    public void initRv(final RecyclerView recyclerView) {
         Observable.create(new ObservableOnSubscribe<List<String>>() {
-                    @Override
-                    public void subscribe(ObservableEmitter<List<String>> emitter) throws Exception {
-                        emitter.onNext(getFrameFileList(fromFile, SheepApp.getInstance().getDir("frame", Context.MODE_PRIVATE).getAbsolutePath(), duration, size));
-                    }
-                })
+            @Override
+            public void subscribe(ObservableEmitter<List<String>> emitter) throws Exception {
+                emitter.onNext(getFrameFileList(fromFile, outDir, duration, size));
+            }
+        })
                 .subscribeOn(Schedulers.io())
                 .observeOn(AndroidSchedulers.mainThread())
-                .subscribe(absObserver);
+                .subscribe(new AbsObserver<List<String>>() {
+                    @Override
+                    public void onNext(final List<String> strings) {
+                        recyclerView.setLayoutManager(new GridLayoutManager(SheepApp.getInstance(), size));
+                        BaseQuickAdapter<String, BaseViewHolder> baseQuickAdapter = new BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_iv_mh, strings) {
+                            @Override
+                            protected void convert(BaseViewHolder helper, String item) {
+                                ImageView imageView = helper.getView(R.id.item_iv);
+                                ViewUtil.setImagePath(imageView, item);
+                            }
+                        };
+                        recyclerView.setAdapter(baseQuickAdapter);
+                        baseQuickAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
+                            @Override
+                            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
+                                Jump2View.getInstance().showImgList(ActivityManager.getInstance().currentActivity(), position, (ArrayList<String>) strings);
+                            }
+                        });
+                    }
+                });
+
+    }
 
+
+    public static String getFilePath(String fromFile, String outDir, int index) {
+        return String.format(Locale.CHINA, "%s%s%s_frame_%d.png", outDir, File.separator, FileUtil.getFileNameNoExFromPath(fromFile), index);
     }
 
     /**
@@ -61,7 +129,7 @@ public class MediaMetadataRetrieverUtil {
      *
      * @param fromFile 要操作的本地视频文件
      * @param outDir   输出路径
-     * @param duration 单位毫秒
+     * @param duration 视频文件的总时长,单位毫秒
      * @param size     需要的图片个数
      * @return
      */
@@ -80,7 +148,7 @@ public class MediaMetadataRetrieverUtil {
             long atTime = i + 1 == size ? (duration * 1000L) : i * per;
             Bitmap bitmap = metadataRetriever.getFrameAtTime(atTime, MediaMetadataRetriever.OPTION_CLOSEST);
 
-            String path = getFilePath(outDir, fromFile, i);
+            String path = getFilePath(fromFile, outDir, i);
             FileOutputStream fileOutputStream = null;
             try {
                 fileOutputStream = new FileOutputStream(path);

+ 19 - 0
app/src/main/java/com/sheep/gamegroup/view/activity/ActEditVideo.java

@@ -16,6 +16,7 @@ import android.view.WindowManager;
 import android.widget.TextView;
 import android.widget.VideoView;
 
+import com.kfzs.duanduan.utils.NumberFormatUtils;
 import com.kfzs.duanduan.utils.StatusBarUtils;
 import com.sheep.gamegroup.absBase.BaseContainerActivity;
 import com.sheep.gamegroup.model.entity.DiscoveryTopic;
@@ -23,12 +24,15 @@ import com.sheep.gamegroup.util.ActionUtil;
 import com.sheep.gamegroup.util.DataUtil;
 import com.sheep.gamegroup.util.KeyEventUtil;
 import com.sheep.gamegroup.util.LogUtil;
+import com.sheep.gamegroup.util.TestUtil;
 import com.sheep.gamegroup.util.ViewUtil;
+import com.sheep.gamegroup.view.customview.VideoFramesView;
 import com.sheep.gamegroup.view.fragment.FgtDiscoveryTopic;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.utils.G;
 
 import butterknife.BindView;
+import rx.functions.Action1;
 
 /**
  * Created by realicing on 2018/11/9.
@@ -47,6 +51,10 @@ public class ActEditVideo extends BaseContainerActivity implements MediaPlayer.O
     VideoView videoView;
     @BindView(R.id.video_loading)
     View video_loading;
+    @BindView(R.id.videoFramesView)
+    VideoFramesView videoFramesView;
+    @BindView(R.id.edit_video_time_tv)
+    TextView edit_video_time_tv;
 
     @Override
     protected int getLayoutId() {
@@ -58,6 +66,7 @@ public class ActEditVideo extends BaseContainerActivity implements MediaPlayer.O
         super.initView();
         initVolume();
         String url = DataUtil.getObject(getIntent(), String.class);
+        final long duration = DataUtil.getObject(getIntent(), Long.class);
         Uri uri = Uri.parse(url);
         videoView.setOnInfoListener(this);
         videoView.setOnPreparedListener(this);
@@ -66,6 +75,16 @@ public class ActEditVideo extends BaseContainerActivity implements MediaPlayer.O
         videoView.addOnLayoutChangeListener(this);
 //        videoView.setMediaController(new MediaController(this));
         videoView.setVideoURI(uri);
+        videoFramesView.initVideo(url, duration).showVideoList().setOnTimeChangeListener(new Action1<Float>() {
+            @Override
+            public void call(Float percent) {
+                ViewUtil.setText(edit_video_time_tv, R.string.has_choose_x_second, NumberFormatUtils.retainMost1(duration * percent / 1000));
+                if(TestUtil.isDev()) {
+                    edit_video_time_tv.append("\t");
+                    edit_video_time_tv.append(videoFramesView.getLineInfo());
+                }
+            }
+        });
     }
 
     @Override

+ 3 - 2
app/src/main/java/com/sheep/gamegroup/view/activity/ActPublishArticle.java

@@ -104,7 +104,8 @@ public class ActPublishArticle extends BaseActivity {
                     helper.itemView.setOnClickListener(new View.OnClickListener() {
                         @Override
                         public void onClick(View view) {
-                            Jump2View.getInstance().goActEditVideo(item);
+                            if(imageCropBean != null)
+                                Jump2View.getInstance().goActEditVideo(imageCropBean.getOriginalPath(), imageCropBean.getDuration());
                         }
                     });
                 }
@@ -144,7 +145,7 @@ public class ActPublishArticle extends BaseActivity {
                         inputAndUrlList.getList().add(imageRadioResultEvent.getResult().getOriginalPath());
                         ViewUtil.notifyDataSetChanged(recyclerView);
                         imageCropBean = imageRadioResultEvent.getResult();
-                        Jump2View.getInstance().goActEditVideo(imageCropBean.getOriginalPath());
+                        Jump2View.getInstance().goActEditVideo(imageCropBean.getOriginalPath(), imageCropBean.getDuration());
                     }
                 })
                 .open();

+ 210 - 0
app/src/main/java/com/sheep/gamegroup/view/customview/VideoFramesView.java

@@ -0,0 +1,210 @@
+package com.sheep.gamegroup.view.customview;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.support.v7.widget.RecyclerView;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.MotionEvent;
+import android.view.View;
+import android.widget.RelativeLayout;
+
+import com.sheep.gamegroup.util.LogUtil;
+import com.sheep.gamegroup.util.MediaMetadataRetrieverUtil;
+import com.sheep.jiuyan.samllsheep.R;
+
+import java.io.File;
+import java.util.Locale;
+
+import rx.functions.Action1;
+
+
+/**
+ * Created by realicing on 2018/11/29.
+ * realicing@sina.com
+ * 显示本地视频文件对应的视频帧
+ */
+public class VideoFramesView extends RelativeLayout {
+    public VideoFramesView(Context context) {
+        super(context);
+        initView();
+    }
+
+    public VideoFramesView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        initView();
+    }
+
+    public VideoFramesView(Context context, AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+        initView();
+    }
+
+    private RecyclerView recyclerView;
+    private View line_start;
+    private View line_end;
+
+    private void initView() {
+        LayoutInflater.from(getContext()).inflate(R.layout.custom_video_frames_view, this, true);
+        recyclerView = findViewById(R.id.recyclerView);
+        line_start = findViewById(R.id.line_start);
+        line_end = findViewById(R.id.line_end);
+        line_start.setOnTouchListener(new OnTouchListener() {
+            private float lastEventX;
+
+            @SuppressLint("ClickableViewAccessibility")
+            @Override
+            public boolean onTouch(View view, MotionEvent event) {
+                float maxX = line_end.getX();
+                switch (event.getAction()) {
+                    case MotionEvent.ACTION_DOWN:
+                        lastEventX = event.getX();
+                        break;
+                    case MotionEvent.ACTION_MOVE:
+                        float mx = view.getX() + event.getX() - lastEventX;
+                        if (mx < firstStartX)
+                            mx = firstStartX;
+                        if (mx > maxX)
+                            mx = maxX;
+                        view.setX(mx);
+                        if (onTimeChangeListener != null) {
+                            onTimeChangeListener.call((maxX - mx) / (rvW - lineW));
+                        }
+                        break;
+                    case MotionEvent.ACTION_UP:
+                        break;
+                    case MotionEvent.ACTION_CANCEL:
+                        break;
+                }
+                view.invalidate();
+                return true;
+            }
+        });
+        line_end.setOnTouchListener(new OnTouchListener() {
+            private float lastEventX;
+
+            @SuppressLint("ClickableViewAccessibility")
+            @Override
+            public boolean onTouch(View view, MotionEvent event) {
+                float minX = line_start.getX();
+                switch (event.getAction()) {
+                    case MotionEvent.ACTION_DOWN:
+                        lastEventX = event.getX();
+                        break;
+                    case MotionEvent.ACTION_MOVE:
+                        float mx = view.getX() + event.getX() - lastEventX;
+                        if (mx < minX)
+                            mx = minX;
+                        if (mx > firstEndX)
+                            mx = firstEndX;
+                        view.setX(mx);
+                        if (onTimeChangeListener != null) {
+                            onTimeChangeListener.call((mx - minX) / (rvW - lineW));
+                        }
+                        break;
+                    case MotionEvent.ACTION_UP:
+                        break;
+                    case MotionEvent.ACTION_CANCEL:
+                        break;
+                }
+                view.invalidate();
+                return true;
+            }
+        });
+    }
+
+    //开头线的进度
+    public float getStartPercent() {
+        if (line_start != null && recyclerView != null) {
+            return (line_start.getX() - firstStartX) / (rvW - lineW);
+        }
+        return 0;
+    }
+
+    private float firstStartX;//初始时开头的x位置
+    private float firstEndX;//初始时结尾的x位置
+    private int lineW;//开头与结尾线的宽度
+    private int rvW;//图片列表的长度,减去lineW后==总进度的长度
+
+    //结尾线的进度
+    public float getEndPercent() {
+        if (line_end != null && recyclerView != null) {
+            return 1.0f - ((firstEndX - line_end.getX()) / (rvW - lineW));
+        }
+        return 0;
+    }
+
+    //总的进度
+    public float getPercent() {
+        if (line_end != null && recyclerView != null) {
+            return (line_end.getX() - line_start.getX()) / (rvW - lineW);
+        }
+        return 0;
+    }
+
+    public String getLineInfo() {
+        return String.format(Locale.CHINA, "firstStartX = %f, firstEndX = %f, startX = %f, endX = %f, lineW = %d, rvW = %d, startPercent = %f, endPercent = %f, percent = %f", firstStartX, firstEndX, line_start.getX(), line_end.getX(), line_end.getWidth(), recyclerView.getWidth(), getStartPercent(), getEndPercent(), getPercent());
+    }
+
+    private MediaMetadataRetrieverUtil mediaMetadataRetrieverUtil;
+
+    public MediaMetadataRetrieverUtil getMediaMetadataRetrieverUtil() {
+        return mediaMetadataRetrieverUtil;
+    }
+
+    /**
+     * 显示视频帧图片列表
+     *
+     * @param videoPath 视频文件路径
+     * @param duration  视频文件时长
+     * @return
+     */
+    public VideoFramesView initVideo(String videoPath, long duration) {
+        if (videoPath == null) {
+            LogUtil.println(VideoFramesView.class.getSimpleName(), "showList", "error", "videoPath is null");
+            return this;
+        }
+        File videoFile = new File(videoPath);
+        if (!videoFile.exists()) {
+            LogUtil.println(VideoFramesView.class.getSimpleName(), "showList", "error", "videoFile not exists");
+            return this;
+        }
+        if (!videoFile.canRead()) {
+            LogUtil.println(VideoFramesView.class.getSimpleName(), "showList", "error", "videoFile cant read");
+            return this;
+        }
+        if (duration < 1) {
+            LogUtil.println(VideoFramesView.class.getSimpleName(), "showList", "error", "duration < 1");
+            return this;
+        }
+        if (mediaMetadataRetrieverUtil == null) {
+            mediaMetadataRetrieverUtil = new MediaMetadataRetrieverUtil(videoPath, duration);
+        }
+        return this;
+    }
+
+    /**
+     * 显示视频帧图片列表
+     */
+    public VideoFramesView showVideoList() {
+        if (mediaMetadataRetrieverUtil != null)
+            mediaMetadataRetrieverUtil.initRv(recyclerView);
+        return this;
+    }
+
+    private Action1<Float> onTimeChangeListener;
+
+    public void setOnTimeChangeListener(Action1<Float> action1) {
+        onTimeChangeListener = action1;
+        postDelayed(new Runnable() {
+            @Override
+            public void run() {
+                firstStartX = line_start.getX();
+                firstEndX = line_end.getX();
+                lineW = line_start.getWidth();
+                rvW = recyclerView.getWidth();
+                onTimeChangeListener.call(1.0f);
+            }
+        }, 100);
+    }
+}

+ 26 - 5
app/src/main/res/layout/act_edit_video.xml

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="utf-8"?>
 <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    xmlns:tools="http://schemas.android.com/tools"
     android:background="#000000"
     tools:context="com.sheep.gamegroup.view.activity.ActEditVideo">
 
@@ -17,7 +17,7 @@
     <View
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:background="#99000000"/>
+        android:background="#99000000" />
 
     <com.github.ybq.android.spinkit.SpinKitView
         android:id="@+id/video_loading"
@@ -35,8 +35,8 @@
         android:layout_width="?attr/actionBarSize"
         android:layout_height="?attr/actionBarSize"
         android:layout_marginTop="20dp"
-        android:scaleType="centerInside"
         android:onClick="onClickBackImg"
+        android:scaleType="centerInside"
         android:src="@drawable/narrow_back_white"
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toTopOf="parent" />
@@ -48,10 +48,10 @@
         android:background="@drawable/shape_white_20_solid_rectangle_15"
         android:gravity="center|start"
         android:maxLength="100"
+        android:onClick="onClickTopic"
         android:paddingStart="18dp"
         android:paddingEnd="18dp"
         android:text="#添加话题#"
-        android:onClick="onClickTopic"
         android:textColor="#FEFFFF"
         android:textSize="13sp"
         app:layout_constraintBottom_toBottomOf="@id/video_back_iv"
@@ -67,10 +67,10 @@
         android:layout_marginEnd="16dp"
         android:background="@drawable/selector_button_full_main"
         android:gravity="center"
+        android:onClick="onClickSure"
         android:paddingTop="6dp"
         android:paddingBottom="6dp"
         android:text="下一步"
-        android:onClick="onClickSure"
         android:textColor="#FEFFFF"
         android:textSize="15sp"
         app:layout_constraintBottom_toBottomOf="@id/video_back_iv"
@@ -85,4 +85,25 @@
         android:layout_marginTop="27dp"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintTop_toBottomOf="@id/edit_video_topic_tv" />
+
+    <com.sheep.gamegroup.view.customview.VideoFramesView
+        android:id="@+id/videoFramesView"
+        android:layout_width="match_parent"
+        android:layout_height="69dp"
+        android:layout_marginStart="36dp"
+        android:layout_marginEnd="36dp"
+        android:layout_marginBottom="17dp"
+        app:layout_constraintBottom_toBottomOf="parent" />
+
+    <TextView
+        android:id="@+id/edit_video_time_tv"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="15dp"
+        android:layout_marginBottom="100dp"
+        android:text="@string/has_choose_x_second"
+        android:textColor="#ffffffff"
+        android:textSize="12sp"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintStart_toStartOf="parent" />
 </android.support.constraint.ConstraintLayout>

+ 59 - 0
app/src/main/res/layout/custom_video_frames_view.xml

@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="69dp"
+    android:layout_marginStart="36dp"
+    android:layout_marginEnd="36dp"
+    android:layout_marginBottom="17dp"
+    app:layout_constraintBottom_toBottomOf="parent">
+
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="61dp"
+        android:layout_marginTop="4dp"
+        android:layout_marginBottom="4dp"
+        android:background="#000" />
+
+    <android.support.v7.widget.RecyclerView
+        android:id="@+id/recyclerView"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_marginStart="12dp"
+        android:layout_marginTop="8dp"
+        android:layout_marginEnd="12dp"
+        android:layout_marginBottom="8dp"
+        android:orientation="horizontal"
+        app:layoutManager="android.support.v7.widget.LinearLayoutManager" />
+
+    <View
+        android:id="@+id/line_start"
+        android:layout_width="6dp"
+        android:layout_height="match_parent"
+        android:layout_alignStart="@id/recyclerView"
+        android:background="@drawable/shape_white_solid_rectangle_5" />
+
+    <View
+        android:id="@+id/line_end"
+        android:layout_width="6dp"
+        android:layout_height="match_parent"
+        android:layout_alignEnd="@id/recyclerView"
+        android:background="@drawable/shape_white_solid_rectangle_5" />
+
+    <include
+        layout="@layout/include_lll"
+        android:layout_width="5dp"
+        android:layout_height="20dp"
+        android:layout_alignParentEnd="true"
+        android:layout_centerVertical="true"
+        android:layout_marginEnd="3dp" />
+
+    <include
+        layout="@layout/include_lll"
+        android:layout_width="5dp"
+        android:layout_height="20dp"
+        android:layout_alignParentStart="true"
+        android:layout_centerVertical="true"
+        android:layout_marginStart="3dp" />
+
+</RelativeLayout>

+ 34 - 0
app/src/main/res/layout/include_lll.xml

@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="horizontal">
+
+    <View
+        android:layout_width="0dp"
+        android:layout_height="match_parent"
+        android:layout_weight="1"
+        android:background="#B0AFAF" />
+
+    <View
+        android:layout_width="0dp"
+        android:layout_height="match_parent"
+        android:layout_weight="1" />
+
+    <View
+        android:layout_width="0dp"
+        android:layout_height="match_parent"
+        android:layout_weight="1"
+        android:background="#B0AFAF" />
+
+    <View
+        android:layout_width="0dp"
+        android:layout_height="match_parent"
+        android:layout_weight="1" />
+
+    <View
+        android:layout_width="0dp"
+        android:layout_height="match_parent"
+        android:layout_weight="1"
+        android:background="#B0AFAF" />
+</LinearLayout>

+ 6 - 0
app/src/main/res/layout/item_iv_mh.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/item_iv"
+    android:layout_width="wrap_content"
+    android:layout_height="match_parent"
+    android:scaleType="fitXY" />

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -142,4 +142,5 @@
     <!--小绵羊3.4.5新增功能 发布发现-->
     <string name="please_say_something">说点什么~</string>
     <string name="jin_x_jin">#%s#</string>
+    <string name="has_choose_x_second">已选取 %s秒</string>
 </resources>

+ 6 - 4
view/src/main/java/com/kfzs/android/view/widget/WrapContentHeightViewPager.java

@@ -45,10 +45,12 @@ public class WrapContentHeightViewPager extends ViewPager {
             @Override
             public void onPageSelected(int position) {
                 View view = getChildAt(position);
-                int height = view.getMeasuredHeight();
-                ViewGroup.LayoutParams layoutParams = getLayoutParams();
-                layoutParams.height = height;
-                setLayoutParams(layoutParams);
+                if(view != null) {
+                    int height = view.getMeasuredHeight();
+                    ViewGroup.LayoutParams layoutParams = getLayoutParams();
+                    layoutParams.height = height;
+                    setLayoutParams(layoutParams);
+                }
             }
 
             @Override