1145873331@qq.com vor 6 Jahren
Ursprung
Commit
91aec04826

+ 4 - 17
app/src/main/java/com/electric/chargingpile/activity/VideoDetaislActivity.java

@ -48,6 +48,7 @@ public class VideoDetaislActivity extends Activity implements View.OnClickListen
48 48
49 49
        pager_video = findViewById(R.id.pager_video);
50 50
51
51 52
        viewPagerAdapter = new SvVideoPagerAdapter(this, new SvVideoShowView.OnDeleteVideoListener() {
52 53
            @Override
53 54
            public void onDelete() {
@ -129,7 +130,6 @@ public class VideoDetaislActivity extends Activity implements View.OnClickListen
129 130
                        }
130 131
                    }
131 132
132
133 133
                    videoShowView.updateView();
134 134
                    videoShowView.initAndPlay();
135 135
                }
@ -138,21 +138,6 @@ public class VideoDetaislActivity extends Activity implements View.OnClickListen
138 138
        }
139 139
    }
140 140
141
    int i = 0;
142
    SvVideoShowView.ReqonseCallback reqonseCallback = new SvVideoShowView.ReqonseCallback() {
143
        @Override
144
        public void onsuccess() {
145
            Toast.makeText(VideoDetaislActivity.this, "i: " + (i += 1), Toast.LENGTH_SHORT).show();
146
147
            videoShowView.initAndPlay();
148
        }
149
150
        @Override
151
        public void failed() {
152
153
        }
154
    };
155
156 141
    @Override
