1145873331@qq.com 6 years ago
parent
commit
5a325da74a

+ 7 - 0
app/bugly/BuglyUploadLog.txt

12
appPackage=com.electric.chargingpile
12
appPackage=com.electric.chargingpile
13
appVersion=3.2.1
13
appVersion=3.2.1
14
14
15
file=C:\Development Projects\Android_project\android_chargingpile\app\build\outputs\mapping\anzhi\debug\mapping.txt
16
sha1=e4dfdf35975c6f448fb7116476e3abc7cc92c751
17
appId=900010422
18
appChannel=anzhi
19
appPackage=com.electric.chargingpile
20
appVersion=3.2.1
21

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

6
import android.support.annotation.Nullable;
6
import android.support.annotation.Nullable;
7
import android.support.v4.view.ViewPager;
7
import android.support.v4.view.ViewPager;
8
import android.view.View;
8
import android.view.View;
9
import android.widget.Toast;
9
10
10
import com.electric.chargingpile.R;
11
import com.electric.chargingpile.R;
11
import com.electric.chargingpile.adapter.SvVideoPagerAdapter;
12
import com.electric.chargingpile.adapter.SvVideoPagerAdapter;
99
    private void addIntentInfo() {
100
    private void addIntentInfo() {
100
        position = getIntent().getIntExtra("pos", 0);
101
        position = getIntent().getIntExtra("pos", 0);
101
        talkRecommendBeans = (List<TalkRecommendBean>) getIntent().getSerializableExtra("list");
102
        talkRecommendBeans = (List<TalkRecommendBean>) getIntent().getSerializableExtra("list");
103
102
        viewPagerAdapter.notifyChanged(talkRecommendBeans);
104
        viewPagerAdapter.notifyChanged(talkRecommendBeans);
103
        pager_video.setCurrentItem(position);
105
        pager_video.setCurrentItem(position);
106
104
        viewPagerAdapter.setInitViewListener(new SvVideoPagerAdapter.InitViewListener() {
107
        viewPagerAdapter.setInitViewListener(new SvVideoPagerAdapter.InitViewListener() {
105
            @Override
108
            @Override
106
            public void initFirstViewAfter() {
109
            public void initFirstViewAfter() {
112
        });
115
        });
113
    }
116
    }
114
117
115
    private void initPlayByPostion(final List<TalkRecommendBean> videoInfos, final int position, final boolean isNeedSer) {
118
    private void initPlayByPostion(final List<TalkRecommendBean> videoInfos, final int position,
119
                                   final boolean isNeedSet) {
116
        videoShowView = viewPagerAdapter.getViewList(position % viewPagerAdapter.getList());
120
        videoShowView = viewPagerAdapter.getViewList(position % viewPagerAdapter.getList());
117
        if (videoShowView.getRootView() != null) {
118
121
122
        if (videoShowView.getRootView() != null) {
119
            mHandler.postDelayed(new Runnable() {
123
            mHandler.postDelayed(new Runnable() {
120
                @Override
124
                @Override
121
                public void run() {
125
                public void run() {
122
                    if (isNeedSer) {
126
                    if (isNeedSet) {
123
                        if (videoInfos.size() > 0 && position < videoInfos.size()) {
127
                        if (videoInfos.size() > 0 && position < videoInfos.size()) {
124
                            videoShowView.setInfo(videoInfos.get(position));
128
                            videoShowView.setInfo(videoInfos.get(position));
125
                        }
129
                        }
126
                    }
130
                    }
127
                    videoShowView.updateView(position, videoInfos.get(position));
131
132
133
                    videoShowView.updateView();
128
                    videoShowView.initAndPlay();
134
                    videoShowView.initAndPlay();
129
                }
135
                }
130
            }, 100);
136
            }, 100);
131
137
132
        }
138
        }
133
    }
139
    }
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
    @Override
157
    protected void onResume() {
158
        if (videoShowView != null) {
159
            videoShowView.onResume();
160
        }
161
        super.onResume();
162
163
    }
164
165
    @Override
166
    protected void onPause() {
167
        if (videoShowView != null) {
168
            videoShowView.onPause();
169
        }
170
        super.onPause();
171
    }
172
173
    @Override
174
    protected void onStop() {
175
        if (videoShowView != null) {
176
            videoShowView.onStop();
177
        }
178
        super.onStop();
179
    }
180
181
    @Override
182
    public void finish() {
183
        viewPagerAdapter.onDestory();
184
        super.finish();
185
    }
186
134
}
187
}

+ 6 - 4
app/src/main/java/com/electric/chargingpile/adapter/SvVideoPagerAdapter.java

16
public class SvVideoPagerAdapter extends PagerAdapter {
16
public class SvVideoPagerAdapter extends PagerAdapter {
17
    InitViewListener initViewListener;
17
    InitViewListener initViewListener;
18
    private Activity activity;
18
    private Activity activity;
19
    private boolean isPlay;
20
19
21
    private List<TalkRecommendBean> videoInfoList = new ArrayList();
20
    private List<TalkRecommendBean> videoInfoList = new ArrayList();
22
    private List<SvVideoShowView> list = new ArrayList();
21
    private List<SvVideoShowView> list = new ArrayList();
35
        list.add(v3);
34
        list.add(v3);
36
    }
35
    }
37
36
38
    public void setIsPlay(boolean play) {
39
        isPlay = play;
40
    }
41
37
42
    @Override
38
    @Override
43
    public int getCount() {
39
    public int getCount() {
97
    public interface InitViewListener {
93
    public interface InitViewListener {
98
        void initFirstViewAfter();
94
        void initFirstViewAfter();
99
    }
95
    }
96
97
    public void onDestory() {
98
        for (SvVideoShowView svVideoShowView : list) {
99
            svVideoShowView.onDestroy();
100
        }
101
    }
100
}
102
}

+ 75 - 19
app/src/main/java/com/electric/chargingpile/fragment/SvVideoShowView.java

1
package com.electric.chargingpile.fragment;
1
package com.electric.chargingpile.fragment;
2
2
3
import android.app.Activity;
3
import android.app.Activity;
4
import android.net.Uri;
5
import android.text.TextUtils;
4
import android.text.TextUtils;
6
import android.util.Log;
5
import android.util.Log;
7
import android.view.LayoutInflater;
6
import android.view.LayoutInflater;
70
            initZoomPhoto(view);
69
            initZoomPhoto(view);
71
        }
70
        }
72
        initBottom(view);
71
        initBottom(view);
72
        getDate();
73
        viewGroup.addView(view);
73
        viewGroup.addView(view);
74
    }
75
76
    public void getDate(){
74
        if (talkRecommendBean.isLoaded) {
77
        if (talkRecommendBean.isLoaded) {
75
            setData();
78
            setData();
76
        } else {
79
        } else {
77
            requestHeaderData(targetType, talkRecommendBean.targetId);
80
            requestHeaderData(talkRecommendBean.targetType, talkRecommendBean.targetId);
78
        }
81
        }
79
    }
82
    }