157 142
    protected void onResume() {
158 143
        if (videoShowView != null) {
@ -180,7 +165,9 @@ public class VideoDetaislActivity extends Activity implements View.OnClickListen
180 165
181 166
    @Override
182 167
    public void finish() {
183
        viewPagerAdapter.onDestory();
168
        if (videoShowView != null) {
169
            videoShowView.onDestroy();
170
        }
184 171
        super.finish();
185 172
    }
186 173

+ 0 - 2
app/src/main/java/com/electric/chargingpile/data/TalkRecommendBean.java

@ -37,7 +37,5 @@ public class TalkRecommendBean implements Serializable {
37 37
    public int commentNums;
38 38
    public int isTop;
39 39
    public int likeFlg;
40
    public boolean isLoaded = false;
41
42 40
43 41
}

+ 79 - 32
app/src/main/java/com/electric/chargingpile/fragment/SvVideoShowView.java

@ -1,16 +1,21 @@
1 1
package com.electric.chargingpile.fragment;
2 2
3 3
import android.app.Activity;
4
import android.support.v4.view.PagerAdapter;
5
import android.support.v4.view.ViewPager;
4 6
import android.text.TextUtils;
5 7
import android.util.Log;
6 8
import android.view.LayoutInflater;
7 9
import android.view.View;
8 10
import android.view.ViewGroup;
11
import android.view.ViewGroup.LayoutParams;
9 12
import android.widget.ImageView;
10 13
import android.widget.LinearLayout;
11 14
import android.widget.TextView;
12 15
import android.widget.Toast;
13 16
17
import com.bumptech.glide.Glide;
18
import com.bumptech.glide.request.RequestOptions;
14 19
import com.electric.chargingpile.R;
15 20
import com.electric.chargingpile.application.MainApplication;
16 21
import com.electric.chargingpile.data.TalkRecommendBean;
@ -20,10 +25,13 @@ import com.electric.chargingpile.util.ToastUtil;
20 25
import com.electric.chargingpile.view.UpVideoView2;
21 26
import com.electric.chargingpile.view.VideoCommentDialog;
22 27
import com.electric.chargingpile.view.VideoPubilshDialog;
28
import com.electric.chargingpile.widge.photoview.PhotoView;
29
import com.electric.chargingpile.widge.photoview.ZoomingViewpager;
23 30
import com.squareup.picasso.Picasso;
24 31
import com.zhy.http.okhttp.OkHttpUtils;
25 32
import com.zhy.http.okhttp.callback.StringCallback;
26 33
34
import java.util.ArrayList;
27 35
import java.util.HashMap;
28 36
import java.util.List;
29 37
import java.util.Map;
@ -43,7 +51,7 @@ public class SvVideoShowView implements View.OnClickListener {
43 51
    private LinearLayout sv_show_forward, sv_show_comment_count_ll, sv_show_like_ll,
44 52
            sv_show_comment_ll;
45 53
    private TextView sv_show_comment_count_tv, sv_show_like_tv, sv_show_tvcon,
46
            sv_show_user_name, sv_show_user_time, sv_show_topic_con;
54
            sv_show_user_name, sv_show_user_time, sv_show_topic_con, vd_title_tv;
47 55
    private ImageView sv_show_like_img, sv_show_user_avatar;
48 56
49 57
    private View sv_show_tvcon_more;
@ -73,12 +81,9 @@ public class SvVideoShowView implements View.OnClickListener {
73 81
        viewGroup.addView(view);
74 82
    }
75 83
76
    public void getDate(){
77
        if (talkRecommendBean.isLoaded) {
78
            setData();
79
        } else {
80
            requestHeaderData(talkRecommendBean.targetType, talkRecommendBean.targetId);
81
        }
84
    public void getDate() {
85
        setData();
86
//            requestHeaderData(talkRecommendBean.targetType, talkRecommendBean.targetId);
82 87
    }
83 88
84 89
@ -103,9 +108,7 @@ public class SvVideoShowView implements View.OnClickListener {
103 108
                    @Override
104 109
                    public void onError(Call call, Exception e) {
105 110
                        ToastUtil.showToast(activity, "加载失败,请重试", Toast.LENGTH_SHORT);
106
                        if (reqonseCallback != null) {
107
                            reqonseCallback.failed();
108
                        }
111
109 112
                    }
110 113
111 114
                    @Override
@ -118,7 +121,6 @@ public class SvVideoShowView implements View.OnClickListener {
118 121
                            if (qadata != null && qadata.size() > 0) {
119 122
                                talkRecommendBean = qadata.get(0);
120 123
                            }
121
                            talkRecommendBean.isLoaded = true;
122 124
                            setData();
123 125
                        }
124 126
                    }
@ -149,11 +151,11 @@ public class SvVideoShowView implements View.OnClickListener {
149 151
                    .into(sv_show_user_avatar);
150 152
        }
151 153
152
        if (talkRecommendBean.targetType == 23) {
153
           initAndPlay();
154
        } else if (talkRecommendBean.targetType == 24) {
155
156
        }
154
//        if (talkRecommendBean.targetType == 23) {
155
//            initAndPlay();
156
//        } else if (talkRecommendBean.targetType == 24) {
157
//
158
//        }
157 159
158 160
        if (talkRecommendBean.likeFlg == 1) {
159 161
//            sv_show_like_img  like
@ -235,7 +237,68 @@ public class SvVideoShowView implements View.OnClickListener {
235 237
        upVideoView2 = view.findViewById(R.id.view_show_video);
236 238
    }
237 239
240
    ZoomingViewpager zoomingViewpager;
241
    ImageAdapter imageAdapter = new ImageAdapter();
242
    List<String> picList = new ArrayList<>();
243
238 244
    private void initZoomPhoto(View view) {
245
        if (picList.size() == 0) {
246
            picList.add("https://r1.ykimg.com/050E0000534CA44167379F055B0BB00E");
247
            picList.add("https://r1.ykimg.com/050E00005C877F89ADA7B2E385018E98");
248
            picList.add("https://r1.ykimg.com/050E00005C9200D5859B5D5E9C0A6520");
249
        }
250
        vd_title_tv = view.findViewById(R.id.vd_title_tv);
251
        vd_title_tv.setText("0/" + picList.size());
252
253
        zoomingViewpager = view.findViewById(R.id.view_show_zoomingphoto);
254
        zoomingViewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
255
            @Override
256
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
257
258
            }
259
260
            @Override
261
            public void onPageSelected(int position) {
262
                vd_title_tv.setText(position + "/" + picList.size());
263
            }
264
265
            @Override
266
            public void onPageScrollStateChanged(int state) {
267
268
            }
269
        });
270
        zoomingViewpager.setAdapter(imageAdapter);
271
272
    }
273
274
    class ImageAdapter extends PagerAdapter {
275
276
        @Override
277
        public int getCount() {
278
            return picList != null ? picList.size() : 0;
279
        }
280
281
        @Override
282
        public boolean isViewFromObject(View view, Object object) {
283
            return view == object;
284
        }
285
286
        @Override
287
        public Object instantiateItem(ViewGroup container, int position) {
288
            PhotoView photoView = new PhotoView(container.getContext());
289
            Glide
290
                    .with(activity)
291
                    .load(picList.get(position))
292
                    .apply(new RequestOptions().fitCenter())
293
                    .into(photoView);            // Now just add PhotoView to ViewPager and return it
294
            container.addView(photoView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
295
            return photoView;
296
        }
297
298
        @Override
299
        public void destroyItem(ViewGroup container, int position, Object object) {
300
            container.removeView((View) object);
301
        }
239 302
240 303
    }
241 304
@ -252,7 +315,6 @@ public class SvVideoShowView implements View.OnClickListener {
252 315
    public void initAndPlay() {
253 316
        if (upVideoView2 != null && !TextUtils.isEmpty(talkRecommendBean.videoUrl)) {
254 317
            String videoUrl = talkRecommendBean.videoUrl;
255
            videoUrl = "http://uprocess.b0.upaiyun.com/demo/short_video/UPYUN_0.flv";
256 318
            Log.d("SvVideoShowView", "play");
257 319
            upVideoView2.setVideoPath(videoUrl);
258 320
            upVideoView2.start();
@ -322,21 +384,6 @@ public class SvVideoShowView implements View.OnClickListener {
322 384
        }
323 385
    }
324 386
325
    ReqonseCallback reqonseCallback;
326
327
    public void setReqonseCallback(ReqonseCallback reqonseCallback) {
328
        this.reqonseCallback = reqonseCallback;
329
    }
330
331
    public ReqonseCallback getReqonseCallback() {
332
        return reqonseCallback;
333
    }
334
335
    public interface ReqonseCallback {
336
        void onsuccess();
337
338
        void failed();
339
    }
340 387
341 388
    public interface OnDeleteVideoListener {
342 389
        void onDelete();

+ 0 - 7
app/src/main/res/layout/activity_videodetails.xml

@ -16,13 +16,6 @@
16 16
        android:layout_height="48dp">
17 17
18 18
19
        <TextView
20
            android:id="@+id/vd_title_tv"
21
            android:layout_width="wrap_content"
22
            android:layout_height="wrap_content"
23
            android:layout_centerInParent="true"
24
            android:textColor="#ffffff"
25
            android:textSize="18sp" />
26 19
27 20
28 21
        <ImageView

+ 10 - 0
app/src/main/res/layout/view_show_zoom.xml

@ -9,6 +9,16 @@
9 9
        android:layout_width="match_parent"
10 10
        android:layout_height="match_parent" />
11 11
12
13
    <TextView
14
        android:id="@+id/vd_title_tv"
15
        android:layout_width="wrap_content"
16
        android:layout_height="48dp"
17
        android:gravity="center_vertical"
18
        android:layout_centerHorizontal="true"
19
        android:textColor="#ffffff"
20
        android:textSize="18sp" />
21
12 22
    <include layout="@layout/view_show_bottom" />
13 23
14 24
</RelativeLayout>