80
83
84
81
    private void requestHeaderData(int targetType, long targetId) {
85
    private void requestHeaderData(int targetType, long targetId) {
82
        String url = MainApplication.urlNew + "/topic/detail.do";
86
        String url = MainApplication.urlNew + "/topic/detail.do";
83
        Map<String, String> map = new HashMap<>();
87
        Map<String, String> map = new HashMap<>();
99
                    @Override
103
                    @Override
100
                    public void onError(Call call, Exception e) {
104
                    public void onError(Call call, Exception e) {
101
                        ToastUtil.showToast(activity, "加载失败,请重试", Toast.LENGTH_SHORT);
105
                        ToastUtil.showToast(activity, "加载失败,请重试", Toast.LENGTH_SHORT);
106
                        if (reqonseCallback != null) {
107
                            reqonseCallback.failed();
108
                        }
102
                    }
109
                    }
103
110
104
                    @Override
111
                    @Override
105
                    public void onResponse(String response) {
112
                    public void onResponse(String response) {
106
107
                        Log.e("SvVideoShowView", talkRecommendBean.toString());
108
109
                        Log.e("SvVideoShowView", response);
110
                        Log.e("SvVideoShowView", "-----------------------------");
111
                        String rtnCode = JsonUtils.getKeyResult(response, "code");
113
                        String rtnCode = JsonUtils.getKeyResult(response, "code");
112
                        if ("1000".equals(rtnCode)) {
114
                        if ("1000".equals(rtnCode)) {
113
                            String rtnMsg = JsonUtils.getKeyResult(response, "data");
115
                            String rtnMsg = JsonUtils.getKeyResult(response, "data");
148
        }
150
        }
149
151
150
        if (talkRecommendBean.targetType == 23) {
152
        if (talkRecommendBean.targetType == 23) {
151
            String videoUrl = talkRecommendBean.videoUrl;
152
            videoUrl = "http://uprocess.b0.upaiyun.com/demo/short_video/UPYUN_0.flv";
153
            if (!TextUtils.isEmpty(videoUrl)) {
154
                upVideoView2.setVideoPath(videoUrl);
155
                if(!upVideoView2.isPlaying()){
156
                    upVideoView2.start();
157
                }
158
            }
153
           initAndPlay();
159
        } else if (talkRecommendBean.targetType == 24) {
154
        } else if (talkRecommendBean.targetType == 24) {
160
155
161
        }
156
        }
249
        return view;
244
        return view;
250
    }
245
    }
251
246
252
    public void updateView(int position, TalkRecommendBean talkRecommendBean) {
253
        int targetType = talkRecommendBean.targetType;
254
        long targetId = talkRecommendBean.targetId;
247
    public void updateView() {
248
//        long targetId = talkRecommendBean.targetId;
255
249
256
    }
250
    }
257
251
258
    public void initAndPlay() {
252
    public void initAndPlay() {
253
        if (upVideoView2 != null && !TextUtils.isEmpty(talkRecommendBean.videoUrl)) {
254
            String videoUrl = talkRecommendBean.videoUrl;
255
            videoUrl = "http://uprocess.b0.upaiyun.com/demo/short_video/UPYUN_0.flv";
256
            Log.d("SvVideoShowView", "play");
257
            upVideoView2.setVideoPath(videoUrl);
258
            upVideoView2.start();
259
        }
259
    }
260
    }
260
261
261
    @Override
262
    @Override
276
277
277
    public void onDestroy() {
278
    public void onDestroy() {
278
        if (upVideoView2 != null) {
279
        if (upVideoView2 != null) {
280
            upVideoView2.stopPlayback();
279
            upVideoView2.release(true);
281
            upVideoView2.release(true);
280
        }
282
        }
281
//释放播放资源
282
    }
283
    }
283
284
285
    public void onStop() {
286
        if (upVideoView2 != null) {
287
            upVideoView2.stopPlayback();
288
        }
289
    }
290
291
    public void onResume() {
292
        if (upVideoView2 != null && !upVideoView2.isPlaying() && talkRecommendBean != null &&
293
                !TextUtils.isEmpty(talkRecommendBean.videoUrl)) {
294
            onResume(talkRecommendBean.videoUrl);
295
        } else if (upVideoView2 == null && talkRecommendBean != null
296
                && talkRecommendBean.targetType == 23
297
                && !TextUtils.isEmpty(talkRecommendBean.videoUrl)) {
298
            initAndPlay();
299
        }
300
    }
301
302
    public void onResume(String url) {
303
        if (upVideoView2 != null) {
304
//            pauseTime=0;
305
//            if (status==STATUS_PLAYING) {
306
//                if (isLive) {
307
//                    videoView.seekTo(0);
308
//                } else {
309
//                    if (currentPosition>0) {
310
//                        videoView.seekTo(currentPosition);
311
//                    }
312
//                }
313
            upVideoView2.start();
314
//            } else if (status == STATUS_IDLE) {
315
//                play(url);
316
        }
317
    }
318
319
    public void onPause() {
320
        if (upVideoView2 != null) {
321
            upVideoView2.stopPlayback();
322
        }
323
    }
324
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
    }
284
340
285
    public interface OnDeleteVideoListener {
341
    public interface OnDeleteVideoListener {
286
        void onDelete();
342
        void onDelete();

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

9
        android:layout_width="match_parent"
9
        android:layout_width="match_parent"
10
        android:layout_height="match_parent" />
10
        android:layout_height="match_parent" />
11
11
12
13
    <include layout="@layout/view_show_bottom" />
12
    <include layout="@layout/view_show_bottom" />
14
13
15
</RelativeLayout>
14
</RelativeLayout>